2 Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <glib/gi18n.h>
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
42 #include <gtk/gtktooltips.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
64 #include "prefs_common.h"
65 #include "prefs_actions.h"
66 #include "prefs_filtering.h"
67 #include "prefs_account.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_folder_column.h"
70 #include "prefs_template.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.h"
87 #include "prefs_gtk.h"
88 #include "pluginwindow.h"
90 #include "progressindicator.h"
91 #include "localfolder.h"
92 #include "filtering.h"
93 #include "folderutils.h"
94 #include "foldersort.h"
95 #include "icon_legend.h"
96 #include "colorlabel.h"
102 #define AC_LABEL_WIDTH 240
104 /* list of all instantiated MainWindow */
105 static GList *mainwin_list = NULL;
107 static GdkCursor *watch_cursor = NULL;
108 static GdkCursor *hand_cursor = NULL;
110 static gint iconified_count = 0;
112 static void main_window_menu_callback_block (MainWindow *mainwin);
113 static void main_window_menu_callback_unblock (MainWindow *mainwin);
115 static void main_window_show_cur_account (MainWindow *mainwin);
117 static void main_window_separation_change (MainWindow *mainwin,
118 LayoutType layout_mode);
120 static void main_window_set_widgets (MainWindow *mainwin,
121 LayoutType layout_mode);
123 static void toolbar_child_attached (GtkWidget *widget,
126 static void toolbar_child_detached (GtkWidget *widget,
130 static gboolean ac_label_button_pressed (GtkWidget *widget,
131 GdkEventButton *event,
134 static gint main_window_close_cb (GtkWidget *widget,
138 static void main_window_size_allocate_cb (GtkWidget *widget,
139 GtkAllocation *allocation,
141 static void folder_window_size_allocate_cb (GtkWidget *widget,
142 GtkAllocation *allocation,
144 static void message_window_size_allocate_cb (GtkWidget *widget,
145 GtkAllocation *allocation,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void foldersort_cb (MainWindow *mainwin,
157 static void import_mbox_cb (MainWindow *mainwin,
160 static void export_mbox_cb (MainWindow *mainwin,
163 static void export_list_mbox_cb (MainWindow *mainwin,
166 static void empty_trash_cb (MainWindow *mainwin,
170 static void save_as_cb (MainWindow *mainwin,
173 static void print_cb (MainWindow *mainwin,
176 static void app_exit_cb (MainWindow *mainwin,
180 static void search_cb (MainWindow *mainwin,
184 static void toggle_message_cb (MainWindow *mainwin,
187 static void toggle_toolbar_cb (MainWindow *mainwin,
190 static void toggle_statusbar_cb (MainWindow *mainwin,
193 static void set_layout_cb (MainWindow *mainwin,
197 static void addressbook_open_cb (MainWindow *mainwin,
200 static void log_window_show_cb (MainWindow *mainwin,
203 static void filtering_debug_window_show_cb (MainWindow *mainwin,
207 static void inc_cancel_cb (MainWindow *mainwin,
211 static void open_msg_cb (MainWindow *mainwin,
215 static void view_source_cb (MainWindow *mainwin,
219 static void show_all_header_cb (MainWindow *mainwin,
223 static void hide_quotes_cb(MainWindow *mainwin,
227 static void move_to_cb (MainWindow *mainwin,
230 static void copy_to_cb (MainWindow *mainwin,
233 static void delete_cb (MainWindow *mainwin,
236 static void delete_trash_cb (MainWindow *mainwin,
240 static void cancel_cb (MainWindow *mainwin,
244 static void mark_cb (MainWindow *mainwin,
247 static void unmark_cb (MainWindow *mainwin,
251 static void mark_as_unread_cb (MainWindow *mainwin,
254 static void mark_as_read_cb (MainWindow *mainwin,
257 static void mark_all_read_cb (MainWindow *mainwin,
260 static void mark_as_spam_cb (MainWindow *mainwin,
264 static void ignore_thread_cb (MainWindow *mainwin,
267 static void unignore_thread_cb (MainWindow *mainwin,
270 static void lock_msgs_cb (MainWindow *mainwin,
273 static void unlock_msgs_cb (MainWindow *mainwin,
277 static void reedit_cb (MainWindow *mainwin,
281 static void add_address_cb (MainWindow *mainwin,
285 static void set_charset_cb (MainWindow *mainwin,
289 static void set_decode_cb (MainWindow *mainwin,
293 static void hide_read_messages (MainWindow *mainwin,
297 static void thread_cb (MainWindow *mainwin,
300 static void expand_threads_cb (MainWindow *mainwin,
303 static void collapse_threads_cb (MainWindow *mainwin,
307 static void set_summary_display_item_cb (MainWindow *mainwin,
310 static void set_folder_display_item_cb (MainWindow *mainwin,
313 static void sort_summary_cb (MainWindow *mainwin,
316 static void sort_summary_type_cb (MainWindow *mainwin,
319 static void attract_by_subject_cb(MainWindow *mainwin,
323 static void delete_duplicated_cb (MainWindow *mainwin,
326 static void delete_duplicated_all_cb (MainWindow *mainwin,
329 static void filter_cb (MainWindow *mainwin,
332 static void execute_summary_cb (MainWindow *mainwin,
335 static void update_summary_cb (MainWindow *mainwin,
339 static void prev_cb (MainWindow *mainwin,
342 static void next_cb (MainWindow *mainwin,
345 static void next_unread_cb (MainWindow *mainwin,
348 static void prev_unread_cb (MainWindow *mainwin,
352 static void prev_new_cb (MainWindow *mainwin,
355 static void next_new_cb (MainWindow *mainwin,
358 static void prev_marked_cb (MainWindow *mainwin,
361 static void next_marked_cb (MainWindow *mainwin,
364 static void prev_labeled_cb (MainWindow *mainwin,
367 static void next_labeled_cb (MainWindow *mainwin,
370 static void last_read_cb (MainWindow *mainwin,
373 static void parent_cb (MainWindow *mainwin,
377 static void goto_folder_cb (MainWindow *mainwin,
380 static void goto_unread_folder_cb(MainWindow *mainwin,
384 static void copy_cb (MainWindow *mainwin,
387 static void allsel_cb (MainWindow *mainwin,
390 static void select_thread_cb (MainWindow *mainwin,
393 static void delete_thread_cb (MainWindow *mainwin,
397 static void create_filter_cb (MainWindow *mainwin,
400 static void create_processing_cb (MainWindow *mainwin,
403 static void open_urls_cb (MainWindow *mainwin,
407 static void prefs_template_open_cb (MainWindow *mainwin,
410 static void prefs_actions_open_cb (MainWindow *mainwin,
413 static void prefs_tags_open_cb (MainWindow *mainwin,
416 static void prefs_account_open_cb (MainWindow *mainwin,
420 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
424 static void prefs_post_processing_open_cb (MainWindow *mainwin,
428 static void prefs_filtering_open_cb (MainWindow *mainwin,
432 static void ssl_manager_open_cb (MainWindow *mainwin,
436 static void new_account_cb (MainWindow *mainwin,
440 static void account_selector_menu_cb (GtkMenuItem *menuitem,
442 static void account_receive_menu_cb (GtkMenuItem *menuitem,
444 static void account_compose_menu_cb (GtkMenuItem *menuitem,
447 static void prefs_open_cb (GtkMenuItem *menuitem,
449 static void plugins_open_cb (GtkMenuItem *menuitem,
452 static void online_switch_clicked(GtkButton *btn,
455 static void manual_open_cb (MainWindow *mainwin,
459 static void legend_open_cb (GtkMenuItem *menuitem,
462 static void scan_tree_func (Folder *folder,
466 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
468 static void addr_harvest_cb ( MainWindow *mainwin,
472 static void addr_harvest_msg_cb ( MainWindow *mainwin,
475 static void sync_cb ( MainWindow *mainwin,
479 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
480 GdkEventFocus *focus,
482 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
483 GdkEventVisibility *state,
485 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
486 GdkEventWindowState *state,
488 static void main_window_reply_cb (MainWindow *mainwin,
491 static gboolean mainwindow_progressindicator_hook (gpointer source,
494 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
497 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
499 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
501 static void mailing_list_compose(GtkWidget *w, gpointer *data);
503 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
504 #define SEPARATE_ACTION 500
505 static void mainwindow_quicksearch (MainWindow *mainwin,
508 static gboolean any_folder_want_synchronise(void);
510 static GtkItemFactoryEntry mainwin_entries[] =
512 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
513 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
514 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
515 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
517 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
519 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
520 {N_("/_File/Exp_ort selected to mbox file..."),
521 NULL, export_list_mbox_cb, 0, NULL},
522 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
524 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
525 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
526 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
527 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
529 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
530 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
531 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
532 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
534 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
536 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
537 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
538 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
539 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_Edit/_Find in current message..."),
541 "<control>F", search_cb, 0, NULL},
542 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
543 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
544 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Message view"),
547 "V", toggle_message_cb, 0, "<ToggleItem>"},
548 {N_("/_View/Show or hi_de/_Toolbar"),
549 NULL, NULL, 0, "<Branch>"},
550 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
551 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
552 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
553 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
554 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
555 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
556 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
557 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
558 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
559 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
560 {N_("/_View/Show or hi_de/Status _bar"),
561 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
562 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
563 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
564 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
566 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
567 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
568 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
569 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
570 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
571 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
572 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
573 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
575 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
576 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
577 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
578 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
580 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
581 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
582 {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
583 {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
584 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
585 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
586 {N_("/_View/_Sort/by a_ttachment"),
587 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
588 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
589 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
590 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
591 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
593 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
594 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Sort/_Attract by subject"),
596 NULL, attract_by_subject_cb, 0, NULL},
597 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
598 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
599 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
600 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
602 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
604 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
605 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
606 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_View/_Go to/P_revious unread message"),
608 "<shift>P", prev_unread_cb, 0, NULL},
609 {N_("/_View/_Go to/N_ext unread message"),
610 "<shift>N", next_unread_cb, 0, NULL},
611 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
612 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
613 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Previous _marked message"),
616 NULL, prev_marked_cb, 0, NULL},
617 {N_("/_View/_Go to/Next m_arked message"),
618 NULL, next_marked_cb, 0, NULL},
619 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Go to/Previous _labeled message"),
621 NULL, prev_labeled_cb, 0, NULL},
622 {N_("/_View/_Go to/Next la_beled message"),
623 NULL, next_labeled_cb, 0, NULL},
624 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_View/_Go to/Last read message"),
626 NULL, last_read_cb, 0, NULL},
627 {N_("/_View/_Go to/Parent message"),
628 "<control>Up", parent_cb, 0, NULL},
629 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
631 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
632 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
634 #define ENC_SEPARATOR \
635 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
636 #define ENC_ACTION(action) \
637 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
639 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
640 {N_("/_View/Character _encoding/_Auto detect"),
641 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
642 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
643 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
644 ENC_ACTION(C_US_ASCII)},
645 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
646 ENC_ACTION(C_UTF_8)},
649 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
650 ENC_ACTION(C_ISO_8859_1)},
651 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
652 ENC_ACTION(C_ISO_8859_15)},
653 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
654 ENC_ACTION(C_WINDOWS_1252)},
657 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
658 ENC_ACTION(C_ISO_8859_2)},
661 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
662 ENC_ACTION(C_ISO_8859_13)},
663 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
664 ENC_ACTION(C_ISO_8859_4)},
667 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
668 ENC_ACTION(C_ISO_8859_7)},
671 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
672 ENC_ACTION(C_ISO_8859_8)},
673 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
674 ENC_ACTION(C_CP1255)},
677 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
678 ENC_ACTION(C_ISO_8859_6)},
679 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
680 ENC_ACTION(C_CP1256)},
683 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
684 ENC_ACTION(C_ISO_8859_9)},
687 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
688 ENC_ACTION(C_ISO_8859_5)},
689 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
690 ENC_ACTION(C_KOI8_R)},
691 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
692 ENC_ACTION(C_KOI8_U)},
693 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
694 ENC_ACTION(C_CP1251)},
697 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
698 ENC_ACTION(C_ISO_2022_JP)},
699 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
700 ENC_ACTION(C_ISO_2022_JP_2)},
701 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
702 ENC_ACTION(C_EUC_JP)},
703 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
704 ENC_ACTION(C_SHIFT_JIS)},
707 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
708 ENC_ACTION(C_GB2312)},
709 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
711 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
713 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
714 ENC_ACTION(C_EUC_TW)},
715 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
716 ENC_ACTION(C_ISO_2022_CN)},
719 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
720 ENC_ACTION(C_EUC_KR)},
721 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
722 ENC_ACTION(C_ISO_2022_KR)},
725 {N_("/_View/Character _encoding/Thai (TIS-620)"),
726 ENC_ACTION(C_TIS_620)},
727 {N_("/_View/Character _encoding/Thai (Windows-874)"),
728 ENC_ACTION(C_WINDOWS_874)},
733 #define DEC_SEPARATOR \
734 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
735 #define DEC_ACTION(action) \
736 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
737 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_View/Decode/_Auto detect"),
739 NULL, set_decode_cb, 0, "<RadioItem>"},
740 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
741 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
742 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
743 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
744 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
749 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
750 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
751 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
752 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
753 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
754 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
755 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
756 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
757 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
758 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
760 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
761 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
762 {N_("/_Message/Recei_ve/Get from _current account"),
763 "<control>I", inc_mail_cb, 0, NULL},
764 {N_("/_Message/Recei_ve/Get from _all accounts"),
765 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
766 {N_("/_Message/Recei_ve/Cancel receivin_g"),
767 NULL, inc_cancel_cb, 0, NULL},
768 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
769 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
770 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
771 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
772 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
773 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
774 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
775 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
776 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
777 {N_("/_Message/Repl_y to/mailing _list"),
778 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
779 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
780 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
781 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
782 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
783 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
785 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
786 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
787 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
788 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
789 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
790 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
791 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
793 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
794 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
795 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
796 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
797 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
798 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
799 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
800 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
801 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
802 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
803 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
804 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
805 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
806 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
807 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
808 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
809 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
810 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
811 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
812 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
813 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
814 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
815 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
816 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
817 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
818 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
820 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
821 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
822 {N_("/_Tools/Add sender to address boo_k"),
823 NULL, add_address_cb, 0, NULL},
824 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
825 {N_("/_Tools/_Harvest addresses/from _Folder..."),
826 NULL, addr_harvest_cb, 0, NULL},
827 {N_("/_Tools/_Harvest addresses/from _Messages..."),
828 NULL, addr_harvest_msg_cb, 0, NULL},
829 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
830 {N_("/_Tools/_Filter all messages in folder"),
831 NULL, filter_cb, 0, NULL},
832 {N_("/_Tools/Filter _selected messages"),
833 NULL, filter_cb, 1, NULL},
834 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
835 {N_("/_Tools/_Create filter rule/_Automatically"),
836 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
837 {N_("/_Tools/_Create filter rule/by _From"),
838 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
839 {N_("/_Tools/_Create filter rule/by _To"),
840 NULL, create_filter_cb, FILTER_BY_TO, NULL},
841 {N_("/_Tools/_Create filter rule/by _Subject"),
842 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
843 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
844 {N_("/_Tools/C_reate processing rule/_Automatically"),
845 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
846 {N_("/_Tools/C_reate processing rule/by _From"),
847 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
848 {N_("/_Tools/C_reate processing rule/by _To"),
849 NULL, create_processing_cb, FILTER_BY_TO, NULL},
850 {N_("/_Tools/C_reate processing rule/by _Subject"),
851 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
852 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
853 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
854 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
855 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
856 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
857 {N_("/_Tools/Ch_eck for new messages in all folders"),
858 NULL, update_folderview_cb, 0, NULL},
859 {N_("/_Tools/Delete du_plicated messages"),
860 NULL, NULL, 0, "<Branch>"},
861 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
862 NULL, delete_duplicated_cb, 0, NULL},
863 {N_("/_Tools/Delete du_plicated messages/In all folders"),
864 NULL, delete_duplicated_all_cb, 0, NULL},
865 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
866 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
868 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
869 {N_("/_Tools/SSL cer_tificates..."),
870 NULL, ssl_manager_open_cb, 0, NULL},
872 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
873 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
874 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
876 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
877 {N_("/_Configuration/C_hange current account"),
878 NULL, NULL, 0, "<Branch>"},
879 {N_("/_Configuration/_Preferences for current account..."),
880 NULL, prefs_account_open_cb, 0, NULL},
881 {N_("/_Configuration/Create _new account..."),
882 NULL, new_account_cb, 0, NULL},
883 {N_("/_Configuration/_Edit accounts..."),
884 NULL, account_edit_open, 0, NULL},
885 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
886 {N_("/_Configuration/P_references..."),
887 NULL, prefs_open_cb, 0, NULL},
888 {N_("/_Configuration/Pre-pr_ocessing..."),
889 NULL, prefs_pre_processing_open_cb, 0, NULL},
890 {N_("/_Configuration/Post-pro_cessing..."),
891 NULL, prefs_post_processing_open_cb, 0, NULL},
892 {N_("/_Configuration/_Filtering..."),
893 NULL, prefs_filtering_open_cb, 0, NULL},
894 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
895 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
896 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
897 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
898 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
900 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
901 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
902 {N_("/_Help/_Online User-contributed FAQ"),
903 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
904 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
905 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
906 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
909 static gboolean offline_ask_sync = TRUE;
910 static guint lastkey;
911 static gboolean is_obscured = FALSE;
913 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
919 MainWindow *mainwin = (MainWindow *)user_data;
921 if (mainwin->summaryview &&
922 mainwin->summaryview->quicksearch &&
923 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
924 (mod == 0 || mod == GDK_SHIFT_MASK)) {
925 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
931 #define N_COLOR_LABELS colorlabel_get_color_count()
933 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
938 GtkCheckMenuItem **items;
943 mainwin = (MainWindow *)data;
944 g_return_if_fail(mainwin != NULL);
946 sel = summary_get_selection(mainwin->summaryview);
949 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
950 g_return_if_fail(menu != NULL);
952 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
954 /* NOTE: don't return prematurely because we set the "dont_toggle"
955 * state for check menu items */
956 g_object_set_data(G_OBJECT(menu), "dont_toggle",
959 /* clear items. get item pointers. */
960 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
961 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
962 gtk_check_menu_item_set_active
963 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
964 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
969 if (n == (N_COLOR_LABELS + 1)) {
970 /* iterate all messages and set the state of the appropriate
972 for (; sel != NULL; sel = sel->next) {
976 msginfo = (MsgInfo *)sel->data;
978 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
979 if (!items[clabel]->active)
980 gtk_check_menu_item_set_active
981 (items[clabel], TRUE);
985 g_warning("invalid number of color elements (%d)\n", n);
988 /* reset "dont_toggle" state */
989 g_object_set_data(G_OBJECT(menu), "dont_toggle",
993 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
996 guint color = GPOINTER_TO_UINT(data);
999 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1000 g_return_if_fail(mainwin != NULL);
1002 /* "dont_toggle" state set? */
1003 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1007 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1010 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1013 MainWindow *mainwin;
1017 GHashTable *menu_table = g_hash_table_new_full(
1022 mainwin = (MainWindow *)data;
1023 g_return_if_fail(mainwin != NULL);
1025 sel = summary_get_selection(mainwin->summaryview);
1028 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1029 g_return_if_fail(menu != NULL);
1031 /* NOTE: don't return prematurely because we set the "dont_toggle"
1032 * state for check menu items */
1033 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1034 GINT_TO_POINTER(1));
1036 /* clear items. get item pointers. */
1037 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1038 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1039 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1041 gtk_check_menu_item_set_active
1042 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1044 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1048 /* iterate all messages and set the state of the appropriate
1050 for (; sel != NULL; sel = sel->next) {
1052 GSList *tags = NULL;
1054 GtkCheckMenuItem *item;
1055 msginfo = (MsgInfo *)sel->data;
1057 tags = msginfo->tags;
1061 for (; tags; tags = tags->next) {
1062 id = GPOINTER_TO_INT(tags->data);
1063 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1064 if (item && !item->active)
1065 gtk_check_menu_item_set_active
1072 g_hash_table_destroy(menu_table);
1073 /* reset "dont_toggle" state */
1074 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1075 GINT_TO_POINTER(0));
1078 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1081 gint id = GPOINTER_TO_INT(data);
1082 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1083 MainWindow *mainwin;
1085 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1086 g_return_if_fail(mainwin != NULL);
1088 /* "dont_toggle" state set? */
1089 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1095 summary_set_tag(mainwin->summaryview, id, NULL);
1098 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1100 GtkWidget *label_menuitem;
1105 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1106 "/Message/Color label");
1107 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1108 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1110 gtk_widget_show(label_menuitem);
1112 menu = gtk_menu_new();
1114 /* create sub items. for the menu item activation callback we pass the
1115 * index of label_colors[] as data parameter. for the None color we
1116 * pass an invalid (high) value. also we attach a data pointer so we
1117 * can always get back the Mainwindow pointer. */
1119 item = gtk_check_menu_item_new_with_label(_("None"));
1120 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1121 g_signal_connect(G_OBJECT(item), "activate",
1122 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1123 GUINT_TO_POINTER(0));
1124 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1125 gtk_widget_show(item);
1127 gtk_widget_add_accelerator(item, "activate",
1128 mainwin->menu_factory->accel_group,
1129 GDK_0, GDK_CONTROL_MASK,
1130 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1132 item = gtk_menu_item_new();
1133 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1134 gtk_widget_show(item);
1136 /* create pixmap/label menu items */
1137 for (i = 0; i < N_COLOR_LABELS; i++) {
1138 item = colorlabel_create_check_color_menu_item(
1139 i, refresh, MAINWIN_COLORMENU);
1140 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1141 g_signal_connect(G_OBJECT(item), "activate",
1142 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1143 GUINT_TO_POINTER(i + 1));
1144 g_object_set_data(G_OBJECT(item), "mainwin",
1146 gtk_widget_show(item);
1148 gtk_widget_add_accelerator(item, "activate",
1149 mainwin->menu_factory->accel_group,
1150 GDK_1+i, GDK_CONTROL_MASK,
1151 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1153 gtk_widget_show(menu);
1154 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1155 mainwin->colorlabel_menu = menu;
1158 static void mainwindow_tags_menu_item_new_tag_activate_cb(GtkWidget *widget,
1161 MainWindow *mainwin;
1163 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1164 g_return_if_fail(mainwin != NULL);
1166 /* "dont_toggle" state set? */
1167 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1171 id = prefs_tags_create_new(mainwin);
1173 summary_set_tag(mainwin->summaryview, id, NULL);
1174 main_window_reflect_tags_changes(mainwindow_get_mainwindow());
1178 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1180 GtkWidget *label_menuitem;
1183 GSList *cur = tags_get_list();
1185 gboolean existing_tags = FALSE;
1187 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1189 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1190 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1193 gtk_widget_show(label_menuitem);
1195 menu = gtk_menu_new();
1197 /* create tags menu items */
1198 for (; cur; cur = cur->next) {
1199 gint id = GPOINTER_TO_INT(cur->data);
1200 const gchar *tag = tags_get_tag(id);
1202 item = gtk_check_menu_item_new_with_label(tag);
1203 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1204 g_signal_connect(G_OBJECT(item), "activate",
1205 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1206 GINT_TO_POINTER(id));
1207 g_object_set_data(G_OBJECT(item), "mainwin",
1209 g_object_set_data(G_OBJECT(item), "tag_id",
1210 GINT_TO_POINTER(id));
1211 gtk_widget_show(item);
1212 existing_tags = TRUE;
1214 if (existing_tags) {
1216 item = gtk_menu_item_new();
1217 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1218 gtk_widget_show(item);
1220 item = gtk_menu_item_new_with_label(_("New tag..."));
1221 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1222 g_signal_connect(G_OBJECT(item), "activate",
1223 G_CALLBACK(mainwindow_tags_menu_item_new_tag_activate_cb),
1225 g_object_set_data(G_OBJECT(item), "mainwin",
1227 gtk_widget_show(item);
1229 gtk_widget_show(menu);
1230 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1231 mainwin->tags_menu = menu;
1234 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1235 MainWindow *mainwindow)
1237 if (evt && evt->button == 1) {
1238 log_window_show_error(mainwindow->logwin);
1239 gtk_widget_hide(mainwindow->warning_btn);
1244 static gboolean warning_visi_notify(GtkWidget *widget,
1245 GdkEventVisibility *event,
1246 MainWindow *mainwindow)
1248 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1252 static gboolean warning_leave_notify(GtkWidget *widget,
1253 GdkEventCrossing *event,
1254 MainWindow *mainwindow)
1256 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1260 static gboolean warning_enter_notify(GtkWidget *widget,
1261 GdkEventCrossing *event,
1262 MainWindow *mainwindow)
1264 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1268 void mainwindow_show_error(void)
1270 MainWindow *mainwin = mainwindow_get_mainwindow();
1271 gtk_widget_show(mainwin->warning_btn);
1274 void mainwindow_clear_error(MainWindow *mainwin)
1276 gtk_widget_hide(mainwin->warning_btn);
1279 MainWindow *main_window_create()
1281 MainWindow *mainwin;
1285 GtkWidget *handlebox;
1286 GtkWidget *vbox_body;
1287 GtkWidget *hbox_stat;
1288 GtkWidget *statusbar;
1289 GtkWidget *progressbar;
1290 GtkWidget *statuslabel;
1291 GtkWidget *ac_button;
1292 GtkWidget *ac_label;
1293 GtkWidget *online_pixmap;
1294 GtkWidget *offline_pixmap;
1295 GtkWidget *online_switch;
1296 GtkWidget *offline_switch;
1298 GtkWidget *warning_icon;
1299 GtkWidget *warning_btn;
1301 FolderView *folderview;
1302 SummaryView *summaryview;
1303 MessageView *messageview;
1304 GdkColormap *colormap;
1306 gboolean success[4];
1307 GtkItemFactory *ifactory;
1309 GtkWidget *menuitem;
1311 guint n_menu_entries;
1313 static GdkGeometry geometry;
1315 debug_print("Creating main window...\n");
1316 mainwin = g_new0(MainWindow, 1);
1319 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
1320 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1321 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1323 if (!geometry.min_height) {
1324 geometry.min_width = 320;
1325 geometry.min_height = 200;
1327 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1330 g_signal_connect(G_OBJECT(window), "delete_event",
1331 G_CALLBACK(main_window_close_cb), mainwin);
1332 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1333 g_signal_connect(G_OBJECT(window), "focus_in_event",
1334 G_CALLBACK(mainwindow_focus_in_event),
1336 g_signal_connect(G_OBJECT(window), "key_press_event",
1337 G_CALLBACK(mainwindow_key_pressed), mainwin);
1339 gtk_widget_realize(window);
1340 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1343 gtkut_widget_set_app_icon(window);
1345 vbox = gtk_vbox_new(FALSE, 0);
1346 gtk_widget_show(vbox);
1347 gtk_container_add(GTK_CONTAINER(window), vbox);
1350 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1351 menubar = menubar_create(window, mainwin_entries,
1352 n_menu_entries, "<Main>", mainwin);
1353 gtk_widget_show(menubar);
1354 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1355 ifactory = gtk_item_factory_from_widget(menubar);
1357 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1358 main_create_mailing_list_menu (mainwin, NULL); */
1360 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1362 if (prefs_common.toolbar_detachable) {
1363 handlebox = gtk_handle_box_new();
1364 gtk_widget_show(handlebox);
1365 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1366 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1367 G_CALLBACK(toolbar_child_attached), mainwin);
1368 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1369 G_CALLBACK(toolbar_child_detached), mainwin);
1371 handlebox = gtk_hbox_new(FALSE, 0);
1372 gtk_widget_show(handlebox);
1373 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1375 /* link window to mainwin->window to avoid gdk warnings */
1376 mainwin->window = window;
1378 /* create toolbar */
1379 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1382 toolbar_set_learn_button
1386 /* vbox that contains body */
1387 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1388 gtk_widget_show(vbox_body);
1389 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1390 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1392 hbox_stat = gtk_hbox_new(FALSE, 2);
1393 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1395 tips = gtk_tooltips_new();
1397 warning_icon = gtk_image_new_from_stock
1398 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1399 warning_btn = gtk_event_box_new();
1400 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1402 mainwin->warning_btn = warning_btn;
1404 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1405 G_CALLBACK(warning_icon_pressed),
1406 (gpointer) mainwin);
1407 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1408 G_CALLBACK(warning_visi_notify), mainwin);
1409 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1410 G_CALLBACK(warning_visi_notify), mainwin);
1411 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1412 G_CALLBACK(warning_leave_notify), mainwin);
1413 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1414 G_CALLBACK(warning_enter_notify), mainwin);
1416 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1418 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1419 _("Some error(s) happened. Click here to view log."), NULL);
1420 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1422 statusbar = statusbar_create();
1423 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1425 progressbar = gtk_progress_bar_new();
1426 gtk_widget_set_size_request(progressbar, 120, 1);
1427 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1429 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1430 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1431 online_switch = gtk_button_new ();
1432 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1433 _("You are online. Click the icon to go offline"), NULL);
1434 offline_switch = gtk_button_new ();
1435 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1436 _("You are offline. Click the icon to go online"),
1438 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1439 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1440 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1441 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1442 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1443 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1444 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1445 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1447 statuslabel = gtk_label_new("");
1448 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1450 ac_button = gtk_button_new();
1451 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1452 ac_button, _("Select account"), NULL);
1453 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1454 gtk_widget_set_size_request(ac_button, -1, 0);
1455 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1456 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1457 G_CALLBACK(ac_label_button_pressed), mainwin);
1459 ac_label = gtk_label_new("");
1460 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1462 gtk_widget_show_all(hbox_stat);
1464 gtk_widget_hide(offline_switch);
1465 gtk_widget_hide(warning_btn);
1468 mainwin->folderview = folderview = folderview_create();
1469 mainwin->summaryview = summaryview = summary_create();
1470 mainwin->messageview = messageview = messageview_create(mainwin);
1472 /* init log instances data before creating log views */
1473 set_log_title(LOG_PROTOCOL, _("Network log"));
1474 set_log_prefs(LOG_PROTOCOL,
1475 &prefs_common.logwin_width,
1476 &prefs_common.logwin_height);
1477 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1478 set_log_prefs(LOG_DEBUG_FILTERING,
1479 &prefs_common.filtering_debugwin_width,
1480 &prefs_common.filtering_debugwin_height);
1482 /* setup log windows */
1483 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1484 log_window_init(mainwin->logwin);
1486 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1487 log_window_set_clipping(mainwin->logwin,
1488 prefs_common.cliplog,
1489 prefs_common.loglength);
1491 log_window_init(mainwin->filtering_debugwin);
1492 log_window_set_clipping(mainwin->filtering_debugwin,
1493 prefs_common.filtering_debug_cliplog,
1494 prefs_common.filtering_debug_loglength);
1495 if (prefs_common.enable_filtering_debug)
1496 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1498 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1500 folderview->mainwin = mainwin;
1501 folderview->summaryview = summaryview;
1503 summaryview->mainwin = mainwin;
1504 summaryview->folderview = folderview;
1505 summaryview->messageview = messageview;
1506 summaryview->window = window;
1508 messageview->statusbar = statusbar;
1509 mainwin->vbox = vbox;
1510 mainwin->menubar = menubar;
1511 mainwin->menu_factory = ifactory;
1512 mainwin->handlebox = handlebox;
1513 mainwin->vbox_body = vbox_body;
1514 mainwin->hbox_stat = hbox_stat;
1515 mainwin->statusbar = statusbar;
1516 mainwin->progressbar = progressbar;
1517 mainwin->statuslabel = statuslabel;
1518 mainwin->online_switch = online_switch;
1519 mainwin->online_pixmap = online_pixmap;
1520 mainwin->offline_pixmap = offline_pixmap;
1521 mainwin->ac_button = ac_button;
1522 mainwin->ac_label = ac_label;
1523 mainwin->offline_switch = offline_switch;
1525 /* set context IDs for status bar */
1526 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1527 (GTK_STATUSBAR(statusbar), "Main Window");
1528 mainwin->folderview_cid = gtk_statusbar_get_context_id
1529 (GTK_STATUSBAR(statusbar), "Folder View");
1530 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1531 (GTK_STATUSBAR(statusbar), "Summary View");
1532 mainwin->messageview_cid = gtk_statusbar_get_context_id
1533 (GTK_STATUSBAR(statusbar), "Message View");
1535 messageview->statusbar_cid = mainwin->messageview_cid;
1537 /* allocate colors for summary view and folder view */
1538 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1539 summaryview->color_marked.blue = (guint16)65535;
1541 summaryview->color_dim.red = summaryview->color_dim.green =
1542 summaryview->color_dim.blue = COLOR_DIM;
1544 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1545 &folderview->color_new);
1547 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1548 &folderview->color_op);
1550 summaryview->color_important.red = 0;
1551 summaryview->color_important.green = 0;
1552 summaryview->color_important.blue = (guint16)65535;
1554 color[0] = summaryview->color_marked;
1555 color[1] = summaryview->color_dim;
1556 color[2] = folderview->color_new;
1557 color[3] = folderview->color_op;
1559 colormap = gdk_drawable_get_colormap(window->window);
1560 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1561 for (i = 0; i < 4; i++) {
1562 if (success[i] == FALSE)
1563 g_warning("MainWindow: color allocation %d failed\n", i);
1566 debug_print("done.\n");
1568 messageview->visible = prefs_common.msgview_visible;
1570 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1572 g_signal_connect(G_OBJECT(window), "size_allocate",
1573 G_CALLBACK(main_window_size_allocate_cb),
1576 /* set menu items */
1577 menuitem = gtk_item_factory_get_item
1578 (ifactory, "/View/Character encoding/Auto detect");
1579 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1581 switch (prefs_common.toolbar_style) {
1583 menuitem = gtk_item_factory_get_item
1584 (ifactory, "/View/Show or hide/Toolbar/Hide");
1587 menuitem = gtk_item_factory_get_item
1588 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1591 menuitem = gtk_item_factory_get_item
1592 (ifactory, "/View/Show or hide/Toolbar/Text only");
1595 menuitem = gtk_item_factory_get_item
1596 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1598 case TOOLBAR_BOTH_HORIZ:
1599 menuitem = gtk_item_factory_get_item
1601 "/View/Show or hide/Toolbar/Text beside icons");
1603 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1605 gtk_widget_hide(mainwin->hbox_stat);
1606 menuitem = gtk_item_factory_get_item
1607 (ifactory, "/View/Show or hide/Status bar");
1608 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1609 prefs_common.show_statusbar);
1611 /* set account selection menu */
1612 ac_menu = gtk_item_factory_get_widget
1613 (ifactory, "/Configuration/Change current account");
1614 mainwin->ac_menu = ac_menu;
1616 toolbar_main_set_sensitive(mainwin);
1618 /* create actions menu */
1619 main_window_update_actions_menu(mainwin);
1621 main_create_mailing_list_menu (mainwin, NULL);
1623 /* attach accel groups to main window */
1624 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1625 gtk_window_add_accel_group \
1627 gtk_item_factory_from_widget(menu)->accel_group); \
1628 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1630 G_CALLBACK(main_window_accel_activate), mainwin);
1633 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1635 /* connect the accelerators for equivalent
1636 menu items in different menus */
1637 menu_connect_identical_items();
1639 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1641 g_signal_connect(G_OBJECT(window), "window_state_event",
1642 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1643 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1644 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1645 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1647 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1648 prefs_common.layout_mode == SMALL_LAYOUT) {
1649 summary_relayout(mainwin->summaryview);
1651 summary_update_unread(mainwin->summaryview, NULL);
1653 gtk_widget_show(mainwin->window);
1655 /* initialize views */
1656 folderview_init(folderview);
1657 summary_init(summaryview);
1658 messageview_init(messageview);
1660 sslcertwindow_register_hook();
1662 mainwin->lock_count = 0;
1663 mainwin->menu_lock_count = 0;
1664 mainwin->cursor_count = 0;
1666 mainwin->progressindicator_hook =
1667 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1670 watch_cursor = gdk_cursor_new(GDK_WATCH);
1672 hand_cursor = gdk_cursor_new(GDK_HAND2);
1674 mainwin_list = g_list_append(mainwin_list, mainwin);
1676 /* init work_offline */
1677 if (prefs_common.work_offline)
1678 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1680 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1681 mainwindow_tags_menu_create(mainwin, FALSE);
1686 void main_window_destroy(MainWindow *mainwin)
1688 /* TODO : destroy other component */
1689 messageview_destroy(mainwin->messageview);
1690 mainwin->messageview = NULL;
1693 void main_window_update_actions_menu(MainWindow *mainwin)
1695 GtkItemFactory *ifactory;
1697 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1698 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1701 void main_window_cursor_wait(MainWindow *mainwin)
1704 if (mainwin->cursor_count == 0) {
1705 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1706 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1709 mainwin->cursor_count++;
1714 void main_window_cursor_normal(MainWindow *mainwin)
1716 if (mainwin->cursor_count)
1717 mainwin->cursor_count--;
1719 if (mainwin->cursor_count == 0) {
1720 gdk_window_set_cursor(mainwin->window->window, NULL);
1721 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1726 /* lock / unlock the user-interface */
1727 void main_window_lock(MainWindow *mainwin)
1729 if (mainwin->lock_count == 0)
1730 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1732 mainwin->lock_count++;
1734 main_window_set_menu_sensitive(mainwin);
1735 toolbar_main_set_sensitive(mainwin);
1738 void main_window_unlock(MainWindow *mainwin)
1740 if (mainwin->lock_count)
1741 mainwin->lock_count--;
1743 main_window_set_menu_sensitive(mainwin);
1744 toolbar_main_set_sensitive(mainwin);
1746 if (mainwin->lock_count == 0)
1747 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1750 static void main_window_menu_callback_block(MainWindow *mainwin)
1752 mainwin->menu_lock_count++;
1755 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1757 if (mainwin->menu_lock_count)
1758 mainwin->menu_lock_count--;
1761 static guint prefs_tag = 0;
1763 void main_window_reflect_prefs_all(void)
1765 main_window_reflect_prefs_all_real(FALSE);
1768 static gboolean reflect_prefs_timeout_cb(gpointer data)
1770 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1772 MainWindow *mainwin;
1775 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1776 mainwin = (MainWindow *)cur->data;
1778 main_window_show_cur_account(mainwin);
1779 main_window_set_menu_sensitive(mainwin);
1780 toolbar_main_set_sensitive(mainwin);
1783 if (pixmap_theme_changed) {
1784 toolbar_update(TOOLBAR_MAIN, mainwin);
1785 messageview_reflect_prefs_pixmap_theme();
1786 compose_reflect_prefs_pixmap_theme();
1787 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1788 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1790 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1791 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1792 mainwin->online_pixmap);
1793 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1794 gtk_widget_show(pixmap);
1795 mainwin->online_pixmap = pixmap;
1796 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1797 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1798 mainwin->offline_pixmap);
1799 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1800 gtk_widget_show(pixmap);
1801 mainwin->offline_pixmap = pixmap;
1804 headerview_set_font(mainwin->messageview->headerview);
1805 headerview_set_visibility(mainwin->messageview->headerview,
1806 prefs_common.display_header_pane);
1807 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1808 folderview_reflect_prefs();
1809 summary_reflect_prefs();
1810 summary_redisplay_msg(mainwin->summaryview);
1816 void main_window_reflect_prefs_all_now(void)
1818 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1821 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1826 /* re-create colorlabel submenu */
1827 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1828 g_return_if_fail(menu != NULL);
1830 /* clear items. get item pointers. */
1831 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1832 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1834 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1835 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1839 void main_window_reflect_tags_changes(MainWindow *mainwin)
1844 /* re-create tags submenu */
1845 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1846 g_return_if_fail(menu != NULL);
1848 /* clear items. get item pointers. */
1849 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1850 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1852 mainwindow_tags_menu_create(mainwin, TRUE);
1853 summary_reflect_tags_changes(mainwin->summaryview);
1857 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1859 if (prefs_tag == 0 || pixmap_theme_changed) {
1860 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1861 GINT_TO_POINTER(pixmap_theme_changed));
1865 void main_window_set_summary_column(void)
1868 MainWindow *mainwin;
1870 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1871 mainwin = (MainWindow *)cur->data;
1872 summary_set_column_order(mainwin->summaryview);
1876 void main_window_set_folder_column(void)
1879 MainWindow *mainwin;
1881 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1882 mainwin = (MainWindow *)cur->data;
1883 folderview_set_column_order(mainwin->folderview);
1887 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1888 GList *account_list)
1890 GList *cur_ac, *cur_item;
1891 GtkWidget *menuitem;
1892 PrefsAccount *ac_prefs;
1894 /* destroy all previous menu item */
1895 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1896 while (cur_item != NULL) {
1897 GList *next = cur_item->next;
1898 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1902 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1903 ac_prefs = (PrefsAccount *)cur_ac->data;
1905 menuitem = gtk_menu_item_new_with_label
1906 (ac_prefs->account_name
1907 ? ac_prefs->account_name : _("Untitled"));
1908 gtk_widget_show(menuitem);
1909 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1910 g_signal_connect(G_OBJECT(menuitem), "activate",
1911 G_CALLBACK(account_selector_menu_cb),
1916 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1917 GList *account_list)
1919 GList *cur_ac, *cur_item;
1921 GtkWidget *menuitem;
1922 PrefsAccount *ac_prefs;
1924 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1925 "/Message/Receive");
1927 /* search for separator */
1928 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1929 cur_item = cur_item->next) {
1930 if (GTK_BIN(cur_item->data)->child == NULL) {
1931 cur_item = cur_item->next;
1936 /* destroy all previous menu item */
1937 while (cur_item != NULL) {
1938 GList *next = cur_item->next;
1939 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1943 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1944 ac_prefs = (PrefsAccount *)cur_ac->data;
1946 menuitem = gtk_menu_item_new_with_label
1947 (ac_prefs->account_name ? ac_prefs->account_name
1949 gtk_widget_show(menuitem);
1950 gtk_menu_append(GTK_MENU(menu), menuitem);
1951 g_signal_connect(G_OBJECT(menuitem), "activate",
1952 G_CALLBACK(account_receive_menu_cb),
1957 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1958 GList *account_list)
1960 GList *cur_ac, *cur_item;
1961 GtkWidget *menuitem;
1962 PrefsAccount *ac_prefs;
1963 GtkWidget *menu = NULL;
1965 if (mainwin->toolbar->getall_btn == NULL
1966 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1969 menu = mainwin->toolbar->getall_combo->menu;
1971 /* destroy all previous menu item */
1972 cur_item = GTK_MENU_SHELL(menu)->children;
1973 while (cur_item != NULL) {
1974 GList *next = cur_item->next;
1975 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1979 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1980 ac_prefs = (PrefsAccount *)cur_ac->data;
1982 menuitem = gtk_menu_item_new_with_label
1983 (ac_prefs->account_name
1984 ? ac_prefs->account_name : _("Untitled"));
1985 gtk_widget_show(menuitem);
1986 gtk_menu_append(GTK_MENU(menu), menuitem);
1987 g_signal_connect(G_OBJECT(menuitem), "activate",
1988 G_CALLBACK(account_receive_menu_cb),
1993 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1994 GList *account_list)
1996 GList *cur_ac, *cur_item;
1997 GtkWidget *menuitem;
1998 PrefsAccount *ac_prefs;
1999 GtkWidget *menu = NULL;
2001 if (mainwin->toolbar->compose_mail_btn == NULL
2002 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
2005 menu = mainwin->toolbar->compose_combo->menu;
2007 /* destroy all previous menu item */
2008 cur_item = GTK_MENU_SHELL(menu)->children;
2009 while (cur_item != NULL) {
2010 GList *next = cur_item->next;
2011 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2015 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2016 ac_prefs = (PrefsAccount *)cur_ac->data;
2018 menuitem = gtk_menu_item_new_with_label
2019 (ac_prefs->account_name
2020 ? ac_prefs->account_name : _("Untitled"));
2021 gtk_widget_show(menuitem);
2022 gtk_menu_append(GTK_MENU(menu), menuitem);
2023 g_signal_connect(G_OBJECT(menuitem), "activate",
2024 G_CALLBACK(account_compose_menu_cb),
2029 void main_window_set_account_menu(GList *account_list)
2032 MainWindow *mainwin;
2034 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2035 mainwin = (MainWindow *)cur->data;
2036 main_window_set_account_selector_menu(mainwin, account_list);
2037 main_window_set_account_receive_menu(mainwin, account_list);
2038 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2039 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2041 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2044 void main_window_set_account_menu_only_toolbar(GList *account_list)
2047 MainWindow *mainwin;
2049 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2050 mainwin = (MainWindow *)cur->data;
2051 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2052 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2056 static void main_window_show_cur_account(MainWindow *mainwin)
2061 ac_name = g_strdup(cur_account
2062 ? (cur_account->account_name
2063 ? cur_account->account_name : _("Untitled"))
2067 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2069 buf = g_strdup(PROG_VERSION);
2070 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2073 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2074 gtk_widget_queue_resize(mainwin->ac_button);
2079 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2081 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2082 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2083 GtkWidget *message_wid = mainwin->messageview->vbox;
2085 if (layout_mode == prefs_common.layout_mode)
2088 debug_print("Changing window separation type from %d to %d\n",
2089 prefs_common.layout_mode, layout_mode);
2091 /* remove widgets from those containers */
2092 gtk_widget_ref(folder_wid);
2093 gtk_widget_ref(summary_wid);
2094 gtk_widget_ref(message_wid);
2095 gtkut_container_remove
2096 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2097 gtkut_container_remove
2098 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2099 gtkut_container_remove
2100 (GTK_CONTAINER(message_wid->parent), message_wid);
2102 gtk_widget_hide(mainwin->window);
2103 main_window_set_widgets(mainwin, layout_mode);
2104 gtk_widget_show(mainwin->window);
2106 gtk_widget_unref(folder_wid);
2107 gtk_widget_unref(summary_wid);
2108 gtk_widget_unref(message_wid);
2111 void mainwindow_reset_paned(GtkPaned *paned)
2115 if (gtk_paned_get_child1(GTK_PANED(paned)))
2116 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2117 if (gtk_paned_get_child2(GTK_PANED(paned)))
2118 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2121 g_object_get (G_OBJECT(paned),
2124 g_object_get (G_OBJECT(paned),
2128 gtk_paned_set_position(GTK_PANED(paned), mid);
2131 static void mainwin_paned_show_first(GtkPaned *paned)
2134 g_object_get (G_OBJECT(paned),
2138 if (gtk_paned_get_child1(GTK_PANED(paned)))
2139 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2140 if (gtk_paned_get_child2(GTK_PANED(paned)))
2141 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2142 gtk_paned_set_position(GTK_PANED(paned), max);
2145 static void mainwin_paned_show_last(GtkPaned *paned)
2148 g_object_get (G_OBJECT(paned),
2152 if (gtk_paned_get_child1(GTK_PANED(paned)))
2153 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2154 if (gtk_paned_get_child2(GTK_PANED(paned)))
2155 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2156 gtk_paned_set_position(GTK_PANED(paned), min);
2159 void main_window_toggle_message_view(MainWindow *mainwin)
2161 SummaryView *summaryview = mainwin->summaryview;
2162 GtkWidget *ppaned = NULL;
2163 GtkWidget *container = NULL;
2165 switch (prefs_common.layout_mode) {
2167 case VERTICAL_LAYOUT:
2169 ppaned = mainwin->vpaned;
2170 container = mainwin->hpaned;
2171 if (ppaned->parent != NULL) {
2172 mainwin->messageview->visible = FALSE;
2173 summaryview->displayed = NULL;
2174 gtk_widget_ref(ppaned);
2175 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2176 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2178 mainwin->messageview->visible = TRUE;
2179 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2180 gtk_container_add(GTK_CONTAINER(container), ppaned);
2181 gtk_widget_unref(ppaned);
2185 ppaned = mainwin->hpaned;
2186 container = mainwin->vpaned;
2187 if (mainwin->messageview->vbox->parent != NULL) {
2188 mainwin->messageview->visible = FALSE;
2189 summaryview->displayed = NULL;
2190 gtk_widget_ref(mainwin->messageview->vbox);
2191 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2193 mainwin->messageview->visible = TRUE;
2194 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2195 gtk_widget_unref(mainwin->messageview->vbox);
2198 case WIDE_MSGLIST_LAYOUT:
2199 g_warning("can't hide messageview in this wide msglist layout");
2203 if (messageview_is_visible(mainwin->messageview))
2204 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2205 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2207 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2208 GTK_ARROW_UP, GTK_SHADOW_OUT);
2210 if (mainwin->messageview->visible == FALSE)
2211 messageview_clear(mainwin->messageview);
2213 main_window_set_menu_sensitive(mainwin);
2215 prefs_common.msgview_visible = mainwin->messageview->visible;
2217 if (messageview_is_visible(mainwin->messageview)) {
2218 gtk_widget_queue_resize(mainwin->hpaned);
2219 gtk_widget_queue_resize(mainwin->vpaned);
2221 summary_grab_focus(summaryview);
2224 void main_window_get_size(MainWindow *mainwin)
2226 GtkAllocation *allocation;
2228 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2229 debug_print("called after messageview "
2230 "has been deallocated!\n");
2234 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2236 if (allocation->width > 1 && allocation->height > 1) {
2237 prefs_common.summaryview_width = allocation->width;
2239 if (messageview_is_visible(mainwin->messageview))
2240 prefs_common.summaryview_height = allocation->height;
2242 prefs_common.mainview_width = allocation->width;
2245 allocation = &mainwin->window->allocation;
2246 if (allocation->width > 1 && allocation->height > 1) {
2247 prefs_common.mainview_height = allocation->height;
2248 prefs_common.mainwin_width = allocation->width;
2249 prefs_common.mainwin_height = allocation->height;
2252 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2253 if (allocation->width > 1 && allocation->height > 1) {
2254 prefs_common.folderview_width = allocation->width;
2255 prefs_common.folderview_height = allocation->height;
2258 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2259 if (allocation->width > 1 && allocation->height > 1) {
2260 prefs_common.msgview_width = allocation->width;
2261 prefs_common.msgview_height = allocation->height;
2264 /* debug_print("summaryview size: %d x %d\n",
2265 prefs_common.summaryview_width,
2266 prefs_common.summaryview_height);
2267 debug_print("folderview size: %d x %d\n",
2268 prefs_common.folderview_width,
2269 prefs_common.folderview_height);
2270 debug_print("messageview size: %d x %d\n",
2271 prefs_common.msgview_width,
2272 prefs_common.msgview_height); */
2275 void main_window_get_position(MainWindow *mainwin)
2279 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2281 prefs_common.mainview_x = x;
2282 prefs_common.mainview_y = y;
2283 prefs_common.mainwin_x = x;
2284 prefs_common.mainwin_y = y;
2286 debug_print("main window position: %d, %d\n", x, y);
2289 void main_window_progress_on(MainWindow *mainwin)
2291 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2294 void main_window_progress_off(MainWindow *mainwin)
2296 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2297 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2300 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2304 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2305 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2306 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2307 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2310 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2312 if (confirm && procmsg_have_trashed_mails_fast()) {
2313 if (alertpanel(_("Empty trash"),
2314 _("Delete all messages in trash folders?"),
2315 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2316 != G_ALERTALTERNATE)
2318 manage_window_focus_in(mainwin->window, NULL, NULL);
2321 procmsg_empty_all_trash();
2323 if (mainwin->summaryview->folder_item &&
2324 mainwin->summaryview->folder_item->stype == F_TRASH)
2325 gtk_widget_grab_focus(mainwin->folderview->ctree);
2328 void main_window_add_mailbox(MainWindow *mainwin)
2333 path = input_dialog(_("Add mailbox"),
2334 _("Input the location of mailbox.\n"
2335 "If an existing mailbox is specified, it will be\n"
2336 "scanned automatically."),
2339 if (folder_find_from_path(path)) {
2340 alertpanel_error(_("The mailbox '%s' already exists."), path);
2344 folder = folder_new(folder_get_class_from_string("mh"),
2345 !strcmp(path, "Mail") ? _("Mailbox") :
2346 g_path_get_basename(path), path);
2349 if (folder->klass->create_tree(folder) < 0) {
2350 alertpanel_error(_("Creation of the mailbox failed.\n"
2351 "Maybe some files already exist, or you don't have the permission to write there."));
2352 folder_destroy(folder);
2357 folder_set_ui_func(folder, scan_tree_func, mainwin);
2358 folder_scan_tree(folder, TRUE);
2359 folder_set_ui_func(folder, NULL, NULL);
2362 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2364 SensitiveCond state = 0;
2365 SummarySelection selection;
2366 FolderItem *item = mainwin->summaryview->folder_item;
2367 GList *account_list = account_get_list();
2370 selection = summary_get_selection_type(mainwin->summaryview);
2372 if (mainwin->lock_count == 0)
2373 state |= M_UNLOCKED;
2374 if (selection != SUMMARY_NONE)
2375 state |= M_MSG_EXIST;
2376 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2378 /* if (item->folder->type != F_NEWS) */
2379 state |= M_ALLOW_DELETE;
2381 if (prefs_common.immediate_exec == 0
2382 && mainwin->lock_count == 0)
2383 state |= M_DELAY_EXEC;
2385 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2386 || selection != SUMMARY_NONE)
2387 state |= M_HIDE_READ_MSG;
2389 if (mainwin->summaryview->threaded)
2390 state |= M_THREADED;
2392 state |= M_UNTHREADED;
2393 if (selection == SUMMARY_SELECTED_SINGLE ||
2394 selection == SUMMARY_SELECTED_MULTIPLE)
2395 state |= M_TARGET_EXIST;
2396 if (selection == SUMMARY_SELECTED_SINGLE)
2397 state |= M_SINGLE_TARGET_EXIST;
2398 if (mainwin->summaryview->folder_item &&
2399 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2402 state |= M_NOT_NEWS;
2403 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2404 state |= M_ACTIONS_EXIST;
2406 tmp = tags_get_list();
2407 if (tmp && g_slist_length(tmp))
2408 state |= M_TAGS_EXIST;
2411 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2412 state |= M_HAVE_QUEUED_MAILS;
2414 if (selection == SUMMARY_SELECTED_SINGLE &&
2416 (folder_has_parent_of_type(item, F_DRAFT) ||
2417 folder_has_parent_of_type(item, F_OUTBOX) ||
2418 folder_has_parent_of_type(item, F_QUEUE))))
2419 state |= M_ALLOW_REEDIT;
2421 state |= M_HAVE_ACCOUNT;
2423 if (any_folder_want_synchronise())
2424 state |= M_WANT_SYNC;
2426 for ( ; account_list != NULL; account_list = account_list->next) {
2427 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2428 state |= M_HAVE_NEWS_ACCOUNT;
2433 if (procmsg_spam_can_learn() &&
2434 (mainwin->summaryview->folder_item &&
2435 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2436 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2437 state |= M_CAN_LEARN_SPAM;
2440 if (inc_is_active())
2441 state |= M_INC_ACTIVE;
2442 if (imap_cancel_all_enabled())
2443 state |= M_INC_ACTIVE;
2445 if (mainwin->summaryview->deleted > 0 ||
2446 mainwin->summaryview->moved > 0 ||
2447 mainwin->summaryview->copied > 0)
2448 state |= M_DELAY_EXEC;
2455 void main_window_set_menu_sensitive(MainWindow *mainwin)
2457 GtkItemFactory *ifactory = mainwin->menu_factory;
2458 SensitiveCond state;
2461 GtkWidget *menuitem;
2462 SummaryView *summaryview;
2467 static const struct {
2471 {"/File/Save as...", M_TARGET_EXIST},
2472 {"/File/Print..." , M_TARGET_EXIST},
2473 {"/File/Synchronise folders", M_WANT_SYNC},
2474 {"/File/Exit" , M_UNLOCKED},
2476 {"/Edit/Select thread" , M_TARGET_EXIST},
2477 {"/Edit/Delete thread" , M_TARGET_EXIST},
2478 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2480 {"/View/Set displayed columns/in Folder list..."
2482 {"/View/Sort" , M_EXEC},
2483 {"/View/Thread view" , M_EXEC},
2484 {"/View/Expand all threads" , M_MSG_EXIST},
2485 {"/View/Collapse all threads" , M_MSG_EXIST},
2486 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2487 {"/View/Go to/Previous message" , M_MSG_EXIST},
2488 {"/View/Go to/Next message" , M_MSG_EXIST},
2489 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2490 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2491 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2492 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2493 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2494 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2495 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2496 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2497 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2498 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2499 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2501 {"/Message/Receive/Get from current account"
2502 , M_HAVE_ACCOUNT|M_UNLOCKED},
2503 {"/Message/Receive/Get from all accounts"
2504 , M_HAVE_ACCOUNT|M_UNLOCKED},
2505 {"/Message/Receive/Cancel receiving"
2507 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2508 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2509 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2510 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2511 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2512 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2513 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2514 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2515 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2516 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2517 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2518 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2519 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2520 {"/Message/Mark" , M_TARGET_EXIST},
2521 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2522 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2523 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2524 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2525 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2526 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2527 {"/Message/Color label" , M_TARGET_EXIST},
2528 {"/Message/Tags" , M_TARGET_EXIST},
2529 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2531 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2532 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2533 {"/Tools/Harvest addresses/from Messages..."
2535 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2536 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2537 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2538 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2539 {"/Tools/List URLs..." , M_TARGET_EXIST},
2540 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2541 {"/Tools/Execute" , M_DELAY_EXEC},
2542 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2544 {"/Configuration", M_UNLOCKED},
2545 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2546 {"/Configuration/Create new account...", M_UNLOCKED},
2547 {"/Configuration/Edit accounts...", M_UNLOCKED},
2552 state = main_window_get_current_state(mainwin);
2554 for (i = 0; entry[i].entry != NULL; i++) {
2555 sensitive = ((entry[i].cond & state) == entry[i].cond);
2556 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2559 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2561 /* search for separator */
2562 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2563 cur_item = cur_item->next) {
2564 if (GTK_BIN(cur_item->data)->child == NULL) {
2565 cur_item = cur_item->next;
2570 for (; cur_item != NULL; cur_item = cur_item->next) {
2571 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2572 (M_UNLOCKED & state) != 0);
2575 main_window_menu_callback_block(mainwin);
2577 #define SET_CHECK_MENU_ACTIVE(path, active) \
2579 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2580 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2583 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2584 messageview_is_visible(mainwin->messageview));
2586 summaryview = mainwin->summaryview;
2587 menu_path = "/View/Sort/Don't sort";
2589 switch (summaryview->sort_key) {
2590 case SORT_BY_NUMBER:
2591 menu_path = "/View/Sort/by number"; break;
2593 menu_path = "/View/Sort/by Size"; break;
2595 menu_path = "/View/Sort/by Date"; break;
2596 case SORT_BY_THREAD_DATE:
2597 menu_path = "/View/Sort/by Thread date"; break;
2599 menu_path = "/View/Sort/by From"; break;
2601 menu_path = "/View/Sort/by To"; break;
2602 case SORT_BY_SUBJECT:
2603 menu_path = "/View/Sort/by Subject"; break;
2605 menu_path = "/View/Sort/by color label"; break;
2607 menu_path = "/View/Sort/by mark"; break;
2608 case SORT_BY_STATUS:
2609 menu_path = "/View/Sort/by status"; break;
2611 menu_path = "/View/Sort/by attachment"; break;
2613 menu_path = "/View/Sort/by score"; break;
2614 case SORT_BY_LOCKED:
2615 menu_path = "/View/Sort/by locked"; break;
2617 menu_path = "/View/Sort/by tag"; break;
2620 menu_path = "/View/Sort/Don't sort"; break;
2622 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2624 if (summaryview->sort_type == SORT_ASCENDING) {
2625 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2627 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2630 if (summaryview->sort_key != SORT_BY_NONE) {
2631 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2632 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2634 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2635 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2638 if (mainwin->messageview
2639 && mainwin->messageview->mimeview
2640 && mainwin->messageview->mimeview->textview)
2641 SET_CHECK_MENU_ACTIVE("/View/All headers",
2642 mainwin->messageview->mimeview->textview->show_all_headers);
2643 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2644 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2645 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2646 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2647 if (prefs_common.hide_quotes == 1)
2648 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2649 if (prefs_common.hide_quotes == 2)
2650 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2651 if (prefs_common.hide_quotes == 3)
2652 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2654 #undef SET_CHECK_MENU_ACTIVE
2656 main_window_menu_callback_unblock(mainwin);
2659 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2661 GtkItemFactory *ifactory;
2663 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2666 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2668 gtk_widget_set_sensitive (gtk_item_factory_get_item
2669 (ifactory,"/Message/Mailing-List"), TRUE);
2671 gtk_widget_set_sensitive (gtk_item_factory_get_item
2672 (ifactory,"/Message/Mailing-List"), FALSE);
2675 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2678 GtkWidget *menuitem;
2680 if (!msginfo || !msginfo->extradata) {
2681 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2682 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2683 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2684 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2685 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2686 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2690 /* Mailing list post */
2691 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2692 g_free(msginfo->extradata->list_post);
2693 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2695 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2697 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2699 /* Mailing list help */
2700 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2702 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2704 /* Mailing list subscribe */
2705 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2707 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2709 /* Mailing list unsubscribe */
2710 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2712 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2714 /* Mailing list view archive */
2715 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2717 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2719 /* Mailing list contact owner */
2720 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2722 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2727 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2729 GtkWidget *item, *menu;
2730 const gchar *url_pt ;
2731 gchar url_decoded[BUFFSIZE];
2732 GList *amenu, *alist;
2735 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2737 /* First delete old submenu */
2738 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2739 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2740 alist = amenu->next;
2741 item = GTK_WIDGET (amenu->data);
2742 gtk_widget_destroy (item);
2746 for (url_pt = list_header; url_pt && *url_pt;) {
2747 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2749 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2750 item = gtk_menu_item_new_with_label ((url_decoded));
2751 g_signal_connect(G_OBJECT(item), "activate",
2752 G_CALLBACK(mailing_list_compose),
2755 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2756 !g_strncasecmp (url_decoded, "https:",6)) {
2758 item = gtk_menu_item_new_with_label ((url_decoded));
2759 g_signal_connect(G_OBJECT(item), "activate",
2760 G_CALLBACK(mailing_list_open_uri),
2764 gtk_menu_append (GTK_MENU(menu), item);
2765 gtk_widget_show (item);
2771 gtk_widget_set_sensitive (menuitem, TRUE);
2773 gtk_widget_set_sensitive (menuitem, FALSE);
2779 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2781 gchar tmp[BUFFSIZE];
2785 gboolean with_plus = TRUE;
2788 *url_decoded = '\0';
2792 /* Ignore spaces, comments and tabs () */
2793 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2795 for (;*buf != ')' && *buf != 0x00; buf++);
2797 /* First non space and non comment must be a < */
2800 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2802 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2807 *url_decoded = '\0';
2812 *url_decoded = '\0';
2818 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2820 /* Prepare the work for the next url in the list */
2821 /* after the closing bracket >, ignore space, comments and tabs */
2822 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2824 for (;*buf != ')' && *buf != 0x00; buf++);
2826 if (!buf || !*buf) {
2831 /* now first non space, non comment must be a comma */
2833 for (;*buf != 0x00; buf++);
2839 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2843 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2844 compose_new(NULL, mailto+7, NULL);
2847 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2852 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2853 open_uri (mailto, prefs_common.uri_cmd);
2856 void main_window_popup(MainWindow *mainwin)
2858 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2859 main_window_show(mainwin);
2861 gtkut_window_popup(mainwin->window);
2862 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2863 if (mainwin->in_folder) {
2864 mainwindow_enter_folder(mainwin);
2866 mainwindow_exit_folder(mainwin);
2871 void main_window_show(MainWindow *mainwin)
2873 gtk_widget_show(mainwin->window);
2874 gtk_widget_show(mainwin->vbox_body);
2876 gtk_widget_set_uposition(mainwin->window,
2877 prefs_common.mainwin_x,
2878 prefs_common.mainwin_y);
2880 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2881 prefs_common.folderview_width,
2882 prefs_common.folderview_height);
2883 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2884 prefs_common.summaryview_width,
2885 prefs_common.summaryview_height);
2886 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2887 prefs_common.msgview_width,
2888 prefs_common.msgview_height);
2891 void main_window_hide(MainWindow *mainwin)
2893 main_window_get_size(mainwin);
2894 main_window_get_position(mainwin);
2896 gtk_widget_hide(mainwin->window);
2897 gtk_widget_hide(mainwin->vbox_body);
2900 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2902 GtkWidget *folderwin = NULL;
2903 GtkWidget *messagewin = NULL;
2906 GtkWidget *vbox_body = mainwin->vbox_body;
2907 GtkItemFactory *ifactory = mainwin->menu_factory;
2908 GtkWidget *menuitem;
2909 gboolean first_set = (mainwin->hpaned == NULL);
2910 debug_print("Setting widgets... ");
2912 if (layout_mode == SMALL_LAYOUT && first_set) {
2913 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2914 prefs_common.folderview_width,
2915 prefs_common.folderview_height);
2916 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2918 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2921 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2922 prefs_common.folderview_width,
2923 prefs_common.folderview_height);
2924 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2925 prefs_common.summaryview_width,
2926 prefs_common.summaryview_height);
2927 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2928 prefs_common.msgview_width,
2929 prefs_common.msgview_height);
2932 mainwin->messageview->statusbar = mainwin->statusbar;
2933 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2935 /* clean top-most container */
2936 if (mainwin->hpaned) {
2937 if (mainwin->hpaned->parent == mainwin->vpaned)
2938 gtk_widget_destroy(mainwin->vpaned);
2940 gtk_widget_destroy(mainwin->hpaned);
2943 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
2944 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
2945 switch (layout_mode) {
2946 case VERTICAL_LAYOUT:
2949 hpaned = gtk_hpaned_new();
2950 if (layout_mode == VERTICAL_LAYOUT)
2951 vpaned = gtk_hpaned_new();
2953 vpaned = gtk_vpaned_new();
2954 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2955 gtk_paned_add1(GTK_PANED(hpaned),
2956 GTK_WIDGET_PTR(mainwin->folderview));
2957 gtk_widget_show(hpaned);
2958 gtk_widget_queue_resize(hpaned);
2960 if (messageview_is_visible(mainwin->messageview)) {
2961 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2962 gtk_paned_add1(GTK_PANED(vpaned),
2963 GTK_WIDGET_PTR(mainwin->summaryview));
2965 gtk_paned_add2(GTK_PANED(hpaned),
2966 GTK_WIDGET_PTR(mainwin->summaryview));
2967 gtk_widget_ref(vpaned);
2969 gtk_paned_add2(GTK_PANED(vpaned),
2970 GTK_WIDGET_PTR(mainwin->messageview));
2971 gtk_widget_show(vpaned);
2972 if (layout_mode == SMALL_LAYOUT && first_set) {
2973 mainwin_paned_show_first(GTK_PANED(hpaned));
2975 gtk_widget_queue_resize(vpaned);
2978 vpaned = gtk_vpaned_new();
2979 hpaned = gtk_hpaned_new();
2980 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2981 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
2983 gtk_paned_add1(GTK_PANED(hpaned),
2984 GTK_WIDGET_PTR(mainwin->folderview));
2985 gtk_paned_add2(GTK_PANED(hpaned),
2986 GTK_WIDGET_PTR(mainwin->summaryview));
2988 gtk_widget_show(hpaned);
2989 gtk_widget_queue_resize(hpaned);
2991 if (messageview_is_visible(mainwin->messageview)) {
2992 gtk_paned_add2(GTK_PANED(vpaned),
2993 GTK_WIDGET_PTR(mainwin->messageview));
2995 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
2997 gtk_widget_show(vpaned);
2998 gtk_widget_queue_resize(vpaned);
3000 case WIDE_MSGLIST_LAYOUT:
3001 vpaned = gtk_vpaned_new();
3002 hpaned = gtk_hpaned_new();
3003 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3005 gtk_paned_add1(GTK_PANED(vpaned),
3006 GTK_WIDGET_PTR(mainwin->summaryview));
3007 gtk_paned_add1(GTK_PANED(hpaned),
3008 GTK_WIDGET_PTR(mainwin->folderview));
3010 gtk_widget_show(hpaned);
3011 gtk_widget_queue_resize(hpaned);
3013 if (messageview_is_visible(mainwin->messageview)) {
3014 gtk_paned_add2(GTK_PANED(hpaned),
3015 GTK_WIDGET_PTR(mainwin->messageview));
3017 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3019 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3021 gtk_widget_show(vpaned);
3022 gtk_widget_queue_resize(vpaned);
3025 g_warning("Unknown layout");
3029 mainwin->hpaned = hpaned;
3030 mainwin->vpaned = vpaned;
3032 if (layout_mode == SMALL_LAYOUT) {
3033 if (mainwin->messageview->visible)
3034 main_window_toggle_message_view(mainwin);
3037 if (layout_mode == SMALL_LAYOUT && first_set) {
3038 gtk_widget_realize(mainwin->window);
3039 gtk_widget_realize(mainwin->folderview->ctree);
3040 gtk_widget_realize(mainwin->summaryview->hbox);
3041 gtk_widget_realize(mainwin->summaryview->hbox_l);
3042 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3043 prefs_common.folderview_width,
3044 prefs_common.folderview_height);
3045 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3047 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3049 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3050 prefs_common.mainwin_width,
3051 prefs_common.mainwin_height);
3052 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3054 /* remove headerview if not in prefs */
3055 headerview_set_visibility(mainwin->messageview->headerview,
3056 prefs_common.display_header_pane);
3058 if (messageview_is_visible(mainwin->messageview))
3059 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3060 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3062 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3063 GTK_ARROW_UP, GTK_SHADOW_OUT);
3065 gtk_window_move(GTK_WINDOW(mainwin->window),
3066 prefs_common.mainwin_x,
3067 prefs_common.mainwin_y);
3069 gtk_widget_queue_resize(vbox_body);
3070 gtk_widget_queue_resize(mainwin->vbox);
3071 gtk_widget_queue_resize(mainwin->window);
3072 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3073 * and mimeview icon list/ctree lose track of their visibility states */
3074 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3075 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3076 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3077 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3078 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
3079 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3081 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3083 prefs_common.layout_mode = layout_mode;
3085 menuitem = gtk_item_factory_get_item
3086 (ifactory, "/View/Show or hide/Message view");
3087 gtk_check_menu_item_set_active
3088 (GTK_CHECK_MENU_ITEM(menuitem),
3089 messageview_is_visible(mainwin->messageview));
3091 #define SET_CHECK_MENU_ACTIVE(path, active) \
3093 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3094 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3097 switch (prefs_common.layout_mode) {
3099 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3101 case VERTICAL_LAYOUT:
3102 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3105 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3107 case WIDE_MSGLIST_LAYOUT:
3108 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
3111 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
3114 #undef SET_CHECK_MENU_ACTIVE
3118 (G_OBJECT(folderwin), "size_allocate",
3119 G_CALLBACK(folder_window_size_allocate_cb),
3124 (G_OBJECT(messagewin), "size_allocate",
3125 G_CALLBACK(message_window_size_allocate_cb),
3129 debug_print("done.\n");
3132 void main_window_destroy_all(void)
3134 while (mainwin_list != NULL) {
3135 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
3137 /* free toolbar stuff */
3138 toolbar_clear_list(TOOLBAR_MAIN);
3139 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
3140 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
3142 mainwin->folderview->mainwin = NULL;
3143 mainwin->summaryview->mainwin = NULL;
3144 mainwin->messageview->mainwin = NULL;
3146 g_free(mainwin->toolbar);
3149 mainwin_list = g_list_remove(mainwin_list, mainwin);
3151 g_list_free(mainwin_list);
3152 mainwin_list = NULL;
3155 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
3158 gtk_widget_set_size_request(child, 1, -1);
3161 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
3164 gtk_widget_set_size_request(child, -1, -1);
3167 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
3170 MainWindow *mainwin = (MainWindow *)data;
3172 if (!event) return FALSE;
3174 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3175 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
3178 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3179 menu_button_position, widget,
3180 event->button, event->time);
3185 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3188 MainWindow *mainwin = (MainWindow *)data;
3189 gboolean close_allowed = TRUE;
3191 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
3193 if (close_allowed && mainwin->lock_count == 0)
3194 app_exit_cb(data, 0, widget);
3199 static void main_window_size_allocate_cb(GtkWidget *widget,
3200 GtkAllocation *allocation,
3203 MainWindow *mainwin = (MainWindow *)data;
3204 main_window_get_size(mainwin);
3207 static void folder_window_size_allocate_cb(GtkWidget *widget,
3208 GtkAllocation *allocation,
3211 MainWindow *mainwin = (MainWindow *)data;
3213 main_window_get_size(mainwin);
3216 static void message_window_size_allocate_cb(GtkWidget *widget,
3217 GtkAllocation *allocation,
3220 MainWindow *mainwin = (MainWindow *)data;
3222 main_window_get_size(mainwin);
3225 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3228 main_window_add_mailbox(mainwin);
3231 static void update_folderview_cb(MainWindow *mainwin, guint action,
3234 summary_show(mainwin->summaryview, NULL);
3235 folderview_check_new_all();
3238 static void foldersort_cb(MainWindow *mainwin, guint action,
3244 static void import_mbox_cb(MainWindow *mainwin, guint action,
3247 /* only notify if import has failed */
3248 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3249 alertpanel_error(_("Mbox import has failed."));
3253 static void export_mbox_cb(MainWindow *mainwin, guint action,
3256 /* only notify if export has failed */
3257 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3258 alertpanel_error(_("Export to mbox has failed."));
3262 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3265 /* only notify if export has failed */
3266 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3267 alertpanel_error(_("Export to mbox has failed."));
3271 static void empty_trash_cb(MainWindow *mainwin, guint action,
3274 main_window_empty_trash(mainwin, TRUE);
3277 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3279 summary_save_as(mainwin->summaryview);
3282 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3284 summary_print(mainwin->summaryview);
3287 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3289 if (prefs_common.confirm_on_exit) {
3290 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3291 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3292 != G_ALERTALTERNATE)
3294 manage_window_focus_in(mainwin->window, NULL, NULL);
3297 app_will_exit(widget, mainwin);
3300 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3303 summary_search(mainwin->summaryview);
3305 message_search(mainwin->messageview);
3308 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3310 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3313 static void toggle_message_cb(MainWindow *mainwin, guint action,
3318 active = GTK_CHECK_MENU_ITEM(widget)->active;
3320 if (active != messageview_is_visible(mainwin->messageview))
3321 summary_toggle_view(mainwin->summaryview);
3324 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3327 toolbar_toggle(action, mainwin);
3330 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3333 MessageView *msgview = (MessageView*)mainwin->messageview;
3334 GSList *msginfo_list = NULL;
3336 g_return_if_fail(msgview != NULL);
3338 msginfo_list = summary_get_selection(mainwin->summaryview);
3339 g_return_if_fail(msginfo_list != NULL);
3340 compose_reply_from_messageview(msgview, msginfo_list, action);
3341 g_slist_free(msginfo_list);
3345 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3348 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3349 gtk_widget_show(mainwin->hbox_stat);
3350 prefs_common.show_statusbar = TRUE;
3352 gtk_widget_hide(mainwin->hbox_stat);
3353 prefs_common.show_statusbar = FALSE;
3357 static void set_layout_cb(MainWindow *mainwin, guint action,
3360 LayoutType layout_mode = action;
3361 LayoutType old_layout_mode = prefs_common.layout_mode;
3362 if (mainwin->menu_lock_count) {
3365 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3369 if (layout_mode == prefs_common.layout_mode) {
3373 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3374 main_window_toggle_message_view(mainwin);
3375 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3376 main_window_toggle_message_view(mainwin);
3378 main_window_separation_change(mainwin, layout_mode);
3379 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3380 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3381 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3383 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3384 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3385 mainwindow_exit_folder(mainwin);
3387 summary_relayout(mainwin->summaryview);
3388 summary_update_unread(mainwin->summaryview, NULL);
3391 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3394 offline_ask_sync = ask_sync;
3396 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3398 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3399 offline_ask_sync = TRUE;
3402 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3404 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3407 static gboolean any_folder_want_synchronise(void)
3409 GList *folderlist = folder_get_list();
3411 /* see if there are synchronised folders */
3412 for (; folderlist; folderlist = folderlist->next) {
3413 Folder *folder = (Folder *)folderlist->data;
3414 if (folder_want_synchronise(folder)) {
3422 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3425 if (!any_folder_want_synchronise())
3428 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3429 _("Do you want to synchronise your folders now?"),
3430 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3433 if (offline_ask_sync)
3434 folder_synchronise(NULL);
3437 static void online_switch_clicked (GtkButton *btn, gpointer data)
3439 MainWindow *mainwin;
3440 GtkItemFactory *ifactory;
3441 GtkCheckMenuItem *menuitem;
3443 mainwin = (MainWindow *) data;
3445 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3446 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3448 g_return_if_fail(mainwin != NULL);
3449 g_return_if_fail(menuitem != NULL);
3451 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3452 gtk_widget_hide (mainwin->online_switch);
3453 gtk_widget_show (mainwin->offline_switch);
3454 menuitem->active = TRUE;
3455 inc_autocheck_timer_remove();
3458 if (prefs_common.work_offline)
3460 mainwindow_check_synchronise(mainwin, TRUE);
3461 prefs_common.work_offline = TRUE;
3462 imap_disconnect_all();
3463 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3466 if (!prefs_common.work_offline)
3468 gtk_widget_hide (mainwin->offline_switch);
3469 gtk_widget_show (mainwin->online_switch);
3470 menuitem->active = FALSE;
3471 prefs_common.work_offline = FALSE;
3472 inc_autocheck_timer_set();
3473 refresh_resolvers();
3474 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3478 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3481 addressbook_open(NULL);
3484 static void log_window_show_cb(MainWindow *mainwin, guint action,
3487 log_window_show(mainwin->logwin);
3490 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3493 log_window_show(mainwin->filtering_debugwin);
3496 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3502 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3504 summary_move_to(mainwin->summaryview);
3507 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3509 summary_copy_to(mainwin->summaryview);
3512 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3514 summary_delete(mainwin->summaryview);
3517 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3519 summary_delete_trash(mainwin->summaryview);
3522 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3524 summary_cancel(mainwin->summaryview);
3527 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3529 summary_open_msg(mainwin->summaryview);
3532 static void view_source_cb(MainWindow *mainwin, guint action,
3535 summary_view_source(mainwin->summaryview);
3538 static void show_all_header_cb(MainWindow *mainwin, guint action,
3541 if (mainwin->menu_lock_count) return;
3542 mainwin->summaryview->messageview->all_headers =
3543 GTK_CHECK_MENU_ITEM(widget)->active;
3544 summary_display_msg_selected(mainwin->summaryview,
3545 GTK_CHECK_MENU_ITEM(widget)->active);
3548 #define SET_CHECK_MENU_ACTIVE(path, active) \
3550 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3551 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3554 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3557 GtkWidget *menuitem;
3558 GtkItemFactory *ifactory = mainwin->menu_factory;
3560 if (mainwin->menu_lock_count) return;
3562 prefs_common.hide_quotes =
3563 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3565 mainwin->menu_lock_count++;
3566 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3567 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3568 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3569 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3570 mainwin->menu_lock_count--;
3572 summary_redisplay_msg(mainwin->summaryview);
3575 #undef SET_CHECK_MENU_ACTIVE
3576 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3578 summary_mark(mainwin->summaryview);
3581 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3583 summary_unmark(mainwin->summaryview);
3586 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3589 summary_mark_as_unread(mainwin->summaryview);
3592 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3595 summary_mark_as_read(mainwin->summaryview);
3598 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3601 summary_mark_all_read(mainwin->summaryview);
3604 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3607 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3610 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3613 summary_ignore_thread(mainwin->summaryview);
3616 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3619 summary_unignore_thread(mainwin->summaryview);
3622 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3625 summary_msgs_lock(mainwin->summaryview);
3628 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3631 summary_msgs_unlock(mainwin->summaryview);
3635 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3637 summary_reedit(mainwin->summaryview);
3640 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3642 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3643 summary_display_msg_selected(mainwin->summaryview,
3644 mainwin->messageview->mimeview->textview->show_all_headers);
3646 messageview_list_urls(mainwin->messageview);
3649 static void add_address_cb(MainWindow *mainwin, guint action,
3652 summary_add_address(mainwin->summaryview);
3655 static void set_charset_cb(MainWindow *mainwin, guint action,
3660 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3661 str = conv_get_charset_str((CharSet)action);
3663 g_free(mainwin->messageview->forced_charset);
3664 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3665 procmime_force_charset(str);
3667 summary_redisplay_msg(mainwin->summaryview);
3669 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3673 static void set_decode_cb(MainWindow *mainwin, guint action,
3676 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3677 mainwin->messageview->forced_encoding = (EncodingType)action;
3679 summary_redisplay_msg(mainwin->summaryview);
3681 debug_print("forced encoding: %d\n", action);
3685 static void hide_read_messages (MainWindow *mainwin, guint action,
3688 if (!mainwin->summaryview->folder_item
3689 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3691 summary_toggle_show_read_messages(mainwin->summaryview);
3694 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3696 gboolean threaded = FALSE;
3697 if (mainwin->menu_lock_count) return;
3698 if (!mainwin->summaryview->folder_item) return;
3700 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3702 mainwin->summaryview->folder_item->threaded = threaded;
3704 mainwin->summaryview->threaded = threaded;
3706 summary_show(mainwin->summaryview,
3707 mainwin->summaryview->folder_item);
3710 static void expand_threads_cb(MainWindow *mainwin, guint action,
3713 summary_expand_threads(mainwin->summaryview);
3716 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3719 summary_collapse_threads(mainwin->summaryview);
3722 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3725 prefs_summary_column_open();
3728 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3731 prefs_folder_column_open();
3734 static void sort_summary_cb(MainWindow *mainwin, guint action,
3737 FolderItem *item = mainwin->summaryview->folder_item;
3738 GtkWidget *menuitem;
3740 if (mainwin->menu_lock_count) return;
3742 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3743 menuitem = gtk_item_factory_get_item
3744 (mainwin->menu_factory, "/View/Sort/Ascending");
3745 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3746 GTK_CHECK_MENU_ITEM(menuitem)->active
3747 ? SORT_ASCENDING : SORT_DESCENDING);
3748 item->sort_key = action;
3752 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3755 FolderItem *item = mainwin->summaryview->folder_item;
3757 if (mainwin->menu_lock_count) return;
3759 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3760 summary_sort(mainwin->summaryview,
3761 item->sort_key, (FolderSortType)action);
3764 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3767 summary_attract_by_subject(mainwin->summaryview);
3770 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3775 item = folderview_get_selected_item(mainwin->folderview);
3777 main_window_cursor_wait(mainwin);
3778 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3780 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3781 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3783 STATUSBAR_POP(mainwin);
3784 main_window_cursor_normal(mainwin);
3794 static void deldup_all(FolderItem *item, gpointer _data)
3796 struct DelDupsData *data = _data;
3799 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3801 data->dups += result;
3806 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3809 struct DelDupsData data = {0, 0};
3811 main_window_cursor_wait(mainwin);
3812 folder_func_to_all_folders(deldup_all, &data);
3813 main_window_cursor_normal(mainwin);
3815 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3816 "Deleted %d duplicate messages in %d folders.\n",
3818 data.dups, data.folders);
3821 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3823 summary_filter(mainwin->summaryview, (gboolean)action);
3826 static void execute_summary_cb(MainWindow *mainwin, guint action,
3829 summary_execute(mainwin->summaryview);
3832 static void update_summary_cb(MainWindow *mainwin, guint action,
3836 FolderView *folderview = mainwin->folderview;
3838 if (!mainwin->summaryview->folder_item) return;
3839 if (!folderview->opened) return;
3841 folder_update_op_count();
3843 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3844 folderview->opened);
3847 folder_item_scan(fitem);
3848 summary_show(mainwin->summaryview, fitem);
3851 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3853 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3856 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3858 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3861 static void prev_unread_cb(MainWindow *mainwin, guint action,
3864 summary_select_prev_unread(mainwin->summaryview);
3867 static void next_unread_cb(MainWindow *mainwin, guint action,
3870 summary_select_next_unread(mainwin->summaryview);
3873 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3875 summary_select_prev_new(mainwin->summaryview);
3878 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3880 summary_select_next_new(mainwin->summaryview);
3883 static void prev_marked_cb(MainWindow *mainwin, guint action,
3886 summary_select_prev_marked(mainwin->summaryview);
3889 static void next_marked_cb(MainWindow *mainwin, guint action,
3892 summary_select_next_marked(mainwin->summaryview);
3895 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3898 summary_select_prev_labeled(mainwin->summaryview);
3901 static void next_labeled_cb(MainWindow *mainwin, guint action,
3904 summary_select_next_labeled(mainwin->summaryview);
3907 static void last_read_cb(MainWindow *mainwin, guint action,
3910 summary_select_last_read(mainwin->summaryview);
3913 static void parent_cb(MainWindow *mainwin, guint action,
3916 summary_select_parent(mainwin->summaryview);
3919 static void goto_folder_cb(MainWindow *mainwin, guint action,
3922 FolderItem *to_folder;
3924 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3927 folderview_select(mainwin->folderview, to_folder);
3930 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3933 folderview_select_next_unread(mainwin->folderview, FALSE);
3936 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3938 messageview_copy_clipboard(mainwin->messageview);
3941 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3943 MessageView *msgview = mainwin->messageview;
3945 if (messageview_is_visible(msgview) &&
3946 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3947 messageview_select_all(mainwin->messageview);
3949 summary_select_all(mainwin->summaryview);
3952 static void select_thread_cb(MainWindow *mainwin, guint action,
3955 summary_select_thread(mainwin->summaryview, FALSE);
3958 static void delete_thread_cb(MainWindow *mainwin, guint action,
3961 summary_select_thread(mainwin->summaryview, TRUE);
3964 static void create_filter_cb(MainWindow *mainwin, guint action,
3967 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3970 static void create_processing_cb(MainWindow *mainwin, guint action,
3973 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3976 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3979 prefs_filtering_open(&pre_global_processing,
3980 _("Processing rules to apply before folder rules"),
3981 MANUAL_ANCHOR_PROCESSING,
3985 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3988 prefs_filtering_open(&post_global_processing,
3989 _("Processing rules to apply after folder rules"),
3990 MANUAL_ANCHOR_PROCESSING,
3994 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3997 prefs_filtering_open(&filtering_rules,
3998 _("Filtering configuration"),
3999 MANUAL_ANCHOR_FILTERING,
4003 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
4006 prefs_template_open();
4009 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
4012 prefs_actions_open(mainwin);
4015 static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
4018 prefs_tags_open(mainwin);
4021 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
4024 ssl_manager_open(mainwin);
4027 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
4031 new_account_cb(mainwin, 0, widget);
4033 account_open(cur_account);
4037 static void new_account_cb(MainWindow *mainwin, guint action,
4040 account_edit_open();
4041 if (!compose_get_compose_list()) account_add();
4044 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
4046 FolderItem *item = NULL;
4047 cur_account = (PrefsAccount *)data;
4049 if (!mainwindow_get_mainwindow())
4051 main_window_show_cur_account(mainwindow_get_mainwindow());
4052 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
4053 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
4054 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
4055 item = folderview_get_selected_item(
4056 mainwindow_get_mainwindow()->folderview);
4058 toolbar_set_compose_button
4059 (mainwindow_get_mainwindow()->toolbar,
4060 FOLDER_TYPE(item->folder) == F_NEWS ?
4061 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
4065 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
4067 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4068 PrefsAccount *account = (PrefsAccount *)data;
4070 inc_account_mail(mainwin, account);
4073 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
4075 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4076 PrefsAccount *account = (PrefsAccount *)data;
4077 FolderItem *item = mainwin->summaryview->folder_item;
4079 compose_new_with_folderitem(account, item, NULL);
4082 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
4087 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
4089 pluginwindow_create();
4092 static void manual_open_cb(MainWindow *mainwin, guint action,
4095 manual_open((ManualType)action, NULL);
4098 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
4103 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
4105 MainWindow *mainwin = (MainWindow *)data;
4109 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
4110 LOCAL_FOLDER(folder)->rootpath,
4114 str = g_strdup_printf(_("Scanning folder %s ..."),
4115 LOCAL_FOLDER(folder)->rootpath);
4117 STATUSBAR_PUSH(mainwin, str);
4118 STATUSBAR_POP(mainwin);
4122 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
4125 SummaryView *summary;
4127 g_return_val_if_fail(data, FALSE);
4128 if (!g_list_find(mainwin_list, data))
4130 summary = ((MainWindow *)data)->summaryview;
4131 g_return_val_if_fail(summary, FALSE);
4133 if (GTK_CLIST(summary->ctree)->selection &&
4134 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
4140 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
4143 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
4147 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
4150 if (!claws_is_starting()
4151 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
4152 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
4154 if (iconified_count > 0)
4155 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
4158 if (state->new_window_state == 0)
4159 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
4163 gboolean mainwindow_is_obscured(void)
4168 #define BREAK_ON_MODIFIER_KEY() \
4169 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
4171 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
4174 MainWindow *mainwin = (MainWindow*) data;
4176 if (!mainwin || !event)
4179 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
4181 lastkey = event->keyval;
4185 switch (event->keyval) {
4186 case GDK_Q: /* Quit */
4187 BREAK_ON_MODIFIER_KEY();
4189 app_exit_cb(mainwin, 0, NULL);
4192 if (mainwin->folderview && mainwin->summaryview
4193 && ((!mainwin->summaryview->displayed
4194 && !mainwin->summaryview->selected)
4195 || (mainwin->summaryview->folder_item
4196 && mainwin->summaryview->folder_item->total_msgs == 0))) {
4197 g_signal_stop_emission_by_name(G_OBJECT(widget),
4199 folderview_select_next_unread(mainwin->folderview, TRUE);
4204 if (maemo_mainwindow_is_fullscreen(widget)) {
4205 gtk_window_unfullscreen(GTK_WINDOW(widget));
4207 gtk_window_fullscreen(GTK_WINDOW(widget));
4217 #undef BREAK_ON_MODIFIER_KEY
4220 * Harvest addresses for selected folder.
4222 static void addr_harvest_cb( MainWindow *mainwin,
4226 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4230 * Harvest addresses for selected messages in summary view.
4232 static void addr_harvest_msg_cb( MainWindow *mainwin,
4236 summary_harvest_address( mainwin->summaryview );
4240 *\brief get a MainWindow
4242 *\return MainWindow * The first mainwindow in the mainwin_list
4244 MainWindow *mainwindow_get_mainwindow(void)
4246 if (mainwin_list && mainwin_list->data)
4247 return (MainWindow *)(mainwin_list->data);
4252 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4254 ProgressData *data = (ProgressData *) source;
4255 MainWindow *mainwin = (MainWindow *) userdata;
4257 switch (data->cmd) {
4258 case PROGRESS_COMMAND_START:
4259 case PROGRESS_COMMAND_STOP:
4260 gtk_progress_bar_set_fraction
4261 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4263 case PROGRESS_COMMAND_SET_PERCENTAGE:
4264 gtk_progress_bar_set_fraction
4265 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4268 while (gtk_events_pending()) gtk_main_iteration ();
4273 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4275 mainwindow_check_synchronise(mainwin, FALSE);
4278 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4280 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4283 void mainwindow_jump_to(const gchar *target, gboolean popup)
4287 FolderItem *item = NULL;
4289 MainWindow *mainwin = mainwindow_get_mainwindow();
4295 printf("not initialized\n");
4299 tmp = g_strdup(target);
4301 if ((p = strstr(tmp, "\r")) != NULL)
4303 if ((p = strstr(tmp, "\n")) != NULL)
4306 if ((item = folder_find_item_from_identifier(tmp))) {
4307 printf("selecting folder '%s'\n", tmp);
4308 folderview_select(mainwin->folderview, item);
4310 main_window_popup(mainwin);
4315 msg = strrchr(tmp, G_DIR_SEPARATOR);
4318 if ((item = folder_find_item_from_identifier(tmp))) {
4319 printf("selecting folder '%s'\n", tmp);
4320 folderview_select(mainwin->folderview, item);
4322 printf("'%s' not found\n", tmp);
4324 if (item && msg && atoi(msg)) {
4325 printf("selecting message %d\n", atoi(msg));
4326 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4327 summary_display_msg_selected(mainwin->summaryview, FALSE);
4329 main_window_popup(mainwin);
4332 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4333 MsgInfo *msginfo = NULL;
4335 msg[strlen(msg)-1] = '\0';
4336 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4338 printf("selecting message %s\n", msg);
4339 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4340 summary_display_msg_selected(mainwin->summaryview, FALSE);
4342 main_window_popup(mainwin);
4344 procmsg_msginfo_free(msginfo);
4347 printf("'%s' not found\n", msg);
4350 printf("'%s' not found\n", msg);
4353 printf("'%s' not found\n", tmp);
4359 void mainwindow_exit_folder(MainWindow *mainwin) {
4360 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4361 folderview_close_opened(mainwin->folderview);
4362 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4364 mainwin->in_folder = FALSE;
4367 void mainwindow_enter_folder(MainWindow *mainwin) {
4368 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4369 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4371 mainwin->in_folder = TRUE;
4375 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4378 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4382 void maemo_window_full_screen_if_needed (GtkWindow *window)
4384 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4385 gtk_window_fullscreen(GTK_WINDOW(window));
4389 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4391 g_signal_connect(G_OBJECT(window), "key_press_event",
4392 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());