2 * Sylpheed -- 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 2 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, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkwindow.h>
27 #include <gtk/gtkwidget.h>
28 #include <gtk/gtksignal.h>
29 #include <gtk/gtkvbox.h>
30 #include <gtk/gtkcontainer.h>
31 #include <gtk/gtkstatusbar.h>
32 #include <gtk/gtkprogressbar.h>
33 #include <gtk/gtkhpaned.h>
34 #include <gtk/gtkvpaned.h>
35 #include <gtk/gtkcheckmenuitem.h>
36 #include <gtk/gtkitemfactory.h>
37 #include <gtk/gtkeditable.h>
38 #include <gtk/gtkmenu.h>
39 #include <gtk/gtkmenuitem.h>
40 #include <gtk/gtkhandlebox.h>
41 #include <gtk/gtktoolbar.h>
42 #include <gtk/gtkbutton.h>
43 #include <gtk/gtktooltips.h>
47 #include "mainwindow.h"
48 #include "folderview.h"
49 #include "foldersel.h"
50 #include "summaryview.h"
51 #include "summary_search.h"
52 #include "messageview.h"
53 #include "message_search.h"
54 #include "headerview.h"
56 #include "stock_pixmap.h"
64 #include "prefs_common.h"
65 #include "prefs_actions.h"
66 #include "prefs_filtering.h"
67 #include "prefs_account.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_folder_column.h"
70 #include "prefs_template.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.h"
87 #include "prefs_gtk.h"
88 #include "pluginwindow.h"
90 #include "progressindicator.h"
91 #include "localfolder.h"
92 #include "filtering.h"
93 #include "folderutils.h"
94 #include "foldersort.h"
95 #include "icon_legend.h"
96 #include "colorlabel.h"
101 #define AC_LABEL_WIDTH 240
103 /* list of all instantiated MainWindow */
104 static GList *mainwin_list = NULL;
106 static GdkCursor *watch_cursor = NULL;
107 static GdkCursor *hand_cursor = NULL;
109 static gint iconified_count = 0;
111 static void main_window_menu_callback_block (MainWindow *mainwin);
112 static void main_window_menu_callback_unblock (MainWindow *mainwin);
114 static void main_window_show_cur_account (MainWindow *mainwin);
116 static void main_window_separation_change (MainWindow *mainwin,
117 LayoutType layout_mode);
119 static void main_window_set_widgets (MainWindow *mainwin,
120 LayoutType layout_mode);
122 static void toolbar_child_attached (GtkWidget *widget,
125 static void toolbar_child_detached (GtkWidget *widget,
129 static gboolean ac_label_button_pressed (GtkWidget *widget,
130 GdkEventButton *event,
133 static gint main_window_close_cb (GtkWidget *widget,
137 static void main_window_size_allocate_cb (GtkWidget *widget,
138 GtkAllocation *allocation,
140 static void folder_window_size_allocate_cb (GtkWidget *widget,
141 GtkAllocation *allocation,
143 static void message_window_size_allocate_cb (GtkWidget *widget,
144 GtkAllocation *allocation,
147 static void update_folderview_cb (MainWindow *mainwin,
150 static void add_mailbox_cb (MainWindow *mainwin,
153 static void foldersort_cb (MainWindow *mainwin,
156 static void import_mbox_cb (MainWindow *mainwin,
159 static void export_mbox_cb (MainWindow *mainwin,
162 static void export_list_mbox_cb (MainWindow *mainwin,
165 static void empty_trash_cb (MainWindow *mainwin,
169 static void save_as_cb (MainWindow *mainwin,
172 static void print_cb (MainWindow *mainwin,
175 static void app_exit_cb (MainWindow *mainwin,
179 static void search_cb (MainWindow *mainwin,
183 static void toggle_message_cb (MainWindow *mainwin,
186 static void toggle_toolbar_cb (MainWindow *mainwin,
189 static void toggle_statusbar_cb (MainWindow *mainwin,
192 static void set_layout_cb (MainWindow *mainwin,
196 static void addressbook_open_cb (MainWindow *mainwin,
199 static void log_window_show_cb (MainWindow *mainwin,
202 static void filtering_debug_window_show_cb (MainWindow *mainwin,
206 static void inc_cancel_cb (MainWindow *mainwin,
210 static void open_msg_cb (MainWindow *mainwin,
214 static void view_source_cb (MainWindow *mainwin,
218 static void show_all_header_cb (MainWindow *mainwin,
222 static void hide_quotes_cb(MainWindow *mainwin,
226 static void move_to_cb (MainWindow *mainwin,
229 static void copy_to_cb (MainWindow *mainwin,
232 static void delete_cb (MainWindow *mainwin,
235 static void delete_trash_cb (MainWindow *mainwin,
239 static void cancel_cb (MainWindow *mainwin,
243 static void mark_cb (MainWindow *mainwin,
246 static void unmark_cb (MainWindow *mainwin,
250 static void mark_as_unread_cb (MainWindow *mainwin,
253 static void mark_as_read_cb (MainWindow *mainwin,
256 static void mark_all_read_cb (MainWindow *mainwin,
259 static void mark_as_spam_cb (MainWindow *mainwin,
263 static void ignore_thread_cb (MainWindow *mainwin,
266 static void unignore_thread_cb (MainWindow *mainwin,
269 static void lock_msgs_cb (MainWindow *mainwin,
272 static void unlock_msgs_cb (MainWindow *mainwin,
276 static void reedit_cb (MainWindow *mainwin,
280 static void add_address_cb (MainWindow *mainwin,
284 static void set_charset_cb (MainWindow *mainwin,
288 static void set_decode_cb (MainWindow *mainwin,
292 static void hide_read_messages (MainWindow *mainwin,
296 static void thread_cb (MainWindow *mainwin,
299 static void expand_threads_cb (MainWindow *mainwin,
302 static void collapse_threads_cb (MainWindow *mainwin,
306 static void set_summary_display_item_cb (MainWindow *mainwin,
309 static void set_folder_display_item_cb (MainWindow *mainwin,
312 static void sort_summary_cb (MainWindow *mainwin,
315 static void sort_summary_type_cb (MainWindow *mainwin,
318 static void attract_by_subject_cb(MainWindow *mainwin,
322 static void delete_duplicated_cb (MainWindow *mainwin,
325 static void delete_duplicated_all_cb (MainWindow *mainwin,
328 static void filter_cb (MainWindow *mainwin,
331 static void execute_summary_cb (MainWindow *mainwin,
334 static void update_summary_cb (MainWindow *mainwin,
338 static void prev_cb (MainWindow *mainwin,
341 static void next_cb (MainWindow *mainwin,
344 static void next_unread_cb (MainWindow *mainwin,
347 static void prev_unread_cb (MainWindow *mainwin,
351 static void prev_new_cb (MainWindow *mainwin,
354 static void next_new_cb (MainWindow *mainwin,
357 static void prev_marked_cb (MainWindow *mainwin,
360 static void next_marked_cb (MainWindow *mainwin,
363 static void prev_labeled_cb (MainWindow *mainwin,
366 static void next_labeled_cb (MainWindow *mainwin,
369 static void last_read_cb (MainWindow *mainwin,
372 static void parent_cb (MainWindow *mainwin,
376 static void goto_folder_cb (MainWindow *mainwin,
379 static void goto_unread_folder_cb(MainWindow *mainwin,
383 static void copy_cb (MainWindow *mainwin,
386 static void allsel_cb (MainWindow *mainwin,
389 static void select_thread_cb (MainWindow *mainwin,
392 static void delete_thread_cb (MainWindow *mainwin,
396 static void create_filter_cb (MainWindow *mainwin,
399 static void create_processing_cb (MainWindow *mainwin,
402 static void open_urls_cb (MainWindow *mainwin,
406 static void prefs_template_open_cb (MainWindow *mainwin,
409 static void prefs_actions_open_cb (MainWindow *mainwin,
412 static void prefs_account_open_cb (MainWindow *mainwin,
416 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
420 static void prefs_post_processing_open_cb (MainWindow *mainwin,
424 static void prefs_filtering_open_cb (MainWindow *mainwin,
428 static void ssl_manager_open_cb (MainWindow *mainwin,
432 static void new_account_cb (MainWindow *mainwin,
436 static void account_selector_menu_cb (GtkMenuItem *menuitem,
438 static void account_receive_menu_cb (GtkMenuItem *menuitem,
440 static void account_compose_menu_cb (GtkMenuItem *menuitem,
443 static void prefs_open_cb (GtkMenuItem *menuitem,
445 static void plugins_open_cb (GtkMenuItem *menuitem,
448 static void online_switch_clicked(GtkButton *btn,
451 static void manual_open_cb (MainWindow *mainwin,
455 static void legend_open_cb (GtkMenuItem *menuitem,
458 static void scan_tree_func (Folder *folder,
462 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
464 static void addr_harvest_cb ( MainWindow *mainwin,
468 static void addr_harvest_msg_cb ( MainWindow *mainwin,
471 static void sync_cb ( MainWindow *mainwin,
475 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
476 GdkEventFocus *focus,
478 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
479 GdkEventVisibility *state,
481 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
482 GdkEventWindowState *state,
484 static void main_window_reply_cb (MainWindow *mainwin,
487 static gboolean mainwindow_progressindicator_hook (gpointer source,
490 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
493 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
495 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
497 static void mailing_list_compose(GtkWidget *w, gpointer *data);
499 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
500 #define SEPARATE_ACTION 500
501 static void mainwindow_quicksearch (MainWindow *mainwin,
504 static gboolean any_folder_want_synchronise(void);
506 static GtkItemFactoryEntry mainwin_entries[] =
508 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
509 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
510 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
511 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
513 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
515 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
516 {N_("/_File/Exp_ort selected to mbox file..."),
517 NULL, export_list_mbox_cb, 0, NULL},
518 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
520 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
522 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
523 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
525 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
526 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
527 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
528 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
530 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
531 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
532 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
533 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
534 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
535 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_Edit/_Find in current message..."),
537 "<control>F", search_cb, 0, NULL},
538 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
539 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
540 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
541 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
542 {N_("/_View/Show or hi_de/_Message view"),
543 "V", toggle_message_cb, 0, "<ToggleItem>"},
544 {N_("/_View/Show or hi_de/_Toolbar"),
545 NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
547 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
548 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
549 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
550 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
551 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
552 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
553 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
554 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
555 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
556 {N_("/_View/Show or hi_de/Status _bar"),
557 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
558 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
559 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
560 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
562 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
564 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
565 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
566 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
567 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
568 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
569 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
570 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
571 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
572 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
573 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
575 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
576 {N_("/_View/_Sort/by _color label"),
577 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
578 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
580 {N_("/_View/_Sort/by a_ttachment"),
581 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
582 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
583 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
584 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
585 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
586 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
587 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
588 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
589 {N_("/_View/_Sort/_Attract by subject"),
590 NULL, attract_by_subject_cb, 0, NULL},
591 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
592 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
593 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
594 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
596 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
597 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
598 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
599 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
600 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
601 {N_("/_View/_Go to/P_revious unread message"),
602 "<shift>P", prev_unread_cb, 0, NULL},
603 {N_("/_View/_Go to/N_ext unread message"),
604 "<shift>N", next_unread_cb, 0, NULL},
605 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
607 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
608 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to/Previous _marked message"),
610 NULL, prev_marked_cb, 0, NULL},
611 {N_("/_View/_Go to/Next m_arked message"),
612 NULL, next_marked_cb, 0, NULL},
613 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_View/_Go to/Previous _labeled message"),
615 NULL, prev_labeled_cb, 0, NULL},
616 {N_("/_View/_Go to/Next la_beled message"),
617 NULL, next_labeled_cb, 0, NULL},
618 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_View/_Go to/Last read message"),
620 NULL, last_read_cb, 0, NULL},
621 {N_("/_View/_Go to/Parent message"),
622 "<control>Up", parent_cb, 0, NULL},
623 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
625 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
626 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
628 #define ENC_SEPARATOR \
629 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
630 #define ENC_ACTION(action) \
631 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
633 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
634 {N_("/_View/Character _encoding/_Auto detect"),
635 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
636 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
637 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
638 ENC_ACTION(C_US_ASCII)},
639 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
640 ENC_ACTION(C_UTF_8)},
643 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
644 ENC_ACTION(C_ISO_8859_1)},
645 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
646 ENC_ACTION(C_ISO_8859_15)},
647 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
648 ENC_ACTION(C_WINDOWS_1252)},
651 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
652 ENC_ACTION(C_ISO_8859_2)},
655 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
656 ENC_ACTION(C_ISO_8859_13)},
657 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
658 ENC_ACTION(C_ISO_8859_4)},
661 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
662 ENC_ACTION(C_ISO_8859_7)},
665 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
666 ENC_ACTION(C_ISO_8859_8)},
667 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
668 ENC_ACTION(C_CP1255)},
671 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
672 ENC_ACTION(C_ISO_8859_6)},
673 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
674 ENC_ACTION(C_CP1256)},
677 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
678 ENC_ACTION(C_ISO_8859_9)},
681 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
682 ENC_ACTION(C_ISO_8859_5)},
683 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
684 ENC_ACTION(C_KOI8_R)},
685 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
686 ENC_ACTION(C_KOI8_U)},
687 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
688 ENC_ACTION(C_CP1251)},
691 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
692 ENC_ACTION(C_ISO_2022_JP)},
693 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
694 ENC_ACTION(C_ISO_2022_JP_2)},
695 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
696 ENC_ACTION(C_EUC_JP)},
697 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
698 ENC_ACTION(C_SHIFT_JIS)},
701 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
702 ENC_ACTION(C_GB2312)},
703 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
705 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
707 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
708 ENC_ACTION(C_EUC_TW)},
709 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
710 ENC_ACTION(C_ISO_2022_CN)},
713 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
714 ENC_ACTION(C_EUC_KR)},
715 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
716 ENC_ACTION(C_ISO_2022_KR)},
719 {N_("/_View/Character _encoding/Thai (TIS-620)"),
720 ENC_ACTION(C_TIS_620)},
721 {N_("/_View/Character _encoding/Thai (Windows-874)"),
722 ENC_ACTION(C_WINDOWS_874)},
727 #define DEC_SEPARATOR \
728 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
729 #define DEC_ACTION(action) \
730 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
731 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
732 {N_("/_View/Decode/_Auto detect"),
733 NULL, set_decode_cb, 0, "<RadioItem>"},
734 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
735 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
736 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
737 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
738 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
743 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
744 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
745 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
746 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
747 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
748 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
749 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
750 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
751 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
752 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
754 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
755 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
756 {N_("/_Message/Recei_ve/Get from _current account"),
757 "<control>I", inc_mail_cb, 0, NULL},
758 {N_("/_Message/Recei_ve/Get from _all accounts"),
759 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
760 {N_("/_Message/Recei_ve/Cancel receivin_g"),
761 NULL, inc_cancel_cb, 0, NULL},
762 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
763 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
764 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
765 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
766 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
767 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
768 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
769 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
770 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
771 {N_("/_Message/Repl_y to/mailing _list"),
772 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
773 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
774 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
775 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
776 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
777 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
779 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
780 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
781 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
782 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
783 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
784 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
785 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
787 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
788 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
789 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
790 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
791 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
792 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
793 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
794 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
795 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
796 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
797 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
798 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
799 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
800 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
801 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
802 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
803 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
804 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
805 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
806 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
807 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
808 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
809 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
810 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
811 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
813 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
814 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
815 {N_("/_Tools/Add sender to address boo_k"),
816 NULL, add_address_cb, 0, NULL},
817 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
818 {N_("/_Tools/_Harvest addresses/from _Folder..."),
819 NULL, addr_harvest_cb, 0, NULL},
820 {N_("/_Tools/_Harvest addresses/from _Messages..."),
821 NULL, addr_harvest_msg_cb, 0, NULL},
822 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
823 {N_("/_Tools/_Filter all messages in folder"),
824 NULL, filter_cb, 0, NULL},
825 {N_("/_Tools/Filter _selected messages"),
826 NULL, filter_cb, 1, NULL},
827 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
828 {N_("/_Tools/_Create filter rule/_Automatically"),
829 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
830 {N_("/_Tools/_Create filter rule/by _From"),
831 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
832 {N_("/_Tools/_Create filter rule/by _To"),
833 NULL, create_filter_cb, FILTER_BY_TO, NULL},
834 {N_("/_Tools/_Create filter rule/by _Subject"),
835 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
836 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
837 {N_("/_Tools/C_reate processing rule/_Automatically"),
838 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
839 {N_("/_Tools/C_reate processing rule/by _From"),
840 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
841 {N_("/_Tools/C_reate processing rule/by _To"),
842 NULL, create_processing_cb, FILTER_BY_TO, NULL},
843 {N_("/_Tools/C_reate processing rule/by _Subject"),
844 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
845 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
846 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
847 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
848 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
849 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
850 {N_("/_Tools/Ch_eck for new messages in all folders"),
851 NULL, update_folderview_cb, 0, NULL},
852 {N_("/_Tools/Delete du_plicated messages"),
853 NULL, NULL, 0, "<Branch>"},
854 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
855 NULL, delete_duplicated_cb, 0, NULL},
856 {N_("/_Tools/Delete du_plicated messages/In all folders"),
857 NULL, delete_duplicated_all_cb, 0, NULL},
858 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
859 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
861 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
862 {N_("/_Tools/SSL cer_tificates..."),
863 NULL, ssl_manager_open_cb, 0, NULL},
865 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
866 {N_("/_Tools/Filtering debug window"), NULL, filtering_debug_window_show_cb, 0, NULL},
867 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
869 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
870 {N_("/_Configuration/C_hange current account"),
871 NULL, NULL, 0, "<Branch>"},
872 {N_("/_Configuration/_Preferences for current account..."),
873 NULL, prefs_account_open_cb, 0, NULL},
874 {N_("/_Configuration/Create _new account..."),
875 NULL, new_account_cb, 0, NULL},
876 {N_("/_Configuration/_Edit accounts..."),
877 NULL, account_edit_open, 0, NULL},
878 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
879 {N_("/_Configuration/P_references..."),
880 NULL, prefs_open_cb, 0, NULL},
881 {N_("/_Configuration/Pre-pr_ocessing..."),
882 NULL, prefs_pre_processing_open_cb, 0, NULL},
883 {N_("/_Configuration/Post-pro_cessing..."),
884 NULL, prefs_post_processing_open_cb, 0, NULL},
885 {N_("/_Configuration/_Filtering..."),
886 NULL, prefs_filtering_open_cb, 0, NULL},
887 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
888 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
889 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
891 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
892 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
893 {N_("/_Help/_Online User-contributed FAQ"),
894 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
895 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
896 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
897 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
900 static gboolean offline_ask_sync = TRUE;
901 static guint lastkey;
902 static gboolean is_obscured = FALSE;
904 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
910 MainWindow *mainwin = (MainWindow *)user_data;
912 if (mainwin->summaryview &&
913 mainwin->summaryview->quicksearch &&
914 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
915 (mod == 0 || mod == GDK_SHIFT_MASK)) {
916 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
922 #define N_COLOR_LABELS colorlabel_get_color_count()
924 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
929 GtkCheckMenuItem **items;
934 mainwin = (MainWindow *)data;
935 g_return_if_fail(mainwin != NULL);
937 sel = summary_get_selection(mainwin->summaryview);
940 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
941 g_return_if_fail(menu != NULL);
943 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
945 /* NOTE: don't return prematurely because we set the "dont_toggle"
946 * state for check menu items */
947 g_object_set_data(G_OBJECT(menu), "dont_toggle",
950 /* clear items. get item pointers. */
951 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
952 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
953 gtk_check_menu_item_set_active
954 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
955 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
960 if (n == (N_COLOR_LABELS + 1)) {
961 /* iterate all messages and set the state of the appropriate
963 for (; sel != NULL; sel = sel->next) {
967 msginfo = (MsgInfo *)sel->data;
969 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
970 if (!items[clabel]->active)
971 gtk_check_menu_item_set_active
972 (items[clabel], TRUE);
976 g_warning("invalid number of color elements (%d)\n", n);
978 /* reset "dont_toggle" state */
979 g_object_set_data(G_OBJECT(menu), "dont_toggle",
983 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
986 guint color = GPOINTER_TO_UINT(data);
989 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
990 g_return_if_fail(mainwin != NULL);
992 /* "dont_toggle" state set? */
993 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
997 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1000 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1002 GtkWidget *label_menuitem;
1007 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1008 "/Message/Color label");
1009 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1010 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1012 gtk_widget_show(label_menuitem);
1014 menu = gtk_menu_new();
1016 /* create sub items. for the menu item activation callback we pass the
1017 * index of label_colors[] as data parameter. for the None color we
1018 * pass an invalid (high) value. also we attach a data pointer so we
1019 * can always get back the Mainwindow pointer. */
1021 item = gtk_check_menu_item_new_with_label(_("None"));
1022 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1023 g_signal_connect(G_OBJECT(item), "activate",
1024 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1025 GUINT_TO_POINTER(0));
1026 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1027 gtk_widget_show(item);
1029 gtk_widget_add_accelerator(item, "activate",
1030 mainwin->menu_factory->accel_group,
1031 GDK_0, GDK_CONTROL_MASK,
1032 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1034 item = gtk_menu_item_new();
1035 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1036 gtk_widget_show(item);
1038 /* create pixmap/label menu items */
1039 for (i = 0; i < N_COLOR_LABELS; i++) {
1040 item = colorlabel_create_check_color_menu_item(
1041 i, refresh, MAINWIN_COLORMENU);
1042 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1043 g_signal_connect(G_OBJECT(item), "activate",
1044 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1045 GUINT_TO_POINTER(i + 1));
1046 g_object_set_data(G_OBJECT(item), "mainwin",
1048 gtk_widget_show(item);
1050 gtk_widget_add_accelerator(item, "activate",
1051 mainwin->menu_factory->accel_group,
1052 GDK_1+i, GDK_CONTROL_MASK,
1053 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1056 gtk_widget_show(menu);
1057 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1058 mainwin->colorlabel_menu = menu;
1061 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1062 MainWindow *mainwindow)
1064 if (evt && evt->button == 1) {
1065 log_window_show_error(mainwindow->logwin);
1066 gtk_widget_hide(mainwindow->warning_btn);
1071 static gboolean warning_visi_notify(GtkWidget *widget,
1072 GdkEventVisibility *event,
1073 MainWindow *mainwindow)
1075 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1079 static gboolean warning_leave_notify(GtkWidget *widget,
1080 GdkEventCrossing *event,
1081 MainWindow *mainwindow)
1083 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1087 static gboolean warning_enter_notify(GtkWidget *widget,
1088 GdkEventCrossing *event,
1089 MainWindow *mainwindow)
1091 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1095 void mainwindow_show_error(void)
1097 MainWindow *mainwin = mainwindow_get_mainwindow();
1098 gtk_widget_show(mainwin->warning_btn);
1101 void mainwindow_clear_error(MainWindow *mainwin)
1103 gtk_widget_hide(mainwin->warning_btn);
1106 MainWindow *main_window_create()
1108 MainWindow *mainwin;
1112 GtkWidget *handlebox;
1113 GtkWidget *vbox_body;
1114 GtkWidget *hbox_stat;
1115 GtkWidget *statusbar;
1116 GtkWidget *progressbar;
1117 GtkWidget *statuslabel;
1118 GtkWidget *ac_button;
1119 GtkWidget *ac_label;
1120 GtkWidget *online_pixmap;
1121 GtkWidget *offline_pixmap;
1122 GtkWidget *online_switch;
1123 GtkWidget *offline_switch;
1125 GtkWidget *warning_icon;
1126 GtkWidget *warning_btn;
1128 FolderView *folderview;
1129 SummaryView *summaryview;
1130 MessageView *messageview;
1131 GdkColormap *colormap;
1133 gboolean success[4];
1134 GtkItemFactory *ifactory;
1136 GtkWidget *menuitem;
1138 guint n_menu_entries;
1140 static GdkGeometry geometry;
1142 debug_print("Creating main window...\n");
1143 mainwin = g_new0(MainWindow, 1);
1146 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
1147 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1148 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1150 if (!geometry.min_height) {
1151 geometry.min_width = 320;
1152 geometry.min_height = 200;
1154 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1157 g_signal_connect(G_OBJECT(window), "delete_event",
1158 G_CALLBACK(main_window_close_cb), mainwin);
1159 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1160 g_signal_connect(G_OBJECT(window), "focus_in_event",
1161 G_CALLBACK(mainwindow_focus_in_event),
1163 g_signal_connect(G_OBJECT(window), "key_press_event",
1164 G_CALLBACK(mainwindow_key_pressed), mainwin);
1166 gtk_widget_realize(window);
1167 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1170 gtkut_widget_set_app_icon(window);
1172 vbox = gtk_vbox_new(FALSE, 0);
1173 gtk_widget_show(vbox);
1174 gtk_container_add(GTK_CONTAINER(window), vbox);
1177 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1178 menubar = menubar_create(window, mainwin_entries,
1179 n_menu_entries, "<Main>", mainwin);
1180 gtk_widget_show(menubar);
1181 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1182 ifactory = gtk_item_factory_from_widget(menubar);
1184 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1185 main_create_mailing_list_menu (mainwin, NULL); */
1187 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1189 if (prefs_common.toolbar_detachable) {
1190 handlebox = gtk_handle_box_new();
1191 gtk_widget_show(handlebox);
1192 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1193 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1194 G_CALLBACK(toolbar_child_attached), mainwin);
1195 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1196 G_CALLBACK(toolbar_child_detached), mainwin);
1198 handlebox = gtk_hbox_new(FALSE, 0);
1199 gtk_widget_show(handlebox);
1200 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1202 /* link window to mainwin->window to avoid gdk warnings */
1203 mainwin->window = window;
1205 /* create toolbar */
1206 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1209 toolbar_set_learn_button
1213 /* vbox that contains body */
1214 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1215 gtk_widget_show(vbox_body);
1216 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1217 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1219 hbox_stat = gtk_hbox_new(FALSE, 2);
1220 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1222 tips = gtk_tooltips_new();
1224 warning_icon = gtk_image_new_from_stock
1225 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1226 warning_btn = gtk_event_box_new();
1227 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1229 mainwin->warning_btn = warning_btn;
1231 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1232 G_CALLBACK(warning_icon_pressed),
1233 (gpointer) mainwin);
1234 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1235 G_CALLBACK(warning_visi_notify), mainwin);
1236 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1237 G_CALLBACK(warning_visi_notify), mainwin);
1238 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1239 G_CALLBACK(warning_leave_notify), mainwin);
1240 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1241 G_CALLBACK(warning_enter_notify), mainwin);
1243 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1245 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1246 _("Some error(s) happened. Click here to view log."), NULL);
1247 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1249 statusbar = statusbar_create();
1250 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1252 progressbar = gtk_progress_bar_new();
1253 gtk_widget_set_size_request(progressbar, 120, 1);
1254 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1256 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1257 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1258 online_switch = gtk_button_new ();
1259 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1260 _("You are online. Click the icon to go offline"), NULL);
1261 offline_switch = gtk_button_new ();
1262 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1263 _("You are offline. Click the icon to go online"),
1265 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1266 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1267 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1268 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1269 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1270 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1271 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1272 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1274 statuslabel = gtk_label_new("");
1275 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1277 ac_button = gtk_button_new();
1278 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1279 ac_button, _("Select account"), NULL);
1280 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1281 gtk_widget_set_size_request(ac_button, -1, 0);
1282 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1283 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1284 G_CALLBACK(ac_label_button_pressed), mainwin);
1286 ac_label = gtk_label_new("");
1287 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1289 gtk_widget_show_all(hbox_stat);
1291 gtk_widget_hide(offline_switch);
1292 gtk_widget_hide(warning_btn);
1295 mainwin->folderview = folderview = folderview_create();
1296 mainwin->summaryview = summaryview = summary_create();
1297 mainwin->messageview = messageview = messageview_create(mainwin);
1299 /* init log instances data before creating log views */
1300 set_log_title(LOG_PROTOCOL, _("Protocol log"));
1301 set_log_prefs(LOG_PROTOCOL,
1302 &prefs_common.logwin_width,
1303 &prefs_common.logwin_height);
1304 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1305 set_log_prefs(LOG_DEBUG_FILTERING,
1306 &prefs_common.filtering_debugwin_width,
1307 &prefs_common.filtering_debugwin_height);
1309 /* setup log windows */
1310 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1311 log_window_init(mainwin->logwin);
1313 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1314 log_window_set_clipping(mainwin->logwin,
1315 prefs_common.cliplog,
1316 prefs_common.loglength);
1318 log_window_init(mainwin->filtering_debugwin);
1319 log_window_set_clipping(mainwin->filtering_debugwin,
1320 prefs_common.filtering_debug_cliplog,
1321 prefs_common.filtering_debug_loglength);
1322 if (prefs_common.enable_filtering_debug)
1323 log_message(LOG_DEBUG_FILTERING, _("filtering debug enabled\n"));
1325 log_message(LOG_DEBUG_FILTERING, _("filtering debug disabled\n"));
1327 folderview->mainwin = mainwin;
1328 folderview->summaryview = summaryview;
1330 summaryview->mainwin = mainwin;
1331 summaryview->folderview = folderview;
1332 summaryview->messageview = messageview;
1333 summaryview->window = window;
1335 messageview->statusbar = statusbar;
1336 mainwin->vbox = vbox;
1337 mainwin->menubar = menubar;
1338 mainwin->menu_factory = ifactory;
1339 mainwin->handlebox = handlebox;
1340 mainwin->vbox_body = vbox_body;
1341 mainwin->hbox_stat = hbox_stat;
1342 mainwin->statusbar = statusbar;
1343 mainwin->progressbar = progressbar;
1344 mainwin->statuslabel = statuslabel;
1345 mainwin->online_switch = online_switch;
1346 mainwin->online_pixmap = online_pixmap;
1347 mainwin->offline_pixmap = offline_pixmap;
1348 mainwin->ac_button = ac_button;
1349 mainwin->ac_label = ac_label;
1350 mainwin->offline_switch = offline_switch;
1352 /* set context IDs for status bar */
1353 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1354 (GTK_STATUSBAR(statusbar), "Main Window");
1355 mainwin->folderview_cid = gtk_statusbar_get_context_id
1356 (GTK_STATUSBAR(statusbar), "Folder View");
1357 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1358 (GTK_STATUSBAR(statusbar), "Summary View");
1359 mainwin->messageview_cid = gtk_statusbar_get_context_id
1360 (GTK_STATUSBAR(statusbar), "Message View");
1362 messageview->statusbar_cid = mainwin->messageview_cid;
1364 /* allocate colors for summary view and folder view */
1365 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1366 summaryview->color_marked.blue = (guint16)65535;
1368 summaryview->color_dim.red = summaryview->color_dim.green =
1369 summaryview->color_dim.blue = COLOR_DIM;
1371 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1372 &folderview->color_new);
1374 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1375 &folderview->color_op);
1377 summaryview->color_important.red = 0;
1378 summaryview->color_important.green = 0;
1379 summaryview->color_important.blue = (guint16)65535;
1381 color[0] = summaryview->color_marked;
1382 color[1] = summaryview->color_dim;
1383 color[2] = folderview->color_new;
1384 color[3] = folderview->color_op;
1386 colormap = gdk_drawable_get_colormap(window->window);
1387 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1388 for (i = 0; i < 4; i++) {
1389 if (success[i] == FALSE)
1390 g_warning("MainWindow: color allocation %d failed\n", i);
1393 debug_print("done.\n");
1395 messageview->visible = prefs_common.msgview_visible;
1397 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1399 g_signal_connect(G_OBJECT(window), "size_allocate",
1400 G_CALLBACK(main_window_size_allocate_cb),
1403 /* set menu items */
1404 menuitem = gtk_item_factory_get_item
1405 (ifactory, "/View/Character encoding/Auto detect");
1406 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1408 switch (prefs_common.toolbar_style) {
1410 menuitem = gtk_item_factory_get_item
1411 (ifactory, "/View/Show or hide/Toolbar/Hide");
1414 menuitem = gtk_item_factory_get_item
1415 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1418 menuitem = gtk_item_factory_get_item
1419 (ifactory, "/View/Show or hide/Toolbar/Text only");
1422 menuitem = gtk_item_factory_get_item
1423 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1425 case TOOLBAR_BOTH_HORIZ:
1426 menuitem = gtk_item_factory_get_item
1428 "/View/Show or hide/Toolbar/Text beside icons");
1430 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1432 gtk_widget_hide(mainwin->hbox_stat);
1433 menuitem = gtk_item_factory_get_item
1434 (ifactory, "/View/Show or hide/Status bar");
1435 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1436 prefs_common.show_statusbar);
1438 /* set account selection menu */
1439 ac_menu = gtk_item_factory_get_widget
1440 (ifactory, "/Configuration/Change current account");
1441 mainwin->ac_menu = ac_menu;
1443 toolbar_main_set_sensitive(mainwin);
1445 /* create actions menu */
1446 main_window_update_actions_menu(mainwin);
1448 main_create_mailing_list_menu (mainwin, NULL);
1450 /* attach accel groups to main window */
1451 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1452 gtk_window_add_accel_group \
1454 gtk_item_factory_from_widget(menu)->accel_group); \
1455 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1457 G_CALLBACK(main_window_accel_activate), mainwin);
1460 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1462 /* connect the accelerators for equivalent
1463 menu items in different menus */
1464 menu_connect_identical_items();
1466 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1468 g_signal_connect(G_OBJECT(window), "window_state_event",
1469 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1470 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1471 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1472 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1474 if (prefs_common.layout_mode == VERTICAL_LAYOUT)
1475 summary_relayout(mainwin->summaryview);
1477 gtk_widget_show(mainwin->window);
1479 /* initialize views */
1480 folderview_init(folderview);
1481 summary_init(summaryview);
1482 messageview_init(messageview);
1484 sslcertwindow_register_hook();
1486 mainwin->lock_count = 0;
1487 mainwin->menu_lock_count = 0;
1488 mainwin->cursor_count = 0;
1490 mainwin->progressindicator_hook =
1491 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1494 watch_cursor = gdk_cursor_new(GDK_WATCH);
1496 hand_cursor = gdk_cursor_new(GDK_HAND2);
1498 mainwin_list = g_list_append(mainwin_list, mainwin);
1500 /* init work_offline */
1501 if (prefs_common.work_offline)
1502 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1504 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1509 void main_window_destroy(MainWindow *mainwin)
1511 /* TODO : destroy other component */
1512 messageview_destroy(mainwin->messageview);
1513 mainwin->messageview = NULL;
1516 void main_window_update_actions_menu(MainWindow *mainwin)
1518 GtkItemFactory *ifactory;
1520 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1521 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1524 void main_window_cursor_wait(MainWindow *mainwin)
1527 if (mainwin->cursor_count == 0) {
1528 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1529 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1532 mainwin->cursor_count++;
1537 void main_window_cursor_normal(MainWindow *mainwin)
1539 if (mainwin->cursor_count)
1540 mainwin->cursor_count--;
1542 if (mainwin->cursor_count == 0) {
1543 gdk_window_set_cursor(mainwin->window->window, NULL);
1544 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1549 /* lock / unlock the user-interface */
1550 void main_window_lock(MainWindow *mainwin)
1552 if (mainwin->lock_count == 0)
1553 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1555 mainwin->lock_count++;
1557 main_window_set_menu_sensitive(mainwin);
1558 toolbar_main_set_sensitive(mainwin);
1561 void main_window_unlock(MainWindow *mainwin)
1563 if (mainwin->lock_count)
1564 mainwin->lock_count--;
1566 main_window_set_menu_sensitive(mainwin);
1567 toolbar_main_set_sensitive(mainwin);
1569 if (mainwin->lock_count == 0)
1570 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1573 static void main_window_menu_callback_block(MainWindow *mainwin)
1575 mainwin->menu_lock_count++;
1578 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1580 if (mainwin->menu_lock_count)
1581 mainwin->menu_lock_count--;
1584 static guint prefs_tag = 0;
1586 void main_window_reflect_prefs_all(void)
1588 main_window_reflect_prefs_all_real(FALSE);
1591 static gboolean reflect_prefs_timeout_cb(gpointer data)
1593 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1595 MainWindow *mainwin;
1598 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1599 mainwin = (MainWindow *)cur->data;
1601 main_window_show_cur_account(mainwin);
1602 main_window_set_menu_sensitive(mainwin);
1603 toolbar_main_set_sensitive(mainwin);
1606 if (pixmap_theme_changed) {
1607 toolbar_update(TOOLBAR_MAIN, mainwin);
1608 messageview_reflect_prefs_pixmap_theme();
1609 compose_reflect_prefs_pixmap_theme();
1610 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1611 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1613 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1614 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1615 mainwin->online_pixmap);
1616 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1617 gtk_widget_show(pixmap);
1618 mainwin->online_pixmap = pixmap;
1619 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1620 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1621 mainwin->offline_pixmap);
1622 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1623 gtk_widget_show(pixmap);
1624 mainwin->offline_pixmap = pixmap;
1627 headerview_set_font(mainwin->messageview->headerview);
1628 headerview_set_visibility(mainwin->messageview->headerview,
1629 prefs_common.display_header_pane);
1630 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1631 folderview_reflect_prefs();
1632 summary_reflect_prefs();
1633 summary_redisplay_msg(mainwin->summaryview);
1639 void main_window_reflect_prefs_all_now(void)
1641 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1644 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1649 /* re-create colorlabel submenu */
1650 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1651 g_return_if_fail(menu != NULL);
1653 /* clear items. get item pointers. */
1654 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1655 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1657 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1658 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1662 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1664 if (prefs_tag == 0 || pixmap_theme_changed) {
1665 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1666 GINT_TO_POINTER(pixmap_theme_changed));
1670 void main_window_set_summary_column(void)
1673 MainWindow *mainwin;
1675 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1676 mainwin = (MainWindow *)cur->data;
1677 summary_set_column_order(mainwin->summaryview);
1681 void main_window_set_folder_column(void)
1684 MainWindow *mainwin;
1686 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1687 mainwin = (MainWindow *)cur->data;
1688 folderview_set_column_order(mainwin->folderview);
1692 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1693 GList *account_list)
1695 GList *cur_ac, *cur_item;
1696 GtkWidget *menuitem;
1697 PrefsAccount *ac_prefs;
1699 /* destroy all previous menu item */
1700 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1701 while (cur_item != NULL) {
1702 GList *next = cur_item->next;
1703 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1707 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1708 ac_prefs = (PrefsAccount *)cur_ac->data;
1710 menuitem = gtk_menu_item_new_with_label
1711 (ac_prefs->account_name
1712 ? ac_prefs->account_name : _("Untitled"));
1713 gtk_widget_show(menuitem);
1714 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1715 g_signal_connect(G_OBJECT(menuitem), "activate",
1716 G_CALLBACK(account_selector_menu_cb),
1721 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1722 GList *account_list)
1724 GList *cur_ac, *cur_item;
1726 GtkWidget *menuitem;
1727 PrefsAccount *ac_prefs;
1729 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1730 "/Message/Receive");
1732 /* search for separator */
1733 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1734 cur_item = cur_item->next) {
1735 if (GTK_BIN(cur_item->data)->child == NULL) {
1736 cur_item = cur_item->next;
1741 /* destroy all previous menu item */
1742 while (cur_item != NULL) {
1743 GList *next = cur_item->next;
1744 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1748 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1749 ac_prefs = (PrefsAccount *)cur_ac->data;
1751 menuitem = gtk_menu_item_new_with_label
1752 (ac_prefs->account_name ? ac_prefs->account_name
1754 gtk_widget_show(menuitem);
1755 gtk_menu_append(GTK_MENU(menu), menuitem);
1756 g_signal_connect(G_OBJECT(menuitem), "activate",
1757 G_CALLBACK(account_receive_menu_cb),
1762 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1763 GList *account_list)
1765 GList *cur_ac, *cur_item;
1766 GtkWidget *menuitem;
1767 PrefsAccount *ac_prefs;
1768 GtkWidget *menu = NULL;
1770 if (mainwin->toolbar->getall_btn == NULL
1771 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1774 menu = mainwin->toolbar->getall_combo->menu;
1776 /* destroy all previous menu item */
1777 cur_item = GTK_MENU_SHELL(menu)->children;
1778 while (cur_item != NULL) {
1779 GList *next = cur_item->next;
1780 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1784 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1785 ac_prefs = (PrefsAccount *)cur_ac->data;
1787 menuitem = gtk_menu_item_new_with_label
1788 (ac_prefs->account_name
1789 ? ac_prefs->account_name : _("Untitled"));
1790 gtk_widget_show(menuitem);
1791 gtk_menu_append(GTK_MENU(menu), menuitem);
1792 g_signal_connect(G_OBJECT(menuitem), "activate",
1793 G_CALLBACK(account_receive_menu_cb),
1798 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1799 GList *account_list)
1801 GList *cur_ac, *cur_item;
1802 GtkWidget *menuitem;
1803 PrefsAccount *ac_prefs;
1804 GtkWidget *menu = NULL;
1806 if (mainwin->toolbar->compose_mail_btn == NULL
1807 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1810 menu = mainwin->toolbar->compose_combo->menu;
1812 /* destroy all previous menu item */
1813 cur_item = GTK_MENU_SHELL(menu)->children;
1814 while (cur_item != NULL) {
1815 GList *next = cur_item->next;
1816 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1820 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1821 ac_prefs = (PrefsAccount *)cur_ac->data;
1823 menuitem = gtk_menu_item_new_with_label
1824 (ac_prefs->account_name
1825 ? ac_prefs->account_name : _("Untitled"));
1826 gtk_widget_show(menuitem);
1827 gtk_menu_append(GTK_MENU(menu), menuitem);
1828 g_signal_connect(G_OBJECT(menuitem), "activate",
1829 G_CALLBACK(account_compose_menu_cb),
1834 void main_window_set_account_menu(GList *account_list)
1837 MainWindow *mainwin;
1839 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1840 mainwin = (MainWindow *)cur->data;
1841 main_window_set_account_selector_menu(mainwin, account_list);
1842 main_window_set_account_receive_menu(mainwin, account_list);
1843 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1844 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1846 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
1849 void main_window_set_account_menu_only_toolbar(GList *account_list)
1852 MainWindow *mainwin;
1854 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1855 mainwin = (MainWindow *)cur->data;
1856 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1857 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1861 static void main_window_show_cur_account(MainWindow *mainwin)
1866 ac_name = g_strdup(cur_account
1867 ? (cur_account->account_name
1868 ? cur_account->account_name : _("Untitled"))
1872 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1874 buf = g_strdup(PROG_VERSION);
1875 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1878 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1879 gtk_widget_queue_resize(mainwin->ac_button);
1884 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
1886 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1887 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1888 GtkWidget *message_wid = mainwin->messageview->vbox;
1890 if (layout_mode == prefs_common.layout_mode)
1893 debug_print("Changing window separation type from %d to %d\n",
1894 prefs_common.layout_mode, layout_mode);
1896 /* remove widgets from those containers */
1897 gtk_widget_ref(folder_wid);
1898 gtk_widget_ref(summary_wid);
1899 gtk_widget_ref(message_wid);
1900 gtkut_container_remove
1901 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1902 gtkut_container_remove
1903 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1904 gtkut_container_remove
1905 (GTK_CONTAINER(message_wid->parent), message_wid);
1907 gtk_widget_hide(mainwin->window);
1908 main_window_set_widgets(mainwin, layout_mode);
1909 gtk_widget_show(mainwin->window);
1911 gtk_widget_unref(folder_wid);
1912 gtk_widget_unref(summary_wid);
1913 gtk_widget_unref(message_wid);
1916 static void mainwin_reset_paned(GtkPaned *paned)
1919 g_object_get (G_OBJECT(paned),
1922 g_object_get (G_OBJECT(paned),
1927 gtk_paned_set_position(GTK_PANED(paned), mid);
1930 void main_window_toggle_message_view(MainWindow *mainwin)
1932 SummaryView *summaryview = mainwin->summaryview;
1933 GtkWidget *ppaned = NULL;
1934 GtkWidget *container = NULL;
1936 switch (prefs_common.layout_mode) {
1938 case VERTICAL_LAYOUT:
1939 ppaned = mainwin->vpaned;
1940 container = mainwin->hpaned;
1941 if (ppaned->parent != NULL) {
1942 mainwin->messageview->visible = FALSE;
1943 summaryview->displayed = NULL;
1944 gtk_widget_ref(ppaned);
1945 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
1946 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1948 mainwin->messageview->visible = TRUE;
1949 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
1950 gtk_container_add(GTK_CONTAINER(container), ppaned);
1951 gtk_widget_unref(ppaned);
1955 ppaned = mainwin->hpaned;
1956 container = mainwin->vpaned;
1957 if (mainwin->messageview->vbox->parent != NULL) {
1958 mainwin->messageview->visible = FALSE;
1959 summaryview->displayed = NULL;
1960 gtk_widget_ref(mainwin->messageview->vbox);
1961 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
1963 mainwin->messageview->visible = TRUE;
1964 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
1965 gtk_widget_unref(mainwin->messageview->vbox);
1968 case WIDE_MSGLIST_LAYOUT:
1969 g_warning("can't hide messageview in this wide msglist layout");
1973 if (messageview_is_visible(mainwin->messageview))
1974 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1975 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1977 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1978 GTK_ARROW_UP, GTK_SHADOW_OUT);
1980 if (mainwin->messageview->visible == FALSE)
1981 messageview_clear(mainwin->messageview);
1983 main_window_set_menu_sensitive(mainwin);
1985 prefs_common.msgview_visible = mainwin->messageview->visible;
1987 if (messageview_is_visible(mainwin->messageview)) {
1988 gtk_widget_queue_resize(mainwin->hpaned);
1989 gtk_widget_queue_resize(mainwin->vpaned);
1991 summary_grab_focus(summaryview);
1994 void main_window_get_size(MainWindow *mainwin)
1996 GtkAllocation *allocation;
1998 if (mainwin_list == NULL || mainwin->messageview == NULL) {
1999 debug_print("called after messageview "
2000 "has been deallocated!\n");
2004 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2006 if (allocation->width > 1 && allocation->height > 1) {
2007 prefs_common.summaryview_width = allocation->width;
2009 if (messageview_is_visible(mainwin->messageview))
2010 prefs_common.summaryview_height = allocation->height;
2012 prefs_common.mainview_width = allocation->width;
2015 allocation = &mainwin->window->allocation;
2016 if (allocation->width > 1 && allocation->height > 1) {
2017 prefs_common.mainview_height = allocation->height;
2018 prefs_common.mainwin_width = allocation->width;
2019 prefs_common.mainwin_height = allocation->height;
2022 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2023 if (allocation->width > 1 && allocation->height > 1) {
2024 prefs_common.folderview_width = allocation->width;
2025 prefs_common.folderview_height = allocation->height;
2028 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2029 if (allocation->width > 1 && allocation->height > 1) {
2030 prefs_common.msgview_width = allocation->width;
2031 prefs_common.msgview_height = allocation->height;
2034 /* debug_print("summaryview size: %d x %d\n",
2035 prefs_common.summaryview_width,
2036 prefs_common.summaryview_height);
2037 debug_print("folderview size: %d x %d\n",
2038 prefs_common.folderview_width,
2039 prefs_common.folderview_height);
2040 debug_print("messageview size: %d x %d\n",
2041 prefs_common.msgview_width,
2042 prefs_common.msgview_height); */
2045 void main_window_get_position(MainWindow *mainwin)
2049 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2051 prefs_common.mainview_x = x;
2052 prefs_common.mainview_y = y;
2053 prefs_common.mainwin_x = x;
2054 prefs_common.mainwin_y = y;
2056 debug_print("main window position: %d, %d\n", x, y);
2059 void main_window_progress_on(MainWindow *mainwin)
2061 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2064 void main_window_progress_off(MainWindow *mainwin)
2066 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2067 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2070 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2074 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2075 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2076 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2077 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2080 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2082 if (confirm && procmsg_have_trashed_mails_fast()) {
2083 if (alertpanel(_("Empty trash"),
2084 _("Delete all messages in trash folders?"),
2085 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2086 != G_ALERTALTERNATE)
2088 manage_window_focus_in(mainwin->window, NULL, NULL);
2091 procmsg_empty_all_trash();
2093 if (mainwin->summaryview->folder_item &&
2094 mainwin->summaryview->folder_item->stype == F_TRASH)
2095 gtk_widget_grab_focus(mainwin->folderview->ctree);
2098 void main_window_add_mailbox(MainWindow *mainwin)
2103 path = input_dialog(_("Add mailbox"),
2104 _("Input the location of mailbox.\n"
2105 "If the existing mailbox is specified, it will be\n"
2106 "scanned automatically."),
2109 if (folder_find_from_path(path)) {
2110 alertpanel_error(_("The mailbox '%s' already exists."), path);
2114 folder = folder_new(folder_get_class_from_string("mh"),
2115 !strcmp(path, "Mail") ? _("Mailbox") :
2116 g_path_get_basename(path), path);
2119 if (folder->klass->create_tree(folder) < 0) {
2120 alertpanel_error(_("Creation of the mailbox failed.\n"
2121 "Maybe some files already exist, or you don't have the permission to write there."));
2122 folder_destroy(folder);
2127 folder_set_ui_func(folder, scan_tree_func, mainwin);
2128 folder_scan_tree(folder, TRUE);
2129 folder_set_ui_func(folder, NULL, NULL);
2132 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2134 SensitiveCond state = 0;
2135 SummarySelection selection;
2136 FolderItem *item = mainwin->summaryview->folder_item;
2137 GList *account_list = account_get_list();
2139 selection = summary_get_selection_type(mainwin->summaryview);
2141 if (mainwin->lock_count == 0)
2142 state |= M_UNLOCKED;
2143 if (selection != SUMMARY_NONE)
2144 state |= M_MSG_EXIST;
2145 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2147 /* if (item->folder->type != F_NEWS) */
2148 state |= M_ALLOW_DELETE;
2150 if (prefs_common.immediate_exec == 0
2151 && mainwin->lock_count == 0)
2152 state |= M_DELAY_EXEC;
2154 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2155 || selection != SUMMARY_NONE)
2156 state |= M_HIDE_READ_MSG;
2158 if (mainwin->summaryview->threaded)
2159 state |= M_THREADED;
2161 state |= M_UNTHREADED;
2162 if (selection == SUMMARY_SELECTED_SINGLE ||
2163 selection == SUMMARY_SELECTED_MULTIPLE)
2164 state |= M_TARGET_EXIST;
2165 if (selection == SUMMARY_SELECTED_SINGLE)
2166 state |= M_SINGLE_TARGET_EXIST;
2167 if (mainwin->summaryview->folder_item &&
2168 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2171 state |= M_NOT_NEWS;
2172 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2173 state |= M_ACTIONS_EXIST;
2175 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2176 state |= M_HAVE_QUEUED_MAILS;
2178 if (selection == SUMMARY_SELECTED_SINGLE &&
2180 (folder_has_parent_of_type(item, F_DRAFT) ||
2181 folder_has_parent_of_type(item, F_OUTBOX) ||
2182 folder_has_parent_of_type(item, F_QUEUE))))
2183 state |= M_ALLOW_REEDIT;
2185 state |= M_HAVE_ACCOUNT;
2187 if (any_folder_want_synchronise())
2188 state |= M_WANT_SYNC;
2190 for ( ; account_list != NULL; account_list = account_list->next) {
2191 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2192 state |= M_HAVE_NEWS_ACCOUNT;
2197 if (procmsg_spam_can_learn() &&
2198 (mainwin->summaryview->folder_item &&
2199 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2200 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2201 state |= M_CAN_LEARN_SPAM;
2204 if (inc_is_active())
2205 state |= M_INC_ACTIVE;
2207 if (mainwin->summaryview->deleted > 0 ||
2208 mainwin->summaryview->moved > 0 ||
2209 mainwin->summaryview->copied > 0)
2210 state |= M_DELAY_EXEC;
2217 void main_window_set_menu_sensitive(MainWindow *mainwin)
2219 GtkItemFactory *ifactory = mainwin->menu_factory;
2220 SensitiveCond state;
2223 GtkWidget *menuitem;
2224 SummaryView *summaryview;
2229 static const struct {
2233 {"/File/Save as...", M_TARGET_EXIST},
2234 {"/File/Print..." , M_TARGET_EXIST},
2235 {"/File/Synchronise folders", M_WANT_SYNC},
2236 {"/File/Exit" , M_UNLOCKED},
2238 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
2239 {"/Edit/Delete thread" , M_SINGLE_TARGET_EXIST},
2240 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2242 {"/View/Set displayed columns/in Folder list..."
2244 {"/View/Sort" , M_EXEC},
2245 {"/View/Thread view" , M_EXEC},
2246 {"/View/Expand all threads" , M_MSG_EXIST},
2247 {"/View/Collapse all threads" , M_MSG_EXIST},
2248 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2249 {"/View/Go to/Previous message" , M_MSG_EXIST},
2250 {"/View/Go to/Next message" , M_MSG_EXIST},
2251 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2252 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2253 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2254 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2255 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2256 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2257 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2258 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2259 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2260 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2261 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2263 {"/Message/Receive/Get from current account"
2264 , M_HAVE_ACCOUNT|M_UNLOCKED},
2265 {"/Message/Receive/Get from all accounts"
2266 , M_HAVE_ACCOUNT|M_UNLOCKED},
2267 {"/Message/Receive/Cancel receiving"
2269 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2270 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2271 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2272 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2273 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2274 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2275 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2276 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2277 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2278 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2279 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2280 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2281 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2282 {"/Message/Mark" , M_TARGET_EXIST},
2283 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2284 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2285 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2286 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2287 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2288 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2289 {"/Message/Color label" , M_TARGET_EXIST},
2290 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2292 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2293 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2294 {"/Tools/Harvest addresses/from Messages..."
2296 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2297 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2298 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2299 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2300 {"/Tools/List URLs..." , M_TARGET_EXIST},
2301 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2302 {"/Tools/Execute" , M_DELAY_EXEC},
2303 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2305 {"/Configuration", M_UNLOCKED},
2310 state = main_window_get_current_state(mainwin);
2312 for (i = 0; entry[i].entry != NULL; i++) {
2313 sensitive = ((entry[i].cond & state) == entry[i].cond);
2314 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2317 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2319 /* search for separator */
2320 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2321 cur_item = cur_item->next) {
2322 if (GTK_BIN(cur_item->data)->child == NULL) {
2323 cur_item = cur_item->next;
2328 for (; cur_item != NULL; cur_item = cur_item->next) {
2329 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2330 (M_UNLOCKED & state) != 0);
2333 main_window_menu_callback_block(mainwin);
2335 #define SET_CHECK_MENU_ACTIVE(path, active) \
2337 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2338 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2341 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2342 messageview_is_visible(mainwin->messageview));
2344 summaryview = mainwin->summaryview;
2345 menu_path = "/View/Sort/Don't sort";
2347 switch (summaryview->sort_key) {
2348 case SORT_BY_NUMBER:
2349 menu_path = "/View/Sort/by number"; break;
2351 menu_path = "/View/Sort/by Size"; break;
2353 menu_path = "/View/Sort/by Date"; break;
2355 menu_path = "/View/Sort/by From"; break;
2357 menu_path = "/View/Sort/by To"; break;
2358 case SORT_BY_SUBJECT:
2359 menu_path = "/View/Sort/by Subject"; break;
2361 menu_path = "/View/Sort/by color label"; break;
2363 menu_path = "/View/Sort/by mark"; break;
2364 case SORT_BY_STATUS:
2365 menu_path = "/View/Sort/by status"; break;
2367 menu_path = "/View/Sort/by attachment"; break;
2369 menu_path = "/View/Sort/by score"; break;
2370 case SORT_BY_LOCKED:
2371 menu_path = "/View/Sort/by locked"; break;
2374 menu_path = "/View/Sort/Don't sort"; break;
2376 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2378 if (summaryview->sort_type == SORT_ASCENDING) {
2379 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2381 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2384 if (summaryview->sort_key != SORT_BY_NONE) {
2385 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2386 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2388 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2389 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2392 if (mainwin->messageview
2393 && mainwin->messageview->mimeview
2394 && mainwin->messageview->mimeview->textview)
2395 SET_CHECK_MENU_ACTIVE("/View/All headers",
2396 mainwin->messageview->mimeview->textview->show_all_headers);
2397 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2398 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2399 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2400 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2401 if (prefs_common.hide_quotes == 1)
2402 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2403 if (prefs_common.hide_quotes == 2)
2404 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2405 if (prefs_common.hide_quotes == 3)
2406 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2408 #undef SET_CHECK_MENU_ACTIVE
2410 main_window_menu_callback_unblock(mainwin);
2413 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2415 GtkItemFactory *ifactory;
2417 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2420 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2422 gtk_widget_set_sensitive (gtk_item_factory_get_item
2423 (ifactory,"/Message/Mailing-List"), TRUE);
2425 gtk_widget_set_sensitive (gtk_item_factory_get_item
2426 (ifactory,"/Message/Mailing-List"), FALSE);
2429 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2432 GtkWidget *menuitem;
2434 if (!msginfo || !msginfo->extradata) {
2435 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2436 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2437 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2438 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2439 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2440 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2444 /* Mailing list post */
2445 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2446 g_free(msginfo->extradata->list_post);
2447 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2449 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2451 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2453 /* Mailing list help */
2454 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2456 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2458 /* Mailing list subscribe */
2459 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2461 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2463 /* Mailing list unsubscribe */
2464 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2466 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2468 /* Mailing list view archive */
2469 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2471 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2473 /* Mailing list contact owner */
2474 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2476 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2481 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2483 GtkWidget *item, *menu;
2484 const gchar *url_pt ;
2485 gchar url_decoded[BUFFSIZE];
2486 GList *amenu, *alist;
2489 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2491 /* First delete old submenu */
2492 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2493 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2494 alist = amenu->next;
2495 item = GTK_WIDGET (amenu->data);
2496 gtk_widget_destroy (item);
2500 for (url_pt = list_header; url_pt && *url_pt;) {
2501 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2503 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2504 item = gtk_menu_item_new_with_label ((url_decoded));
2505 g_signal_connect(G_OBJECT(item), "activate",
2506 G_CALLBACK(mailing_list_compose),
2509 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2510 !g_strncasecmp (url_decoded, "https:",6)) {
2512 item = gtk_menu_item_new_with_label ((url_decoded));
2513 g_signal_connect(G_OBJECT(item), "activate",
2514 G_CALLBACK(mailing_list_open_uri),
2518 gtk_menu_append (GTK_MENU(menu), item);
2519 gtk_widget_show (item);
2525 gtk_widget_set_sensitive (menuitem, TRUE);
2527 gtk_widget_set_sensitive (menuitem, FALSE);
2533 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2535 gchar tmp[BUFFSIZE];
2539 gboolean with_plus = TRUE;
2542 *url_decoded = '\0';
2546 /* Ignore spaces, comments and tabs () */
2547 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2549 for (;*buf != ')' && *buf != 0x00; buf++);
2551 /* First non space and non comment must be a < */
2554 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2556 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2561 *url_decoded = '\0';
2566 *url_decoded = '\0';
2572 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2574 /* Prepare the work for the next url in the list */
2575 /* after the closing bracket >, ignore space, comments and tabs */
2576 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2578 for (;*buf != ')' && *buf != 0x00; buf++);
2580 if (!buf || !*buf) {
2585 /* now first non space, non comment must be a comma */
2587 for (;*buf != 0x00; buf++);
2593 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2597 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2598 compose_new(NULL, mailto+7, NULL);
2601 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2606 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2607 open_uri (mailto, prefs_common.uri_cmd);
2610 void main_window_popup(MainWindow *mainwin)
2612 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2613 main_window_show(mainwin);
2615 gtkut_window_popup(mainwin->window);
2618 void main_window_show(MainWindow *mainwin)
2620 gtk_widget_show(mainwin->window);
2621 gtk_widget_show(mainwin->vbox_body);
2623 gtk_widget_set_uposition(mainwin->window,
2624 prefs_common.mainwin_x,
2625 prefs_common.mainwin_y);
2627 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2628 prefs_common.folderview_width,
2629 prefs_common.folderview_height);
2630 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2631 prefs_common.summaryview_width,
2632 prefs_common.summaryview_height);
2633 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2634 prefs_common.msgview_width,
2635 prefs_common.msgview_height);
2638 void main_window_hide(MainWindow *mainwin)
2640 main_window_get_size(mainwin);
2641 main_window_get_position(mainwin);
2643 gtk_widget_hide(mainwin->window);
2644 gtk_widget_hide(mainwin->vbox_body);
2647 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2649 GtkWidget *folderwin = NULL;
2650 GtkWidget *messagewin = NULL;
2653 GtkWidget *vbox_body = mainwin->vbox_body;
2654 GtkItemFactory *ifactory = mainwin->menu_factory;
2655 GtkWidget *menuitem;
2657 debug_print("Setting widgets... ");
2659 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2660 prefs_common.folderview_width,
2661 prefs_common.folderview_height);
2662 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2663 prefs_common.summaryview_width,
2664 prefs_common.summaryview_height);
2665 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2666 prefs_common.msgview_width,
2667 prefs_common.msgview_height);
2669 mainwin->messageview->statusbar = mainwin->statusbar;
2670 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2672 /* clean top-most container */
2673 if (mainwin->hpaned) {
2674 if (mainwin->hpaned->parent == mainwin->vpaned)
2675 gtk_widget_destroy(mainwin->vpaned);
2677 gtk_widget_destroy(mainwin->hpaned);
2680 menu_set_sensitive(ifactory, "/View/Show or hide/Message view", (layout_mode != WIDE_MSGLIST_LAYOUT));
2681 switch (layout_mode) {
2682 case VERTICAL_LAYOUT:
2684 hpaned = gtk_hpaned_new();
2685 if (layout_mode == VERTICAL_LAYOUT)
2686 vpaned = gtk_hpaned_new();
2688 vpaned = gtk_vpaned_new();
2689 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2690 gtk_paned_add1(GTK_PANED(hpaned),
2691 GTK_WIDGET_PTR(mainwin->folderview));
2692 gtk_widget_show(hpaned);
2693 gtk_widget_queue_resize(hpaned);
2695 if (messageview_is_visible(mainwin->messageview)) {
2696 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2697 gtk_paned_add1(GTK_PANED(vpaned),
2698 GTK_WIDGET_PTR(mainwin->summaryview));
2700 gtk_paned_add2(GTK_PANED(hpaned),
2701 GTK_WIDGET_PTR(mainwin->summaryview));
2702 gtk_widget_ref(vpaned);
2704 gtk_paned_add2(GTK_PANED(vpaned),
2705 GTK_WIDGET_PTR(mainwin->messageview));
2706 gtk_widget_show(vpaned);
2707 gtk_widget_queue_resize(vpaned);
2710 vpaned = gtk_vpaned_new();
2711 hpaned = gtk_hpaned_new();
2712 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2713 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
2715 gtk_paned_add1(GTK_PANED(hpaned),
2716 GTK_WIDGET_PTR(mainwin->folderview));
2717 gtk_paned_add2(GTK_PANED(hpaned),
2718 GTK_WIDGET_PTR(mainwin->summaryview));
2720 gtk_widget_show(hpaned);
2721 gtk_widget_queue_resize(hpaned);
2723 if (messageview_is_visible(mainwin->messageview)) {
2724 gtk_paned_add2(GTK_PANED(vpaned),
2725 GTK_WIDGET_PTR(mainwin->messageview));
2727 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
2729 gtk_widget_show(vpaned);
2730 gtk_widget_queue_resize(vpaned);
2732 case WIDE_MSGLIST_LAYOUT:
2733 vpaned = gtk_vpaned_new();
2734 hpaned = gtk_hpaned_new();
2735 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2737 gtk_paned_add1(GTK_PANED(vpaned),
2738 GTK_WIDGET_PTR(mainwin->summaryview));
2739 gtk_paned_add1(GTK_PANED(hpaned),
2740 GTK_WIDGET_PTR(mainwin->folderview));
2742 gtk_widget_show(hpaned);
2743 gtk_widget_queue_resize(hpaned);
2745 if (messageview_is_visible(mainwin->messageview)) {
2746 gtk_paned_add2(GTK_PANED(hpaned),
2747 GTK_WIDGET_PTR(mainwin->messageview));
2749 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
2751 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
2753 gtk_widget_show(vpaned);
2754 gtk_widget_queue_resize(vpaned);
2757 g_warning("Unknown layout");
2761 mainwin->hpaned = hpaned;
2762 mainwin->vpaned = vpaned;
2764 /* remove headerview if not in prefs */
2765 headerview_set_visibility(mainwin->messageview->headerview,
2766 prefs_common.display_header_pane);
2768 if (messageview_is_visible(mainwin->messageview))
2769 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2770 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2772 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2773 GTK_ARROW_UP, GTK_SHADOW_OUT);
2775 gtk_window_move(GTK_WINDOW(mainwin->window),
2776 prefs_common.mainwin_x,
2777 prefs_common.mainwin_y);
2779 gtk_widget_queue_resize(vbox_body);
2780 gtk_widget_queue_resize(mainwin->vbox);
2781 gtk_widget_queue_resize(mainwin->window);
2782 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2783 * and mimeview icon list/ctree lose track of their visibility states */
2784 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2785 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2786 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2787 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2788 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2789 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2791 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2793 prefs_common.layout_mode = layout_mode;
2795 menuitem = gtk_item_factory_get_item
2796 (ifactory, "/View/Show or hide/Message view");
2797 gtk_check_menu_item_set_active
2798 (GTK_CHECK_MENU_ITEM(menuitem),
2799 messageview_is_visible(mainwin->messageview));
2801 #define SET_CHECK_MENU_ACTIVE(path, active) \
2803 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2804 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2807 switch (prefs_common.layout_mode) {
2809 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
2811 case VERTICAL_LAYOUT:
2812 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
2815 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
2817 case WIDE_MSGLIST_LAYOUT:
2818 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
2821 #undef SET_CHECK_MENU_ACTIVE
2825 (G_OBJECT(folderwin), "size_allocate",
2826 G_CALLBACK(folder_window_size_allocate_cb),
2831 (G_OBJECT(messagewin), "size_allocate",
2832 G_CALLBACK(message_window_size_allocate_cb),
2836 debug_print("done.\n");
2839 void main_window_destroy_all(void)
2841 while (mainwin_list != NULL) {
2842 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2844 /* free toolbar stuff */
2845 toolbar_clear_list(TOOLBAR_MAIN);
2846 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2847 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2849 mainwin->folderview->mainwin = NULL;
2850 mainwin->summaryview->mainwin = NULL;
2851 mainwin->messageview->mainwin = NULL;
2853 g_free(mainwin->toolbar);
2856 mainwin_list = g_list_remove(mainwin_list, mainwin);
2858 g_list_free(mainwin_list);
2859 mainwin_list = NULL;
2862 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2865 gtk_widget_set_size_request(child, 1, -1);
2868 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2871 gtk_widget_set_size_request(child, -1, -1);
2874 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2877 MainWindow *mainwin = (MainWindow *)data;
2879 if (!event) return FALSE;
2881 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2882 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2885 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2886 menu_button_position, widget,
2887 event->button, event->time);
2892 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2895 MainWindow *mainwin = (MainWindow *)data;
2896 gboolean close_allowed = TRUE;
2898 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
2900 if (close_allowed && mainwin->lock_count == 0)
2901 app_exit_cb(data, 0, widget);
2906 static void main_window_size_allocate_cb(GtkWidget *widget,
2907 GtkAllocation *allocation,
2910 MainWindow *mainwin = (MainWindow *)data;
2912 main_window_get_size(mainwin);
2915 static void folder_window_size_allocate_cb(GtkWidget *widget,
2916 GtkAllocation *allocation,
2919 MainWindow *mainwin = (MainWindow *)data;
2921 main_window_get_size(mainwin);
2924 static void message_window_size_allocate_cb(GtkWidget *widget,
2925 GtkAllocation *allocation,
2928 MainWindow *mainwin = (MainWindow *)data;
2930 main_window_get_size(mainwin);
2933 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2936 main_window_add_mailbox(mainwin);
2939 static void update_folderview_cb(MainWindow *mainwin, guint action,
2942 summary_show(mainwin->summaryview, NULL);
2943 folderview_check_new_all();
2946 static void foldersort_cb(MainWindow *mainwin, guint action,
2952 static void import_mbox_cb(MainWindow *mainwin, guint action,
2955 /* only notify if import has failed */
2956 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
2957 alertpanel_error(_("Mbox import has failed."));
2961 static void export_mbox_cb(MainWindow *mainwin, guint action,
2964 /* only notify if export has failed */
2965 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
2966 alertpanel_error(_("Export to mbox has failed."));
2970 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2973 /* only notify if export has failed */
2974 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
2975 alertpanel_error(_("Export to mbox has failed."));
2979 static void empty_trash_cb(MainWindow *mainwin, guint action,
2982 main_window_empty_trash(mainwin, TRUE);
2985 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2987 summary_save_as(mainwin->summaryview);
2990 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2992 summary_print(mainwin->summaryview);
2995 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2997 if (prefs_common.confirm_on_exit) {
2998 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
2999 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3000 != G_ALERTALTERNATE)
3002 manage_window_focus_in(mainwin->window, NULL, NULL);
3005 app_will_exit(widget, mainwin);
3008 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3011 summary_search(mainwin->summaryview);
3013 message_search(mainwin->messageview);
3016 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3018 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3021 static void toggle_message_cb(MainWindow *mainwin, guint action,
3026 active = GTK_CHECK_MENU_ITEM(widget)->active;
3028 if (active != messageview_is_visible(mainwin->messageview))
3029 summary_toggle_view(mainwin->summaryview);
3032 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3035 toolbar_toggle(action, mainwin);
3038 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3041 MessageView *msgview = (MessageView*)mainwin->messageview;
3042 GSList *msginfo_list = NULL;
3044 g_return_if_fail(msgview != NULL);
3046 msginfo_list = summary_get_selection(mainwin->summaryview);
3047 g_return_if_fail(msginfo_list != NULL);
3048 compose_reply_from_messageview(msgview, msginfo_list, action);
3049 g_slist_free(msginfo_list);
3053 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3056 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3057 gtk_widget_show(mainwin->hbox_stat);
3058 prefs_common.show_statusbar = TRUE;
3060 gtk_widget_hide(mainwin->hbox_stat);
3061 prefs_common.show_statusbar = FALSE;
3065 static void set_layout_cb(MainWindow *mainwin, guint action,
3068 LayoutType layout_mode = action;
3070 if (mainwin->menu_lock_count) {
3073 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3077 if (layout_mode == prefs_common.layout_mode) {
3081 if (!mainwin->messageview->visible)
3082 main_window_toggle_message_view(mainwin);
3084 main_window_separation_change(mainwin, layout_mode);
3086 mainwin_reset_paned(GTK_PANED(mainwin->vpaned));
3087 summary_relayout(mainwin->summaryview);
3090 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3093 offline_ask_sync = ask_sync;
3095 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3097 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3098 offline_ask_sync = TRUE;
3101 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3103 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3106 static gboolean any_folder_want_synchronise(void)
3108 GList *folderlist = folder_get_list();
3110 /* see if there are synchronised folders */
3111 for (; folderlist; folderlist = folderlist->next) {
3112 Folder *folder = (Folder *)folderlist->data;
3113 if (folder_want_synchronise(folder)) {
3121 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3124 if (!any_folder_want_synchronise())
3127 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3128 _("Do you want to synchronise your folders now?"),
3129 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3132 folder_synchronise(NULL);
3135 static void online_switch_clicked (GtkButton *btn, gpointer data)
3137 MainWindow *mainwin;
3138 GtkItemFactory *ifactory;
3139 GtkCheckMenuItem *menuitem;
3141 mainwin = (MainWindow *) data;
3143 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3144 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3146 g_return_if_fail(mainwin != NULL);
3147 g_return_if_fail(menuitem != NULL);
3149 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3150 gtk_widget_hide (mainwin->online_switch);
3151 gtk_widget_show (mainwin->offline_switch);
3152 menuitem->active = TRUE;
3153 inc_autocheck_timer_remove();
3156 if (prefs_common.work_offline)
3158 mainwindow_check_synchronise(mainwin, TRUE);
3159 prefs_common.work_offline = TRUE;
3160 imap_disconnect_all();
3161 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3164 if (!prefs_common.work_offline)
3166 gtk_widget_hide (mainwin->offline_switch);
3167 gtk_widget_show (mainwin->online_switch);
3168 menuitem->active = FALSE;
3169 prefs_common.work_offline = FALSE;
3170 inc_autocheck_timer_set();
3171 refresh_resolvers();
3172 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3176 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3179 addressbook_open(NULL);
3182 static void log_window_show_cb(MainWindow *mainwin, guint action,
3185 log_window_show(mainwin->logwin);
3188 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3191 log_window_show(mainwin->filtering_debugwin);
3194 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3199 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3201 summary_move_to(mainwin->summaryview);
3204 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3206 summary_copy_to(mainwin->summaryview);
3209 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3211 summary_delete(mainwin->summaryview);
3214 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3216 summary_delete_trash(mainwin->summaryview);
3219 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3221 summary_cancel(mainwin->summaryview);
3224 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3226 summary_open_msg(mainwin->summaryview);
3229 static void view_source_cb(MainWindow *mainwin, guint action,
3232 summary_view_source(mainwin->summaryview);
3235 static void show_all_header_cb(MainWindow *mainwin, guint action,
3238 if (mainwin->menu_lock_count) return;
3239 mainwin->summaryview->messageview->all_headers =
3240 GTK_CHECK_MENU_ITEM(widget)->active;
3241 summary_display_msg_selected(mainwin->summaryview,
3242 GTK_CHECK_MENU_ITEM(widget)->active);
3245 #define SET_CHECK_MENU_ACTIVE(path, active) \
3247 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3248 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3251 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3254 GtkWidget *menuitem;
3255 GtkItemFactory *ifactory = mainwin->menu_factory;
3257 if (mainwin->menu_lock_count) return;
3259 prefs_common.hide_quotes =
3260 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3262 mainwin->menu_lock_count++;
3263 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3264 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3265 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3266 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3267 mainwin->menu_lock_count--;
3269 summary_redisplay_msg(mainwin->summaryview);
3272 #undef SET_CHECK_MENU_ACTIVE
3273 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3275 summary_mark(mainwin->summaryview);
3278 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3280 summary_unmark(mainwin->summaryview);
3283 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3286 summary_mark_as_unread(mainwin->summaryview);
3289 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3292 summary_mark_as_read(mainwin->summaryview);
3295 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3298 summary_mark_all_read(mainwin->summaryview);
3301 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3304 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3307 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3310 summary_ignore_thread(mainwin->summaryview);
3313 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3316 summary_unignore_thread(mainwin->summaryview);
3319 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3322 summary_msgs_lock(mainwin->summaryview);
3325 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3328 summary_msgs_unlock(mainwin->summaryview);
3332 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3334 summary_reedit(mainwin->summaryview);
3337 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3339 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3340 summary_display_msg_selected(mainwin->summaryview,
3341 mainwin->messageview->mimeview->textview->show_all_headers);
3343 messageview_list_urls(mainwin->messageview);
3346 static void add_address_cb(MainWindow *mainwin, guint action,
3349 summary_add_address(mainwin->summaryview);
3352 static void set_charset_cb(MainWindow *mainwin, guint action,
3357 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3358 str = conv_get_charset_str((CharSet)action);
3360 g_free(mainwin->messageview->forced_charset);
3361 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3362 procmime_force_charset(str);
3364 summary_redisplay_msg(mainwin->summaryview);
3366 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3370 static void set_decode_cb(MainWindow *mainwin, guint action,
3373 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3374 mainwin->messageview->forced_encoding = (EncodingType)action;
3376 summary_redisplay_msg(mainwin->summaryview);
3378 debug_print("forced encoding: %d\n", action);
3382 static void hide_read_messages (MainWindow *mainwin, guint action,
3385 if (!mainwin->summaryview->folder_item
3386 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3388 summary_toggle_show_read_messages(mainwin->summaryview);
3391 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3393 gboolean threaded = FALSE;
3394 if (mainwin->menu_lock_count) return;
3395 if (!mainwin->summaryview->folder_item) return;
3397 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3399 mainwin->summaryview->folder_item->threaded = threaded;
3401 mainwin->summaryview->threaded = threaded;
3403 summary_show(mainwin->summaryview,
3404 mainwin->summaryview->folder_item);
3407 static void expand_threads_cb(MainWindow *mainwin, guint action,
3410 summary_expand_threads(mainwin->summaryview);
3413 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3416 summary_collapse_threads(mainwin->summaryview);
3419 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3422 prefs_summary_column_open();
3425 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3428 prefs_folder_column_open();
3431 static void sort_summary_cb(MainWindow *mainwin, guint action,
3434 FolderItem *item = mainwin->summaryview->folder_item;
3435 GtkWidget *menuitem;
3437 if (mainwin->menu_lock_count) return;
3439 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3440 menuitem = gtk_item_factory_get_item
3441 (mainwin->menu_factory, "/View/Sort/Ascending");
3442 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3443 GTK_CHECK_MENU_ITEM(menuitem)->active
3444 ? SORT_ASCENDING : SORT_DESCENDING);
3445 item->sort_key = action;
3449 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3452 FolderItem *item = mainwin->summaryview->folder_item;
3454 if (mainwin->menu_lock_count) return;
3456 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3457 summary_sort(mainwin->summaryview,
3458 item->sort_key, (FolderSortType)action);
3461 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3464 summary_attract_by_subject(mainwin->summaryview);
3467 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3472 item = folderview_get_selected_item(mainwin->folderview);
3474 main_window_cursor_wait(mainwin);
3475 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3477 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3478 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3480 STATUSBAR_POP(mainwin);
3481 main_window_cursor_normal(mainwin);
3491 static void deldup_all(FolderItem *item, gpointer _data)
3493 struct DelDupsData *data = _data;
3496 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3498 data->dups += result;
3503 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3506 struct DelDupsData data = {0, 0};
3508 main_window_cursor_wait(mainwin);
3509 folder_func_to_all_folders(deldup_all, &data);
3510 main_window_cursor_normal(mainwin);
3512 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3513 "Deleted %d duplicate messages in %d folders.\n",
3515 data.dups, data.folders);
3518 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3520 summary_filter(mainwin->summaryview, (gboolean)action);
3523 static void execute_summary_cb(MainWindow *mainwin, guint action,
3526 summary_execute(mainwin->summaryview);
3529 static void update_summary_cb(MainWindow *mainwin, guint action,
3533 FolderView *folderview = mainwin->folderview;
3535 if (!mainwin->summaryview->folder_item) return;
3536 if (!folderview->opened) return;
3538 folder_update_op_count();
3540 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3541 folderview->opened);
3544 folder_item_scan(fitem);
3545 summary_show(mainwin->summaryview, fitem);
3548 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3550 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3553 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3555 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3558 static void prev_unread_cb(MainWindow *mainwin, guint action,
3561 summary_select_prev_unread(mainwin->summaryview);
3564 static void next_unread_cb(MainWindow *mainwin, guint action,
3567 summary_select_next_unread(mainwin->summaryview);
3570 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3572 summary_select_prev_new(mainwin->summaryview);
3575 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3577 summary_select_next_new(mainwin->summaryview);
3580 static void prev_marked_cb(MainWindow *mainwin, guint action,
3583 summary_select_prev_marked(mainwin->summaryview);
3586 static void next_marked_cb(MainWindow *mainwin, guint action,
3589 summary_select_next_marked(mainwin->summaryview);
3592 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3595 summary_select_prev_labeled(mainwin->summaryview);
3598 static void next_labeled_cb(MainWindow *mainwin, guint action,
3601 summary_select_next_labeled(mainwin->summaryview);
3604 static void last_read_cb(MainWindow *mainwin, guint action,
3607 summary_select_last_read(mainwin->summaryview);
3610 static void parent_cb(MainWindow *mainwin, guint action,
3613 summary_select_parent(mainwin->summaryview);
3616 static void goto_folder_cb(MainWindow *mainwin, guint action,
3619 FolderItem *to_folder;
3621 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3624 folderview_select(mainwin->folderview, to_folder);
3627 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3630 folderview_select_next_unread(mainwin->folderview, FALSE);
3633 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3635 messageview_copy_clipboard(mainwin->messageview);
3638 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3640 MessageView *msgview = mainwin->messageview;
3642 if (messageview_is_visible(msgview) &&
3643 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3644 messageview_select_all(mainwin->messageview);
3646 summary_select_all(mainwin->summaryview);
3649 static void select_thread_cb(MainWindow *mainwin, guint action,
3652 summary_select_thread(mainwin->summaryview, FALSE);
3655 static void delete_thread_cb(MainWindow *mainwin, guint action,
3658 summary_select_thread(mainwin->summaryview, TRUE);
3661 static void create_filter_cb(MainWindow *mainwin, guint action,
3664 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3667 static void create_processing_cb(MainWindow *mainwin, guint action,
3670 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3673 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3676 prefs_filtering_open(&pre_global_processing,
3677 _("Processing rules to apply before folder rules"),
3678 MANUAL_ANCHOR_PROCESSING,
3682 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3685 prefs_filtering_open(&post_global_processing,
3686 _("Processing rules to apply after folder rules"),
3687 MANUAL_ANCHOR_PROCESSING,
3691 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3694 prefs_filtering_open(&filtering_rules,
3695 _("Filtering configuration"),
3696 MANUAL_ANCHOR_FILTERING,
3700 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3703 prefs_template_open();
3706 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3709 prefs_actions_open(mainwin);
3712 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3715 ssl_manager_open(mainwin);
3718 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3722 new_account_cb(mainwin, 0, widget);
3724 account_open(cur_account);
3728 static void new_account_cb(MainWindow *mainwin, guint action,
3731 account_edit_open();
3732 if (!compose_get_compose_list()) account_add();
3735 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3737 FolderItem *item = NULL;
3738 cur_account = (PrefsAccount *)data;
3740 if (!mainwindow_get_mainwindow())
3742 main_window_show_cur_account(mainwindow_get_mainwindow());
3743 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3744 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3745 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3746 item = folderview_get_selected_item(
3747 mainwindow_get_mainwindow()->folderview);
3749 toolbar_set_compose_button
3750 (mainwindow_get_mainwindow()->toolbar,
3751 FOLDER_TYPE(item->folder) == F_NEWS ?
3752 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3756 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3758 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3759 PrefsAccount *account = (PrefsAccount *)data;
3761 inc_account_mail(mainwin, account);
3764 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3766 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3767 PrefsAccount *account = (PrefsAccount *)data;
3768 FolderItem *item = mainwin->summaryview->folder_item;
3770 compose_new_with_folderitem(account, item, NULL);
3773 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3778 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3780 pluginwindow_create();
3783 static void manual_open_cb(MainWindow *mainwin, guint action,
3786 manual_open((ManualType)action, NULL);
3789 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3794 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3796 MainWindow *mainwin = (MainWindow *)data;
3800 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3801 LOCAL_FOLDER(folder)->rootpath,
3805 str = g_strdup_printf(_("Scanning folder %s ..."),
3806 LOCAL_FOLDER(folder)->rootpath);
3808 STATUSBAR_PUSH(mainwin, str);
3809 STATUSBAR_POP(mainwin);
3813 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3816 SummaryView *summary;
3818 g_return_val_if_fail(data, FALSE);
3819 if (!g_list_find(mainwin_list, data))
3821 summary = ((MainWindow *)data)->summaryview;
3822 g_return_val_if_fail(summary, FALSE);
3824 if (GTK_CLIST(summary->ctree)->selection &&
3825 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3831 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
3834 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
3838 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
3841 if (!claws_is_starting()
3842 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
3843 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
3845 if (iconified_count > 0)
3846 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
3849 if (state->new_window_state == 0)
3850 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
3854 gboolean mainwindow_is_obscured(void)
3859 #define BREAK_ON_MODIFIER_KEY() \
3860 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3862 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3865 MainWindow *mainwin = (MainWindow*) data;
3867 if (!mainwin || !event)
3870 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3872 lastkey = event->keyval;
3876 switch (event->keyval) {
3877 case GDK_Q: /* Quit */
3878 BREAK_ON_MODIFIER_KEY();
3880 app_exit_cb(mainwin, 0, NULL);
3883 if (mainwin->folderview && mainwin->summaryview
3884 && ((!mainwin->summaryview->displayed
3885 && !mainwin->summaryview->selected)
3886 || (mainwin->summaryview->folder_item
3887 && mainwin->summaryview->folder_item->total_msgs == 0))) {
3888 g_signal_stop_emission_by_name(G_OBJECT(widget),
3890 folderview_select_next_unread(mainwin->folderview, TRUE);
3899 #undef BREAK_ON_MODIFIER_KEY
3902 * Harvest addresses for selected folder.
3904 static void addr_harvest_cb( MainWindow *mainwin,
3908 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3912 * Harvest addresses for selected messages in summary view.
3914 static void addr_harvest_msg_cb( MainWindow *mainwin,
3918 summary_harvest_address( mainwin->summaryview );
3922 *\brief get a MainWindow
3924 *\return MainWindow * The first mainwindow in the mainwin_list
3926 MainWindow *mainwindow_get_mainwindow(void)
3928 if (mainwin_list && mainwin_list->data)
3929 return (MainWindow *)(mainwin_list->data);
3934 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3936 ProgressData *data = (ProgressData *) source;
3937 MainWindow *mainwin = (MainWindow *) userdata;
3939 switch (data->cmd) {
3940 case PROGRESS_COMMAND_START:
3941 case PROGRESS_COMMAND_STOP:
3942 gtk_progress_bar_set_fraction
3943 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3945 case PROGRESS_COMMAND_SET_PERCENTAGE:
3946 gtk_progress_bar_set_fraction
3947 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3950 while (gtk_events_pending()) gtk_main_iteration ();
3955 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3957 mainwindow_check_synchronise(mainwin, FALSE);
3960 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
3962 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
3965 void mainwindow_jump_to(const gchar *target)
3969 FolderItem *item = NULL;
3971 MainWindow *mainwin = mainwindow_get_mainwindow();
3977 printf("not initialized\n");
3981 tmp = g_strdup(target);
3983 if ((p = strstr(tmp, "\r")) != NULL)
3985 if ((p = strstr(tmp, "\n")) != NULL)
3988 if ((item = folder_find_item_from_identifier(tmp))) {
3989 printf("selecting folder '%s'\n", tmp);
3990 folderview_select(mainwin->folderview, item);
3991 main_window_popup(mainwin);
3996 msg = strrchr(tmp, G_DIR_SEPARATOR);
3999 if ((item = folder_find_item_from_identifier(tmp))) {
4000 printf("selecting folder '%s'\n", tmp);
4001 folderview_select(mainwin->folderview, item);
4003 printf("'%s' not found\n", tmp);
4005 if (item && msg && atoi(msg)) {
4006 printf("selecting message %d\n", atoi(msg));
4007 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4008 summary_display_msg_selected(mainwin->summaryview, FALSE);
4009 main_window_popup(mainwin);
4012 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4013 MsgInfo *msginfo = NULL;
4015 msg[strlen(msg)-1] = '\0';
4016 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4018 printf("selecting message %s\n", msg);
4019 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4020 summary_display_msg_selected(mainwin->summaryview, FALSE);
4021 main_window_popup(mainwin);
4023 procmsg_msginfo_free(msginfo);
4026 printf("'%s' not found\n", msg);
4029 printf("'%s' not found\n", msg);
4032 printf("'%s' not found\n", tmp);