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 void main_window_menu_callback_block (MainWindow *mainwin);
110 static void main_window_menu_callback_unblock (MainWindow *mainwin);
112 static void main_window_show_cur_account (MainWindow *mainwin);
114 static void main_window_set_widgets (MainWindow *mainwin,
117 static void toolbar_child_attached (GtkWidget *widget,
120 static void toolbar_child_detached (GtkWidget *widget,
124 static gboolean ac_label_button_pressed (GtkWidget *widget,
125 GdkEventButton *event,
128 static gint main_window_close_cb (GtkWidget *widget,
131 static gint folder_window_close_cb (GtkWidget *widget,
134 static gint message_window_close_cb (GtkWidget *widget,
138 static void main_window_size_allocate_cb (GtkWidget *widget,
139 GtkAllocation *allocation,
141 static void folder_window_size_allocate_cb (GtkWidget *widget,
142 GtkAllocation *allocation,
144 static void message_window_size_allocate_cb (GtkWidget *widget,
145 GtkAllocation *allocation,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void foldersort_cb (MainWindow *mainwin,
157 static void import_mbox_cb (MainWindow *mainwin,
160 static void export_mbox_cb (MainWindow *mainwin,
163 static void export_list_mbox_cb (MainWindow *mainwin,
166 static void empty_trash_cb (MainWindow *mainwin,
170 static void save_as_cb (MainWindow *mainwin,
173 static void print_cb (MainWindow *mainwin,
176 static void app_exit_cb (MainWindow *mainwin,
180 static void search_cb (MainWindow *mainwin,
184 static void toggle_folder_cb (MainWindow *mainwin,
187 static void toggle_message_cb (MainWindow *mainwin,
190 static void toggle_toolbar_cb (MainWindow *mainwin,
193 static void toggle_statusbar_cb (MainWindow *mainwin,
196 static void separate_widget_cb (MainWindow *mainwin,
200 static void addressbook_open_cb (MainWindow *mainwin,
203 static void log_window_show_cb (MainWindow *mainwin,
207 static void inc_cancel_cb (MainWindow *mainwin,
211 static void open_msg_cb (MainWindow *mainwin,
215 static void view_source_cb (MainWindow *mainwin,
219 static void show_all_header_cb (MainWindow *mainwin,
223 static void hide_quotes_cb(MainWindow *mainwin,
227 static void move_to_cb (MainWindow *mainwin,
230 static void copy_to_cb (MainWindow *mainwin,
233 static void delete_cb (MainWindow *mainwin,
236 static void delete_trash_cb (MainWindow *mainwin,
240 static void cancel_cb (MainWindow *mainwin,
244 static void mark_cb (MainWindow *mainwin,
247 static void unmark_cb (MainWindow *mainwin,
251 static void mark_as_unread_cb (MainWindow *mainwin,
254 static void mark_as_read_cb (MainWindow *mainwin,
257 static void mark_all_read_cb (MainWindow *mainwin,
260 static void mark_as_spam_cb (MainWindow *mainwin,
264 static void ignore_thread_cb (MainWindow *mainwin,
267 static void unignore_thread_cb (MainWindow *mainwin,
270 static void lock_msgs_cb (MainWindow *mainwin,
273 static void unlock_msgs_cb (MainWindow *mainwin,
277 static void reedit_cb (MainWindow *mainwin,
281 static void add_address_cb (MainWindow *mainwin,
285 static void set_charset_cb (MainWindow *mainwin,
289 static void set_decode_cb (MainWindow *mainwin,
293 static void hide_read_messages (MainWindow *mainwin,
297 static void thread_cb (MainWindow *mainwin,
300 static void expand_threads_cb (MainWindow *mainwin,
303 static void collapse_threads_cb (MainWindow *mainwin,
307 static void set_summary_display_item_cb (MainWindow *mainwin,
310 static void set_folder_display_item_cb (MainWindow *mainwin,
313 static void sort_summary_cb (MainWindow *mainwin,
316 static void sort_summary_type_cb (MainWindow *mainwin,
319 static void attract_by_subject_cb(MainWindow *mainwin,
323 static void delete_duplicated_cb (MainWindow *mainwin,
326 static void delete_duplicated_all_cb (MainWindow *mainwin,
329 static void filter_cb (MainWindow *mainwin,
332 static void execute_summary_cb (MainWindow *mainwin,
335 static void update_summary_cb (MainWindow *mainwin,
339 static void prev_cb (MainWindow *mainwin,
342 static void next_cb (MainWindow *mainwin,
345 static void next_unread_cb (MainWindow *mainwin,
348 static void prev_unread_cb (MainWindow *mainwin,
352 static void prev_new_cb (MainWindow *mainwin,
355 static void next_new_cb (MainWindow *mainwin,
358 static void prev_marked_cb (MainWindow *mainwin,
361 static void next_marked_cb (MainWindow *mainwin,
364 static void prev_labeled_cb (MainWindow *mainwin,
367 static void next_labeled_cb (MainWindow *mainwin,
370 static void last_read_cb (MainWindow *mainwin,
373 static void parent_cb (MainWindow *mainwin,
377 static void goto_folder_cb (MainWindow *mainwin,
380 static void goto_unread_folder_cb(MainWindow *mainwin,
384 static void copy_cb (MainWindow *mainwin,
387 static void allsel_cb (MainWindow *mainwin,
390 static void select_thread_cb (MainWindow *mainwin,
393 static void delete_thread_cb (MainWindow *mainwin,
397 static void create_filter_cb (MainWindow *mainwin,
400 static void create_processing_cb (MainWindow *mainwin,
404 static void prefs_template_open_cb (MainWindow *mainwin,
407 static void prefs_actions_open_cb (MainWindow *mainwin,
410 static void prefs_account_open_cb (MainWindow *mainwin,
414 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
418 static void prefs_post_processing_open_cb (MainWindow *mainwin,
422 static void prefs_filtering_open_cb (MainWindow *mainwin,
426 static void ssl_manager_open_cb (MainWindow *mainwin,
430 static void new_account_cb (MainWindow *mainwin,
434 static void account_selector_menu_cb (GtkMenuItem *menuitem,
436 static void account_receive_menu_cb (GtkMenuItem *menuitem,
438 static void account_compose_menu_cb (GtkMenuItem *menuitem,
441 static void prefs_open_cb (GtkMenuItem *menuitem,
443 static void plugins_open_cb (GtkMenuItem *menuitem,
446 static void online_switch_clicked(GtkButton *btn,
449 static void manual_open_cb (MainWindow *mainwin,
453 static void legend_open_cb (GtkMenuItem *menuitem,
456 static void scan_tree_func (Folder *folder,
460 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
462 static void addr_harvest_cb ( MainWindow *mainwin,
466 static void addr_harvest_msg_cb ( MainWindow *mainwin,
469 static void sync_cb ( MainWindow *mainwin,
473 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
474 GdkEventFocus *focus,
476 void main_window_reply_cb (MainWindow *mainwin,
479 gboolean mainwindow_progressindicator_hook (gpointer source,
482 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
485 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
487 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
489 static void mailing_list_compose(GtkWidget *w, gpointer *data);
491 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
492 #define SEPARATE_ACTION 500
493 static void mainwindow_quicksearch (MainWindow *mainwin,
496 static gboolean any_folder_want_synchronise(void);
498 static GtkItemFactoryEntry mainwin_entries[] =
500 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
501 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
502 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
503 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
505 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
506 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
507 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
508 {N_("/_File/Exp_ort selected to mbox file..."),
509 NULL, export_list_mbox_cb, 0, NULL},
510 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
512 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
514 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
515 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
517 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
518 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
519 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
520 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
522 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
523 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
524 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
525 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
526 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
527 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_Edit/_Find in current message..."),
529 "<control>F", search_cb, 0, NULL},
530 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
531 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
532 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
533 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
534 {N_("/_View/Show or hi_de/_Folder tree"),
535 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
536 {N_("/_View/Show or hi_de/_Message view"),
537 "V", toggle_message_cb, 0, "<ToggleItem>"},
538 {N_("/_View/Show or hi_de/_Toolbar"),
539 NULL, NULL, 0, "<Branch>"},
540 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
541 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
542 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
543 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
544 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
545 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
546 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
547 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
548 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
549 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
550 {N_("/_View/Show or hi_de/Status _bar"),
551 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
552 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
553 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
554 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
556 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
558 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
559 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
561 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
562 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
563 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
564 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
565 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
566 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
567 {N_("/_View/_Sort/by _color label"),
568 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
569 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
570 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
571 {N_("/_View/_Sort/by a_ttachment"),
572 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
573 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
575 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
576 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
577 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
578 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
579 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
580 {N_("/_View/_Sort/_Attract by subject"),
581 NULL, attract_by_subject_cb, 0, NULL},
582 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
583 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
584 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
585 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
587 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
589 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
590 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
591 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_View/_Go to/P_revious unread message"),
593 "<shift>P", prev_unread_cb, 0, NULL},
594 {N_("/_View/_Go to/N_ext unread message"),
595 "<shift>N", next_unread_cb, 0, NULL},
596 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
597 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
598 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
599 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
600 {N_("/_View/_Go to/Previous _marked message"),
601 NULL, prev_marked_cb, 0, NULL},
602 {N_("/_View/_Go to/Next m_arked message"),
603 NULL, next_marked_cb, 0, NULL},
604 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_View/_Go to/Previous _labeled message"),
606 NULL, prev_labeled_cb, 0, NULL},
607 {N_("/_View/_Go to/Next la_beled message"),
608 NULL, next_labeled_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/Last read message"),
611 NULL, last_read_cb, 0, NULL},
612 {N_("/_View/_Go to/Parent message"),
613 "<control>Up", parent_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
616 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
617 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
619 #define ENC_SEPARATOR \
620 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
621 #define ENC_ACTION(action) \
622 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
624 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
625 {N_("/_View/Character _encoding/_Auto detect"),
626 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
627 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
629 ENC_ACTION(C_US_ASCII)},
630 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
631 ENC_ACTION(C_UTF_8)},
634 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
635 ENC_ACTION(C_ISO_8859_1)},
636 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
637 ENC_ACTION(C_ISO_8859_15)},
638 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
639 ENC_ACTION(C_WINDOWS_1252)},
642 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
643 ENC_ACTION(C_ISO_8859_2)},
646 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
647 ENC_ACTION(C_ISO_8859_13)},
648 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
649 ENC_ACTION(C_ISO_8859_4)},
652 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
653 ENC_ACTION(C_ISO_8859_7)},
656 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
657 ENC_ACTION(C_ISO_8859_8)},
658 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
659 ENC_ACTION(C_CP1255)},
662 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
663 ENC_ACTION(C_ISO_8859_6)},
664 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
665 ENC_ACTION(C_CP1256)},
668 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
669 ENC_ACTION(C_ISO_8859_9)},
672 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
673 ENC_ACTION(C_ISO_8859_5)},
674 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
675 ENC_ACTION(C_KOI8_R)},
676 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
677 ENC_ACTION(C_KOI8_U)},
678 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
679 ENC_ACTION(C_CP1251)},
682 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
683 ENC_ACTION(C_ISO_2022_JP)},
684 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
685 ENC_ACTION(C_ISO_2022_JP_2)},
686 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
687 ENC_ACTION(C_EUC_JP)},
688 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
689 ENC_ACTION(C_SHIFT_JIS)},
692 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
693 ENC_ACTION(C_GB2312)},
694 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
696 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
698 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
699 ENC_ACTION(C_EUC_TW)},
700 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
701 ENC_ACTION(C_ISO_2022_CN)},
704 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
705 ENC_ACTION(C_EUC_KR)},
706 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
707 ENC_ACTION(C_ISO_2022_KR)},
710 {N_("/_View/Character _encoding/Thai (TIS-620)"),
711 ENC_ACTION(C_TIS_620)},
712 {N_("/_View/Character _encoding/Thai (Windows-874)"),
713 ENC_ACTION(C_WINDOWS_874)},
718 #define DEC_SEPARATOR \
719 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
720 #define DEC_ACTION(action) \
721 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
722 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
723 {N_("/_View/Decode/_Auto detect"),
724 NULL, set_decode_cb, 0, "<RadioItem>"},
725 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
726 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
727 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
728 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
729 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
734 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
735 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
736 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
737 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
738 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
739 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
740 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
741 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
742 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
743 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
745 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
746 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Message/Recei_ve/Get from _current account"),
748 "<control>I", inc_mail_cb, 0, NULL},
749 {N_("/_Message/Recei_ve/Get from _all accounts"),
750 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
751 {N_("/_Message/Recei_ve/Cancel receivin_g"),
752 NULL, inc_cancel_cb, 0, NULL},
753 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
754 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
755 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
756 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
757 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
758 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
759 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
760 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
761 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
762 {N_("/_Message/Repl_y to/mailing _list"),
763 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
764 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
765 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
766 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
767 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
768 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
770 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
771 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
772 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
773 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
774 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
775 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
776 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
778 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
779 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
780 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
781 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
782 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
783 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
784 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
785 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
786 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
787 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
788 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
789 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
790 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
791 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
792 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
793 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
794 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
795 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
796 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
797 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
798 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
799 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
800 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
801 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
802 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
804 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
805 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
806 {N_("/_Tools/Add sender to address boo_k"),
807 NULL, add_address_cb, 0, NULL},
808 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
809 {N_("/_Tools/_Harvest addresses/from _Folder..."),
810 NULL, addr_harvest_cb, 0, NULL},
811 {N_("/_Tools/_Harvest addresses/from _Messages..."),
812 NULL, addr_harvest_msg_cb, 0, NULL},
813 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
814 {N_("/_Tools/_Filter all messages in folder"),
815 NULL, filter_cb, 0, NULL},
816 {N_("/_Tools/Filter _selected messages"),
817 NULL, filter_cb, 1, NULL},
818 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
819 {N_("/_Tools/_Create filter rule/_Automatically"),
820 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
821 {N_("/_Tools/_Create filter rule/by _From"),
822 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
823 {N_("/_Tools/_Create filter rule/by _To"),
824 NULL, create_filter_cb, FILTER_BY_TO, NULL},
825 {N_("/_Tools/_Create filter rule/by _Subject"),
826 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
827 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
828 {N_("/_Tools/C_reate processing rule/_Automatically"),
829 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
830 {N_("/_Tools/C_reate processing rule/by _From"),
831 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
832 {N_("/_Tools/C_reate processing rule/by _To"),
833 NULL, create_processing_cb, FILTER_BY_TO, NULL},
834 {N_("/_Tools/C_reate processing rule/by _Subject"),
835 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
836 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
837 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
838 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
839 {N_("/_Tools/Ch_eck for new messages in all folders"),
840 NULL, update_folderview_cb, 0, NULL},
841 {N_("/_Tools/Delete du_plicated messages"),
842 NULL, NULL, 0, "<Branch>"},
843 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
844 NULL, delete_duplicated_cb, 0, NULL},
845 {N_("/_Tools/Delete du_plicated messages/In all folders"),
846 NULL, delete_duplicated_all_cb, 0, NULL},
847 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
848 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
850 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
851 {N_("/_Tools/SSL cer_tificates..."),
852 NULL, ssl_manager_open_cb, 0, NULL},
854 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
855 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
857 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
858 {N_("/_Configuration/C_hange current account"),
859 NULL, NULL, 0, "<Branch>"},
860 {N_("/_Configuration/_Preferences for current account..."),
861 NULL, prefs_account_open_cb, 0, NULL},
862 {N_("/_Configuration/Create _new account..."),
863 NULL, new_account_cb, 0, NULL},
864 {N_("/_Configuration/_Edit accounts..."),
865 NULL, account_edit_open, 0, NULL},
866 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
867 {N_("/_Configuration/P_references..."),
868 NULL, prefs_open_cb, 0, NULL},
869 {N_("/_Configuration/Pre-pr_ocessing..."),
870 NULL, prefs_pre_processing_open_cb, 0, NULL},
871 {N_("/_Configuration/Post-pro_cessing..."),
872 NULL, prefs_post_processing_open_cb, 0, NULL},
873 {N_("/_Configuration/_Filtering..."),
874 NULL, prefs_filtering_open_cb, 0, NULL},
875 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
876 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
877 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
879 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
880 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
881 {N_("/_Help/_Online User-contributed FAQ"),
882 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
883 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
884 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
885 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
888 static gboolean offline_ask_sync = TRUE;
889 static guint lastkey;
891 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
897 MainWindow *mainwin = (MainWindow *)user_data;
899 if (mainwin->summaryview &&
900 mainwin->summaryview->quicksearch &&
901 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
902 (mod == 0 || mod == GDK_SHIFT_MASK)) {
903 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
909 #define N_COLOR_LABELS colorlabel_get_color_count()
911 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
916 GtkCheckMenuItem **items;
921 mainwin = (MainWindow *)data;
922 g_return_if_fail(mainwin != NULL);
924 sel = summary_get_selection(mainwin->summaryview);
927 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
928 g_return_if_fail(menu != NULL);
930 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
932 /* NOTE: don't return prematurely because we set the "dont_toggle"
933 * state for check menu items */
934 g_object_set_data(G_OBJECT(menu), "dont_toggle",
937 /* clear items. get item pointers. */
938 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
939 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
940 gtk_check_menu_item_set_active
941 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
942 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
947 if (n == (N_COLOR_LABELS + 1)) {
948 /* iterate all messages and set the state of the appropriate
950 for (; sel != NULL; sel = sel->next) {
954 msginfo = (MsgInfo *)sel->data;
956 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
957 if (!items[clabel]->active)
958 gtk_check_menu_item_set_active
959 (items[clabel], TRUE);
963 g_warning("invalid number of color elements (%d)\n", n);
965 /* reset "dont_toggle" state */
966 g_object_set_data(G_OBJECT(menu), "dont_toggle",
970 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
973 guint color = GPOINTER_TO_UINT(data);
976 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
977 g_return_if_fail(mainwin != NULL);
979 /* "dont_toggle" state set? */
980 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
984 summary_set_colorlabel(mainwin->summaryview, color, NULL);
987 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
989 GtkWidget *label_menuitem;
994 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
995 "/Message/Color label");
996 g_signal_connect(G_OBJECT(label_menuitem), "activate",
997 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
999 gtk_widget_show(label_menuitem);
1001 menu = gtk_menu_new();
1003 /* create sub items. for the menu item activation callback we pass the
1004 * index of label_colors[] as data parameter. for the None color we
1005 * pass an invalid (high) value. also we attach a data pointer so we
1006 * can always get back the Mainwindow pointer. */
1008 item = gtk_check_menu_item_new_with_label(_("None"));
1009 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1010 g_signal_connect(G_OBJECT(item), "activate",
1011 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1012 GUINT_TO_POINTER(0));
1013 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1014 gtk_widget_show(item);
1016 gtk_widget_add_accelerator(item, "activate",
1017 mainwin->menu_factory->accel_group,
1018 GDK_0, GDK_CONTROL_MASK,
1019 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1021 item = gtk_menu_item_new();
1022 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1023 gtk_widget_show(item);
1025 /* create pixmap/label menu items */
1026 for (i = 0; i < N_COLOR_LABELS; i++) {
1027 item = colorlabel_create_check_color_menu_item(
1028 i, refresh, MAINWIN_COLORMENU);
1029 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1030 g_signal_connect(G_OBJECT(item), "activate",
1031 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1032 GUINT_TO_POINTER(i + 1));
1033 g_object_set_data(G_OBJECT(item), "mainwin",
1035 gtk_widget_show(item);
1036 gtk_widget_add_accelerator(item, "activate",
1037 mainwin->menu_factory->accel_group,
1038 GDK_1+i, GDK_CONTROL_MASK,
1039 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1042 gtk_widget_show(menu);
1043 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1044 mainwin->colorlabel_menu = menu;
1047 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1048 MainWindow *mainwindow)
1050 if (evt && evt->button == 1) {
1051 log_window_show_error(mainwindow->logwin);
1052 gtk_widget_hide(mainwindow->warning_btn);
1057 static gboolean warning_visi_notify(GtkWidget *widget,
1058 GdkEventVisibility *event,
1059 MainWindow *mainwindow)
1061 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1065 static gboolean warning_leave_notify(GtkWidget *widget,
1066 GdkEventCrossing *event,
1067 MainWindow *mainwindow)
1069 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1073 static gboolean warning_enter_notify(GtkWidget *widget,
1074 GdkEventCrossing *event,
1075 MainWindow *mainwindow)
1077 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1081 void mainwindow_show_error(void)
1083 MainWindow *mainwin = mainwindow_get_mainwindow();
1084 gtk_widget_show(mainwin->warning_btn);
1087 void mainwindow_clear_error(MainWindow *mainwin)
1089 gtk_widget_hide(mainwin->warning_btn);
1092 MainWindow *main_window_create(SeparateType type)
1094 MainWindow *mainwin;
1098 GtkWidget *handlebox;
1099 GtkWidget *vbox_body;
1100 GtkWidget *hbox_stat;
1101 GtkWidget *statusbar;
1102 GtkWidget *progressbar;
1103 GtkWidget *statuslabel;
1104 GtkWidget *ac_button;
1105 GtkWidget *ac_label;
1106 GtkWidget *online_pixmap;
1107 GtkWidget *offline_pixmap;
1108 GtkWidget *online_switch;
1109 GtkWidget *offline_switch;
1111 GtkWidget *warning_icon;
1112 GtkWidget *warning_btn;
1114 FolderView *folderview;
1115 SummaryView *summaryview;
1116 MessageView *messageview;
1117 GdkColormap *colormap;
1119 gboolean success[4];
1120 GtkItemFactory *ifactory;
1122 GtkWidget *menuitem;
1124 guint n_menu_entries;
1126 static GdkGeometry geometry;
1128 debug_print("Creating main window...\n");
1129 mainwin = g_new0(MainWindow, 1);
1132 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1133 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1134 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1136 if (!geometry.min_height) {
1137 geometry.min_width = 320;
1138 geometry.min_height = 200;
1140 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1143 g_signal_connect(G_OBJECT(window), "delete_event",
1144 G_CALLBACK(main_window_close_cb), mainwin);
1145 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1146 g_signal_connect(G_OBJECT(window), "focus_in_event",
1147 G_CALLBACK(mainwindow_focus_in_event),
1149 g_signal_connect(G_OBJECT(window), "key_press_event",
1150 G_CALLBACK(mainwindow_key_pressed), mainwin);
1152 gtk_widget_realize(window);
1153 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1156 gtkut_widget_set_app_icon(window);
1158 vbox = gtk_vbox_new(FALSE, 0);
1159 gtk_widget_show(vbox);
1160 gtk_container_add(GTK_CONTAINER(window), vbox);
1163 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1164 menubar = menubar_create(window, mainwin_entries,
1165 n_menu_entries, "<Main>", mainwin);
1166 gtk_widget_show(menubar);
1167 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1168 ifactory = gtk_item_factory_from_widget(menubar);
1170 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1171 main_create_mailing_list_menu (mainwin, NULL); */
1173 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1175 if (prefs_common.toolbar_detachable) {
1176 handlebox = gtk_handle_box_new();
1177 gtk_widget_show(handlebox);
1178 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1179 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1180 G_CALLBACK(toolbar_child_attached), mainwin);
1181 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1182 G_CALLBACK(toolbar_child_detached), mainwin);
1184 handlebox = gtk_hbox_new(FALSE, 0);
1185 gtk_widget_show(handlebox);
1186 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1188 /* link window to mainwin->window to avoid gdk warnings */
1189 mainwin->window = window;
1191 /* create toolbar */
1192 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1195 toolbar_set_learn_button
1199 /* vbox that contains body */
1200 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1201 gtk_widget_show(vbox_body);
1202 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1203 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1205 hbox_stat = gtk_hbox_new(FALSE, 2);
1206 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1208 tips = gtk_tooltips_new();
1210 warning_icon = gtk_image_new_from_stock
1211 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1212 warning_btn = gtk_event_box_new();
1213 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1215 mainwin->warning_btn = warning_btn;
1217 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1218 G_CALLBACK(warning_icon_pressed),
1219 (gpointer) mainwin);
1220 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1221 G_CALLBACK(warning_visi_notify), mainwin);
1222 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1223 G_CALLBACK(warning_visi_notify), mainwin);
1224 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1225 G_CALLBACK(warning_leave_notify), mainwin);
1226 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1227 G_CALLBACK(warning_enter_notify), mainwin);
1229 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1231 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1232 _("Some error(s) happened. Click here to view log."), NULL);
1233 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1235 statusbar = statusbar_create();
1236 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1238 progressbar = gtk_progress_bar_new();
1239 gtk_widget_set_size_request(progressbar, 120, 1);
1240 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1242 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1243 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1244 online_switch = gtk_button_new ();
1245 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1246 _("You are online. Click the icon to go offline"), NULL);
1247 offline_switch = gtk_button_new ();
1248 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1249 _("You are offline. Click the icon to go online"),
1251 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1252 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1253 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1254 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1255 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1256 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1257 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1258 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1260 statuslabel = gtk_label_new("");
1261 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1263 ac_button = gtk_button_new();
1264 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1265 ac_button, _("Select account"), NULL);
1266 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1267 gtk_widget_set_size_request(ac_button, -1, 0);
1268 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1269 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1270 G_CALLBACK(ac_label_button_pressed), mainwin);
1272 ac_label = gtk_label_new("");
1273 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1275 gtk_widget_show_all(hbox_stat);
1277 gtk_widget_hide(offline_switch);
1278 gtk_widget_hide(warning_btn);
1280 mainwin->folderview = folderview = folderview_create();
1281 mainwin->summaryview = summaryview = summary_create();
1282 mainwin->messageview = messageview = messageview_create(mainwin);
1283 mainwin->logwin = log_window_create();
1285 log_window_init(mainwin->logwin);
1286 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1287 prefs_common.loglength);
1289 folderview->mainwin = mainwin;
1290 folderview->summaryview = summaryview;
1292 summaryview->mainwin = mainwin;
1293 summaryview->folderview = folderview;
1294 summaryview->messageview = messageview;
1295 summaryview->window = window;
1297 messageview->statusbar = statusbar;
1298 mainwin->vbox = vbox;
1299 mainwin->menubar = menubar;
1300 mainwin->menu_factory = ifactory;
1301 mainwin->handlebox = handlebox;
1302 mainwin->vbox_body = vbox_body;
1303 mainwin->hbox_stat = hbox_stat;
1304 mainwin->statusbar = statusbar;
1305 mainwin->progressbar = progressbar;
1306 mainwin->statuslabel = statuslabel;
1307 mainwin->online_switch = online_switch;
1308 mainwin->online_pixmap = online_pixmap;
1309 mainwin->offline_pixmap = offline_pixmap;
1310 mainwin->ac_button = ac_button;
1311 mainwin->ac_label = ac_label;
1312 mainwin->offline_switch = offline_switch;
1314 /* set context IDs for status bar */
1315 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1316 (GTK_STATUSBAR(statusbar), "Main Window");
1317 mainwin->folderview_cid = gtk_statusbar_get_context_id
1318 (GTK_STATUSBAR(statusbar), "Folder View");
1319 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1320 (GTK_STATUSBAR(statusbar), "Summary View");
1321 mainwin->messageview_cid = gtk_statusbar_get_context_id
1322 (GTK_STATUSBAR(statusbar), "Message View");
1324 messageview->statusbar_cid = mainwin->messageview_cid;
1326 /* allocate colors for summary view and folder view */
1327 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1328 summaryview->color_marked.blue = (guint16)65535;
1330 summaryview->color_dim.red = summaryview->color_dim.green =
1331 summaryview->color_dim.blue = COLOR_DIM;
1333 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1334 &folderview->color_new);
1336 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1337 &folderview->color_op);
1339 summaryview->color_important.red = 0;
1340 summaryview->color_important.green = 0;
1341 summaryview->color_important.blue = (guint16)65535;
1343 color[0] = summaryview->color_marked;
1344 color[1] = summaryview->color_dim;
1345 color[2] = folderview->color_new;
1346 color[3] = folderview->color_op;
1348 colormap = gdk_drawable_get_colormap(window->window);
1349 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1350 for (i = 0; i < 4; i++) {
1351 if (success[i] == FALSE)
1352 g_warning("MainWindow: color allocation %d failed\n", i);
1355 debug_print("done.\n");
1357 messageview->visible = prefs_common.msgview_visible;
1359 main_window_set_widgets(mainwin, type);
1361 g_signal_connect(G_OBJECT(window), "size_allocate",
1362 G_CALLBACK(main_window_size_allocate_cb),
1365 /* set menu items */
1366 menuitem = gtk_item_factory_get_item
1367 (ifactory, "/View/Character encoding/Auto detect");
1368 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1370 switch (prefs_common.toolbar_style) {
1372 menuitem = gtk_item_factory_get_item
1373 (ifactory, "/View/Show or hide/Toolbar/Hide");
1376 menuitem = gtk_item_factory_get_item
1377 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1380 menuitem = gtk_item_factory_get_item
1381 (ifactory, "/View/Show or hide/Toolbar/Text only");
1384 menuitem = gtk_item_factory_get_item
1385 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1387 case TOOLBAR_BOTH_HORIZ:
1388 menuitem = gtk_item_factory_get_item
1390 "/View/Show or hide/Toolbar/Text beside icons");
1392 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1394 gtk_widget_hide(mainwin->hbox_stat);
1395 menuitem = gtk_item_factory_get_item
1396 (ifactory, "/View/Show or hide/Status bar");
1397 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1398 prefs_common.show_statusbar);
1400 /* set account selection menu */
1401 ac_menu = gtk_item_factory_get_widget
1402 (ifactory, "/Configuration/Change current account");
1403 mainwin->ac_menu = ac_menu;
1405 toolbar_main_set_sensitive(mainwin);
1407 /* create actions menu */
1408 main_window_update_actions_menu(mainwin);
1410 main_create_mailing_list_menu (mainwin, NULL);
1412 /* attach accel groups to main window */
1413 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1414 gtk_window_add_accel_group \
1416 gtk_item_factory_from_widget(menu)->accel_group); \
1417 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1419 G_CALLBACK(main_window_accel_activate), mainwin);
1422 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1424 /* connect the accelerators for equivalent
1425 menu items in different menus */
1426 menu_connect_identical_items();
1429 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1431 gtk_widget_show(mainwin->window);
1433 /* initialize views */
1434 folderview_init(folderview);
1435 summary_init(summaryview);
1436 messageview_init(messageview);
1438 sslcertwindow_register_hook();
1440 mainwin->lock_count = 0;
1441 mainwin->menu_lock_count = 0;
1442 mainwin->cursor_count = 0;
1444 mainwin->progressindicator_hook =
1445 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1448 watch_cursor = gdk_cursor_new(GDK_WATCH);
1450 hand_cursor = gdk_cursor_new(GDK_HAND2);
1452 mainwin_list = g_list_append(mainwin_list, mainwin);
1454 /* init work_offline */
1455 if (prefs_common.work_offline)
1456 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1458 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1463 void main_window_destroy(MainWindow *mainwin)
1465 /* TODO : destroy other component */
1466 messageview_destroy(mainwin->messageview);
1467 mainwin->messageview = NULL;
1470 void main_window_update_actions_menu(MainWindow *mainwin)
1472 GtkItemFactory *ifactory;
1474 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1475 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1478 void main_window_cursor_wait(MainWindow *mainwin)
1481 if (mainwin->cursor_count == 0) {
1482 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1483 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1486 mainwin->cursor_count++;
1491 void main_window_cursor_normal(MainWindow *mainwin)
1493 if (mainwin->cursor_count)
1494 mainwin->cursor_count--;
1496 if (mainwin->cursor_count == 0) {
1497 gdk_window_set_cursor(mainwin->window->window, NULL);
1498 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1503 /* lock / unlock the user-interface */
1504 void main_window_lock(MainWindow *mainwin)
1506 if (mainwin->lock_count == 0)
1507 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1509 mainwin->lock_count++;
1511 main_window_set_menu_sensitive(mainwin);
1512 toolbar_main_set_sensitive(mainwin);
1515 void main_window_unlock(MainWindow *mainwin)
1517 if (mainwin->lock_count)
1518 mainwin->lock_count--;
1520 main_window_set_menu_sensitive(mainwin);
1521 toolbar_main_set_sensitive(mainwin);
1523 if (mainwin->lock_count == 0)
1524 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1527 static void main_window_menu_callback_block(MainWindow *mainwin)
1529 mainwin->menu_lock_count++;
1532 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1534 if (mainwin->menu_lock_count)
1535 mainwin->menu_lock_count--;
1538 static guint prefs_tag = 0;
1540 void main_window_reflect_prefs_all(void)
1542 main_window_reflect_prefs_all_real(FALSE);
1545 static gboolean reflect_prefs_timeout_cb(gpointer data)
1547 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1549 MainWindow *mainwin;
1552 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1553 mainwin = (MainWindow *)cur->data;
1555 main_window_show_cur_account(mainwin);
1556 main_window_set_menu_sensitive(mainwin);
1557 toolbar_main_set_sensitive(mainwin);
1560 if (pixmap_theme_changed) {
1561 toolbar_update(TOOLBAR_MAIN, mainwin);
1562 messageview_reflect_prefs_pixmap_theme();
1563 compose_reflect_prefs_pixmap_theme();
1564 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1565 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1567 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1568 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1569 mainwin->online_pixmap);
1570 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1571 gtk_widget_show(pixmap);
1572 mainwin->online_pixmap = pixmap;
1573 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1574 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1575 mainwin->offline_pixmap);
1576 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1577 gtk_widget_show(pixmap);
1578 mainwin->offline_pixmap = pixmap;
1581 headerview_set_font(mainwin->messageview->headerview);
1582 headerview_set_visibility(mainwin->messageview->headerview,
1583 prefs_common.display_header_pane);
1584 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1585 folderview_reflect_prefs();
1586 summary_reflect_prefs();
1587 summary_redisplay_msg(mainwin->summaryview);
1593 void main_window_reflect_prefs_all_now(void)
1595 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1598 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1603 /* re-create colorlabel submenu */
1604 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1605 g_return_if_fail(menu != NULL);
1607 /* clear items. get item pointers. */
1608 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1609 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1611 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1612 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1616 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1618 if (prefs_tag == 0 || pixmap_theme_changed) {
1619 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1620 GINT_TO_POINTER(pixmap_theme_changed));
1624 void main_window_set_summary_column(void)
1627 MainWindow *mainwin;
1629 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1630 mainwin = (MainWindow *)cur->data;
1631 summary_set_column_order(mainwin->summaryview);
1635 void main_window_set_folder_column(void)
1638 MainWindow *mainwin;
1640 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1641 mainwin = (MainWindow *)cur->data;
1642 folderview_set_column_order(mainwin->folderview);
1646 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1647 GList *account_list)
1649 GList *cur_ac, *cur_item;
1650 GtkWidget *menuitem;
1651 PrefsAccount *ac_prefs;
1653 /* destroy all previous menu item */
1654 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1655 while (cur_item != NULL) {
1656 GList *next = cur_item->next;
1657 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1661 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1662 ac_prefs = (PrefsAccount *)cur_ac->data;
1664 menuitem = gtk_menu_item_new_with_label
1665 (ac_prefs->account_name
1666 ? ac_prefs->account_name : _("Untitled"));
1667 gtk_widget_show(menuitem);
1668 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1669 g_signal_connect(G_OBJECT(menuitem), "activate",
1670 G_CALLBACK(account_selector_menu_cb),
1675 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1676 GList *account_list)
1678 GList *cur_ac, *cur_item;
1680 GtkWidget *menuitem;
1681 PrefsAccount *ac_prefs;
1683 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1684 "/Message/Receive");
1686 /* search for separator */
1687 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1688 cur_item = cur_item->next) {
1689 if (GTK_BIN(cur_item->data)->child == NULL) {
1690 cur_item = cur_item->next;
1695 /* destroy all previous menu item */
1696 while (cur_item != NULL) {
1697 GList *next = cur_item->next;
1698 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1702 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1703 ac_prefs = (PrefsAccount *)cur_ac->data;
1705 menuitem = gtk_menu_item_new_with_label
1706 (ac_prefs->account_name ? ac_prefs->account_name
1708 gtk_widget_show(menuitem);
1709 gtk_menu_append(GTK_MENU(menu), menuitem);
1710 g_signal_connect(G_OBJECT(menuitem), "activate",
1711 G_CALLBACK(account_receive_menu_cb),
1716 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1717 GList *account_list)
1719 GList *cur_ac, *cur_item;
1720 GtkWidget *menuitem;
1721 PrefsAccount *ac_prefs;
1722 GtkWidget *menu = NULL;
1724 if (mainwin->toolbar->getall_btn == NULL
1725 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1728 menu = mainwin->toolbar->getall_combo->menu;
1730 /* destroy all previous menu item */
1731 cur_item = GTK_MENU_SHELL(menu)->children;
1732 while (cur_item != NULL) {
1733 GList *next = cur_item->next;
1734 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1738 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1739 ac_prefs = (PrefsAccount *)cur_ac->data;
1741 menuitem = gtk_menu_item_new_with_label
1742 (ac_prefs->account_name
1743 ? ac_prefs->account_name : _("Untitled"));
1744 gtk_widget_show(menuitem);
1745 gtk_menu_append(GTK_MENU(menu), menuitem);
1746 g_signal_connect(G_OBJECT(menuitem), "activate",
1747 G_CALLBACK(account_receive_menu_cb),
1752 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1753 GList *account_list)
1755 GList *cur_ac, *cur_item;
1756 GtkWidget *menuitem;
1757 PrefsAccount *ac_prefs;
1758 GtkWidget *menu = NULL;
1760 if (mainwin->toolbar->compose_mail_btn == NULL
1761 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1764 menu = mainwin->toolbar->compose_combo->menu;
1766 /* destroy all previous menu item */
1767 cur_item = GTK_MENU_SHELL(menu)->children;
1768 while (cur_item != NULL) {
1769 GList *next = cur_item->next;
1770 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1774 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1775 ac_prefs = (PrefsAccount *)cur_ac->data;
1777 menuitem = gtk_menu_item_new_with_label
1778 (ac_prefs->account_name
1779 ? ac_prefs->account_name : _("Untitled"));
1780 gtk_widget_show(menuitem);
1781 gtk_menu_append(GTK_MENU(menu), menuitem);
1782 g_signal_connect(G_OBJECT(menuitem), "activate",
1783 G_CALLBACK(account_compose_menu_cb),
1788 void main_window_set_account_menu(GList *account_list)
1791 MainWindow *mainwin;
1793 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1794 mainwin = (MainWindow *)cur->data;
1795 main_window_set_account_selector_menu(mainwin, account_list);
1796 main_window_set_account_receive_menu(mainwin, account_list);
1797 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1798 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1800 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
1803 void main_window_set_account_menu_only_toolbar(GList *account_list)
1806 MainWindow *mainwin;
1808 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1809 mainwin = (MainWindow *)cur->data;
1810 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1811 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1815 static void main_window_show_cur_account(MainWindow *mainwin)
1820 ac_name = g_strdup(cur_account
1821 ? (cur_account->account_name
1822 ? cur_account->account_name : _("Untitled"))
1826 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1828 buf = g_strdup(PROG_VERSION);
1829 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1832 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1833 gtk_widget_queue_resize(mainwin->ac_button);
1838 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1840 switch (mainwin->type) {
1841 case SEPARATE_FOLDER:
1842 return mainwin->win.sep_folder.folderwin;
1844 return mainwin->win.sep_both.folderwin;
1850 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1852 switch (mainwin->type) {
1853 case SEPARATE_MESSAGE:
1854 return mainwin->win.sep_message.messagewin;
1856 return mainwin->win.sep_both.messagewin;
1862 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1864 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1865 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1866 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1867 GtkWidget *message_wid = mainwin->messageview->vbox;
1869 debug_print("Changing window separation type from %d to %d\n",
1870 mainwin->type, type);
1872 if (mainwin->type == type) return;
1874 /* remove widgets from those containers */
1875 gtk_widget_ref(folder_wid);
1876 gtk_widget_ref(summary_wid);
1877 gtk_widget_ref(message_wid);
1878 gtkut_container_remove
1879 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1880 gtkut_container_remove
1881 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1882 gtkut_container_remove
1883 (GTK_CONTAINER(message_wid->parent), message_wid);
1885 /* clean containers */
1886 switch (mainwin->type) {
1888 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1890 case SEPARATE_FOLDER:
1891 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1892 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1894 case SEPARATE_MESSAGE:
1895 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1896 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1899 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1900 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1904 gtk_widget_hide(mainwin->window);
1905 main_window_set_widgets(mainwin, type);
1906 gtk_widget_show(mainwin->window);
1908 gtk_widget_unref(folder_wid);
1909 gtk_widget_unref(summary_wid);
1910 gtk_widget_unref(message_wid);
1913 void main_window_toggle_message_view(MainWindow *mainwin)
1915 SummaryView *summaryview = mainwin->summaryview;
1916 union CompositeWin *cwin = &mainwin->win;
1917 GtkWidget *vpaned = NULL;
1918 GtkWidget *container = NULL;
1919 GtkWidget *msgwin = NULL;
1921 switch (mainwin->type) {
1923 vpaned = cwin->sep_none.vpaned;
1924 container = cwin->sep_none.hpaned;
1926 case SEPARATE_FOLDER:
1927 vpaned = cwin->sep_folder.vpaned;
1928 container = mainwin->vbox_body;
1930 case SEPARATE_MESSAGE:
1931 msgwin = mainwin->win.sep_message.messagewin;
1934 msgwin = mainwin->win.sep_both.messagewin;
1939 if (GTK_WIDGET_VISIBLE(msgwin)) {
1940 gtk_widget_hide(msgwin);
1941 mainwin->messageview->visible = FALSE;
1942 summaryview->displayed = NULL;
1944 gtk_widget_show(msgwin);
1945 mainwin->messageview->visible = TRUE;
1947 } else if (vpaned->parent != NULL) {
1948 mainwin->messageview->visible = FALSE;
1949 summaryview->displayed = NULL;
1950 gtk_widget_ref(vpaned);
1951 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1952 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1954 mainwin->messageview->visible = TRUE;
1955 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1956 gtk_container_add(GTK_CONTAINER(container), vpaned);
1957 gtk_widget_unref(vpaned);
1960 if (messageview_is_visible(mainwin->messageview))
1961 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1962 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1964 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1965 GTK_ARROW_UP, GTK_SHADOW_OUT);
1967 if (mainwin->messageview->visible == FALSE)
1968 messageview_clear(mainwin->messageview);
1970 main_window_set_menu_sensitive(mainwin);
1972 prefs_common.msgview_visible = mainwin->messageview->visible;
1974 summary_grab_focus(summaryview);
1977 void main_window_get_size(MainWindow *mainwin)
1979 GtkAllocation *allocation;
1981 if (mainwin_list == NULL || mainwin->messageview == NULL) {
1982 debug_print("called after messageview "
1983 "has been deallocated!\n");
1987 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1989 if (allocation->width > 1 && allocation->height > 1) {
1990 prefs_common.summaryview_width = allocation->width;
1992 if ((mainwin->type == SEPARATE_NONE ||
1993 mainwin->type == SEPARATE_FOLDER) &&
1994 messageview_is_visible(mainwin->messageview))
1995 prefs_common.summaryview_height = allocation->height;
1997 prefs_common.mainview_width = allocation->width;
2000 allocation = &mainwin->window->allocation;
2001 if (allocation->width > 1 && allocation->height > 1) {
2002 prefs_common.mainview_height = allocation->height;
2003 prefs_common.mainwin_width = allocation->width;
2004 prefs_common.mainwin_height = allocation->height;
2007 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2008 if (allocation->width > 1 && allocation->height > 1) {
2009 prefs_common.folderview_width = allocation->width;
2010 prefs_common.folderview_height = allocation->height;
2013 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2014 if (allocation->width > 1 && allocation->height > 1) {
2015 prefs_common.msgview_width = allocation->width;
2016 prefs_common.msgview_height = allocation->height;
2019 /* debug_print("summaryview size: %d x %d\n",
2020 prefs_common.summaryview_width,
2021 prefs_common.summaryview_height);
2022 debug_print("folderview size: %d x %d\n",
2023 prefs_common.folderview_width,
2024 prefs_common.folderview_height);
2025 debug_print("messageview size: %d x %d\n",
2026 prefs_common.msgview_width,
2027 prefs_common.msgview_height); */
2030 void main_window_get_position(MainWindow *mainwin)
2035 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2037 prefs_common.mainview_x = x;
2038 prefs_common.mainview_y = y;
2039 prefs_common.mainwin_x = x;
2040 prefs_common.mainwin_y = y;
2042 debug_print("main window position: %d, %d\n", x, y);
2044 window = main_window_get_folder_window(mainwin);
2046 gtkut_widget_get_uposition(window, &x, &y);
2047 prefs_common.folderwin_x = x;
2048 prefs_common.folderwin_y = y;
2049 debug_print("folder window position: %d, %d\n", x, y);
2051 window = main_window_get_message_window(mainwin);
2053 gtkut_widget_get_uposition(window, &x, &y);
2054 prefs_common.main_msgwin_x = x;
2055 prefs_common.main_msgwin_y = y;
2056 debug_print("message window position: %d, %d\n", x, y);
2060 void main_window_progress_on(MainWindow *mainwin)
2062 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2065 void main_window_progress_off(MainWindow *mainwin)
2067 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2068 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2071 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2075 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2076 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2077 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2078 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2081 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2084 if (alertpanel(_("Empty trash"),
2085 _("Delete all messages in trash folders?"),
2086 GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
2087 != G_ALERTALTERNATE)
2089 manage_window_focus_in(mainwin->window, NULL, NULL);
2092 procmsg_empty_all_trash();
2094 if (mainwin->summaryview->folder_item &&
2095 mainwin->summaryview->folder_item->stype == F_TRASH)
2096 gtk_widget_grab_focus(mainwin->folderview->ctree);
2099 void main_window_add_mailbox(MainWindow *mainwin)
2104 path = input_dialog(_("Add mailbox"),
2105 _("Input the location of mailbox.\n"
2106 "If the existing mailbox is specified, it will be\n"
2107 "scanned automatically."),
2110 if (folder_find_from_path(path)) {
2111 alertpanel_error(_("The mailbox '%s' already exists."), path);
2115 folder = folder_new(folder_get_class_from_string("mh"),
2116 !strcmp(path, "Mail") ? _("Mailbox") :
2117 g_path_get_basename(path), path);
2120 if (folder->klass->create_tree(folder) < 0) {
2121 alertpanel_error(_("Creation of the mailbox failed.\n"
2122 "Maybe some files already exist, or you don't have the permission to write there."));
2123 folder_destroy(folder);
2128 folder_set_ui_func(folder, scan_tree_func, mainwin);
2129 folder_scan_tree(folder, TRUE);
2130 folder_set_ui_func(folder, NULL, NULL);
2133 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2135 SensitiveCond state = 0;
2136 SummarySelection selection;
2137 FolderItem *item = mainwin->summaryview->folder_item;
2138 GList *account_list = account_get_list();
2140 selection = summary_get_selection_type(mainwin->summaryview);
2142 if (mainwin->lock_count == 0)
2143 state |= M_UNLOCKED;
2144 if (selection != SUMMARY_NONE)
2145 state |= M_MSG_EXIST;
2146 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2148 /* if (item->folder->type != F_NEWS) */
2149 state |= M_ALLOW_DELETE;
2151 if (prefs_common.immediate_exec == 0
2152 && mainwin->lock_count == 0)
2153 state |= M_DELAY_EXEC;
2155 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2156 || selection != SUMMARY_NONE)
2157 state |= M_HIDE_READ_MSG;
2159 if (mainwin->summaryview->threaded)
2160 state |= M_THREADED;
2162 state |= M_UNTHREADED;
2163 if (selection == SUMMARY_SELECTED_SINGLE ||
2164 selection == SUMMARY_SELECTED_MULTIPLE)
2165 state |= M_TARGET_EXIST;
2166 if (selection == SUMMARY_SELECTED_SINGLE)
2167 state |= M_SINGLE_TARGET_EXIST;
2168 if (mainwin->summaryview->folder_item &&
2169 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2172 state |= M_NOT_NEWS;
2173 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2174 state |= M_ACTIONS_EXIST;
2176 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2177 state |= M_HAVE_QUEUED_MAILS;
2179 if (selection == SUMMARY_SELECTED_SINGLE &&
2181 (folder_has_parent_of_type(item, F_DRAFT) ||
2182 folder_has_parent_of_type(item, F_OUTBOX) ||
2183 folder_has_parent_of_type(item, F_QUEUE))))
2184 state |= M_ALLOW_REEDIT;
2186 state |= M_HAVE_ACCOUNT;
2188 if (any_folder_want_synchronise())
2189 state |= M_WANT_SYNC;
2191 for ( ; account_list != NULL; account_list = account_list->next) {
2192 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2193 state |= M_HAVE_NEWS_ACCOUNT;
2198 if (procmsg_spam_can_learn()) {
2199 state |= M_CAN_LEARN_SPAM;
2202 if (inc_is_active())
2203 state |= M_INC_ACTIVE;
2205 if (mainwin->summaryview->deleted > 0 ||
2206 mainwin->summaryview->moved > 0 ||
2207 mainwin->summaryview->copied > 0)
2208 state |= M_DELAY_EXEC;
2215 void main_window_set_menu_sensitive(MainWindow *mainwin)
2217 GtkItemFactory *ifactory = mainwin->menu_factory;
2218 SensitiveCond state;
2221 GtkWidget *menuitem;
2222 SummaryView *summaryview;
2227 static const struct {
2231 {"/File/Save as...", M_TARGET_EXIST},
2232 {"/File/Print..." , M_TARGET_EXIST},
2233 {"/File/Synchronise folders", M_WANT_SYNC},
2234 {"/File/Exit" , M_UNLOCKED},
2236 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
2237 {"/Edit/Delete thread" , M_SINGLE_TARGET_EXIST},
2238 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2240 {"/View/Set displayed columns/in Folder list..."
2242 {"/View/Sort" , M_EXEC},
2243 {"/View/Thread view" , M_EXEC},
2244 {"/View/Expand all threads" , M_MSG_EXIST},
2245 {"/View/Collapse all threads" , M_MSG_EXIST},
2246 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2247 {"/View/Go to/Previous message" , M_MSG_EXIST},
2248 {"/View/Go to/Next message" , M_MSG_EXIST},
2249 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2250 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2251 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2252 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2253 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2254 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2255 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2256 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2257 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2258 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2259 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2261 {"/Message/Receive/Get from current account"
2262 , M_HAVE_ACCOUNT|M_UNLOCKED},
2263 {"/Message/Receive/Get from all accounts"
2264 , M_HAVE_ACCOUNT|M_UNLOCKED},
2265 {"/Message/Receive/Cancel receiving"
2267 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2268 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2269 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2270 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2271 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2272 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2273 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2274 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2275 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2276 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2277 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2278 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2279 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2280 {"/Message/Mark" , M_TARGET_EXIST},
2281 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2282 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2283 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2284 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2285 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2286 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2287 {"/Message/Color label" , M_TARGET_EXIST},
2288 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2290 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2291 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2292 {"/Tools/Harvest addresses/from Messages..."
2294 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2295 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2296 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2297 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2298 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2299 {"/Tools/Execute" , M_DELAY_EXEC},
2300 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2302 {"/Configuration", M_UNLOCKED},
2307 state = main_window_get_current_state(mainwin);
2309 for (i = 0; entry[i].entry != NULL; i++) {
2310 sensitive = ((entry[i].cond & state) == entry[i].cond);
2311 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2314 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2316 /* search for separator */
2317 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2318 cur_item = cur_item->next) {
2319 if (GTK_BIN(cur_item->data)->child == NULL) {
2320 cur_item = cur_item->next;
2325 for (; cur_item != NULL; cur_item = cur_item->next) {
2326 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2327 (M_UNLOCKED & state) != 0);
2330 main_window_menu_callback_block(mainwin);
2332 #define SET_CHECK_MENU_ACTIVE(path, active) \
2334 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2335 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2338 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2339 messageview_is_visible(mainwin->messageview));
2341 summaryview = mainwin->summaryview;
2342 menu_path = "/View/Sort/Don't sort";
2344 switch (summaryview->sort_key) {
2345 case SORT_BY_NUMBER:
2346 menu_path = "/View/Sort/by number"; break;
2348 menu_path = "/View/Sort/by Size"; break;
2350 menu_path = "/View/Sort/by Date"; break;
2352 menu_path = "/View/Sort/by From"; break;
2354 menu_path = "/View/Sort/by To"; break;
2355 case SORT_BY_SUBJECT:
2356 menu_path = "/View/Sort/by Subject"; break;
2358 menu_path = "/View/Sort/by color label"; break;
2360 menu_path = "/View/Sort/by mark"; break;
2361 case SORT_BY_STATUS:
2362 menu_path = "/View/Sort/by status"; break;
2364 menu_path = "/View/Sort/by attachment"; break;
2366 menu_path = "/View/Sort/by score"; break;
2367 case SORT_BY_LOCKED:
2368 menu_path = "/View/Sort/by locked"; break;
2371 menu_path = "/View/Sort/Don't sort"; break;
2373 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2375 if (summaryview->sort_type == SORT_ASCENDING) {
2376 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2378 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2381 if (summaryview->sort_key != SORT_BY_NONE) {
2382 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2383 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2385 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2386 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2389 if (mainwin->messageview
2390 && mainwin->messageview->mimeview
2391 && mainwin->messageview->mimeview->textview)
2392 SET_CHECK_MENU_ACTIVE("/View/All headers",
2393 mainwin->messageview->mimeview->textview->show_all_headers);
2394 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2395 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2396 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2397 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2398 if (prefs_common.hide_quotes == 1)
2399 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2400 if (prefs_common.hide_quotes == 2)
2401 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2402 if (prefs_common.hide_quotes == 3)
2403 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2405 #undef SET_CHECK_MENU_ACTIVE
2407 main_window_menu_callback_unblock(mainwin);
2410 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2412 GtkItemFactory *ifactory;
2414 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2417 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2419 gtk_widget_set_sensitive (gtk_item_factory_get_item
2420 (ifactory,"/Message/Mailing-List"), TRUE);
2422 gtk_widget_set_sensitive (gtk_item_factory_get_item
2423 (ifactory,"/Message/Mailing-List"), FALSE);
2426 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2429 GtkWidget *menuitem;
2431 if (!msginfo || !msginfo->extradata) {
2432 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2433 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2434 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2435 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2436 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2437 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2441 /* Mailing list post */
2442 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2443 g_free(msginfo->extradata->list_post);
2444 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2446 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2448 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2450 /* Mailing list help */
2451 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2453 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2455 /* Mailing list subscribe */
2456 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2458 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2460 /* Mailing list unsubscribe */
2461 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2463 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2465 /* Mailing list view archive */
2466 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2468 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2470 /* Mailing list contact owner */
2471 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2473 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2478 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2480 GtkWidget *item, *menu;
2481 const gchar *url_pt ;
2482 gchar url_decoded[BUFFSIZE];
2483 GList *amenu, *alist;
2486 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2488 /* First delete old submenu */
2489 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2490 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2491 alist = amenu->next;
2492 item = GTK_WIDGET (amenu->data);
2493 gtk_widget_destroy (item);
2497 for (url_pt = list_header; url_pt && *url_pt;) {
2498 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2500 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2501 item = gtk_menu_item_new_with_label ((url_decoded));
2502 g_signal_connect(G_OBJECT(item), "activate",
2503 G_CALLBACK(mailing_list_compose),
2506 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2507 !g_strncasecmp (url_decoded, "https:",6)) {
2509 item = gtk_menu_item_new_with_label ((url_decoded));
2510 g_signal_connect(G_OBJECT(item), "activate",
2511 G_CALLBACK(mailing_list_open_uri),
2515 gtk_menu_append (GTK_MENU(menu), item);
2516 gtk_widget_show (item);
2522 gtk_widget_set_sensitive (menuitem, TRUE);
2524 gtk_widget_set_sensitive (menuitem, FALSE);
2530 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2532 gchar tmp[BUFFSIZE];
2538 *url_decoded = '\0';
2542 /* Ignore spaces, comments and tabs () */
2543 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2545 for (;*buf != ')' && *buf != 0x00; buf++);
2547 /* First non space and non comment must be a < */
2550 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2555 *url_decoded = '\0';
2560 *url_decoded = '\0';
2566 decode_uri (url_decoded, (const gchar *)tmp);
2568 /* Prepare the work for the next url in the list */
2569 /* after the closing bracket >, ignore space, comments and tabs */
2570 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2572 for (;*buf != ')' && *buf != 0x00; buf++);
2574 if (!buf || !*buf) {
2579 /* now first non space, non comment must be a comma */
2581 for (;*buf != 0x00; buf++);
2587 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2591 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2592 compose_new(NULL, mailto+7, NULL);
2595 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2600 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2601 open_uri (mailto, prefs_common.uri_cmd);
2604 void main_window_popup(MainWindow *mainwin)
2606 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2607 main_window_show(mainwin);
2609 gtkut_window_popup(mainwin->window);
2611 switch (mainwin->type) {
2612 case SEPARATE_FOLDER:
2613 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2615 case SEPARATE_MESSAGE:
2616 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2619 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2620 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2627 void main_window_show(MainWindow *mainwin)
2629 gtk_widget_show(mainwin->window);
2630 gtk_widget_show(mainwin->vbox_body);
2632 gtk_widget_set_uposition(mainwin->window,
2633 prefs_common.mainwin_x,
2634 prefs_common.mainwin_y);
2636 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2637 prefs_common.folderview_width,
2638 prefs_common.folderview_height);
2639 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2640 prefs_common.summaryview_width,
2641 prefs_common.summaryview_height);
2642 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2643 prefs_common.msgview_width,
2644 prefs_common.msgview_height);
2646 if (mainwin->type & SEPARATE_FOLDER) {
2647 GtkWidget *folderwin;
2649 folderwin = main_window_get_folder_window(mainwin);
2650 gtk_widget_show(folderwin);
2651 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2652 prefs_common.folderwin_y);
2655 if (mainwin->type & SEPARATE_MESSAGE) {
2656 GtkWidget *messagewin;
2658 messagewin = main_window_get_message_window(mainwin);
2659 gtk_widget_show(messagewin);
2660 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2661 prefs_common.main_msgwin_y);
2665 void main_window_hide(MainWindow *mainwin)
2667 main_window_get_size(mainwin);
2668 main_window_get_position(mainwin);
2670 gtk_widget_hide(mainwin->window);
2671 gtk_widget_hide(mainwin->vbox_body);
2673 if (mainwin->type & SEPARATE_FOLDER) {
2674 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2677 if (mainwin->type & SEPARATE_MESSAGE) {
2678 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2682 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2684 GtkWidget *folderwin = NULL;
2685 GtkWidget *messagewin = NULL;
2688 GtkWidget *vbox_body = mainwin->vbox_body;
2689 GtkItemFactory *ifactory = mainwin->menu_factory;
2690 GtkWidget *menuitem;
2691 GtkItemFactory *msgview_ifactory;
2693 debug_print("Setting widgets... ");
2695 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2696 prefs_common.folderview_width,
2697 prefs_common.folderview_height);
2698 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2699 prefs_common.summaryview_width,
2700 prefs_common.summaryview_height);
2701 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2702 prefs_common.msgview_width,
2703 prefs_common.msgview_height);
2705 /* create separated window(s) if needed */
2706 if (type & SEPARATE_FOLDER) {
2707 static GdkGeometry folderwin_geometry;
2709 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2710 gtk_window_set_title(GTK_WINDOW(folderwin),
2711 _("Claws Mail - Folder View"));
2713 gtk_window_move(GTK_WINDOW(folderwin),
2714 prefs_common.folderwin_x,
2715 prefs_common.folderwin_y);
2717 if (!folderwin_geometry.min_height) {
2718 folderwin_geometry.min_width = 320;
2719 folderwin_geometry.min_height = 200;
2721 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2722 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2724 gtk_widget_set_size_request(folderwin,
2725 prefs_common.folderview_width,
2726 prefs_common.folderview_height);
2728 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2731 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2732 G_CALLBACK(folder_window_close_cb),
2734 gtk_container_add(GTK_CONTAINER(folderwin),
2735 GTK_WIDGET_PTR(mainwin->folderview));
2736 gtk_widget_realize(folderwin);
2738 if (prefs_common.folderview_visible)
2739 gtk_widget_show(folderwin);
2742 if (type & SEPARATE_MESSAGE) {
2743 static GdkGeometry msgwin_geometry;
2745 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2746 gtk_window_set_title(GTK_WINDOW(messagewin),
2747 _("Claws Mail - Message View"));
2749 gtk_window_move(GTK_WINDOW(messagewin),
2750 prefs_common.main_msgwin_x,
2751 prefs_common.main_msgwin_y);
2753 if (!msgwin_geometry.min_height) {
2754 msgwin_geometry.min_width = 320;
2755 msgwin_geometry.min_height = 200;
2757 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2758 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2760 gtk_widget_set_size_request(messagewin,
2761 prefs_common.msgwin_width,
2762 prefs_common.msgwin_height);
2764 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2766 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2767 G_CALLBACK(message_window_close_cb),
2769 if (messageview_is_visible(mainwin->messageview))
2770 gtk_widget_show(messagewin);
2772 mainwin->messageview->statusbar = mainwin->statusbar;
2773 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2778 hpaned = gtk_hpaned_new();
2779 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2780 gtk_paned_add1(GTK_PANED(hpaned),
2781 GTK_WIDGET_PTR(mainwin->folderview));
2782 gtk_widget_show(hpaned);
2783 gtk_widget_queue_resize(hpaned);
2785 vpaned = gtk_vpaned_new();
2786 if (messageview_is_visible(mainwin->messageview)) {
2787 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2788 gtk_paned_add1(GTK_PANED(vpaned),
2789 GTK_WIDGET_PTR(mainwin->summaryview));
2791 gtk_paned_add2(GTK_PANED(hpaned),
2792 GTK_WIDGET_PTR(mainwin->summaryview));
2793 gtk_widget_ref(vpaned);
2795 gtk_paned_add2(GTK_PANED(vpaned),
2796 GTK_WIDGET_PTR(mainwin->messageview));
2797 gtk_widget_show(vpaned);
2798 gtk_widget_queue_resize(vpaned);
2800 mainwin->win.sep_none.hpaned = hpaned;
2801 mainwin->win.sep_none.vpaned = vpaned;
2803 /* remove headerview if not in prefs */
2804 headerview_set_visibility(mainwin->messageview->headerview,
2805 prefs_common.display_header_pane);
2807 case SEPARATE_FOLDER:
2808 vpaned = gtk_vpaned_new();
2809 if (messageview_is_visible(mainwin->messageview)) {
2810 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2812 gtk_paned_add1(GTK_PANED(vpaned),
2813 GTK_WIDGET_PTR(mainwin->summaryview));
2815 gtk_box_pack_start(GTK_BOX(vbox_body),
2816 GTK_WIDGET_PTR(mainwin->summaryview),
2818 gtk_widget_ref(vpaned);
2820 gtk_paned_add2(GTK_PANED(vpaned),
2821 GTK_WIDGET_PTR(mainwin->messageview));
2822 gtk_widget_show(vpaned);
2823 gtk_widget_queue_resize(vpaned);
2825 mainwin->win.sep_folder.folderwin = folderwin;
2826 mainwin->win.sep_folder.vpaned = vpaned;
2828 /* remove headerview if not in prefs */
2829 headerview_set_visibility(mainwin->messageview->headerview,
2830 prefs_common.display_header_pane);
2833 case SEPARATE_MESSAGE:
2834 hpaned = gtk_hpaned_new();
2835 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2836 gtk_paned_add1(GTK_PANED(hpaned),
2837 GTK_WIDGET_PTR(mainwin->folderview));
2838 gtk_paned_add2(GTK_PANED(hpaned),
2839 GTK_WIDGET_PTR(mainwin->summaryview));
2840 gtk_widget_show(hpaned);
2841 gtk_widget_queue_resize(hpaned);
2842 messageview_add_toolbar(mainwin->messageview, messagewin);
2843 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2844 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2846 mainwin->win.sep_message.messagewin = messagewin;
2847 mainwin->win.sep_message.hpaned = hpaned;
2849 gtk_widget_realize(messagewin);
2850 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2851 gtk_widget_show_all(messagewin);
2852 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2853 mainwin->messageview->handlebox,
2854 prefs_common.toolbar_style);
2856 /* remove headerview if not in prefs */
2857 headerview_set_visibility(mainwin->messageview->headerview,
2858 prefs_common.display_header_pane);
2862 messageview_add_toolbar(mainwin->messageview, messagewin);
2863 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2864 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2866 gtk_box_pack_start(GTK_BOX(vbox_body),
2867 GTK_WIDGET_PTR(mainwin->summaryview),
2870 mainwin->win.sep_both.folderwin = folderwin;
2871 mainwin->win.sep_both.messagewin = messagewin;
2873 gtk_widget_realize(messagewin);
2874 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2875 gtk_widget_show_all(messagewin);
2876 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2877 mainwin->messageview->handlebox,
2878 prefs_common.toolbar_style);
2880 /* remove headerview if not in prefs */
2881 headerview_set_visibility(mainwin->messageview->headerview,
2882 prefs_common.display_header_pane);
2887 if (messageview_is_visible(mainwin->messageview))
2888 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2889 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2891 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2892 GTK_ARROW_UP, GTK_SHADOW_OUT);
2894 gtk_window_move(GTK_WINDOW(mainwin->window),
2895 prefs_common.mainwin_x,
2896 prefs_common.mainwin_y);
2898 gtk_widget_queue_resize(vbox_body);
2899 gtk_widget_queue_resize(mainwin->vbox);
2900 gtk_widget_queue_resize(mainwin->window);
2901 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2902 * and mimeview icon list/ctree lose track of their visibility states */
2903 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2904 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2905 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2906 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2907 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2908 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2910 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2912 mainwin->type = type;
2915 /* toggle menu state */
2916 menuitem = gtk_item_factory_get_item
2917 (ifactory, "/View/Show or hide/Folder tree");
2918 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2919 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2920 prefs_common.folderview_visible);
2921 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2922 menuitem = gtk_item_factory_get_item
2923 (ifactory, "/View/Show or hide/Message view");
2924 gtk_check_menu_item_set_active
2925 (GTK_CHECK_MENU_ITEM(menuitem),
2926 messageview_is_visible(mainwin->messageview));
2928 menuitem = gtk_item_factory_get_item
2929 (ifactory, "/View/Separate folder tree");
2930 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2931 ((type & SEPARATE_FOLDER) != 0));
2932 menuitem = gtk_item_factory_get_item
2933 (ifactory, "/View/Separate message view");
2934 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2935 ((type & SEPARATE_MESSAGE) != 0));
2939 (G_OBJECT(folderwin), "size_allocate",
2940 G_CALLBACK(folder_window_size_allocate_cb),
2945 (G_OBJECT(messagewin), "size_allocate",
2946 G_CALLBACK(message_window_size_allocate_cb),
2950 debug_print("done.\n");
2953 void main_window_destroy_all(void)
2955 while (mainwin_list != NULL) {
2956 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2958 /* free toolbar stuff */
2959 toolbar_clear_list(TOOLBAR_MAIN);
2960 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2961 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2963 mainwin->folderview->mainwin = NULL;
2964 mainwin->summaryview->mainwin = NULL;
2965 mainwin->messageview->mainwin = NULL;
2967 g_free(mainwin->toolbar);
2970 mainwin_list = g_list_remove(mainwin_list, mainwin);
2972 g_list_free(mainwin_list);
2973 mainwin_list = NULL;
2976 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2979 gtk_widget_set_size_request(child, 1, -1);
2982 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2985 gtk_widget_set_size_request(child, -1, -1);
2988 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2991 MainWindow *mainwin = (MainWindow *)data;
2993 if (!event) return FALSE;
2995 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2996 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2999 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3000 menu_button_position, widget,
3001 event->button, event->time);
3006 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3009 MainWindow *mainwin = (MainWindow *)data;
3011 if (mainwin->lock_count == 0)
3012 app_exit_cb(data, 0, widget);
3017 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3020 MainWindow *mainwin = (MainWindow *)data;
3021 GtkWidget *menuitem;
3023 menuitem = gtk_item_factory_get_item
3024 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
3025 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3030 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3033 MainWindow *mainwin = (MainWindow *)data;
3034 GtkWidget *menuitem;
3036 menuitem = gtk_item_factory_get_item
3037 (mainwin->menu_factory, "/View/Show or hide/Message view");
3038 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3040 mainwin->messageview->statusbar = mainwin->statusbar;
3041 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3046 static void main_window_size_allocate_cb(GtkWidget *widget,
3047 GtkAllocation *allocation,
3050 MainWindow *mainwin = (MainWindow *)data;
3052 main_window_get_size(mainwin);
3055 static void folder_window_size_allocate_cb(GtkWidget *widget,
3056 GtkAllocation *allocation,
3059 MainWindow *mainwin = (MainWindow *)data;
3061 main_window_get_size(mainwin);
3064 static void message_window_size_allocate_cb(GtkWidget *widget,
3065 GtkAllocation *allocation,
3068 MainWindow *mainwin = (MainWindow *)data;
3070 main_window_get_size(mainwin);
3073 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3076 main_window_add_mailbox(mainwin);
3079 static void update_folderview_cb(MainWindow *mainwin, guint action,
3082 summary_show(mainwin->summaryview, NULL);
3083 folderview_check_new_all();
3086 static void foldersort_cb(MainWindow *mainwin, guint action,
3092 static void import_mbox_cb(MainWindow *mainwin, guint action,
3095 /* only notify if import has failed */
3096 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3097 alertpanel_error(_("Mbox import has failed."));
3101 static void export_mbox_cb(MainWindow *mainwin, guint action,
3104 /* only notify if export has failed */
3105 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3106 alertpanel_error(_("Export to mbox has failed."));
3110 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3113 /* only notify if export has failed */
3114 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3115 alertpanel_error(_("Export to mbox has failed."));
3119 static void empty_trash_cb(MainWindow *mainwin, guint action,
3122 main_window_empty_trash(mainwin, TRUE);
3125 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3127 summary_save_as(mainwin->summaryview);
3130 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3132 summary_print(mainwin->summaryview);
3135 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3137 if (prefs_common.confirm_on_exit) {
3138 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3139 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3140 != G_ALERTALTERNATE)
3142 manage_window_focus_in(mainwin->window, NULL, NULL);
3145 app_will_exit(widget, mainwin);
3148 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3151 summary_search(mainwin->summaryview);
3153 message_search(mainwin->messageview);
3156 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3158 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3161 static void toggle_folder_cb(MainWindow *mainwin, guint action,
3166 active = GTK_CHECK_MENU_ITEM(widget)->active;
3168 switch (mainwin->type) {
3170 case SEPARATE_MESSAGE:
3172 case SEPARATE_FOLDER:
3173 debug_print("separate folder\n");
3175 gtk_widget_show(mainwin->win.sep_folder.folderwin);
3177 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
3181 gtk_widget_show(mainwin->win.sep_both.folderwin);
3183 gtk_widget_hide(mainwin->win.sep_both.folderwin);
3187 prefs_common.folderview_visible = active;
3190 static void toggle_message_cb(MainWindow *mainwin, guint action,
3195 active = GTK_CHECK_MENU_ITEM(widget)->active;
3197 if (active != messageview_is_visible(mainwin->messageview))
3198 summary_toggle_view(mainwin->summaryview);
3201 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3204 toolbar_toggle(action, mainwin);
3207 void main_window_reply_cb(MainWindow *mainwin, guint action,
3210 MessageView *msgview = (MessageView*)mainwin->messageview;
3211 GSList *msginfo_list = NULL;
3213 g_return_if_fail(msgview != NULL);
3215 msginfo_list = summary_get_selection(mainwin->summaryview);
3216 g_return_if_fail(msginfo_list != NULL);
3217 compose_reply_from_messageview(msgview, msginfo_list, action);
3218 g_slist_free(msginfo_list);
3222 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3225 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3226 gtk_widget_show(mainwin->hbox_stat);
3227 prefs_common.show_statusbar = TRUE;
3229 gtk_widget_hide(mainwin->hbox_stat);
3230 prefs_common.show_statusbar = FALSE;
3234 static void separate_widget_cb(MainWindow *mainwin, guint action,
3239 if (GTK_CHECK_MENU_ITEM(widget)->active)
3240 type = mainwin->type | action;
3242 type = mainwin->type & ~action;
3244 main_window_separation_change(mainwin, type);
3246 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
3247 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
3250 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3253 offline_ask_sync = ask_sync;
3255 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3257 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3258 offline_ask_sync = TRUE;
3261 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3263 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3266 static gboolean any_folder_want_synchronise(void)
3268 GList *folderlist = folder_get_list();
3270 /* see if there are synchronised folders */
3271 for (; folderlist; folderlist = folderlist->next) {
3272 Folder *folder = (Folder *)folderlist->data;
3273 if (folder_want_synchronise(folder)) {
3281 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3284 if (!any_folder_want_synchronise())
3287 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3288 _("Do you want to synchronise your folders now?"),
3289 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3292 folder_synchronise(NULL);
3295 static void online_switch_clicked (GtkButton *btn, gpointer data)
3297 MainWindow *mainwin;
3298 GtkItemFactory *ifactory;
3299 GtkCheckMenuItem *menuitem;
3301 mainwin = (MainWindow *) data;
3303 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3304 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3306 g_return_if_fail(mainwin != NULL);
3307 g_return_if_fail(menuitem != NULL);
3309 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3310 gtk_widget_hide (mainwin->online_switch);
3311 gtk_widget_show (mainwin->offline_switch);
3312 menuitem->active = TRUE;
3313 inc_autocheck_timer_remove();
3316 if (prefs_common.work_offline)
3318 mainwindow_check_synchronise(mainwin, TRUE);
3319 prefs_common.work_offline = TRUE;
3320 imap_disconnect_all();
3321 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3324 if (!prefs_common.work_offline)
3326 gtk_widget_hide (mainwin->offline_switch);
3327 gtk_widget_show (mainwin->online_switch);
3328 menuitem->active = FALSE;
3329 prefs_common.work_offline = FALSE;
3330 inc_autocheck_timer_set();
3331 refresh_resolvers();
3332 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3336 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3339 addressbook_open(NULL);
3342 static void log_window_show_cb(MainWindow *mainwin, guint action,
3345 log_window_show(mainwin->logwin);
3348 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3353 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3355 summary_move_to(mainwin->summaryview);
3358 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3360 summary_copy_to(mainwin->summaryview);
3363 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3365 summary_delete(mainwin->summaryview);
3368 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3370 summary_delete_trash(mainwin->summaryview);
3373 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3375 summary_cancel(mainwin->summaryview);
3378 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3380 summary_open_msg(mainwin->summaryview);
3383 static void view_source_cb(MainWindow *mainwin, guint action,
3386 summary_view_source(mainwin->summaryview);
3389 static void show_all_header_cb(MainWindow *mainwin, guint action,
3392 if (mainwin->menu_lock_count) return;
3393 mainwin->summaryview->messageview->all_headers =
3394 GTK_CHECK_MENU_ITEM(widget)->active;
3395 summary_display_msg_selected(mainwin->summaryview,
3396 GTK_CHECK_MENU_ITEM(widget)->active);
3399 #define SET_CHECK_MENU_ACTIVE(path, active) \
3401 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3402 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3405 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3408 GtkWidget *menuitem;
3409 GtkItemFactory *ifactory = mainwin->menu_factory;
3411 if (mainwin->menu_lock_count) return;
3413 prefs_common.hide_quotes =
3414 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3416 mainwin->menu_lock_count++;
3417 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3418 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3419 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3420 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3421 mainwin->menu_lock_count--;
3423 summary_redisplay_msg(mainwin->summaryview);
3426 #undef SET_CHECK_MENU_ACTIVE
3427 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3429 summary_mark(mainwin->summaryview);
3432 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3434 summary_unmark(mainwin->summaryview);
3437 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3440 summary_mark_as_unread(mainwin->summaryview);
3443 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3446 summary_mark_as_read(mainwin->summaryview);
3449 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3452 summary_mark_all_read(mainwin->summaryview);
3455 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3458 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3461 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3464 summary_ignore_thread(mainwin->summaryview);
3467 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3470 summary_unignore_thread(mainwin->summaryview);
3473 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3476 summary_msgs_lock(mainwin->summaryview);
3479 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3482 summary_msgs_unlock(mainwin->summaryview);
3486 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3488 summary_reedit(mainwin->summaryview);
3491 static void add_address_cb(MainWindow *mainwin, guint action,
3494 summary_add_address(mainwin->summaryview);
3497 static void set_charset_cb(MainWindow *mainwin, guint action,
3502 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3503 str = conv_get_charset_str((CharSet)action);
3505 g_free(mainwin->messageview->forced_charset);
3506 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3507 procmime_force_charset(str);
3509 summary_redisplay_msg(mainwin->summaryview);
3511 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3515 static void set_decode_cb(MainWindow *mainwin, guint action,
3518 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3519 mainwin->messageview->forced_encoding = (EncodingType)action;
3521 summary_redisplay_msg(mainwin->summaryview);
3523 debug_print("forced encoding: %d\n", action);
3527 static void hide_read_messages (MainWindow *mainwin, guint action,
3530 if (!mainwin->summaryview->folder_item
3531 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3533 summary_toggle_show_read_messages(mainwin->summaryview);
3536 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3538 gboolean threaded = FALSE;
3539 if (mainwin->menu_lock_count) return;
3540 if (!mainwin->summaryview->folder_item) return;
3542 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3544 mainwin->summaryview->folder_item->threaded = threaded;
3546 mainwin->summaryview->threaded = threaded;
3548 summary_show(mainwin->summaryview,
3549 mainwin->summaryview->folder_item);
3552 static void expand_threads_cb(MainWindow *mainwin, guint action,
3555 summary_expand_threads(mainwin->summaryview);
3558 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3561 summary_collapse_threads(mainwin->summaryview);
3564 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3567 prefs_summary_column_open();
3570 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3573 prefs_folder_column_open();
3576 static void sort_summary_cb(MainWindow *mainwin, guint action,
3579 FolderItem *item = mainwin->summaryview->folder_item;
3580 GtkWidget *menuitem;
3582 if (mainwin->menu_lock_count) return;
3584 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3585 menuitem = gtk_item_factory_get_item
3586 (mainwin->menu_factory, "/View/Sort/Ascending");
3587 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3588 GTK_CHECK_MENU_ITEM(menuitem)->active
3589 ? SORT_ASCENDING : SORT_DESCENDING);
3590 item->sort_key = action;
3594 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3597 FolderItem *item = mainwin->summaryview->folder_item;
3599 if (mainwin->menu_lock_count) return;
3601 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3602 summary_sort(mainwin->summaryview,
3603 item->sort_key, (FolderSortType)action);
3606 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3609 summary_attract_by_subject(mainwin->summaryview);
3612 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3617 item = folderview_get_selected_item(mainwin->folderview);
3619 main_window_cursor_wait(mainwin);
3620 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3622 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3623 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3625 STATUSBAR_POP(mainwin);
3626 main_window_cursor_normal(mainwin);
3636 static void deldup_all(FolderItem *item, gpointer _data)
3638 struct DelDupsData *data = _data;
3641 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3643 data->dups += result;
3648 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3651 struct DelDupsData data = {0, 0};
3653 main_window_cursor_wait(mainwin);
3654 folder_func_to_all_folders(deldup_all, &data);
3655 main_window_cursor_normal(mainwin);
3657 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3658 "Deleted %d duplicate messages in %d folders.\n",
3660 data.dups, data.folders);
3663 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3665 summary_filter(mainwin->summaryview, (gboolean)action);
3668 static void execute_summary_cb(MainWindow *mainwin, guint action,
3671 summary_execute(mainwin->summaryview);
3674 static void update_summary_cb(MainWindow *mainwin, guint action,
3678 FolderView *folderview = mainwin->folderview;
3680 if (!mainwin->summaryview->folder_item) return;
3681 if (!folderview->opened) return;
3683 folder_update_op_count();
3685 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3686 folderview->opened);
3689 folder_item_scan(fitem);
3690 summary_show(mainwin->summaryview, fitem);
3693 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3695 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3698 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3700 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3703 static void prev_unread_cb(MainWindow *mainwin, guint action,
3706 summary_select_prev_unread(mainwin->summaryview);
3709 static void next_unread_cb(MainWindow *mainwin, guint action,
3712 summary_select_next_unread(mainwin->summaryview);
3715 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3717 summary_select_prev_new(mainwin->summaryview);
3720 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3722 summary_select_next_new(mainwin->summaryview);
3725 static void prev_marked_cb(MainWindow *mainwin, guint action,
3728 summary_select_prev_marked(mainwin->summaryview);
3731 static void next_marked_cb(MainWindow *mainwin, guint action,
3734 summary_select_next_marked(mainwin->summaryview);
3737 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3740 summary_select_prev_labeled(mainwin->summaryview);
3743 static void next_labeled_cb(MainWindow *mainwin, guint action,
3746 summary_select_next_labeled(mainwin->summaryview);
3749 static void last_read_cb(MainWindow *mainwin, guint action,
3752 summary_select_last_read(mainwin->summaryview);
3755 static void parent_cb(MainWindow *mainwin, guint action,
3758 summary_select_parent(mainwin->summaryview);
3761 static void goto_folder_cb(MainWindow *mainwin, guint action,
3764 FolderItem *to_folder;
3766 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3769 folderview_select(mainwin->folderview, to_folder);
3772 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3775 folderview_select_next_unread(mainwin->folderview, FALSE);
3778 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3780 messageview_copy_clipboard(mainwin->messageview);
3783 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3785 MessageView *msgview = mainwin->messageview;
3787 if (messageview_is_visible(msgview) &&
3788 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3789 messageview_select_all(mainwin->messageview);
3791 summary_select_all(mainwin->summaryview);
3794 static void select_thread_cb(MainWindow *mainwin, guint action,
3797 summary_select_thread(mainwin->summaryview, FALSE);
3800 static void delete_thread_cb(MainWindow *mainwin, guint action,
3803 summary_select_thread(mainwin->summaryview, TRUE);
3806 static void create_filter_cb(MainWindow *mainwin, guint action,
3809 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3812 static void create_processing_cb(MainWindow *mainwin, guint action,
3815 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3818 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3821 prefs_filtering_open(&pre_global_processing,
3822 _("Processing rules to apply before folder rules"),
3823 MANUAL_ANCHOR_PROCESSING,
3827 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3830 prefs_filtering_open(&post_global_processing,
3831 _("Processing rules to apply after folder rules"),
3832 MANUAL_ANCHOR_PROCESSING,
3836 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3839 prefs_filtering_open(&filtering_rules,
3840 _("Filtering configuration"),
3841 MANUAL_ANCHOR_FILTERING,
3845 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3848 prefs_template_open();
3851 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3854 prefs_actions_open(mainwin);
3857 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3860 ssl_manager_open(mainwin);
3863 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3867 new_account_cb(mainwin, 0, widget);
3869 account_open(cur_account);
3873 static void new_account_cb(MainWindow *mainwin, guint action,
3876 account_edit_open();
3877 if (!compose_get_compose_list()) account_add();
3880 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3882 FolderItem *item = NULL;
3883 cur_account = (PrefsAccount *)data;
3885 if (!mainwindow_get_mainwindow())
3887 main_window_show_cur_account(mainwindow_get_mainwindow());
3888 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3889 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3890 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3891 item = folderview_get_selected_item(
3892 mainwindow_get_mainwindow()->folderview);
3894 toolbar_set_compose_button
3895 (mainwindow_get_mainwindow()->toolbar,
3896 FOLDER_TYPE(item->folder) == F_NEWS ?
3897 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3901 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3903 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3904 PrefsAccount *account = (PrefsAccount *)data;
3906 inc_account_mail(mainwin, account);
3909 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3911 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3912 PrefsAccount *account = (PrefsAccount *)data;
3913 FolderItem *item = mainwin->summaryview->folder_item;
3915 compose_new_with_folderitem(account, item, NULL);
3918 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3923 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3925 pluginwindow_create();
3928 static void manual_open_cb(MainWindow *mainwin, guint action,
3931 manual_open((ManualType)action, NULL);
3934 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3939 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3941 MainWindow *mainwin = (MainWindow *)data;
3945 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3946 LOCAL_FOLDER(folder)->rootpath,
3950 str = g_strdup_printf(_("Scanning folder %s ..."),
3951 LOCAL_FOLDER(folder)->rootpath);
3953 STATUSBAR_PUSH(mainwin, str);
3954 STATUSBAR_POP(mainwin);
3958 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3961 SummaryView *summary;
3963 g_return_val_if_fail(data, FALSE);
3964 if (!g_list_find(mainwin_list, data))
3966 summary = ((MainWindow *)data)->summaryview;
3967 g_return_val_if_fail(summary, FALSE);
3969 if (GTK_CLIST(summary->ctree)->selection &&
3970 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3976 #define BREAK_ON_MODIFIER_KEY() \
3977 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3979 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3982 MainWindow *mainwin = (MainWindow*) data;
3984 if (!mainwin || !event)
3987 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3989 lastkey = event->keyval;
3993 switch (event->keyval) {
3994 case GDK_Q: /* Quit */
3995 BREAK_ON_MODIFIER_KEY();
3997 app_exit_cb(mainwin, 0, NULL);
4000 if (mainwin->folderview && mainwin->summaryview
4001 && ((!mainwin->summaryview->displayed
4002 && !mainwin->summaryview->selected)
4003 || (mainwin->summaryview->folder_item
4004 && mainwin->summaryview->folder_item->total_msgs == 0))) {
4005 g_signal_stop_emission_by_name(G_OBJECT(widget),
4007 folderview_select_next_unread(mainwin->folderview, TRUE);
4016 #undef BREAK_ON_MODIFIER_KEY
4019 * Harvest addresses for selected folder.
4021 static void addr_harvest_cb( MainWindow *mainwin,
4025 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4029 * Harvest addresses for selected messages in summary view.
4031 static void addr_harvest_msg_cb( MainWindow *mainwin,
4035 summary_harvest_address( mainwin->summaryview );
4039 *\brief get a MainWindow
4041 *\return MainWindow * The first mainwindow in the mainwin_list
4043 MainWindow *mainwindow_get_mainwindow(void)
4045 if (mainwin_list && mainwin_list->data)
4046 return (MainWindow *)(mainwin_list->data);
4051 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4053 ProgressData *data = (ProgressData *) source;
4054 MainWindow *mainwin = (MainWindow *) userdata;
4056 switch (data->cmd) {
4057 case PROGRESS_COMMAND_START:
4058 case PROGRESS_COMMAND_STOP:
4059 gtk_progress_bar_set_fraction
4060 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4062 case PROGRESS_COMMAND_SET_PERCENTAGE:
4063 gtk_progress_bar_set_fraction
4064 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4067 while (gtk_events_pending()) gtk_main_iteration ();
4072 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4074 mainwindow_check_synchronise(mainwin, FALSE);
4077 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4079 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4082 void mainwindow_jump_to(const gchar *target)
4086 FolderItem *item = NULL;
4088 MainWindow *mainwin = mainwindow_get_mainwindow();
4094 printf("not initialized\n");
4098 tmp = g_strdup(target);
4100 if ((p = strstr(tmp, "\r")) != NULL)
4102 if ((p = strstr(tmp, "\n")) != NULL)
4105 if ((item = folder_find_item_from_identifier(tmp))) {
4106 printf("selecting folder '%s'\n", tmp);
4107 folderview_select(mainwin->folderview, item);
4108 main_window_popup(mainwin);
4113 msg = strrchr(tmp, G_DIR_SEPARATOR);
4116 if ((item = folder_find_item_from_identifier(tmp))) {
4117 printf("selecting folder '%s'\n", tmp);
4118 folderview_select(mainwin->folderview, item);
4120 printf("'%s' not found\n", tmp);
4122 if (item && msg && atoi(msg)) {
4123 printf("selecting message %d\n", atoi(msg));
4124 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4125 summary_display_msg_selected(mainwin->summaryview, FALSE);
4126 main_window_popup(mainwin);
4129 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4130 MsgInfo *msginfo = NULL;
4132 msg[strlen(msg)-1] = '\0';
4133 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4135 printf("selecting message %s\n", msg);
4136 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4137 summary_display_msg_selected(mainwin->summaryview, FALSE);
4138 main_window_popup(mainwin);
4140 procmsg_msginfo_free(msginfo);
4143 printf("'%s' not found\n", msg);
4146 printf("'%s' not found\n", msg);
4149 printf("'%s' not found\n", tmp);