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,
451 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
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,
465 static void account_compose_menu_cb (GtkMenuItem *menuitem,
468 static void prefs_open_cb (GtkMenuItem *menuitem,
470 static void plugins_open_cb (GtkMenuItem *menuitem,
473 static void online_switch_clicked(GtkButton *btn,
476 static void manual_open_cb (MainWindow *mainwin,
480 static void legend_open_cb (GtkMenuItem *menuitem,
483 static void scan_tree_func (Folder *folder,
487 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
489 static void addr_harvest_cb ( MainWindow *mainwin,
493 static void addr_harvest_msg_cb ( MainWindow *mainwin,
496 static void sync_cb ( MainWindow *mainwin,
500 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
501 GdkEventFocus *focus,
503 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
504 GdkEventVisibility *state,
506 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
507 GdkEventWindowState *state,
509 static void main_window_reply_cb (MainWindow *mainwin,
512 static gboolean mainwindow_progressindicator_hook (gpointer source,
515 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
518 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
520 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
522 static void mailing_list_compose(GtkWidget *w, gpointer *data);
524 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
525 #define SEPARATE_ACTION 500
526 static void mainwindow_quicksearch (MainWindow *mainwin,
529 static gboolean any_folder_want_synchronise(void);
531 static GtkItemFactoryEntry mainwin_entries[] =
533 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
534 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
536 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
537 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
538 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
540 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
541 {N_("/_File/Exp_ort selected to mbox file..."),
542 NULL, export_list_mbox_cb, 0, NULL},
543 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
545 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
546 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
547 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
548 {N_("/_File/Page setup..."), NULL, page_setup_cb, 0, NULL},
550 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
551 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
553 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
554 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
555 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
556 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
558 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
559 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
560 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
561 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
562 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
563 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
564 {N_("/_Edit/_Find in current message..."),
565 "<control>F", search_cb, 0, NULL},
566 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
567 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
568 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
569 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
570 {N_("/_View/Show or hi_de/_Toolbar"),
571 NULL, NULL, 0, "<Branch>"},
572 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
573 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
574 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
575 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
576 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
577 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
578 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
579 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
581 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
582 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
584 {N_("/_View/Show or hi_de/_Message view"),
585 "V", toggle_message_cb, 0, "<ToggleItem>"},
587 {N_("/_View/Show or hi_de/Status _bar"),
588 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
590 {N_("/_View/Show or hi_de/Column headers"),
591 NULL, toggle_col_headers_cb, 0, "<ToggleItem>"},
592 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
593 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
594 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
596 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
599 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
600 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
601 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
602 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
603 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
604 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
607 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
608 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
609 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
610 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
611 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
612 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
613 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
614 {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
615 {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
616 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
617 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
618 {N_("/_View/_Sort/by a_ttachment"),
619 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
620 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
621 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
622 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
623 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
625 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
626 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_View/_Sort/_Attract by subject"),
628 NULL, attract_by_subject_cb, 0, NULL},
629 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
630 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
631 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
632 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
634 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
636 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
637 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
638 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_View/_Go to/P_revious unread message"),
640 "<shift>P", prev_unread_cb, 0, NULL},
641 {N_("/_View/_Go to/N_ext unread message"),
642 "<shift>N", next_unread_cb, 0, NULL},
643 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
645 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
646 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
647 {N_("/_View/_Go to/Previous _marked message"),
648 NULL, prev_marked_cb, 0, NULL},
649 {N_("/_View/_Go to/Next m_arked message"),
650 NULL, next_marked_cb, 0, NULL},
651 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_View/_Go to/Previous _labeled message"),
653 NULL, prev_labeled_cb, 0, NULL},
654 {N_("/_View/_Go to/Next la_beled message"),
655 NULL, next_labeled_cb, 0, NULL},
656 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_View/_Go to/Last read message"),
658 NULL, last_read_cb, 0, NULL},
659 {N_("/_View/_Go to/Parent message"),
660 "<control>Up", parent_cb, 0, NULL},
661 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
663 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
664 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
666 #define ENC_SEPARATOR \
667 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
668 #define ENC_ACTION(action) \
669 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
671 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
672 {N_("/_View/Character _encoding/_Auto detect"),
673 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
676 {N_("/_View/Character _encoding/7bit ASCII (US-ASC_II)"),
677 ENC_ACTION(C_US_ASCII)},
678 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
679 ENC_ACTION(C_UTF_8)},
682 {N_("/_View/Character _encoding/Western European"),NULL, NULL, 0, "<Branch>"},
683 {N_("/_View/Character _encoding/Western European/ISO-8859-_1"),
684 ENC_ACTION(C_ISO_8859_1)},
685 {N_("/_View/Character _encoding/Western European/ISO-8859-15"),
686 ENC_ACTION(C_ISO_8859_15)},
687 {N_("/_View/Character _encoding/Western European/Windows-1252"),
688 ENC_ACTION(C_WINDOWS_1252)},
690 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
691 ENC_ACTION(C_ISO_8859_2)},
693 {N_("/_View/Character _encoding/Baltic"), NULL, NULL, 0, "<Branch>"},
694 {N_("/_View/Character _encoding/Baltic/ISO-8859-13"),
695 ENC_ACTION(C_ISO_8859_13)},
696 {N_("/_View/Character _encoding/Baltic/ISO-8859-_4"),
697 ENC_ACTION(C_ISO_8859_4)},
699 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
700 ENC_ACTION(C_ISO_8859_7)},
702 {N_("/_View/Character _encoding/Hebrew"), NULL, NULL, 0, "<Branch>"},
703 {N_("/_View/Character _encoding/Hebrew/ISO-8859-_8"),
704 ENC_ACTION(C_ISO_8859_8)},
705 {N_("/_View/Character _encoding/Hebrew/Windows-1255"),
706 ENC_ACTION(C_CP1255)},
708 {N_("/_View/Character _encoding/Arabic"), NULL, NULL, 0, "<Branch>"},
709 {N_("/_View/Character _encoding/Arabic/ISO-8859-_6"),
710 ENC_ACTION(C_ISO_8859_6)},
711 {N_("/_View/Character _encoding/Arabic/Windows-1256"),
712 ENC_ACTION(C_CP1256)},
714 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
715 ENC_ACTION(C_ISO_8859_9)},
717 {N_("/_View/Character _encoding/Cyrillic"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_View/Character _encoding/Cyrillic/ISO-8859-_5"),
719 ENC_ACTION(C_ISO_8859_5)},
720 {N_("/_View/Character _encoding/Cyrillic/KOI8-_R"),
721 ENC_ACTION(C_KOI8_R)},
722 {N_("/_View/Character _encoding/Cyrillic/KOI8-U"),
723 ENC_ACTION(C_KOI8_U)},
724 {N_("/_View/Character _encoding/Cyrillic/Windows-1251"),
725 ENC_ACTION(C_CP1251)},
727 {N_("/_View/Character _encoding/Japanese"), NULL, NULL, 0, "<Branch>"},
728 {N_("/_View/Character _encoding/Japanese/ISO-2022-_JP"),
729 ENC_ACTION(C_ISO_2022_JP)},
730 {N_("/_View/Character _encoding/Japanese/ISO-2022-JP-2"),
731 ENC_ACTION(C_ISO_2022_JP_2)},
732 {N_("/_View/Character _encoding/Japanese/_EUC-JP"),
733 ENC_ACTION(C_EUC_JP)},
734 {N_("/_View/Character _encoding/Japanese/_Shift__JIS"),
735 ENC_ACTION(C_SHIFT_JIS)},
737 {N_("/_View/Character _encoding/Chinese"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_View/Character _encoding/Chinese/Simplified (_GB2312)"),
739 ENC_ACTION(C_GB2312)},
740 {N_("/_View/Character _encoding/Chinese/Simplified (GBK)"),
742 {N_("/_View/Character _encoding/Chinese/Traditional (_Big5)"),
744 {N_("/_View/Character _encoding/Chinese/Traditional (EUC-_TW)"),
745 ENC_ACTION(C_EUC_TW)},
746 {N_("/_View/Character _encoding/Chinese/ISO-2022-_CN"),
747 ENC_ACTION(C_ISO_2022_CN)},
749 {N_("/_View/Character _encoding/Korean"), NULL, NULL, 0, "<Branch>"},
750 {N_("/_View/Character _encoding/Korean/EUC-_KR"),
751 ENC_ACTION(C_EUC_KR)},
752 {N_("/_View/Character _encoding/Korean/ISO-2022-KR"),
753 ENC_ACTION(C_ISO_2022_KR)},
755 {N_("/_View/Character _encoding/Thai"), NULL, NULL, 0, "<Branch>"},
756 {N_("/_View/Character _encoding/Thai/TIS-620"),
757 ENC_ACTION(C_TIS_620)},
758 {N_("/_View/Character _encoding/Thai/Windows-874"),
759 ENC_ACTION(C_WINDOWS_874)},
764 #define DEC_SEPARATOR \
765 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
766 #define DEC_ACTION(action) \
767 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
768 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
769 {N_("/_View/Decode/_Auto detect"),
770 NULL, set_decode_cb, 0, "<RadioItem>"},
771 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
772 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
773 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
774 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
775 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
780 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
781 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
782 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
783 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
784 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
785 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
786 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
787 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
788 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
789 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
791 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
792 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
793 {N_("/_Message/Recei_ve/Get from _current account"),
794 "<control>I", inc_mail_cb, 0, NULL},
795 {N_("/_Message/Recei_ve/Get from _all accounts"),
796 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
797 {N_("/_Message/Recei_ve/Cancel receivin_g"),
798 NULL, inc_cancel_cb, 0, NULL},
799 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
800 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
801 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
802 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
803 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
804 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
805 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
806 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
807 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
808 {N_("/_Message/Repl_y to/mailing _list"),
809 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
810 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
811 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
812 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
813 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
814 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
816 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
817 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
818 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
819 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
820 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
821 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
822 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
824 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
825 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
826 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
827 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
828 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
829 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
830 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
831 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
832 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
833 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
834 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
835 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
836 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
837 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
838 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
839 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
840 {N_("/_Message/_Mark/Watch thread"), NULL, watch_thread_cb, 0, NULL},
841 {N_("/_Message/_Mark/Unwatch thread"), NULL, unwatch_thread_cb, 0, NULL},
842 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
843 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
844 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
845 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
846 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
847 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
848 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
849 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
850 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
851 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
853 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
854 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
855 {N_("/_Tools/Add sender to address boo_k"),
856 NULL, add_address_cb, 0, NULL},
857 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
858 {N_("/_Tools/_Harvest addresses/from _Folder..."),
859 NULL, addr_harvest_cb, 0, NULL},
860 {N_("/_Tools/_Harvest addresses/from _Messages..."),
861 NULL, addr_harvest_msg_cb, 0, NULL},
862 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
863 {N_("/_Tools/_Filter all messages in folder"),
864 NULL, filter_cb, 0, NULL},
865 {N_("/_Tools/Filter _selected messages"),
866 NULL, filter_cb, 1, NULL},
867 {N_("/_Tools/Run folder processing rules"),
868 NULL, process_cb, 0, NULL},
869 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
870 {N_("/_Tools/_Create filter rule/_Automatically"),
871 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
872 {N_("/_Tools/_Create filter rule/by _From"),
873 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
874 {N_("/_Tools/_Create filter rule/by _To"),
875 NULL, create_filter_cb, FILTER_BY_TO, NULL},
876 {N_("/_Tools/_Create filter rule/by _Subject"),
877 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
878 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
879 {N_("/_Tools/C_reate processing rule/_Automatically"),
880 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
881 {N_("/_Tools/C_reate processing rule/by _From"),
882 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
883 {N_("/_Tools/C_reate processing rule/by _To"),
884 NULL, create_processing_cb, FILTER_BY_TO, NULL},
885 {N_("/_Tools/C_reate processing rule/by _Subject"),
886 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
887 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
888 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
889 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
890 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
891 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
892 {N_("/_Tools/Ch_eck for new messages in all folders"),
893 NULL, update_folderview_cb, 0, NULL},
894 {N_("/_Tools/Delete du_plicated messages"),
895 NULL, NULL, 0, "<Branch>"},
896 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
897 NULL, delete_duplicated_cb, 0, NULL},
898 {N_("/_Tools/Delete du_plicated messages/In all folders"),
899 NULL, delete_duplicated_all_cb, 0, NULL},
900 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
901 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
902 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
903 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
904 {N_("/_Tools/SSL cer_tificates..."),
905 NULL, ssl_manager_open_cb, 0, NULL},
907 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
908 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
909 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
911 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
912 {N_("/_Configuration/C_hange current account"),
913 NULL, NULL, 0, "<Branch>"},
914 {N_("/_Configuration/_Preferences for current account..."),
915 NULL, prefs_account_open_cb, 0, NULL},
916 {N_("/_Configuration/Create _new account..."),
917 NULL, new_account_cb, 0, NULL},
918 {N_("/_Configuration/_Edit accounts..."),
919 NULL, account_edit_open, 0, NULL},
920 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
921 {N_("/_Configuration/P_references..."),
922 NULL, prefs_open_cb, 0, NULL},
923 {N_("/_Configuration/Pre-pr_ocessing..."),
924 NULL, prefs_pre_processing_open_cb, 0, NULL},
925 {N_("/_Configuration/Post-pro_cessing..."),
926 NULL, prefs_post_processing_open_cb, 0, NULL},
927 {N_("/_Configuration/_Filtering..."),
928 NULL, prefs_filtering_open_cb, 0, NULL},
929 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
930 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
931 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
932 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
933 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
935 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
936 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_CLAWS, NULL},
937 {N_("/_Help/_Online User-contributed FAQ"),
938 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
939 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
940 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
941 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
944 static gboolean offline_ask_sync = TRUE;
945 static guint lastkey;
946 static gboolean is_obscured = FALSE;
948 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
954 MainWindow *mainwin = (MainWindow *)user_data;
956 if (mainwin->summaryview &&
957 mainwin->summaryview->quicksearch &&
958 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
959 (mod == 0 || mod == GDK_SHIFT_MASK)) {
960 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
966 #define N_COLOR_LABELS colorlabel_get_color_count()
968 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
973 GtkCheckMenuItem **items;
978 mainwin = (MainWindow *)data;
979 g_return_if_fail(mainwin != NULL);
981 sel = summary_get_selection(mainwin->summaryview);
984 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
985 g_return_if_fail(menu != NULL);
987 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
989 /* NOTE: don't return prematurely because we set the "dont_toggle"
990 * state for check menu items */
991 g_object_set_data(G_OBJECT(menu), "dont_toggle",
994 /* clear items. get item pointers. */
995 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
996 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
997 gtk_check_menu_item_set_active
998 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
999 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
1004 if (n == (N_COLOR_LABELS + 1)) {
1005 /* iterate all messages and set the state of the appropriate
1007 for (; sel != NULL; sel = sel->next) {
1011 msginfo = (MsgInfo *)sel->data;
1013 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
1014 if (!items[clabel]->active)
1015 gtk_check_menu_item_set_active
1016 (items[clabel], TRUE);
1020 g_warning("invalid number of color elements (%d)\n", n);
1023 /* reset "dont_toggle" state */
1024 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1025 GINT_TO_POINTER(0));
1028 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
1031 guint color = GPOINTER_TO_UINT(data);
1032 MainWindow *mainwin;
1034 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1035 g_return_if_fail(mainwin != NULL);
1037 /* "dont_toggle" state set? */
1038 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1042 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1045 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1048 MainWindow *mainwin;
1052 GHashTable *menu_table = g_hash_table_new_full(
1056 GHashTable *menu_allsel_table = g_hash_table_new_full(
1061 mainwin = (MainWindow *)data;
1062 g_return_if_fail(mainwin != NULL);
1064 sel = summary_get_selection(mainwin->summaryview);
1067 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1068 g_return_if_fail(menu != NULL);
1070 /* NOTE: don't return prematurely because we set the "dont_toggle"
1071 * state for check menu items */
1072 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1073 GINT_TO_POINTER(1));
1075 /* clear items. get item pointers. */
1076 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1077 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1078 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1080 gtk_check_menu_item_set_active
1081 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1083 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1084 g_hash_table_insert(menu_allsel_table, GINT_TO_POINTER(id), GINT_TO_POINTER(0));
1088 /* iterate all messages and set the state of the appropriate
1091 for (; sel != NULL; sel = sel->next) {
1093 GSList *tags = NULL;
1095 GtkCheckMenuItem *item;
1096 msginfo = (MsgInfo *)sel->data;
1099 tags = msginfo->tags;
1103 for (; tags; tags = tags->next) {
1104 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
1105 id = GPOINTER_TO_INT(tags->data);
1106 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1107 if (item && !item->active) {
1108 gtk_check_menu_item_set_active
1112 g_hash_table_replace(menu_allsel_table, tags->data, GINT_TO_POINTER(num_checked));
1117 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1118 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1119 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1121 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, GINT_TO_POINTER(id)));
1122 if (num_checked < sel_len && num_checked > 0)
1123 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), TRUE);
1125 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1129 g_hash_table_destroy(menu_table);
1130 g_hash_table_destroy(menu_allsel_table);
1131 /* reset "dont_toggle" state */
1132 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1133 GINT_TO_POINTER(0));
1136 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1139 gint id = GPOINTER_TO_INT(data);
1140 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1141 MainWindow *mainwin;
1143 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1144 g_return_if_fail(mainwin != NULL);
1146 /* "dont_toggle" state set? */
1147 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1153 summary_set_tag(mainwin->summaryview, id, NULL);
1156 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1158 GtkWidget *label_menuitem;
1163 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1164 "/Message/Color label");
1165 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1166 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1168 gtk_widget_show(label_menuitem);
1170 menu = gtk_menu_new();
1172 /* create sub items. for the menu item activation callback we pass the
1173 * index of label_colors[] as data parameter. for the None color we
1174 * pass an invalid (high) value. also we attach a data pointer so we
1175 * can always get back the Mainwindow pointer. */
1177 item = gtk_check_menu_item_new_with_label(_("None"));
1178 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1179 g_signal_connect(G_OBJECT(item), "activate",
1180 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1181 GUINT_TO_POINTER(0));
1182 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1183 gtk_widget_show(item);
1185 gtk_widget_add_accelerator(item, "activate",
1186 mainwin->menu_factory->accel_group,
1187 GDK_0, GDK_CONTROL_MASK,
1188 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1190 item = gtk_menu_item_new();
1191 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1192 gtk_widget_show(item);
1194 /* create pixmap/label menu items */
1195 for (i = 0; i < N_COLOR_LABELS; i++) {
1196 item = colorlabel_create_check_color_menu_item(
1197 i, refresh, MAINWIN_COLORMENU);
1198 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1199 g_signal_connect(G_OBJECT(item), "activate",
1200 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1201 GUINT_TO_POINTER(i + 1));
1202 g_object_set_data(G_OBJECT(item), "mainwin",
1204 gtk_widget_show(item);
1206 gtk_widget_add_accelerator(item, "activate",
1207 mainwin->menu_factory->accel_group,
1208 GDK_1+i, GDK_CONTROL_MASK,
1209 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1211 gtk_widget_show(menu);
1212 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1213 mainwin->colorlabel_menu = menu;
1216 static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
1219 MainWindow *mainwin;
1221 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1222 g_return_if_fail(mainwin != NULL);
1224 /* "dont_toggle" state set? */
1225 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1229 tag_apply_open(summary_get_selection(mainwin->summaryview));
1232 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1234 GtkWidget *label_menuitem;
1237 GSList *cur = tags_get_list();
1239 gboolean existing_tags = FALSE;
1241 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1243 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1244 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1247 gtk_widget_show(label_menuitem);
1249 menu = gtk_menu_new();
1251 /* create tags menu items */
1252 for (; cur; cur = cur->next) {
1253 gint id = GPOINTER_TO_INT(cur->data);
1254 const gchar *tag = tags_get_tag(id);
1256 item = gtk_check_menu_item_new_with_label(tag);
1257 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1258 g_signal_connect(G_OBJECT(item), "activate",
1259 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1260 GINT_TO_POINTER(id));
1261 g_object_set_data(G_OBJECT(item), "mainwin",
1263 g_object_set_data(G_OBJECT(item), "tag_id",
1264 GINT_TO_POINTER(id));
1265 gtk_widget_show(item);
1266 existing_tags = TRUE;
1268 if (existing_tags) {
1270 item = gtk_menu_item_new();
1271 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1272 gtk_widget_show(item);
1275 item = gtk_menu_item_new_with_label(_("Apply tags..."));
1276 gtk_widget_add_accelerator(item, "activate",
1277 mainwin->menu_factory->accel_group,
1278 GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
1279 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1280 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1281 g_signal_connect(G_OBJECT(item), "activate",
1282 G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
1284 g_object_set_data(G_OBJECT(item), "mainwin",
1286 gtk_widget_show(item);
1289 gtk_widget_show(menu);
1290 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1291 mainwin->tags_menu = menu;
1294 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1295 MainWindow *mainwindow)
1297 if (evt && evt->button == 1) {
1298 log_window_show_error(mainwindow->logwin);
1299 gtk_widget_hide(mainwindow->warning_btn);
1304 static gboolean warning_visi_notify(GtkWidget *widget,
1305 GdkEventVisibility *event,
1306 MainWindow *mainwindow)
1308 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1312 static gboolean warning_leave_notify(GtkWidget *widget,
1313 GdkEventCrossing *event,
1314 MainWindow *mainwindow)
1316 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1320 static gboolean warning_enter_notify(GtkWidget *widget,
1321 GdkEventCrossing *event,
1322 MainWindow *mainwindow)
1324 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1328 void mainwindow_show_error(void)
1330 MainWindow *mainwin = mainwindow_get_mainwindow();
1331 gtk_widget_show(mainwin->warning_btn);
1334 void mainwindow_clear_error(MainWindow *mainwin)
1336 gtk_widget_hide(mainwin->warning_btn);
1339 #define BREAK_ON_MODIFIER_KEY() \
1340 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
1342 static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
1345 MainWindow *mainwin = (MainWindow*) data;
1347 if (!mainwin || !event)
1350 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
1352 lastkey = event->keyval;
1356 switch (event->keyval) {
1357 case GDK_Q: /* Quit */
1358 BREAK_ON_MODIFIER_KEY();
1360 app_exit_cb(mainwin, 0, NULL);
1363 if (mainwin->folderview && mainwin->summaryview
1364 && ((!mainwin->summaryview->displayed
1365 && !mainwin->summaryview->selected)
1366 || (mainwin->summaryview->folder_item
1367 && mainwin->summaryview->folder_item->total_msgs == 0))) {
1368 g_signal_stop_emission_by_name(G_OBJECT(widget),
1370 folderview_select_next_unread(mainwin->folderview, TRUE);
1375 if (maemo_mainwindow_is_fullscreen(widget)) {
1376 gtk_window_unfullscreen(GTK_WINDOW(widget));
1378 gtk_window_fullscreen(GTK_WINDOW(widget));
1382 if (mainwin->summaryview &&
1383 mainwin->summaryview->ext_messageview &&
1384 mainwin->summaryview->ext_messageview->window &&
1385 widget == mainwin->summaryview->ext_messageview->window) {
1386 messageview_destroy(mainwin->summaryview->ext_messageview);
1396 #undef BREAK_ON_MODIFIER_KEY
1398 MainWindow *main_window_create()
1400 MainWindow *mainwin;
1404 GtkWidget *handlebox;
1405 GtkWidget *vbox_body;
1407 GtkWidget *hbox_stat;
1408 GtkWidget *statusbar;
1409 GtkWidget *progressbar;
1410 GtkWidget *statuslabel;
1411 GtkWidget *ac_button;
1412 GtkWidget *ac_label;
1413 GtkWidget *online_pixmap;
1414 GtkWidget *offline_pixmap;
1416 GtkWidget *warning_icon;
1417 GtkWidget *warning_btn;
1419 GtkWidget *online_switch;
1420 GtkWidget *offline_switch;
1421 FolderView *folderview;
1422 SummaryView *summaryview;
1423 MessageView *messageview;
1424 GdkColormap *colormap;
1426 gboolean success[4];
1427 GtkItemFactory *ifactory;
1429 GtkWidget *menuitem;
1431 guint n_menu_entries;
1433 static GdkGeometry geometry;
1435 debug_print("Creating main window...\n");
1436 mainwin = g_new0(MainWindow, 1);
1439 window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
1440 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1441 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1443 prefs_common.layout_mode = SMALL_LAYOUT;
1445 if (!geometry.min_height) {
1446 geometry.min_width = 320;
1447 geometry.min_height = 200;
1449 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1452 g_signal_connect(G_OBJECT(window), "delete_event",
1453 G_CALLBACK(main_window_close_cb), mainwin);
1454 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1455 g_signal_connect(G_OBJECT(window), "focus_in_event",
1456 G_CALLBACK(mainwindow_focus_in_event),
1458 g_signal_connect(G_OBJECT(window), "key_press_event",
1459 G_CALLBACK(mainwindow_key_pressed), mainwin);
1461 gtk_widget_realize(window);
1462 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1465 gtkut_widget_set_app_icon(window);
1467 vbox = gtk_vbox_new(FALSE, 0);
1468 gtk_widget_show(vbox);
1469 gtk_container_add(GTK_CONTAINER(window), vbox);
1472 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1473 menubar = menubar_create(window, mainwin_entries,
1474 n_menu_entries, "<Main>", mainwin);
1475 gtk_widget_show(menubar);
1478 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1481 ifactory = gtk_item_factory_from_widget(menubar);
1483 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1484 main_create_mailing_list_menu (mainwin, NULL); */
1486 if (prefs_common.toolbar_detachable) {
1487 handlebox = gtk_handle_box_new();
1488 gtk_widget_show(handlebox);
1489 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1490 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1491 G_CALLBACK(toolbar_child_attached), mainwin);
1492 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1493 G_CALLBACK(toolbar_child_detached), mainwin);
1495 handlebox = gtk_hbox_new(FALSE, 0);
1496 gtk_widget_show(handlebox);
1497 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1499 /* link window to mainwin->window to avoid gdk warnings */
1500 mainwin->window = window;
1501 mainwin_list = g_list_append(mainwin_list, mainwin);
1504 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1508 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1512 toolbar_set_learn_button
1516 /* vbox that contains body */
1517 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1518 gtk_widget_show(vbox_body);
1519 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1520 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1523 hbox_stat = gtk_hbox_new(FALSE, 2);
1524 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1526 tips = gtk_tooltips_new();
1528 warning_icon = gtk_image_new_from_stock
1529 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1530 warning_btn = gtk_event_box_new();
1531 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1533 mainwin->warning_btn = warning_btn;
1535 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1536 G_CALLBACK(warning_icon_pressed),
1537 (gpointer) mainwin);
1538 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1539 G_CALLBACK(warning_visi_notify), mainwin);
1540 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1541 G_CALLBACK(warning_visi_notify), mainwin);
1542 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1543 G_CALLBACK(warning_leave_notify), mainwin);
1544 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1545 G_CALLBACK(warning_enter_notify), mainwin);
1547 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1549 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1550 _("Some error(s) happened. Click here to view log."), NULL);
1551 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1553 statusbar = statusbar_create();
1554 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1556 progressbar = gtk_progress_bar_new();
1557 gtk_widget_set_size_request(progressbar, 120, 1);
1558 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1560 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1561 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1562 online_switch = gtk_button_new ();
1563 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1564 _("You are online. Click the icon to go offline"), NULL);
1565 offline_switch = gtk_button_new ();
1566 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1567 _("You are offline. Click the icon to go online"),
1569 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1570 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1571 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1572 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1573 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1574 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1575 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1576 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1578 statuslabel = gtk_label_new("");
1579 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1581 ac_button = gtk_button_new();
1582 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1583 ac_button, _("Select account"), NULL);
1584 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1585 gtk_widget_set_size_request(ac_button, -1, 0);
1586 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1587 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1588 G_CALLBACK(ac_label_button_pressed), mainwin);
1590 ac_label = gtk_label_new("");
1591 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1593 gtk_widget_show_all(hbox_stat);
1595 gtk_widget_hide(offline_switch);
1596 gtk_widget_hide(warning_btn);
1598 online_switch = gtk_button_new ();
1599 offline_switch = gtk_button_new ();
1600 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1601 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1604 mainwin->folderview = folderview = folderview_create();
1605 mainwin->summaryview = summaryview = summary_create();
1606 mainwin->messageview = messageview = messageview_create(mainwin);
1608 /* init log instances data before creating log views */
1609 set_log_title(LOG_PROTOCOL, _("Network log"));
1610 set_log_prefs(LOG_PROTOCOL,
1611 &prefs_common.logwin_width,
1612 &prefs_common.logwin_height);
1613 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1614 set_log_prefs(LOG_DEBUG_FILTERING,
1615 &prefs_common.filtering_debugwin_width,
1616 &prefs_common.filtering_debugwin_height);
1618 /* setup log windows */
1619 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1620 log_window_init(mainwin->logwin);
1622 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1623 log_window_set_clipping(mainwin->logwin,
1624 prefs_common.cliplog,
1625 prefs_common.loglength);
1627 log_window_init(mainwin->filtering_debugwin);
1628 log_window_set_clipping(mainwin->filtering_debugwin,
1629 prefs_common.filtering_debug_cliplog,
1630 prefs_common.filtering_debug_loglength);
1631 if (prefs_common.enable_filtering_debug)
1632 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1634 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1636 folderview->mainwin = mainwin;
1637 folderview->summaryview = summaryview;
1639 summaryview->mainwin = mainwin;
1640 summaryview->folderview = folderview;
1641 summaryview->messageview = messageview;
1642 summaryview->window = window;
1644 mainwin->vbox = vbox;
1645 mainwin->menubar = menubar;
1646 mainwin->menu_factory = ifactory;
1647 mainwin->handlebox = handlebox;
1648 mainwin->vbox_body = vbox_body;
1649 mainwin->online_switch = online_switch;
1650 mainwin->offline_switch = offline_switch;
1652 messageview->statusbar = statusbar;
1653 mainwin->statusbar = statusbar;
1654 mainwin->hbox_stat = hbox_stat;
1655 mainwin->progressbar = progressbar;
1656 mainwin->statuslabel = statuslabel;
1657 mainwin->online_pixmap = online_pixmap;
1658 mainwin->offline_pixmap = offline_pixmap;
1659 mainwin->ac_button = ac_button;
1660 mainwin->ac_label = ac_label;
1661 /* set context IDs for status bar */
1662 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1663 (GTK_STATUSBAR(statusbar), "Main Window");
1664 mainwin->folderview_cid = gtk_statusbar_get_context_id
1665 (GTK_STATUSBAR(statusbar), "Folder View");
1666 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1667 (GTK_STATUSBAR(statusbar), "Summary View");
1668 mainwin->messageview_cid = gtk_statusbar_get_context_id
1669 (GTK_STATUSBAR(statusbar), "Message View");
1670 messageview->statusbar_cid = mainwin->messageview_cid;
1673 messageview->statusbar = NULL;
1674 mainwin->statusbar = NULL;
1675 mainwin->hbox_stat = NULL;
1676 /* mainwin->progressbar is set in toolbar.c */
1677 mainwin->statuslabel = NULL;
1678 mainwin->online_pixmap = NULL;
1679 mainwin->offline_pixmap = NULL;
1680 mainwin->ac_button = NULL;
1681 mainwin->ac_label = NULL;
1684 /* allocate colors for summary view and folder view */
1685 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1686 summaryview->color_marked.blue = (guint16)65535;
1688 summaryview->color_dim.red = summaryview->color_dim.green =
1689 summaryview->color_dim.blue = COLOR_DIM;
1691 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1692 &folderview->color_new);
1694 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1695 &folderview->color_op);
1697 summaryview->color_important.red = 0;
1698 summaryview->color_important.green = 0;
1699 summaryview->color_important.blue = (guint16)65535;
1701 color[0] = summaryview->color_marked;
1702 color[1] = summaryview->color_dim;
1703 color[2] = folderview->color_new;
1704 color[3] = folderview->color_op;
1706 colormap = gdk_drawable_get_colormap(window->window);
1707 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1708 for (i = 0; i < 4; i++) {
1709 if (success[i] == FALSE)
1710 g_warning("MainWindow: color allocation %d failed\n", i);
1713 debug_print("done.\n");
1715 messageview->visible = prefs_common.msgview_visible;
1717 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1719 g_signal_connect(G_OBJECT(window), "size_allocate",
1720 G_CALLBACK(main_window_size_allocate_cb),
1723 /* set menu items */
1724 menuitem = gtk_item_factory_get_item
1725 (ifactory, "/View/Character encoding/Auto detect");
1726 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1728 switch (prefs_common.toolbar_style) {
1730 menuitem = gtk_item_factory_get_item
1731 (ifactory, "/View/Show or hide/Toolbar/Hide");
1734 menuitem = gtk_item_factory_get_item
1735 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1738 menuitem = gtk_item_factory_get_item
1739 (ifactory, "/View/Show or hide/Toolbar/Text only");
1742 menuitem = gtk_item_factory_get_item
1743 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1745 case TOOLBAR_BOTH_HORIZ:
1746 menuitem = gtk_item_factory_get_item
1748 "/View/Show or hide/Toolbar/Text beside icons");
1750 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1753 gtk_widget_hide(mainwin->hbox_stat);
1754 menuitem = gtk_item_factory_get_item
1755 (ifactory, "/View/Show or hide/Status bar");
1756 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1757 prefs_common.show_statusbar);
1759 menuitem = gtk_item_factory_get_item
1760 (ifactory, "/View/Show or hide/Column headers");
1761 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1762 prefs_common.show_col_headers);
1763 /* set account selection menu */
1764 ac_menu = gtk_item_factory_get_widget
1765 (ifactory, "/Configuration/Change current account");
1766 mainwin->ac_menu = ac_menu;
1768 toolbar_main_set_sensitive(mainwin);
1770 /* create actions menu */
1771 main_window_update_actions_menu(mainwin);
1773 main_create_mailing_list_menu (mainwin, NULL);
1775 /* attach accel groups to main window */
1776 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1777 gtk_window_add_accel_group \
1779 gtk_item_factory_from_widget(menu)->accel_group); \
1780 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1782 G_CALLBACK(main_window_accel_activate), mainwin);
1785 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1787 /* connect the accelerators for equivalent
1788 menu items in different menus */
1789 menu_connect_identical_items();
1792 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1795 g_signal_connect(G_OBJECT(window), "window_state_event",
1796 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1797 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1798 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1799 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1801 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1802 prefs_common.layout_mode == SMALL_LAYOUT) {
1803 summary_relayout(mainwin->summaryview);
1805 summary_update_unread(mainwin->summaryview, NULL);
1807 gtk_widget_show(mainwin->window);
1809 /* initialize views */
1810 folderview_init(folderview);
1811 summary_init(summaryview);
1812 messageview_init(messageview);
1813 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1814 sslcertwindow_register_hook();
1816 mainwin->lock_count = 0;
1817 mainwin->menu_lock_count = 0;
1818 mainwin->cursor_count = 0;
1820 mainwin->progressindicator_hook =
1821 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1824 watch_cursor = gdk_cursor_new(GDK_WATCH);
1826 hand_cursor = gdk_cursor_new(GDK_HAND2);
1828 /* init work_offline */
1829 if (prefs_common.work_offline)
1830 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1832 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1833 mainwindow_tags_menu_create(mainwin, FALSE);
1838 void main_window_update_actions_menu(MainWindow *mainwin)
1840 GtkItemFactory *ifactory;
1842 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1843 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1846 void main_window_cursor_wait(MainWindow *mainwin)
1849 if (mainwin->cursor_count == 0) {
1850 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1851 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1854 mainwin->cursor_count++;
1859 void main_window_cursor_normal(MainWindow *mainwin)
1861 if (mainwin->cursor_count)
1862 mainwin->cursor_count--;
1864 if (mainwin->cursor_count == 0) {
1865 gdk_window_set_cursor(mainwin->window->window, NULL);
1866 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1871 /* lock / unlock the user-interface */
1872 void main_window_lock(MainWindow *mainwin)
1874 if (mainwin->lock_count == 0 && mainwin->ac_button)
1875 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1877 mainwin->lock_count++;
1879 main_window_set_menu_sensitive(mainwin);
1880 toolbar_main_set_sensitive(mainwin);
1883 void main_window_unlock(MainWindow *mainwin)
1885 if (mainwin->lock_count)
1886 mainwin->lock_count--;
1888 main_window_set_menu_sensitive(mainwin);
1889 toolbar_main_set_sensitive(mainwin);
1891 if (mainwin->lock_count == 0 && mainwin->ac_button)
1892 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1895 static void main_window_menu_callback_block(MainWindow *mainwin)
1897 mainwin->menu_lock_count++;
1900 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1902 if (mainwin->menu_lock_count)
1903 mainwin->menu_lock_count--;
1906 static guint prefs_tag = 0;
1908 void main_window_reflect_prefs_all(void)
1910 main_window_reflect_prefs_all_real(FALSE);
1913 static gboolean reflect_prefs_timeout_cb(gpointer data)
1915 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1917 MainWindow *mainwin;
1921 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1922 mainwin = (MainWindow *)cur->data;
1924 main_window_show_cur_account(mainwin);
1925 main_window_set_menu_sensitive(mainwin);
1926 toolbar_main_set_sensitive(mainwin);
1929 if (pixmap_theme_changed) {
1930 toolbar_update(TOOLBAR_MAIN, mainwin);
1931 messageview_reflect_prefs_pixmap_theme();
1932 compose_reflect_prefs_pixmap_theme();
1933 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1934 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1936 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1937 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1938 mainwin->online_pixmap);
1939 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1940 gtk_widget_show(pixmap);
1941 mainwin->online_pixmap = pixmap;
1942 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1943 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1944 mainwin->offline_pixmap);
1945 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1946 gtk_widget_show(pixmap);
1947 mainwin->offline_pixmap = pixmap;
1951 headerview_set_font(mainwin->messageview->headerview);
1952 headerview_set_visibility(mainwin->messageview->headerview,
1953 prefs_common.display_header_pane);
1954 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1955 folderview_reflect_prefs();
1956 summary_reflect_prefs();
1958 summary_redisplay_msg(mainwin->summaryview);
1960 if (prefs_common.layout_mode == SMALL_LAYOUT) {
1961 if (mainwin->in_folder) {
1962 mainwindow_enter_folder(mainwin);
1964 mainwindow_exit_folder(mainwin);
1972 void main_window_reflect_prefs_all_now(void)
1974 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1977 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1982 /* re-create colorlabel submenu */
1983 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1984 g_return_if_fail(menu != NULL);
1986 /* clear items. get item pointers. */
1987 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1988 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1990 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1991 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1995 void main_window_reflect_tags_changes(MainWindow *mainwin)
2000 /* re-create tags submenu */
2001 menu = GTK_MENU_SHELL(mainwin->tags_menu);
2002 g_return_if_fail(menu != NULL);
2004 /* clear items. get item pointers. */
2005 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
2006 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
2008 mainwindow_tags_menu_create(mainwin, TRUE);
2009 summary_reflect_tags_changes(mainwin->summaryview);
2013 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
2015 if (prefs_tag == 0 || pixmap_theme_changed) {
2016 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
2017 GINT_TO_POINTER(pixmap_theme_changed));
2021 void main_window_set_summary_column(void)
2024 MainWindow *mainwin;
2026 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2027 mainwin = (MainWindow *)cur->data;
2028 summary_set_column_order(mainwin->summaryview);
2032 void main_window_set_folder_column(void)
2035 MainWindow *mainwin;
2037 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2038 mainwin = (MainWindow *)cur->data;
2039 folderview_set_column_order(mainwin->folderview);
2043 static void main_window_set_account_selector_menu(MainWindow *mainwin,
2044 GList *account_list)
2046 GList *cur_ac, *cur_item;
2047 GtkWidget *menuitem;
2048 PrefsAccount *ac_prefs;
2050 /* destroy all previous menu item */
2051 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
2052 while (cur_item != NULL) {
2053 GList *next = cur_item->next;
2054 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2058 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2059 ac_prefs = (PrefsAccount *)cur_ac->data;
2061 menuitem = gtk_menu_item_new_with_label
2062 (ac_prefs->account_name
2063 ? ac_prefs->account_name : _("Untitled"));
2064 gtk_widget_show(menuitem);
2065 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
2066 g_signal_connect(G_OBJECT(menuitem), "activate",
2067 G_CALLBACK(account_selector_menu_cb),
2072 static void main_window_set_account_receive_menu(MainWindow *mainwin,
2073 GList *account_list)
2075 GList *cur_ac, *cur_item;
2077 GtkWidget *menuitem;
2078 PrefsAccount *ac_prefs;
2080 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
2081 "/Message/Receive");
2083 /* search for separator */
2084 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2085 cur_item = cur_item->next) {
2086 if (GTK_BIN(cur_item->data)->child == NULL) {
2087 cur_item = cur_item->next;
2092 /* destroy all previous menu item */
2093 while (cur_item != NULL) {
2094 GList *next = cur_item->next;
2095 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2099 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2100 ac_prefs = (PrefsAccount *)cur_ac->data;
2102 menuitem = gtk_menu_item_new_with_label
2103 (ac_prefs->account_name ? ac_prefs->account_name
2105 gtk_widget_show(menuitem);
2106 gtk_menu_append(GTK_MENU(menu), menuitem);
2107 g_signal_connect(G_OBJECT(menuitem), "activate",
2108 G_CALLBACK(account_receive_menu_cb),
2113 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
2114 GList *account_list)
2117 GtkWidget *menuitem;
2118 PrefsAccount *ac_prefs;
2119 GtkWidget *menu = NULL;
2121 if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
2124 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
2126 gtk_widget_destroy(menu);
2127 menu = gtk_menu_new();
2129 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2130 ac_prefs = (PrefsAccount *)cur_ac->data;
2132 menuitem = gtk_menu_item_new_with_label
2133 (ac_prefs->account_name
2134 ? ac_prefs->account_name : _("Untitled"));
2135 gtk_widget_show(menuitem);
2136 gtk_menu_append(GTK_MENU(menu), menuitem);
2137 g_signal_connect(G_OBJECT(menuitem), "activate",
2138 G_CALLBACK(account_receive_menu_cb),
2141 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
2144 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
2145 GList *account_list)
2149 GtkWidget *menuitem;
2150 PrefsAccount *ac_prefs;
2151 GtkWidget *menu = NULL;
2153 if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
2156 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
2158 gtk_widget_destroy(menu);
2159 menu = gtk_menu_new();
2161 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2162 ac_prefs = (PrefsAccount *)cur_ac->data;
2164 menuitem = gtk_menu_item_new_with_label
2165 (ac_prefs->account_name
2166 ? ac_prefs->account_name : _("Untitled"));
2167 gtk_widget_show(menuitem);
2168 gtk_menu_append(GTK_MENU(menu), menuitem);
2169 g_signal_connect(G_OBJECT(menuitem), "activate",
2170 G_CALLBACK(account_compose_menu_cb),
2173 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
2177 void main_window_set_account_menu(GList *account_list)
2180 MainWindow *mainwin;
2182 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2183 mainwin = (MainWindow *)cur->data;
2184 main_window_set_account_selector_menu(mainwin, account_list);
2185 main_window_set_account_receive_menu(mainwin, account_list);
2186 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2187 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2189 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2192 void main_window_set_account_menu_only_toolbar(GList *account_list)
2195 MainWindow *mainwin;
2197 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2198 mainwin = (MainWindow *)cur->data;
2199 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2200 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2204 static void main_window_show_cur_account(MainWindow *mainwin)
2209 ac_name = g_strdup(cur_account
2210 ? (cur_account->account_name
2211 ? cur_account->account_name : _("Untitled"))
2215 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2217 buf = g_strdup(PROG_VERSION);
2218 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2221 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2222 if (mainwin->ac_button)
2223 gtk_widget_queue_resize(mainwin->ac_button);
2228 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2230 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2231 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2232 GtkWidget *message_wid = mainwin->messageview->vbox;
2234 if (layout_mode == prefs_common.layout_mode)
2237 debug_print("Changing window separation type from %d to %d\n",
2238 prefs_common.layout_mode, layout_mode);
2240 /* remove widgets from those containers */
2241 gtk_widget_ref(folder_wid);
2242 gtk_widget_ref(summary_wid);
2243 gtk_widget_ref(message_wid);
2244 gtkut_container_remove
2245 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2246 gtkut_container_remove
2247 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2248 gtkut_container_remove
2249 (GTK_CONTAINER(message_wid->parent), message_wid);
2251 gtk_widget_hide(mainwin->window);
2252 main_window_set_widgets(mainwin, layout_mode);
2253 gtk_widget_show(mainwin->window);
2255 gtk_widget_unref(folder_wid);
2256 gtk_widget_unref(summary_wid);
2257 gtk_widget_unref(message_wid);
2260 void mainwindow_reset_paned(GtkPaned *paned)
2264 if (gtk_paned_get_child1(GTK_PANED(paned)))
2265 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2266 if (gtk_paned_get_child2(GTK_PANED(paned)))
2267 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2270 g_object_get (G_OBJECT(paned),
2273 g_object_get (G_OBJECT(paned),
2277 gtk_paned_set_position(GTK_PANED(paned), mid);
2280 static void mainwin_paned_show_first(GtkPaned *paned)
2283 g_object_get (G_OBJECT(paned),
2287 if (gtk_paned_get_child1(GTK_PANED(paned)))
2288 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2289 if (gtk_paned_get_child2(GTK_PANED(paned)))
2290 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2291 gtk_paned_set_position(GTK_PANED(paned), max);
2294 static void mainwin_paned_show_last(GtkPaned *paned)
2297 g_object_get (G_OBJECT(paned),
2301 if (gtk_paned_get_child1(GTK_PANED(paned)))
2302 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2303 if (gtk_paned_get_child2(GTK_PANED(paned)))
2304 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2305 gtk_paned_set_position(GTK_PANED(paned), min);
2308 void main_window_toggle_message_view(MainWindow *mainwin)
2310 SummaryView *summaryview = mainwin->summaryview;
2311 GtkWidget *ppaned = NULL;
2312 GtkWidget *container = NULL;
2314 switch (prefs_common.layout_mode) {
2316 case VERTICAL_LAYOUT:
2318 ppaned = mainwin->vpaned;
2319 container = mainwin->hpaned;
2320 if (ppaned->parent != NULL) {
2321 mainwin->messageview->visible = FALSE;
2322 summaryview->displayed = NULL;
2323 gtk_widget_ref(ppaned);
2324 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2325 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2327 mainwin->messageview->visible = TRUE;
2328 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2329 gtk_container_add(GTK_CONTAINER(container), ppaned);
2330 gtk_widget_unref(ppaned);
2334 ppaned = mainwin->hpaned;
2335 container = mainwin->vpaned;
2336 if (mainwin->messageview->vbox->parent != NULL) {
2337 mainwin->messageview->visible = FALSE;
2338 summaryview->displayed = NULL;
2339 gtk_widget_ref(mainwin->messageview->vbox);
2340 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2342 mainwin->messageview->visible = TRUE;
2343 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2344 gtk_widget_unref(mainwin->messageview->vbox);
2347 case WIDE_MSGLIST_LAYOUT:
2348 g_warning("can't hide messageview in this wide msglist layout");
2352 if (messageview_is_visible(mainwin->messageview))
2353 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2354 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2356 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2357 GTK_ARROW_UP, GTK_SHADOW_OUT);
2359 if (mainwin->messageview->visible == FALSE)
2360 messageview_clear(mainwin->messageview);
2362 main_window_set_menu_sensitive(mainwin);
2364 prefs_common.msgview_visible = mainwin->messageview->visible;
2366 if (messageview_is_visible(mainwin->messageview)) {
2367 gtk_widget_queue_resize(mainwin->hpaned);
2368 gtk_widget_queue_resize(mainwin->vpaned);
2370 summary_grab_focus(summaryview);
2373 void main_window_get_size(MainWindow *mainwin)
2375 GtkAllocation *allocation;
2377 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2378 debug_print("called after messageview "
2379 "has been deallocated!\n");
2383 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2385 if (allocation->width > 1 && allocation->height > 1) {
2386 prefs_common.summaryview_width = allocation->width;
2388 if (messageview_is_visible(mainwin->messageview))
2389 prefs_common.summaryview_height = allocation->height;
2391 prefs_common.mainview_width = allocation->width;
2394 allocation = &mainwin->window->allocation;
2395 if (allocation->width > 1 && allocation->height > 1) {
2396 prefs_common.mainview_height = allocation->height;
2397 prefs_common.mainwin_width = allocation->width;
2398 prefs_common.mainwin_height = allocation->height;
2401 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2402 if (allocation->width > 1 && allocation->height > 1) {
2403 prefs_common.folderview_width = allocation->width;
2404 prefs_common.folderview_height = allocation->height;
2407 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2408 if (allocation->width > 1 && allocation->height > 1) {
2409 prefs_common.msgview_width = allocation->width;
2410 prefs_common.msgview_height = allocation->height;
2413 /* debug_print("summaryview size: %d x %d\n",
2414 prefs_common.summaryview_width,
2415 prefs_common.summaryview_height);
2416 debug_print("folderview size: %d x %d\n",
2417 prefs_common.folderview_width,
2418 prefs_common.folderview_height);
2419 debug_print("messageview size: %d x %d\n",
2420 prefs_common.msgview_width,
2421 prefs_common.msgview_height); */
2424 void main_window_get_position(MainWindow *mainwin)
2428 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2430 prefs_common.mainview_x = x;
2431 prefs_common.mainview_y = y;
2432 prefs_common.mainwin_x = x;
2433 prefs_common.mainwin_y = y;
2435 debug_print("main window position: %d, %d\n", x, y);
2438 void main_window_progress_on(MainWindow *mainwin)
2440 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2443 void main_window_progress_off(MainWindow *mainwin)
2445 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2446 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2449 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2451 if (confirm && procmsg_have_trashed_mails_fast()) {
2452 if (alertpanel(_("Empty trash"),
2453 _("Delete all messages in trash folders?"),
2454 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2455 != G_ALERTALTERNATE)
2457 manage_window_focus_in(mainwin->window, NULL, NULL);
2460 procmsg_empty_all_trash();
2462 if (mainwin->summaryview->folder_item &&
2463 mainwin->summaryview->folder_item->stype == F_TRASH)
2464 gtk_widget_grab_focus(mainwin->folderview->ctree);
2467 static void main_window_add_mailbox(MainWindow *mainwin)
2472 path = input_dialog(_("Add mailbox"),
2473 _("Input the location of mailbox.\n"
2474 "If an existing mailbox is specified, it will be\n"
2475 "scanned automatically."),
2478 if (folder_find_from_path(path)) {
2479 alertpanel_error(_("The mailbox '%s' already exists."), path);
2483 folder = folder_new(folder_get_class_from_string("mh"),
2484 !strcmp(path, "Mail") ? _("Mailbox") :
2485 g_path_get_basename(path), path);
2488 if (folder->klass->create_tree(folder) < 0) {
2489 alertpanel_error(_("Creation of the mailbox failed.\n"
2490 "Maybe some files already exist, or you don't have the permission to write there."));
2491 folder_destroy(folder);
2496 folder_set_ui_func(folder, scan_tree_func, mainwin);
2497 folder_scan_tree(folder, TRUE);
2498 folder_set_ui_func(folder, NULL, NULL);
2501 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2503 SensitiveCond state = 0;
2504 SummarySelection selection;
2505 FolderItem *item = mainwin->summaryview->folder_item;
2506 GList *account_list = account_get_list();
2509 selection = summary_get_selection_type(mainwin->summaryview);
2511 if (mainwin->lock_count == 0 && !claws_is_starting())
2512 state |= M_UNLOCKED;
2513 if (selection != SUMMARY_NONE)
2514 state |= M_MSG_EXIST;
2515 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2517 /* if (item->folder->type != F_NEWS) */
2518 state |= M_ALLOW_DELETE;
2520 if (prefs_common.immediate_exec == 0
2521 && mainwin->lock_count == 0)
2522 state |= M_DELAY_EXEC;
2524 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2525 || selection != SUMMARY_NONE)
2526 state |= M_HIDE_READ_MSG;
2528 if (mainwin->summaryview->threaded)
2529 state |= M_THREADED;
2531 state |= M_UNTHREADED;
2532 if (selection == SUMMARY_SELECTED_SINGLE ||
2533 selection == SUMMARY_SELECTED_MULTIPLE)
2534 state |= M_TARGET_EXIST;
2535 if (selection == SUMMARY_SELECTED_SINGLE)
2536 state |= M_SINGLE_TARGET_EXIST;
2537 if (mainwin->summaryview->folder_item &&
2538 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2541 state |= M_NOT_NEWS;
2542 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2543 state |= M_ACTIONS_EXIST;
2545 tmp = tags_get_list();
2546 if (tmp && g_slist_length(tmp))
2547 state |= M_TAGS_EXIST;
2550 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2551 state |= M_HAVE_QUEUED_MAILS;
2553 if (selection == SUMMARY_SELECTED_SINGLE &&
2555 (folder_has_parent_of_type(item, F_DRAFT) ||
2556 folder_has_parent_of_type(item, F_OUTBOX) ||
2557 folder_has_parent_of_type(item, F_QUEUE))))
2558 state |= M_ALLOW_REEDIT;
2560 state |= M_HAVE_ACCOUNT;
2562 if (any_folder_want_synchronise())
2563 state |= M_WANT_SYNC;
2565 if (item && item->prefs->processing && selection != SUMMARY_NONE)
2566 state |= M_HAVE_PROCESSING;
2568 for ( ; account_list != NULL; account_list = account_list->next) {
2569 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2570 state |= M_HAVE_NEWS_ACCOUNT;
2575 if (procmsg_spam_can_learn() &&
2576 (mainwin->summaryview->folder_item &&
2577 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2578 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2579 state |= M_CAN_LEARN_SPAM;
2582 if (inc_is_active())
2583 state |= M_INC_ACTIVE;
2584 if (imap_cancel_all_enabled())
2585 state |= M_INC_ACTIVE;
2587 if (mainwin->summaryview->deleted > 0 ||
2588 mainwin->summaryview->moved > 0 ||
2589 mainwin->summaryview->copied > 0)
2590 state |= M_DELAY_EXEC;
2597 void main_window_set_menu_sensitive(MainWindow *mainwin)
2599 GtkItemFactory *ifactory = mainwin->menu_factory;
2600 SensitiveCond state;
2603 GtkWidget *menuitem;
2604 SummaryView *summaryview;
2609 static const struct {
2613 {"/File/Save as...", M_TARGET_EXIST},
2614 {"/File/Print..." , M_TARGET_EXIST},
2615 {"/File/Synchronise folders", M_WANT_SYNC},
2616 {"/File/Exit" , M_UNLOCKED},
2618 {"/Edit/Select thread" , M_TARGET_EXIST},
2619 {"/Edit/Delete thread" , M_TARGET_EXIST},
2620 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2622 {"/View/Set displayed columns/in Folder list..."
2624 {"/View/Sort" , M_EXEC},
2625 {"/View/Thread view" , M_EXEC},
2626 {"/View/Expand all threads" , M_MSG_EXIST},
2627 {"/View/Collapse all threads" , M_MSG_EXIST},
2628 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2629 {"/View/Go to/Previous message" , M_MSG_EXIST},
2630 {"/View/Go to/Next message" , M_MSG_EXIST},
2631 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2632 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2633 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2634 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2635 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2636 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2637 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2638 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2639 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2640 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2641 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2643 {"/Message/Receive/Get from current account"
2644 , M_HAVE_ACCOUNT|M_UNLOCKED},
2645 {"/Message/Receive/Get from all accounts"
2646 , M_HAVE_ACCOUNT|M_UNLOCKED},
2647 {"/Message/Receive/Cancel receiving"
2649 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2650 {"/Message/Compose an email message", M_HAVE_ACCOUNT},
2651 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2652 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2653 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2654 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2655 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2656 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2657 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2658 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2659 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2660 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2661 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2662 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2663 {"/Message/Mark" , M_TARGET_EXIST},
2664 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2665 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2666 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2667 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2668 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2669 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2670 {"/Message/Color label" , M_TARGET_EXIST},
2671 {"/Message/Tags" , M_TARGET_EXIST},
2672 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2674 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2675 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2676 {"/Tools/Harvest addresses/from Messages..."
2678 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2679 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2680 {"/Tools/Run folder processing rules" , M_HAVE_PROCESSING},
2681 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2682 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2683 {"/Tools/List URLs..." , M_TARGET_EXIST},
2684 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2685 {"/Tools/Execute" , M_DELAY_EXEC},
2686 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2688 {"/Configuration", M_UNLOCKED},
2689 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2690 {"/Configuration/Create new account...", M_UNLOCKED},
2691 {"/Configuration/Edit accounts...", M_UNLOCKED},
2696 state = main_window_get_current_state(mainwin);
2698 for (i = 0; entry[i].entry != NULL; i++) {
2699 sensitive = ((entry[i].cond & state) == entry[i].cond);
2700 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2703 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2705 /* search for separator */
2706 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2707 cur_item = cur_item->next) {
2708 if (GTK_BIN(cur_item->data)->child == NULL) {
2709 cur_item = cur_item->next;
2714 for (; cur_item != NULL; cur_item = cur_item->next) {
2715 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2716 (M_UNLOCKED & state) != 0);
2719 main_window_menu_callback_block(mainwin);
2721 #define SET_CHECK_MENU_ACTIVE(path, active) \
2723 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2724 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2727 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2728 messageview_is_visible(mainwin->messageview));
2730 summaryview = mainwin->summaryview;
2731 menu_path = "/View/Sort/Don't sort";
2733 switch (summaryview->sort_key) {
2734 case SORT_BY_NUMBER:
2735 menu_path = "/View/Sort/by number"; break;
2737 menu_path = "/View/Sort/by Size"; break;
2739 menu_path = "/View/Sort/by Date"; break;
2740 case SORT_BY_THREAD_DATE:
2741 menu_path = "/View/Sort/by Thread date"; break;
2743 menu_path = "/View/Sort/by From"; break;
2745 menu_path = "/View/Sort/by To"; break;
2746 case SORT_BY_SUBJECT:
2747 menu_path = "/View/Sort/by Subject"; break;
2749 menu_path = "/View/Sort/by color label"; break;
2751 menu_path = "/View/Sort/by mark"; break;
2752 case SORT_BY_STATUS:
2753 menu_path = "/View/Sort/by status"; break;
2755 menu_path = "/View/Sort/by attachment"; break;
2757 menu_path = "/View/Sort/by score"; break;
2758 case SORT_BY_LOCKED:
2759 menu_path = "/View/Sort/by locked"; break;
2761 menu_path = "/View/Sort/by tag"; break;
2764 menu_path = "/View/Sort/Don't sort"; break;
2766 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2768 if (summaryview->sort_type == SORT_ASCENDING) {
2769 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2771 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2774 if (summaryview->sort_key != SORT_BY_NONE) {
2775 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2776 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2778 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2779 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2782 if (mainwin->messageview
2783 && mainwin->messageview->mimeview
2784 && mainwin->messageview->mimeview->textview)
2785 SET_CHECK_MENU_ACTIVE("/View/All headers",
2786 mainwin->messageview->mimeview->textview->show_all_headers);
2787 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2788 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2789 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2790 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2791 if (prefs_common.hide_quotes == 1)
2792 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2793 if (prefs_common.hide_quotes == 2)
2794 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2795 if (prefs_common.hide_quotes == 3)
2796 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2798 #undef SET_CHECK_MENU_ACTIVE
2800 main_window_menu_callback_unblock(mainwin);
2803 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2805 GtkItemFactory *ifactory;
2807 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2810 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2812 gtk_widget_set_sensitive (gtk_item_factory_get_item
2813 (ifactory,"/Message/Mailing-List"), TRUE);
2815 gtk_widget_set_sensitive (gtk_item_factory_get_item
2816 (ifactory,"/Message/Mailing-List"), FALSE);
2819 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2822 GtkWidget *menuitem;
2824 if (!msginfo || !msginfo->extradata) {
2825 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2826 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2827 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2828 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2829 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2830 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2834 /* Mailing list post */
2835 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2836 g_free(msginfo->extradata->list_post);
2837 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2839 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2841 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2843 /* Mailing list help */
2844 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2846 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2848 /* Mailing list subscribe */
2849 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2851 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2853 /* Mailing list unsubscribe */
2854 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2856 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2858 /* Mailing list view archive */
2859 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2861 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2863 /* Mailing list contact owner */
2864 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2866 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2871 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2873 GtkWidget *item, *menu;
2874 const gchar *url_pt ;
2875 gchar url_decoded[BUFFSIZE];
2876 GList *amenu, *alist;
2879 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2881 /* First delete old submenu */
2882 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2883 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2884 alist = amenu->next;
2885 item = GTK_WIDGET (amenu->data);
2886 gtk_widget_destroy (item);
2890 for (url_pt = list_header; url_pt && *url_pt;) {
2891 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2893 if (!g_ascii_strncasecmp(url_decoded, "mailto:", 7)) {
2894 item = gtk_menu_item_new_with_label ((url_decoded));
2895 g_signal_connect(G_OBJECT(item), "activate",
2896 G_CALLBACK(mailing_list_compose),
2899 else if (!g_ascii_strncasecmp(url_decoded, "http:", 5) ||
2900 !g_ascii_strncasecmp(url_decoded, "https:",6)) {
2902 item = gtk_menu_item_new_with_label ((url_decoded));
2903 g_signal_connect(G_OBJECT(item), "activate",
2904 G_CALLBACK(mailing_list_open_uri),
2908 gtk_menu_append (GTK_MENU(menu), item);
2909 gtk_widget_show (item);
2915 gtk_widget_set_sensitive (menuitem, TRUE);
2917 gtk_widget_set_sensitive (menuitem, FALSE);
2923 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2925 gchar tmp[BUFFSIZE];
2929 gboolean with_plus = TRUE;
2932 *url_decoded = '\0';
2936 /* Ignore spaces, comments and tabs () */
2937 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2939 for (;*buf != ')' && *buf != 0x00; buf++);
2941 /* First non space and non comment must be a < */
2944 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2946 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2951 *url_decoded = '\0';
2956 *url_decoded = '\0';
2962 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2964 /* Prepare the work for the next url in the list */
2965 /* after the closing bracket >, ignore space, comments and tabs */
2966 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2968 for (;*buf != ')' && *buf != 0x00; buf++);
2970 if (!buf || !*buf) {
2975 /* now first non space, non comment must be a comma */
2977 for (;*buf != 0x00; buf++);
2983 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2987 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2988 compose_new(NULL, mailto+7, NULL);
2991 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2996 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2997 open_uri (mailto, prefs_common.uri_cmd);
3000 void main_window_popup(MainWindow *mainwin)
3002 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
3003 main_window_show(mainwin);
3005 gtkut_window_popup(mainwin->window);
3006 if (prefs_common.layout_mode == SMALL_LAYOUT) {
3007 if (mainwin->in_folder) {
3008 mainwindow_enter_folder(mainwin);
3010 mainwindow_exit_folder(mainwin);
3015 void main_window_show(MainWindow *mainwin)
3017 gtk_widget_show(mainwin->window);
3018 gtk_widget_show(mainwin->vbox_body);
3020 gtk_widget_set_uposition(mainwin->window,
3021 prefs_common.mainwin_x,
3022 prefs_common.mainwin_y);
3024 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3025 prefs_common.folderview_width,
3026 prefs_common.folderview_height);
3027 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3028 prefs_common.summaryview_width,
3029 prefs_common.summaryview_height);
3030 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3031 prefs_common.msgview_width,
3032 prefs_common.msgview_height);
3035 void main_window_hide(MainWindow *mainwin)
3037 main_window_get_size(mainwin);
3038 main_window_get_position(mainwin);
3040 gtk_widget_hide(mainwin->window);
3041 gtk_widget_hide(mainwin->vbox_body);
3044 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
3046 GtkWidget *folderwin = NULL;
3047 GtkWidget *messagewin = NULL;
3050 GtkWidget *vbox_body = mainwin->vbox_body;
3051 GtkItemFactory *ifactory = mainwin->menu_factory;
3052 GtkWidget *menuitem;
3053 gboolean first_set = (mainwin->hpaned == NULL);
3054 debug_print("Setting widgets... ");
3056 if (layout_mode == SMALL_LAYOUT && first_set) {
3057 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3058 prefs_common.folderview_width,
3059 prefs_common.folderview_height);
3060 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3062 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3065 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3066 prefs_common.folderview_width,
3067 prefs_common.folderview_height);
3068 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3069 prefs_common.summaryview_width,
3070 prefs_common.summaryview_height);
3071 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3072 prefs_common.msgview_width,
3073 prefs_common.msgview_height);
3077 mainwin->messageview->statusbar = mainwin->statusbar;
3078 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3080 /* clean top-most container */
3081 if (mainwin->hpaned) {
3082 if (mainwin->hpaned->parent == mainwin->vpaned)
3083 gtk_widget_destroy(mainwin->vpaned);
3085 gtk_widget_destroy(mainwin->hpaned);
3088 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
3089 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
3090 switch (layout_mode) {
3091 case VERTICAL_LAYOUT:
3094 hpaned = gtk_hpaned_new();
3095 if (layout_mode == VERTICAL_LAYOUT)
3096 vpaned = gtk_hpaned_new();
3098 vpaned = gtk_vpaned_new();
3099 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
3100 gtk_paned_add1(GTK_PANED(hpaned),
3101 GTK_WIDGET_PTR(mainwin->folderview));
3102 gtk_widget_show(hpaned);
3103 gtk_widget_queue_resize(hpaned);
3105 if (messageview_is_visible(mainwin->messageview)) {
3106 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
3107 gtk_paned_add1(GTK_PANED(vpaned),
3108 GTK_WIDGET_PTR(mainwin->summaryview));
3110 gtk_paned_add2(GTK_PANED(hpaned),
3111 GTK_WIDGET_PTR(mainwin->summaryview));
3112 gtk_widget_ref(vpaned);
3114 gtk_paned_add2(GTK_PANED(vpaned),
3115 GTK_WIDGET_PTR(mainwin->messageview));
3116 gtk_widget_show(vpaned);
3117 if (layout_mode == SMALL_LAYOUT && first_set) {
3118 mainwin_paned_show_first(GTK_PANED(hpaned));
3120 gtk_widget_queue_resize(vpaned);
3123 vpaned = gtk_vpaned_new();
3124 hpaned = gtk_hpaned_new();
3125 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3126 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
3128 gtk_paned_add1(GTK_PANED(hpaned),
3129 GTK_WIDGET_PTR(mainwin->folderview));
3130 gtk_paned_add2(GTK_PANED(hpaned),
3131 GTK_WIDGET_PTR(mainwin->summaryview));
3133 gtk_widget_show(hpaned);
3134 gtk_widget_queue_resize(hpaned);
3136 if (messageview_is_visible(mainwin->messageview)) {
3137 gtk_paned_add2(GTK_PANED(vpaned),
3138 GTK_WIDGET_PTR(mainwin->messageview));
3140 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3142 gtk_widget_show(vpaned);
3143 gtk_widget_queue_resize(vpaned);
3145 case WIDE_MSGLIST_LAYOUT:
3146 vpaned = gtk_vpaned_new();
3147 hpaned = gtk_hpaned_new();
3148 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3150 gtk_paned_add1(GTK_PANED(vpaned),
3151 GTK_WIDGET_PTR(mainwin->summaryview));
3152 gtk_paned_add1(GTK_PANED(hpaned),
3153 GTK_WIDGET_PTR(mainwin->folderview));
3155 gtk_widget_show(hpaned);
3156 gtk_widget_queue_resize(hpaned);
3158 if (messageview_is_visible(mainwin->messageview)) {
3159 gtk_paned_add2(GTK_PANED(hpaned),
3160 GTK_WIDGET_PTR(mainwin->messageview));
3162 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3164 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3166 gtk_widget_show(vpaned);
3167 gtk_widget_queue_resize(vpaned);
3170 g_warning("Unknown layout");
3174 mainwin->hpaned = hpaned;
3175 mainwin->vpaned = vpaned;
3177 if (layout_mode == SMALL_LAYOUT) {
3178 if (mainwin->messageview->visible)
3179 main_window_toggle_message_view(mainwin);
3182 if (layout_mode == SMALL_LAYOUT && first_set) {
3183 gtk_widget_realize(mainwin->window);
3184 gtk_widget_realize(mainwin->folderview->ctree);
3185 gtk_widget_realize(mainwin->summaryview->hbox);
3186 gtk_widget_realize(mainwin->summaryview->hbox_l);
3187 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3188 prefs_common.folderview_width,
3189 prefs_common.folderview_height);
3190 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3192 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3194 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3195 prefs_common.mainwin_width,
3196 prefs_common.mainwin_height);
3197 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3199 /* remove headerview if not in prefs */
3200 headerview_set_visibility(mainwin->messageview->headerview,
3201 prefs_common.display_header_pane);
3203 if (messageview_is_visible(mainwin->messageview))
3204 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3205 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3207 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3208 GTK_ARROW_UP, GTK_SHADOW_OUT);
3210 gtk_window_move(GTK_WINDOW(mainwin->window),
3211 prefs_common.mainwin_x,
3212 prefs_common.mainwin_y);
3214 gtk_widget_queue_resize(vbox_body);
3215 gtk_widget_queue_resize(mainwin->vbox);
3216 gtk_widget_queue_resize(mainwin->window);
3217 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3218 * and mimeview icon list/ctree lose track of their visibility states */
3219 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3220 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3221 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3222 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3223 if (mainwin->messageview->mimeview->ctree_mode)
3224 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3226 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3228 prefs_common.layout_mode = layout_mode;
3230 menuitem = gtk_item_factory_get_item
3231 (ifactory, "/View/Show or hide/Message view");
3232 gtk_check_menu_item_set_active
3233 (GTK_CHECK_MENU_ITEM(menuitem),
3234 messageview_is_visible(mainwin->messageview));
3236 #define SET_CHECK_MENU_ACTIVE(path, active) \
3238 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3239 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3243 switch (prefs_common.layout_mode) {
3245 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3247 case VERTICAL_LAYOUT:
3248 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3251 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3253 case WIDE_MSGLIST_LAYOUT:
3254 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
3257 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
3261 #undef SET_CHECK_MENU_ACTIVE
3265 (G_OBJECT(folderwin), "size_allocate",
3266 G_CALLBACK(folder_window_size_allocate_cb),
3271 (G_OBJECT(messagewin), "size_allocate",
3272 G_CALLBACK(message_window_size_allocate_cb),
3276 debug_print("done.\n");
3279 void main_window_destroy_all(void)
3281 while (mainwin_list != NULL) {
3282 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
3284 /* free toolbar stuff */
3285 toolbar_clear_list(TOOLBAR_MAIN);
3286 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
3287 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
3289 mainwin->folderview->mainwin = NULL;
3290 mainwin->summaryview->mainwin = NULL;
3291 mainwin->messageview->mainwin = NULL;
3293 g_free(mainwin->toolbar);
3296 mainwin_list = g_list_remove(mainwin_list, mainwin);
3298 g_list_free(mainwin_list);
3299 mainwin_list = NULL;
3302 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
3305 gtk_widget_set_size_request(child, 1, -1);
3308 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
3311 gtk_widget_set_size_request(child, -1, -1);
3314 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
3317 MainWindow *mainwin = (MainWindow *)data;
3319 if (!event) return FALSE;
3321 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3322 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
3325 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3326 menu_button_position, widget,
3327 event->button, event->time);
3332 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3335 MainWindow *mainwin = (MainWindow *)data;
3336 gboolean close_allowed = TRUE;
3338 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
3340 if (close_allowed && mainwin->lock_count == 0)
3341 app_exit_cb(data, 0, widget);
3346 static void main_window_size_allocate_cb(GtkWidget *widget,
3347 GtkAllocation *allocation,
3350 MainWindow *mainwin = (MainWindow *)data;
3351 main_window_get_size(mainwin);
3354 static void folder_window_size_allocate_cb(GtkWidget *widget,
3355 GtkAllocation *allocation,
3358 MainWindow *mainwin = (MainWindow *)data;
3360 main_window_get_size(mainwin);
3363 static void message_window_size_allocate_cb(GtkWidget *widget,
3364 GtkAllocation *allocation,
3367 MainWindow *mainwin = (MainWindow *)data;
3369 main_window_get_size(mainwin);
3372 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3375 main_window_add_mailbox(mainwin);
3378 static void update_folderview_cb(MainWindow *mainwin, guint action,
3381 summary_show(mainwin->summaryview, NULL);
3382 folderview_check_new_all();
3385 static void foldersort_cb(MainWindow *mainwin, guint action,
3391 static void import_mbox_cb(MainWindow *mainwin, guint action,
3394 /* only notify if import has failed */
3395 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3396 alertpanel_error(_("Mbox import has failed."));
3400 static void export_mbox_cb(MainWindow *mainwin, guint action,
3403 /* only notify if export has failed */
3404 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3405 alertpanel_error(_("Export to mbox has failed."));
3409 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3412 /* only notify if export has failed */
3413 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3414 alertpanel_error(_("Export to mbox has failed."));
3418 static void empty_trash_cb(MainWindow *mainwin, guint action,
3421 main_window_empty_trash(mainwin, TRUE);
3424 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3426 summary_save_as(mainwin->summaryview);
3429 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3431 summary_print(mainwin->summaryview);
3434 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
3435 static void page_setup_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3437 MainWindow *mainwindow;
3440 mainwindow = mainwindow_get_mainwindow();
3441 win = (mainwindow ? GTK_WINDOW(mainwindow->window) : NULL);
3443 printing_page_setup(win);
3447 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3449 if (prefs_common.confirm_on_exit) {
3450 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3451 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3452 != G_ALERTALTERNATE)
3454 manage_window_focus_in(mainwin->window, NULL, NULL);
3457 app_will_exit(widget, mainwin);
3460 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3463 summary_search(mainwin->summaryview);
3465 message_search(mainwin->messageview);
3468 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3470 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3473 static void toggle_message_cb(MainWindow *mainwin, guint action,
3478 active = GTK_CHECK_MENU_ITEM(widget)->active;
3480 if (active != messageview_is_visible(mainwin->messageview))
3481 summary_toggle_view(mainwin->summaryview);
3484 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3487 toolbar_toggle(action, mainwin);
3490 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3493 MessageView *msgview = (MessageView*)mainwin->messageview;
3494 GSList *msginfo_list = NULL;
3496 g_return_if_fail(msgview != NULL);
3498 msginfo_list = summary_get_selection(mainwin->summaryview);
3499 g_return_if_fail(msginfo_list != NULL);
3500 compose_reply_from_messageview(msgview, msginfo_list, action);
3501 g_slist_free(msginfo_list);
3504 static void toggle_col_headers_cb(MainWindow *mainwin, guint action,
3507 FolderView *folderview = mainwin->folderview;
3508 SummaryView *summaryview = mainwin->summaryview;
3510 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3511 gtk_clist_column_titles_show(GTK_CLIST(folderview->ctree));
3512 gtk_clist_column_titles_show(GTK_CLIST(summaryview->ctree));
3513 prefs_common.show_col_headers = TRUE;
3515 gtk_clist_column_titles_hide(GTK_CLIST(folderview->ctree));
3516 gtk_clist_column_titles_hide(GTK_CLIST(summaryview->ctree));
3517 prefs_common.show_col_headers = FALSE;
3522 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3525 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3526 gtk_widget_show(mainwin->hbox_stat);
3527 prefs_common.show_statusbar = TRUE;
3529 gtk_widget_hide(mainwin->hbox_stat);
3530 prefs_common.show_statusbar = FALSE;
3534 static void set_layout_cb(MainWindow *mainwin, guint action,
3537 LayoutType layout_mode = action;
3538 LayoutType old_layout_mode = prefs_common.layout_mode;
3539 if (mainwin->menu_lock_count) {
3542 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3546 if (layout_mode == prefs_common.layout_mode) {
3550 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3551 main_window_toggle_message_view(mainwin);
3552 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3553 main_window_toggle_message_view(mainwin);
3555 main_window_separation_change(mainwin, layout_mode);
3556 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3557 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3558 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3560 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3561 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3562 mainwindow_exit_folder(mainwin);
3564 summary_relayout(mainwin->summaryview);
3565 summary_update_unread(mainwin->summaryview, NULL);
3569 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3572 offline_ask_sync = ask_sync;
3574 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3576 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3577 offline_ask_sync = TRUE;
3580 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3582 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3585 static gboolean any_folder_want_synchronise(void)
3587 GList *folderlist = folder_get_list();
3589 /* see if there are synchronised folders */
3590 for (; folderlist; folderlist = folderlist->next) {
3591 Folder *folder = (Folder *)folderlist->data;
3592 if (folder_want_synchronise(folder)) {
3600 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3603 if (!any_folder_want_synchronise())
3606 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3607 _("Do you want to synchronise your folders now?"),
3608 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3611 if (offline_ask_sync)
3612 folder_synchronise(NULL);
3615 static void online_switch_clicked (GtkButton *btn, gpointer data)
3617 MainWindow *mainwin;
3618 GtkItemFactory *ifactory;
3619 GtkCheckMenuItem *menuitem;
3621 mainwin = (MainWindow *) data;
3623 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3624 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3626 g_return_if_fail(mainwin != NULL);
3627 g_return_if_fail(menuitem != NULL);
3629 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3631 gtk_widget_hide (mainwin->online_switch);
3632 gtk_widget_show (mainwin->offline_switch);
3634 menuitem->active = TRUE;
3635 inc_autocheck_timer_remove();
3638 if (prefs_common.work_offline)
3640 mainwindow_check_synchronise(mainwin, TRUE);
3641 prefs_common.work_offline = TRUE;
3642 imap_disconnect_all();
3643 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3646 if (!prefs_common.work_offline)
3649 gtk_widget_hide (mainwin->offline_switch);
3650 gtk_widget_show (mainwin->online_switch);
3652 menuitem->active = FALSE;
3653 prefs_common.work_offline = FALSE;
3654 inc_autocheck_timer_set();
3655 refresh_resolvers();
3656 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3660 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3663 addressbook_open(NULL);
3666 static void log_window_show_cb(MainWindow *mainwin, guint action,
3669 log_window_show(mainwin->logwin);
3672 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3675 log_window_show(mainwin->filtering_debugwin);
3678 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3684 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3686 summary_move_to(mainwin->summaryview);
3689 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3691 summary_copy_to(mainwin->summaryview);
3694 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3696 summary_delete(mainwin->summaryview);
3699 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3701 summary_delete_trash(mainwin->summaryview);
3704 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3706 summary_cancel(mainwin->summaryview);
3709 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3711 summary_open_msg(mainwin->summaryview);
3714 static void view_source_cb(MainWindow *mainwin, guint action,
3717 summary_view_source(mainwin->summaryview);
3720 static void show_all_header_cb(MainWindow *mainwin, guint action,
3723 if (mainwin->menu_lock_count) return;
3724 mainwin->summaryview->messageview->all_headers =
3725 GTK_CHECK_MENU_ITEM(widget)->active;
3726 summary_display_msg_selected(mainwin->summaryview,
3727 GTK_CHECK_MENU_ITEM(widget)->active);
3730 #define SET_CHECK_MENU_ACTIVE(path, active) \
3732 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3733 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3736 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3739 GtkWidget *menuitem;
3740 GtkItemFactory *ifactory = mainwin->menu_factory;
3742 if (mainwin->menu_lock_count) return;
3744 prefs_common.hide_quotes =
3745 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3747 mainwin->menu_lock_count++;
3748 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3749 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3750 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3751 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3752 mainwin->menu_lock_count--;
3754 summary_redisplay_msg(mainwin->summaryview);
3757 #undef SET_CHECK_MENU_ACTIVE
3758 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3760 summary_mark(mainwin->summaryview);
3763 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3765 summary_unmark(mainwin->summaryview);
3768 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3771 summary_mark_as_unread(mainwin->summaryview);
3774 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3777 summary_mark_as_read(mainwin->summaryview);
3780 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3783 summary_mark_all_read(mainwin->summaryview);
3786 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3789 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3792 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3795 summary_ignore_thread(mainwin->summaryview);
3798 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3801 summary_unignore_thread(mainwin->summaryview);
3804 static void watch_thread_cb(MainWindow *mainwin, guint action,
3807 summary_watch_thread(mainwin->summaryview);
3810 static void unwatch_thread_cb(MainWindow *mainwin, guint action,
3813 summary_unwatch_thread(mainwin->summaryview);
3816 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3819 summary_msgs_lock(mainwin->summaryview);
3822 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3825 summary_msgs_unlock(mainwin->summaryview);
3829 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3831 summary_reedit(mainwin->summaryview);
3834 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3836 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3837 summary_display_msg_selected(mainwin->summaryview,
3838 mainwin->messageview->mimeview->textview->show_all_headers);
3840 messageview_list_urls(mainwin->messageview);
3843 static void add_address_cb(MainWindow *mainwin, guint action,
3846 summary_add_address(mainwin->summaryview);
3849 static void set_charset_cb(MainWindow *mainwin, guint action,
3854 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3855 str = conv_get_charset_str((CharSet)action);
3857 g_free(mainwin->messageview->forced_charset);
3858 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3859 procmime_force_charset(str);
3861 summary_redisplay_msg(mainwin->summaryview);
3863 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3867 static void set_decode_cb(MainWindow *mainwin, guint action,
3870 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3871 mainwin->messageview->forced_encoding = (EncodingType)action;
3873 summary_redisplay_msg(mainwin->summaryview);
3875 debug_print("forced encoding: %d\n", action);
3879 static void hide_read_messages (MainWindow *mainwin, guint action,
3882 if (!mainwin->summaryview->folder_item
3883 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3885 summary_toggle_show_read_messages(mainwin->summaryview);
3888 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3890 gboolean threaded = FALSE;
3891 if (mainwin->menu_lock_count) return;
3892 if (!mainwin->summaryview->folder_item) return;
3894 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3896 mainwin->summaryview->folder_item->threaded = threaded;
3898 mainwin->summaryview->threaded = threaded;
3900 summary_show(mainwin->summaryview,
3901 mainwin->summaryview->folder_item);
3904 static void expand_threads_cb(MainWindow *mainwin, guint action,
3907 summary_expand_threads(mainwin->summaryview);
3910 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3913 summary_collapse_threads(mainwin->summaryview);
3916 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3919 prefs_summary_column_open();
3922 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3925 prefs_folder_column_open();
3928 static void sort_summary_cb(MainWindow *mainwin, guint action,
3931 FolderItem *item = mainwin->summaryview->folder_item;
3932 GtkWidget *menuitem;
3934 if (mainwin->menu_lock_count) return;
3936 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3937 menuitem = gtk_item_factory_get_item
3938 (mainwin->menu_factory, "/View/Sort/Ascending");
3939 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3940 GTK_CHECK_MENU_ITEM(menuitem)->active
3941 ? SORT_ASCENDING : SORT_DESCENDING);
3942 item->sort_key = action;
3946 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3949 FolderItem *item = mainwin->summaryview->folder_item;
3951 if (mainwin->menu_lock_count) return;
3953 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3954 summary_sort(mainwin->summaryview,
3955 item->sort_key, (FolderSortType)action);
3958 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3961 summary_attract_by_subject(mainwin->summaryview);
3964 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3969 item = folderview_get_selected_item(mainwin->folderview);
3971 main_window_cursor_wait(mainwin);
3972 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3974 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3975 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3977 STATUSBAR_POP(mainwin);
3978 main_window_cursor_normal(mainwin);
3988 static void deldup_all(FolderItem *item, gpointer _data)
3990 struct DelDupsData *data = _data;
3993 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3995 data->dups += result;
4000 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
4003 struct DelDupsData data = {0, 0};
4005 main_window_cursor_wait(mainwin);
4006 folder_func_to_all_folders(deldup_all, &data);
4007 main_window_cursor_normal(mainwin);
4009 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
4010 "Deleted %d duplicate messages in %d folders.\n",
4012 data.dups, data.folders);
4015 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4017 summary_filter(mainwin->summaryview, (gboolean)action);
4020 static void process_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4022 FolderItem *item = mainwin->summaryview->folder_item;
4023 g_return_if_fail(item != NULL);
4025 folder_item_apply_processing(item);
4028 static void execute_summary_cb(MainWindow *mainwin, guint action,
4031 summary_execute(mainwin->summaryview);
4034 static void update_summary_cb(MainWindow *mainwin, guint action,
4038 FolderView *folderview = mainwin->folderview;
4040 if (!mainwin->summaryview->folder_item) return;
4041 if (!folderview->opened) return;
4043 folder_update_op_count();
4045 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
4046 folderview->opened);
4049 folder_item_scan(fitem);
4050 summary_show(mainwin->summaryview, fitem);
4053 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4055 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
4058 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4060 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
4063 static void prev_unread_cb(MainWindow *mainwin, guint action,
4066 summary_select_prev_unread(mainwin->summaryview);
4069 static void next_unread_cb(MainWindow *mainwin, guint action,
4072 summary_select_next_unread(mainwin->summaryview);
4075 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4077 summary_select_prev_new(mainwin->summaryview);
4080 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4082 summary_select_next_new(mainwin->summaryview);
4085 static void prev_marked_cb(MainWindow *mainwin, guint action,
4088 summary_select_prev_marked(mainwin->summaryview);
4091 static void next_marked_cb(MainWindow *mainwin, guint action,
4094 summary_select_next_marked(mainwin->summaryview);
4097 static void prev_labeled_cb(MainWindow *mainwin, guint action,
4100 summary_select_prev_labeled(mainwin->summaryview);
4103 static void next_labeled_cb(MainWindow *mainwin, guint action,
4106 summary_select_next_labeled(mainwin->summaryview);
4109 static void last_read_cb(MainWindow *mainwin, guint action,
4112 summary_select_last_read(mainwin->summaryview);
4115 static void parent_cb(MainWindow *mainwin, guint action,
4118 summary_select_parent(mainwin->summaryview);
4121 static void goto_folder_cb(MainWindow *mainwin, guint action,
4124 FolderItem *to_folder;
4126 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
4129 folderview_select(mainwin->folderview, to_folder);
4132 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
4135 folderview_select_next_unread(mainwin->folderview, FALSE);
4138 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4140 messageview_copy_clipboard(mainwin->messageview);
4143 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4145 MessageView *msgview = mainwin->messageview;
4147 if (messageview_is_visible(msgview) &&
4148 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
4149 messageview_select_all(mainwin->messageview);
4151 summary_select_all(mainwin->summaryview);
4154 static void select_thread_cb(MainWindow *mainwin, guint action,
4157 summary_select_thread(mainwin->summaryview, FALSE);
4160 static void delete_thread_cb(MainWindow *mainwin, guint action,
4163 summary_select_thread(mainwin->summaryview, TRUE);
4166 static void create_filter_cb(MainWindow *mainwin, guint action,
4169 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
4172 static void create_processing_cb(MainWindow *mainwin, guint action,
4175 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
4178 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
4181 prefs_filtering_open(&pre_global_processing,
4182 _("Processing rules to apply before folder rules"),
4183 MANUAL_ANCHOR_PROCESSING,
4187 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
4190 prefs_filtering_open(&post_global_processing,
4191 _("Processing rules to apply after folder rules"),
4192 MANUAL_ANCHOR_PROCESSING,
4196 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
4199 prefs_filtering_open(&filtering_rules,
4200 _("Filtering configuration"),
4201 MANUAL_ANCHOR_FILTERING,
4205 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
4208 prefs_template_open();
4211 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
4214 prefs_actions_open(mainwin);
4217 static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
4220 prefs_tags_open(mainwin);
4222 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
4223 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
4226 ssl_manager_open(mainwin);
4229 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
4233 new_account_cb(mainwin, 0, widget);
4235 account_open(cur_account);
4239 static void new_account_cb(MainWindow *mainwin, guint action,
4242 account_edit_open();
4243 if (!compose_get_compose_list()) account_add();
4246 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
4248 FolderItem *item = NULL;
4249 cur_account = (PrefsAccount *)data;
4251 if (!mainwindow_get_mainwindow())
4253 main_window_show_cur_account(mainwindow_get_mainwindow());
4254 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
4255 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
4256 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
4257 item = folderview_get_selected_item(
4258 mainwindow_get_mainwindow()->folderview);
4260 toolbar_set_compose_button
4261 (mainwindow_get_mainwindow()->toolbar,
4262 FOLDER_TYPE(item->folder) == F_NEWS ?
4263 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
4267 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
4269 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4270 PrefsAccount *account = (PrefsAccount *)data;
4272 inc_account_mail(mainwin, account);
4275 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
4277 PrefsAccount *account = (PrefsAccount *)data;
4279 compose_new_with_folderitem(account, NULL, NULL);
4282 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
4287 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
4289 pluginwindow_create();
4292 static void manual_open_cb(MainWindow *mainwin, guint action,
4295 manual_open((ManualType)action, NULL);
4298 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
4303 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
4305 MainWindow *mainwin = (MainWindow *)data;
4309 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
4310 LOCAL_FOLDER(folder)->rootpath,
4314 str = g_strdup_printf(_("Scanning folder %s ..."),
4315 LOCAL_FOLDER(folder)->rootpath);
4317 STATUSBAR_PUSH(mainwin, str);
4318 STATUSBAR_POP(mainwin);
4322 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
4325 SummaryView *summary;
4327 g_return_val_if_fail(data, FALSE);
4328 if (!g_list_find(mainwin_list, data))
4330 summary = ((MainWindow *)data)->summaryview;
4331 g_return_val_if_fail(summary, FALSE);
4333 if (GTK_CLIST(summary->ctree)->selection &&
4334 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
4340 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
4343 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
4347 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
4350 if (!claws_is_starting()
4351 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
4352 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
4354 if (iconified_count > 0)
4355 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
4358 if (state->new_window_state == 0)
4359 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
4363 gboolean mainwindow_is_obscured(void)
4369 * Harvest addresses for selected folder.
4371 static void addr_harvest_cb( MainWindow *mainwin,
4375 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4379 * Harvest addresses for selected messages in summary view.
4381 static void addr_harvest_msg_cb( MainWindow *mainwin,
4385 summary_harvest_address( mainwin->summaryview );
4389 *\brief get a MainWindow
4391 *\return MainWindow * The first mainwindow in the mainwin_list
4393 MainWindow *mainwindow_get_mainwindow(void)
4395 if (mainwin_list && mainwin_list->data)
4396 return (MainWindow *)(mainwin_list->data);
4401 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4403 ProgressData *data = (ProgressData *) source;
4404 MainWindow *mainwin = (MainWindow *) userdata;
4406 switch (data->cmd) {
4407 case PROGRESS_COMMAND_START:
4408 case PROGRESS_COMMAND_STOP:
4409 gtk_progress_bar_set_fraction
4410 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4412 case PROGRESS_COMMAND_SET_PERCENTAGE:
4413 gtk_progress_bar_set_fraction
4414 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4417 while (gtk_events_pending()) gtk_main_iteration ();
4422 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4424 mainwindow_check_synchronise(mainwin, FALSE);
4427 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4429 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4432 void mainwindow_jump_to(const gchar *target, gboolean popup)
4436 FolderItem *item = NULL;
4438 MainWindow *mainwin = mainwindow_get_mainwindow();
4444 g_print("not initialized\n");
4448 tmp = g_strdup(target);
4450 if ((p = strstr(tmp, "\r")) != NULL)
4452 if ((p = strstr(tmp, "\n")) != NULL)
4455 if ((item = folder_find_item_from_identifier(tmp))) {
4456 g_print("selecting folder '%s'\n", tmp);
4457 folderview_select(mainwin->folderview, item);
4459 main_window_popup(mainwin);
4464 msg = strrchr(tmp, G_DIR_SEPARATOR);
4467 if ((item = folder_find_item_from_identifier(tmp))) {
4468 g_print("selecting folder '%s'\n", tmp);
4469 folderview_select(mainwin->folderview, item);
4471 g_print("'%s' not found\n", tmp);
4473 if (item && msg && atoi(msg)) {
4474 g_print("selecting message %d\n", atoi(msg));
4475 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4476 summary_display_msg_selected(mainwin->summaryview, FALSE);
4478 main_window_popup(mainwin);
4481 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4482 MsgInfo *msginfo = NULL;
4484 msg[strlen(msg)-1] = '\0';
4485 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4487 g_print("selecting message %s\n", msg);
4488 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4489 summary_display_msg_selected(mainwin->summaryview, FALSE);
4491 main_window_popup(mainwin);
4493 procmsg_msginfo_free(msginfo);
4496 g_print("'%s' not found\n", msg);
4499 g_print("'%s' not found\n", msg);
4502 g_print("'%s' not found\n", tmp);
4508 void mainwindow_exit_folder(MainWindow *mainwin) {
4509 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4510 folderview_close_opened(mainwin->folderview);
4511 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4513 mainwin->in_folder = FALSE;
4516 void mainwindow_enter_folder(MainWindow *mainwin) {
4517 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4518 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4520 mainwin->in_folder = TRUE;
4524 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4527 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4531 void maemo_window_full_screen_if_needed (GtkWindow *window)
4533 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4534 gtk_window_fullscreen(GTK_WINDOW(window));
4538 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4540 g_signal_connect(G_OBJECT(window), "key_press_event",
4541 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());