2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws 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,
394 static void create_filter_cb (MainWindow *mainwin,
397 static void create_processing_cb (MainWindow *mainwin,
401 static void prefs_template_open_cb (MainWindow *mainwin,
404 static void prefs_actions_open_cb (MainWindow *mainwin,
407 static void prefs_account_open_cb (MainWindow *mainwin,
411 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
415 static void prefs_post_processing_open_cb (MainWindow *mainwin,
419 static void prefs_filtering_open_cb (MainWindow *mainwin,
423 static void ssl_manager_open_cb (MainWindow *mainwin,
427 static void new_account_cb (MainWindow *mainwin,
431 static void account_selector_menu_cb (GtkMenuItem *menuitem,
433 static void account_receive_menu_cb (GtkMenuItem *menuitem,
435 static void account_compose_menu_cb (GtkMenuItem *menuitem,
438 static void prefs_open_cb (GtkMenuItem *menuitem,
440 static void plugins_open_cb (GtkMenuItem *menuitem,
443 static void online_switch_clicked(GtkButton *btn,
446 static void manual_open_cb (MainWindow *mainwin,
450 static void legend_open_cb (GtkMenuItem *menuitem,
453 static void scan_tree_func (Folder *folder,
457 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
459 static void addr_harvest_cb ( MainWindow *mainwin,
463 static void addr_harvest_msg_cb ( MainWindow *mainwin,
466 static void sync_cb ( MainWindow *mainwin,
470 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
471 GdkEventFocus *focus,
473 void main_window_reply_cb (MainWindow *mainwin,
476 gboolean mainwindow_progressindicator_hook (gpointer source,
479 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
482 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
484 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
486 static void mailing_list_compose(GtkWidget *w, gpointer *data);
488 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
489 #define SEPARATE_ACTION 500
490 static void mainwindow_quicksearch (MainWindow *mainwin,
494 static GtkItemFactoryEntry mainwin_entries[] =
496 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
498 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
499 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
501 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
503 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
504 {N_("/_File/Exp_ort selected to mbox file..."),
505 NULL, export_list_mbox_cb, 0, NULL},
506 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
508 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
509 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
510 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
511 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
513 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
514 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
515 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
516 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
518 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
519 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
520 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
521 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
522 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_Edit/_Find in current message..."),
524 "<control>F", search_cb, 0, NULL},
525 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
526 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
527 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
528 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
529 {N_("/_View/Show or hi_de/_Folder tree"),
530 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
531 {N_("/_View/Show or hi_de/_Message view"),
532 "V", toggle_message_cb, 0, "<ToggleItem>"},
533 {N_("/_View/Show or hi_de/_Toolbar"),
534 NULL, NULL, 0, "<Branch>"},
535 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
536 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
537 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
538 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
539 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
540 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
541 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
542 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
543 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
544 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
545 {N_("/_View/Show or hi_de/Status _bar"),
546 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
547 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
548 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
549 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
551 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
553 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
554 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
555 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
556 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
557 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
558 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
559 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
560 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
561 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
562 {N_("/_View/_Sort/by _color label"),
563 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
564 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
565 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
566 {N_("/_View/_Sort/by a_ttachment"),
567 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
568 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
569 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
570 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
571 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
572 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
573 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
574 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_View/_Sort/_Attract by subject"),
576 NULL, attract_by_subject_cb, 0, NULL},
577 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
578 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
579 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
580 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
582 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
584 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
585 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
586 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_View/_Go to/P_revious unread message"),
588 "<shift>P", prev_unread_cb, 0, NULL},
589 {N_("/_View/_Go to/N_ext unread message"),
590 "<shift>N", next_unread_cb, 0, NULL},
591 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
593 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
594 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Go to/Previous _marked message"),
596 NULL, prev_marked_cb, 0, NULL},
597 {N_("/_View/_Go to/Next m_arked message"),
598 NULL, next_marked_cb, 0, NULL},
599 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
600 {N_("/_View/_Go to/Previous _labeled message"),
601 NULL, prev_labeled_cb, 0, NULL},
602 {N_("/_View/_Go to/Next la_beled message"),
603 NULL, next_labeled_cb, 0, NULL},
604 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_View/_Go to/Last read message"),
606 NULL, last_read_cb, 0, NULL},
607 {N_("/_View/_Go to/Parent message"),
608 "<control>Up", parent_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
611 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
612 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
614 #define ENC_SEPARATOR \
615 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
616 #define ENC_ACTION(action) \
617 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
619 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
620 {N_("/_View/Character _encoding/_Auto detect"),
621 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
622 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
624 ENC_ACTION(C_US_ASCII)},
625 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
626 ENC_ACTION(C_UTF_8)},
629 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
630 ENC_ACTION(C_ISO_8859_1)},
631 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
632 ENC_ACTION(C_ISO_8859_15)},
633 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
634 ENC_ACTION(C_WINDOWS_1252)},
637 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
638 ENC_ACTION(C_ISO_8859_2)},
641 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
642 ENC_ACTION(C_ISO_8859_13)},
643 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
644 ENC_ACTION(C_ISO_8859_4)},
647 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
648 ENC_ACTION(C_ISO_8859_7)},
651 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
652 ENC_ACTION(C_ISO_8859_8)},
653 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
654 ENC_ACTION(C_CP1255)},
657 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
658 ENC_ACTION(C_ISO_8859_6)},
659 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
660 ENC_ACTION(C_CP1256)},
663 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
664 ENC_ACTION(C_ISO_8859_9)},
667 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
668 ENC_ACTION(C_ISO_8859_5)},
669 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
670 ENC_ACTION(C_KOI8_R)},
671 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
672 ENC_ACTION(C_KOI8_U)},
673 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
674 ENC_ACTION(C_CP1251)},
677 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
678 ENC_ACTION(C_ISO_2022_JP)},
679 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
680 ENC_ACTION(C_ISO_2022_JP_2)},
681 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
682 ENC_ACTION(C_EUC_JP)},
683 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
684 ENC_ACTION(C_SHIFT_JIS)},
687 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
688 ENC_ACTION(C_GB2312)},
689 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
691 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
693 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
694 ENC_ACTION(C_EUC_TW)},
695 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
696 ENC_ACTION(C_ISO_2022_CN)},
699 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
700 ENC_ACTION(C_EUC_KR)},
701 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
702 ENC_ACTION(C_ISO_2022_KR)},
705 {N_("/_View/Character _encoding/Thai (TIS-620)"),
706 ENC_ACTION(C_TIS_620)},
707 {N_("/_View/Character _encoding/Thai (Windows-874)"),
708 ENC_ACTION(C_WINDOWS_874)},
713 #define DEC_SEPARATOR \
714 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
715 #define DEC_ACTION(action) \
716 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
717 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_View/Decode/_Auto detect"),
719 NULL, set_decode_cb, 0, "<RadioItem>"},
720 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
721 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
722 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
723 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
724 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
729 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
731 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
732 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
733 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
734 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
735 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
736 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
737 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
738 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
740 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
741 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
742 {N_("/_Message/Recei_ve/Get from _current account"),
743 "<control>I", inc_mail_cb, 0, NULL},
744 {N_("/_Message/Recei_ve/Get from _all accounts"),
745 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
746 {N_("/_Message/Recei_ve/Cancel receivin_g"),
747 NULL, inc_cancel_cb, 0, NULL},
748 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
749 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
750 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
751 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
752 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
753 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
754 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
755 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
756 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
757 {N_("/_Message/Repl_y to/mailing _list"),
758 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
759 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
760 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
762 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
763 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
765 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
766 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
767 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
768 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
769 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
770 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
771 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
773 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
774 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
775 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
776 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
777 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
778 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
779 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
780 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
781 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
782 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
783 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
784 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
785 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
786 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
787 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
788 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
789 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
790 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
791 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
792 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
793 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
794 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
795 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
796 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
797 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
799 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
800 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
801 {N_("/_Tools/Add sender to address boo_k"),
802 NULL, add_address_cb, 0, NULL},
803 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
804 {N_("/_Tools/_Harvest addresses/from _Folder..."),
805 NULL, addr_harvest_cb, 0, NULL},
806 {N_("/_Tools/_Harvest addresses/from _Messages..."),
807 NULL, addr_harvest_msg_cb, 0, NULL},
808 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
809 {N_("/_Tools/_Filter all messages in folder"),
810 NULL, filter_cb, 0, NULL},
811 {N_("/_Tools/Filter _selected messages"),
812 NULL, filter_cb, 1, NULL},
813 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
814 {N_("/_Tools/_Create filter rule/_Automatically"),
815 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
816 {N_("/_Tools/_Create filter rule/by _From"),
817 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
818 {N_("/_Tools/_Create filter rule/by _To"),
819 NULL, create_filter_cb, FILTER_BY_TO, NULL},
820 {N_("/_Tools/_Create filter rule/by _Subject"),
821 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
822 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
823 {N_("/_Tools/C_reate processing rule/_Automatically"),
824 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
825 {N_("/_Tools/C_reate processing rule/by _From"),
826 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
827 {N_("/_Tools/C_reate processing rule/by _To"),
828 NULL, create_processing_cb, FILTER_BY_TO, NULL},
829 {N_("/_Tools/C_reate processing rule/by _Subject"),
830 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
831 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
832 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
833 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
834 {N_("/_Tools/Ch_eck for new messages in all folders"),
835 NULL, update_folderview_cb, 0, NULL},
836 {N_("/_Tools/Delete du_plicated messages"),
837 NULL, NULL, 0, "<Branch>"},
838 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
839 NULL, delete_duplicated_cb, 0, NULL},
840 {N_("/_Tools/Delete du_plicated messages/In all folders"),
841 NULL, delete_duplicated_all_cb, 0, NULL},
842 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
843 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
845 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
846 {N_("/_Tools/SSL cer_tificates..."),
847 NULL, ssl_manager_open_cb, 0, NULL},
849 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
850 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
852 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
853 {N_("/_Configuration/C_hange current account"),
854 NULL, NULL, 0, "<Branch>"},
855 {N_("/_Configuration/_Preferences for current account..."),
856 NULL, prefs_account_open_cb, 0, NULL},
857 {N_("/_Configuration/Create _new account..."),
858 NULL, new_account_cb, 0, NULL},
859 {N_("/_Configuration/_Edit accounts..."),
860 NULL, account_edit_open, 0, NULL},
861 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
862 {N_("/_Configuration/P_references..."),
863 NULL, prefs_open_cb, 0, NULL},
864 {N_("/_Configuration/Pre-pr_ocessing..."),
865 NULL, prefs_pre_processing_open_cb, 0, NULL},
866 {N_("/_Configuration/Post-pro_cessing..."),
867 NULL, prefs_post_processing_open_cb, 0, NULL},
868 {N_("/_Configuration/_Filtering..."),
869 NULL, prefs_filtering_open_cb, 0, NULL},
870 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
871 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
872 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
874 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
875 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
876 {N_("/_Help/_Online User-contributed FAQ"),
877 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
878 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
879 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
880 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
883 static gboolean offline_ask_sync = TRUE;
884 static guint lastkey;
886 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
892 MainWindow *mainwin = (MainWindow *)user_data;
894 if (mainwin->summaryview &&
895 mainwin->summaryview->quicksearch &&
896 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
897 (mod == 0 || mod == GDK_SHIFT_MASK)) {
898 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
904 #define N_COLOR_LABELS colorlabel_get_color_count()
906 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
911 GtkCheckMenuItem **items;
915 mainwin = (MainWindow *)data;
916 g_return_if_fail(mainwin != NULL);
918 sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
921 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
922 g_return_if_fail(menu != NULL);
924 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
926 /* NOTE: don't return prematurely because we set the "dont_toggle"
927 * state for check menu items */
928 g_object_set_data(G_OBJECT(menu), "dont_toggle",
931 /* clear items. get item pointers. */
932 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
933 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
934 gtk_check_menu_item_set_active
935 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
936 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
941 if (n == (N_COLOR_LABELS + 1)) {
942 /* iterate all messages and set the state of the appropriate
944 for (; sel != NULL; sel = sel->next) {
948 msginfo = gtk_ctree_node_get_row_data
949 (GTK_CTREE(mainwin->summaryview->ctree),
950 GTK_CTREE_NODE(sel->data));
952 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
953 if (!items[clabel]->active)
954 gtk_check_menu_item_set_active
955 (items[clabel], TRUE);
959 g_warning("invalid number of color elements (%d)\n", n);
961 /* reset "dont_toggle" state */
962 g_object_set_data(G_OBJECT(menu), "dont_toggle",
966 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
969 guint color = GPOINTER_TO_UINT(data);
972 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
973 g_return_if_fail(mainwin != NULL);
975 /* "dont_toggle" state set? */
976 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
980 summary_set_colorlabel(mainwin->summaryview, color, NULL);
983 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
985 GtkWidget *label_menuitem;
990 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
991 "/Message/Color label");
992 g_signal_connect(G_OBJECT(label_menuitem), "activate",
993 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
995 gtk_widget_show(label_menuitem);
997 menu = gtk_menu_new();
999 /* create sub items. for the menu item activation callback we pass the
1000 * index of label_colors[] as data parameter. for the None color we
1001 * pass an invalid (high) value. also we attach a data pointer so we
1002 * can always get back the Mainwindow pointer. */
1004 item = gtk_check_menu_item_new_with_label(_("None"));
1005 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1006 g_signal_connect(G_OBJECT(item), "activate",
1007 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1008 GUINT_TO_POINTER(0));
1009 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1010 gtk_widget_show(item);
1012 gtk_widget_add_accelerator(item, "activate",
1013 mainwin->menu_factory->accel_group,
1014 GDK_0, GDK_CONTROL_MASK,
1015 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1017 item = gtk_menu_item_new();
1018 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1019 gtk_widget_show(item);
1021 /* create pixmap/label menu items */
1022 for (i = 0; i < N_COLOR_LABELS; i++) {
1023 item = colorlabel_create_check_color_menu_item(
1024 i, refresh, MAINWIN_COLORMENU);
1025 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1026 g_signal_connect(G_OBJECT(item), "activate",
1027 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1028 GUINT_TO_POINTER(i + 1));
1029 g_object_set_data(G_OBJECT(item), "mainwin",
1031 gtk_widget_show(item);
1032 gtk_widget_add_accelerator(item, "activate",
1033 mainwin->menu_factory->accel_group,
1034 GDK_1+i, GDK_CONTROL_MASK,
1035 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1038 gtk_widget_show(menu);
1039 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1040 mainwin->colorlabel_menu = menu;
1043 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1044 MainWindow *mainwindow)
1046 if (evt && evt->button == 1) {
1047 log_window_show_error(mainwindow->logwin);
1048 gtk_widget_hide(mainwindow->warning_btn);
1053 static gboolean warning_visi_notify(GtkWidget *widget,
1054 GdkEventVisibility *event,
1055 MainWindow *mainwindow)
1057 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1061 static gboolean warning_leave_notify(GtkWidget *widget,
1062 GdkEventCrossing *event,
1063 MainWindow *mainwindow)
1065 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1069 static gboolean warning_enter_notify(GtkWidget *widget,
1070 GdkEventCrossing *event,
1071 MainWindow *mainwindow)
1073 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1077 void mainwindow_show_error(void)
1079 MainWindow *mainwin = mainwindow_get_mainwindow();
1080 gtk_widget_show(mainwin->warning_btn);
1083 void mainwindow_clear_error(MainWindow *mainwin)
1085 gtk_widget_hide(mainwin->warning_btn);
1088 MainWindow *main_window_create(SeparateType type)
1090 MainWindow *mainwin;
1094 GtkWidget *handlebox;
1095 GtkWidget *vbox_body;
1096 GtkWidget *hbox_stat;
1097 GtkWidget *statusbar;
1098 GtkWidget *progressbar;
1099 GtkWidget *statuslabel;
1100 GtkWidget *ac_button;
1101 GtkWidget *ac_label;
1102 GtkWidget *online_pixmap;
1103 GtkWidget *offline_pixmap;
1104 GtkWidget *online_switch;
1105 GtkWidget *offline_switch;
1107 GtkWidget *warning_icon;
1108 GtkWidget *warning_btn;
1110 FolderView *folderview;
1111 SummaryView *summaryview;
1112 MessageView *messageview;
1113 GdkColormap *colormap;
1115 gboolean success[4];
1116 GtkItemFactory *ifactory;
1118 GtkWidget *menuitem;
1120 guint n_menu_entries;
1122 static GdkGeometry geometry;
1124 debug_print("Creating main window...\n");
1125 mainwin = g_new0(MainWindow, 1);
1128 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1129 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1130 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1132 if (!geometry.min_height) {
1133 geometry.min_width = 320;
1134 geometry.min_height = 200;
1136 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1139 g_signal_connect(G_OBJECT(window), "delete_event",
1140 G_CALLBACK(main_window_close_cb), mainwin);
1141 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1142 g_signal_connect(G_OBJECT(window), "focus_in_event",
1143 G_CALLBACK(mainwindow_focus_in_event),
1145 g_signal_connect(G_OBJECT(window), "key_press_event",
1146 G_CALLBACK(mainwindow_key_pressed), mainwin);
1148 gtk_widget_realize(window);
1149 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1152 gtkut_widget_set_app_icon(window);
1154 vbox = gtk_vbox_new(FALSE, 0);
1155 gtk_widget_show(vbox);
1156 gtk_container_add(GTK_CONTAINER(window), vbox);
1159 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1160 menubar = menubar_create(window, mainwin_entries,
1161 n_menu_entries, "<Main>", mainwin);
1162 gtk_widget_show(menubar);
1163 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1164 ifactory = gtk_item_factory_from_widget(menubar);
1166 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1167 main_create_mailing_list_menu (mainwin, NULL); */
1169 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1171 if (prefs_common.toolbar_detachable) {
1172 handlebox = gtk_handle_box_new();
1173 gtk_widget_show(handlebox);
1174 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1175 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1176 G_CALLBACK(toolbar_child_attached), mainwin);
1177 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1178 G_CALLBACK(toolbar_child_detached), mainwin);
1180 handlebox = gtk_hbox_new(FALSE, 0);
1181 gtk_widget_show(handlebox);
1182 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1184 /* link window to mainwin->window to avoid gdk warnings */
1185 mainwin->window = window;
1187 /* create toolbar */
1188 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1191 toolbar_set_learn_button
1195 /* vbox that contains body */
1196 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1197 gtk_widget_show(vbox_body);
1198 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1199 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1201 hbox_stat = gtk_hbox_new(FALSE, 2);
1202 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1204 tips = gtk_tooltips_new();
1206 warning_icon = gtk_image_new_from_stock
1207 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1208 warning_btn = gtk_event_box_new();
1209 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1211 mainwin->warning_btn = warning_btn;
1213 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1214 G_CALLBACK(warning_icon_pressed),
1215 (gpointer) mainwin);
1216 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1217 G_CALLBACK(warning_visi_notify), mainwin);
1218 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1219 G_CALLBACK(warning_visi_notify), mainwin);
1220 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1221 G_CALLBACK(warning_leave_notify), mainwin);
1222 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1223 G_CALLBACK(warning_enter_notify), mainwin);
1225 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1227 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1228 _("Some error(s) happened. Click here to view log."), NULL);
1229 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1231 statusbar = statusbar_create();
1232 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1234 progressbar = gtk_progress_bar_new();
1235 gtk_widget_set_size_request(progressbar, 120, 1);
1236 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1238 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1239 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1240 online_switch = gtk_button_new ();
1241 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1242 _("You are online. Click the icon to go offline"), NULL);
1243 offline_switch = gtk_button_new ();
1244 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1245 _("You are offline. Click the icon to go online"),
1247 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1248 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1249 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1250 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1251 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1252 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1253 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1254 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1256 statuslabel = gtk_label_new("");
1257 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1259 ac_button = gtk_button_new();
1260 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1261 ac_button, _("Select account"), NULL);
1262 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1263 gtk_widget_set_size_request(ac_button, -1, 0);
1264 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1265 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1266 G_CALLBACK(ac_label_button_pressed), mainwin);
1268 ac_label = gtk_label_new("");
1269 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1271 gtk_widget_show_all(hbox_stat);
1273 gtk_widget_hide(offline_switch);
1274 gtk_widget_hide(warning_btn);
1276 mainwin->folderview = folderview = folderview_create();
1277 mainwin->summaryview = summaryview = summary_create();
1278 mainwin->messageview = messageview = messageview_create(mainwin);
1279 mainwin->logwin = log_window_create();
1281 log_window_init(mainwin->logwin);
1282 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1283 prefs_common.loglength);
1285 folderview->mainwin = mainwin;
1286 folderview->summaryview = summaryview;
1288 summaryview->mainwin = mainwin;
1289 summaryview->folderview = folderview;
1290 summaryview->messageview = messageview;
1291 summaryview->window = window;
1293 messageview->statusbar = statusbar;
1294 mainwin->vbox = vbox;
1295 mainwin->menubar = menubar;
1296 mainwin->menu_factory = ifactory;
1297 mainwin->handlebox = handlebox;
1298 mainwin->vbox_body = vbox_body;
1299 mainwin->hbox_stat = hbox_stat;
1300 mainwin->statusbar = statusbar;
1301 mainwin->progressbar = progressbar;
1302 mainwin->statuslabel = statuslabel;
1303 mainwin->online_switch = online_switch;
1304 mainwin->online_pixmap = online_pixmap;
1305 mainwin->offline_pixmap = offline_pixmap;
1306 mainwin->ac_button = ac_button;
1307 mainwin->ac_label = ac_label;
1308 mainwin->offline_switch = offline_switch;
1310 /* set context IDs for status bar */
1311 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1312 (GTK_STATUSBAR(statusbar), "Main Window");
1313 mainwin->folderview_cid = gtk_statusbar_get_context_id
1314 (GTK_STATUSBAR(statusbar), "Folder View");
1315 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1316 (GTK_STATUSBAR(statusbar), "Summary View");
1317 mainwin->messageview_cid = gtk_statusbar_get_context_id
1318 (GTK_STATUSBAR(statusbar), "Message View");
1320 messageview->statusbar_cid = mainwin->messageview_cid;
1322 /* allocate colors for summary view and folder view */
1323 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1324 summaryview->color_marked.blue = (guint16)65535;
1326 summaryview->color_dim.red = summaryview->color_dim.green =
1327 summaryview->color_dim.blue = COLOR_DIM;
1329 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1330 &folderview->color_new);
1332 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1333 &folderview->color_op);
1335 summaryview->color_important.red = 0;
1336 summaryview->color_important.green = 0;
1337 summaryview->color_important.blue = (guint16)65535;
1339 color[0] = summaryview->color_marked;
1340 color[1] = summaryview->color_dim;
1341 color[2] = folderview->color_new;
1342 color[3] = folderview->color_op;
1344 colormap = gdk_drawable_get_colormap(window->window);
1345 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1346 for (i = 0; i < 4; i++) {
1347 if (success[i] == FALSE)
1348 g_warning("MainWindow: color allocation %d failed\n", i);
1351 debug_print("done.\n");
1353 messageview->visible = prefs_common.msgview_visible;
1355 main_window_set_widgets(mainwin, type);
1357 g_signal_connect(G_OBJECT(window), "size_allocate",
1358 G_CALLBACK(main_window_size_allocate_cb),
1361 /* set menu items */
1362 menuitem = gtk_item_factory_get_item
1363 (ifactory, "/View/Character encoding/Auto detect");
1364 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1366 switch (prefs_common.toolbar_style) {
1368 menuitem = gtk_item_factory_get_item
1369 (ifactory, "/View/Show or hide/Toolbar/Hide");
1372 menuitem = gtk_item_factory_get_item
1373 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1376 menuitem = gtk_item_factory_get_item
1377 (ifactory, "/View/Show or hide/Toolbar/Text only");
1380 menuitem = gtk_item_factory_get_item
1381 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1383 case TOOLBAR_BOTH_HORIZ:
1384 menuitem = gtk_item_factory_get_item
1386 "/View/Show or hide/Toolbar/Text beside icons");
1388 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1390 gtk_widget_hide(mainwin->hbox_stat);
1391 menuitem = gtk_item_factory_get_item
1392 (ifactory, "/View/Show or hide/Status bar");
1393 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1394 prefs_common.show_statusbar);
1396 /* set account selection menu */
1397 ac_menu = gtk_item_factory_get_widget
1398 (ifactory, "/Configuration/Change current account");
1399 mainwin->ac_menu = ac_menu;
1401 toolbar_main_set_sensitive(mainwin);
1403 /* create actions menu */
1404 main_window_update_actions_menu(mainwin);
1406 main_create_mailing_list_menu (mainwin, NULL);
1408 /* attach accel groups to main window */
1409 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1410 gtk_window_add_accel_group \
1412 gtk_item_factory_from_widget(menu)->accel_group); \
1413 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1415 G_CALLBACK(main_window_accel_activate), mainwin);
1418 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1420 /* connect the accelerators for equivalent
1421 menu items in different menus */
1422 menu_connect_identical_items();
1425 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1427 gtk_widget_show(mainwin->window);
1429 /* initialize views */
1430 folderview_init(folderview);
1431 summary_init(summaryview);
1432 messageview_init(messageview);
1434 sslcertwindow_register_hook();
1436 mainwin->lock_count = 0;
1437 mainwin->menu_lock_count = 0;
1438 mainwin->cursor_count = 0;
1440 mainwin->progressindicator_hook =
1441 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1444 watch_cursor = gdk_cursor_new(GDK_WATCH);
1446 hand_cursor = gdk_cursor_new(GDK_HAND2);
1448 mainwin_list = g_list_append(mainwin_list, mainwin);
1450 /* init work_offline */
1451 if (prefs_common.work_offline)
1452 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1454 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1459 void main_window_destroy(MainWindow *mainwin)
1461 /* TODO : destroy other component */
1462 messageview_destroy(mainwin->messageview);
1463 mainwin->messageview = NULL;
1466 void main_window_update_actions_menu(MainWindow *mainwin)
1468 GtkItemFactory *ifactory;
1470 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1471 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1474 void main_window_cursor_wait(MainWindow *mainwin)
1477 if (mainwin->cursor_count == 0) {
1478 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1479 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1482 mainwin->cursor_count++;
1487 void main_window_cursor_normal(MainWindow *mainwin)
1489 if (mainwin->cursor_count)
1490 mainwin->cursor_count--;
1492 if (mainwin->cursor_count == 0) {
1493 gdk_window_set_cursor(mainwin->window->window, NULL);
1494 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1499 /* lock / unlock the user-interface */
1500 void main_window_lock(MainWindow *mainwin)
1502 if (mainwin->lock_count == 0)
1503 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1505 mainwin->lock_count++;
1507 main_window_set_menu_sensitive(mainwin);
1508 toolbar_main_set_sensitive(mainwin);
1511 void main_window_unlock(MainWindow *mainwin)
1513 if (mainwin->lock_count)
1514 mainwin->lock_count--;
1516 main_window_set_menu_sensitive(mainwin);
1517 toolbar_main_set_sensitive(mainwin);
1519 if (mainwin->lock_count == 0)
1520 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1523 static void main_window_menu_callback_block(MainWindow *mainwin)
1525 mainwin->menu_lock_count++;
1528 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1530 if (mainwin->menu_lock_count)
1531 mainwin->menu_lock_count--;
1534 static guint prefs_tag = 0;
1536 void main_window_reflect_prefs_all(void)
1538 main_window_reflect_prefs_all_real(FALSE);
1541 static gboolean reflect_prefs_timeout_cb(gpointer data)
1543 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1545 MainWindow *mainwin;
1548 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1549 mainwin = (MainWindow *)cur->data;
1551 main_window_show_cur_account(mainwin);
1552 main_window_set_menu_sensitive(mainwin);
1553 toolbar_main_set_sensitive(mainwin);
1556 if (pixmap_theme_changed) {
1557 toolbar_update(TOOLBAR_MAIN, mainwin);
1558 messageview_reflect_prefs_pixmap_theme();
1559 compose_reflect_prefs_pixmap_theme();
1560 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1561 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1563 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1564 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1565 mainwin->online_pixmap);
1566 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1567 gtk_widget_show(pixmap);
1568 mainwin->online_pixmap = pixmap;
1569 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1570 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1571 mainwin->offline_pixmap);
1572 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1573 gtk_widget_show(pixmap);
1574 mainwin->offline_pixmap = pixmap;
1577 headerview_set_font(mainwin->messageview->headerview);
1578 headerview_set_visibility(mainwin->messageview->headerview,
1579 prefs_common.display_header_pane);
1580 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1581 folderview_reflect_prefs();
1582 summary_reflect_prefs();
1583 summary_redisplay_msg(mainwin->summaryview);
1589 void main_window_reflect_prefs_all_now(void)
1591 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1594 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1599 /* re-create colorlabel submenu */
1600 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1601 g_return_if_fail(menu != NULL);
1603 /* clear items. get item pointers. */
1604 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1605 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1607 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1608 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1612 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1614 if (prefs_tag == 0 || pixmap_theme_changed) {
1615 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1616 GINT_TO_POINTER(pixmap_theme_changed));
1620 void main_window_set_summary_column(void)
1623 MainWindow *mainwin;
1625 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1626 mainwin = (MainWindow *)cur->data;
1627 summary_set_column_order(mainwin->summaryview);
1631 void main_window_set_folder_column(void)
1634 MainWindow *mainwin;
1636 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1637 mainwin = (MainWindow *)cur->data;
1638 folderview_set_column_order(mainwin->folderview);
1642 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1643 GList *account_list)
1645 GList *cur_ac, *cur_item;
1646 GtkWidget *menuitem;
1647 PrefsAccount *ac_prefs;
1649 /* destroy all previous menu item */
1650 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1651 while (cur_item != NULL) {
1652 GList *next = cur_item->next;
1653 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1657 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1658 ac_prefs = (PrefsAccount *)cur_ac->data;
1660 menuitem = gtk_menu_item_new_with_label
1661 (ac_prefs->account_name
1662 ? ac_prefs->account_name : _("Untitled"));
1663 gtk_widget_show(menuitem);
1664 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1665 g_signal_connect(G_OBJECT(menuitem), "activate",
1666 G_CALLBACK(account_selector_menu_cb),
1671 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1672 GList *account_list)
1674 GList *cur_ac, *cur_item;
1676 GtkWidget *menuitem;
1677 PrefsAccount *ac_prefs;
1679 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1680 "/Message/Receive");
1682 /* search for separator */
1683 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1684 cur_item = cur_item->next) {
1685 if (GTK_BIN(cur_item->data)->child == NULL) {
1686 cur_item = cur_item->next;
1691 /* destroy all previous menu item */
1692 while (cur_item != NULL) {
1693 GList *next = cur_item->next;
1694 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1698 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1699 ac_prefs = (PrefsAccount *)cur_ac->data;
1701 menuitem = gtk_menu_item_new_with_label
1702 (ac_prefs->account_name ? ac_prefs->account_name
1704 gtk_widget_show(menuitem);
1705 gtk_menu_append(GTK_MENU(menu), menuitem);
1706 g_signal_connect(G_OBJECT(menuitem), "activate",
1707 G_CALLBACK(account_receive_menu_cb),
1712 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1713 GList *account_list)
1715 GList *cur_ac, *cur_item;
1716 GtkWidget *menuitem;
1717 PrefsAccount *ac_prefs;
1718 GtkWidget *menu = NULL;
1720 if (mainwin->toolbar->getall_btn == NULL
1721 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1724 menu = mainwin->toolbar->getall_combo->menu;
1726 /* destroy all previous menu item */
1727 cur_item = GTK_MENU_SHELL(menu)->children;
1728 while (cur_item != NULL) {
1729 GList *next = cur_item->next;
1730 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1734 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1735 ac_prefs = (PrefsAccount *)cur_ac->data;
1737 menuitem = gtk_menu_item_new_with_label
1738 (ac_prefs->account_name
1739 ? ac_prefs->account_name : _("Untitled"));
1740 gtk_widget_show(menuitem);
1741 gtk_menu_append(GTK_MENU(menu), menuitem);
1742 g_signal_connect(G_OBJECT(menuitem), "activate",
1743 G_CALLBACK(account_receive_menu_cb),
1748 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1749 GList *account_list)
1751 GList *cur_ac, *cur_item;
1752 GtkWidget *menuitem;
1753 PrefsAccount *ac_prefs;
1754 GtkWidget *menu = NULL;
1756 if (mainwin->toolbar->compose_mail_btn == NULL
1757 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1760 menu = mainwin->toolbar->compose_combo->menu;
1762 /* destroy all previous menu item */
1763 cur_item = GTK_MENU_SHELL(menu)->children;
1764 while (cur_item != NULL) {
1765 GList *next = cur_item->next;
1766 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1770 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1771 ac_prefs = (PrefsAccount *)cur_ac->data;
1773 menuitem = gtk_menu_item_new_with_label
1774 (ac_prefs->account_name
1775 ? ac_prefs->account_name : _("Untitled"));
1776 gtk_widget_show(menuitem);
1777 gtk_menu_append(GTK_MENU(menu), menuitem);
1778 g_signal_connect(G_OBJECT(menuitem), "activate",
1779 G_CALLBACK(account_compose_menu_cb),
1784 void main_window_set_account_menu(GList *account_list)
1787 MainWindow *mainwin;
1789 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1790 mainwin = (MainWindow *)cur->data;
1791 main_window_set_account_selector_menu(mainwin, account_list);
1792 main_window_set_account_receive_menu(mainwin, account_list);
1793 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1794 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1798 void main_window_set_account_menu_only_toolbar(GList *account_list)
1801 MainWindow *mainwin;
1803 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1804 mainwin = (MainWindow *)cur->data;
1805 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1806 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1810 static void main_window_show_cur_account(MainWindow *mainwin)
1815 ac_name = g_strdup(cur_account
1816 ? (cur_account->account_name
1817 ? cur_account->account_name : _("Untitled"))
1821 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1823 buf = g_strdup(PROG_VERSION);
1824 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1827 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1828 gtk_widget_queue_resize(mainwin->ac_button);
1833 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1835 switch (mainwin->type) {
1836 case SEPARATE_FOLDER:
1837 return mainwin->win.sep_folder.folderwin;
1839 return mainwin->win.sep_both.folderwin;
1845 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1847 switch (mainwin->type) {
1848 case SEPARATE_MESSAGE:
1849 return mainwin->win.sep_message.messagewin;
1851 return mainwin->win.sep_both.messagewin;
1857 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1859 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1860 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1861 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1862 GtkWidget *message_wid = mainwin->messageview->vbox;
1864 debug_print("Changing window separation type from %d to %d\n",
1865 mainwin->type, type);
1867 if (mainwin->type == type) return;
1869 /* remove widgets from those containers */
1870 gtk_widget_ref(folder_wid);
1871 gtk_widget_ref(summary_wid);
1872 gtk_widget_ref(message_wid);
1873 gtkut_container_remove
1874 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1875 gtkut_container_remove
1876 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1877 gtkut_container_remove
1878 (GTK_CONTAINER(message_wid->parent), message_wid);
1880 /* clean containers */
1881 switch (mainwin->type) {
1883 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1885 case SEPARATE_FOLDER:
1886 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1887 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1889 case SEPARATE_MESSAGE:
1890 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1891 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1894 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1895 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1899 gtk_widget_hide(mainwin->window);
1900 main_window_set_widgets(mainwin, type);
1901 gtk_widget_show(mainwin->window);
1903 gtk_widget_unref(folder_wid);
1904 gtk_widget_unref(summary_wid);
1905 gtk_widget_unref(message_wid);
1908 void main_window_toggle_message_view(MainWindow *mainwin)
1910 SummaryView *summaryview = mainwin->summaryview;
1911 union CompositeWin *cwin = &mainwin->win;
1912 GtkWidget *vpaned = NULL;
1913 GtkWidget *container = NULL;
1914 GtkWidget *msgwin = NULL;
1916 switch (mainwin->type) {
1918 vpaned = cwin->sep_none.vpaned;
1919 container = cwin->sep_none.hpaned;
1921 case SEPARATE_FOLDER:
1922 vpaned = cwin->sep_folder.vpaned;
1923 container = mainwin->vbox_body;
1925 case SEPARATE_MESSAGE:
1926 msgwin = mainwin->win.sep_message.messagewin;
1929 msgwin = mainwin->win.sep_both.messagewin;
1934 if (GTK_WIDGET_VISIBLE(msgwin)) {
1935 gtk_widget_hide(msgwin);
1936 mainwin->messageview->visible = FALSE;
1937 summaryview->displayed = NULL;
1939 gtk_widget_show(msgwin);
1940 mainwin->messageview->visible = TRUE;
1942 } else if (vpaned->parent != NULL) {
1943 mainwin->messageview->visible = FALSE;
1944 summaryview->displayed = NULL;
1945 gtk_widget_ref(vpaned);
1946 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1947 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1949 mainwin->messageview->visible = TRUE;
1950 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1951 gtk_container_add(GTK_CONTAINER(container), vpaned);
1952 gtk_widget_unref(vpaned);
1955 if (messageview_is_visible(mainwin->messageview))
1956 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1957 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1959 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1960 GTK_ARROW_UP, GTK_SHADOW_OUT);
1962 if (mainwin->messageview->visible == FALSE)
1963 messageview_clear(mainwin->messageview);
1965 main_window_set_menu_sensitive(mainwin);
1967 prefs_common.msgview_visible = mainwin->messageview->visible;
1969 gtk_widget_grab_focus(summaryview->ctree);
1972 void main_window_get_size(MainWindow *mainwin)
1974 GtkAllocation *allocation;
1976 if (mainwin_list == NULL || mainwin->messageview == NULL) {
1977 debug_print("called after messageview "
1978 "has been deallocated!\n");
1982 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1984 if (allocation->width > 1 && allocation->height > 1) {
1985 prefs_common.summaryview_width = allocation->width;
1987 if ((mainwin->type == SEPARATE_NONE ||
1988 mainwin->type == SEPARATE_FOLDER) &&
1989 messageview_is_visible(mainwin->messageview))
1990 prefs_common.summaryview_height = allocation->height;
1992 prefs_common.mainview_width = allocation->width;
1995 allocation = &mainwin->window->allocation;
1996 if (allocation->width > 1 && allocation->height > 1) {
1997 prefs_common.mainview_height = allocation->height;
1998 prefs_common.mainwin_width = allocation->width;
1999 prefs_common.mainwin_height = allocation->height;
2002 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2003 if (allocation->width > 1 && allocation->height > 1) {
2004 prefs_common.folderview_width = allocation->width;
2005 prefs_common.folderview_height = allocation->height;
2008 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2009 if (allocation->width > 1 && allocation->height > 1) {
2010 prefs_common.msgview_width = allocation->width;
2011 prefs_common.msgview_height = allocation->height;
2014 /* debug_print("summaryview size: %d x %d\n",
2015 prefs_common.summaryview_width,
2016 prefs_common.summaryview_height);
2017 debug_print("folderview size: %d x %d\n",
2018 prefs_common.folderview_width,
2019 prefs_common.folderview_height);
2020 debug_print("messageview size: %d x %d\n",
2021 prefs_common.msgview_width,
2022 prefs_common.msgview_height); */
2025 void main_window_get_position(MainWindow *mainwin)
2030 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2032 prefs_common.mainview_x = x;
2033 prefs_common.mainview_y = y;
2034 prefs_common.mainwin_x = x;
2035 prefs_common.mainwin_y = y;
2037 debug_print("main window position: %d, %d\n", x, y);
2039 window = main_window_get_folder_window(mainwin);
2041 gtkut_widget_get_uposition(window, &x, &y);
2042 prefs_common.folderwin_x = x;
2043 prefs_common.folderwin_y = y;
2044 debug_print("folder window position: %d, %d\n", x, y);
2046 window = main_window_get_message_window(mainwin);
2048 gtkut_widget_get_uposition(window, &x, &y);
2049 prefs_common.main_msgwin_x = x;
2050 prefs_common.main_msgwin_y = y;
2051 debug_print("message window position: %d, %d\n", x, y);
2055 void main_window_progress_on(MainWindow *mainwin)
2057 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2060 void main_window_progress_off(MainWindow *mainwin)
2062 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2063 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2066 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2070 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2071 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2072 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2073 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2076 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2079 if (alertpanel(_("Empty trash"),
2080 _("Delete all messages in trash folders?"),
2081 GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
2082 != G_ALERTALTERNATE)
2084 manage_window_focus_in(mainwin->window, NULL, NULL);
2087 procmsg_empty_all_trash();
2089 if (mainwin->summaryview->folder_item &&
2090 mainwin->summaryview->folder_item->stype == F_TRASH)
2091 gtk_widget_grab_focus(mainwin->folderview->ctree);
2094 void main_window_add_mailbox(MainWindow *mainwin)
2099 path = input_dialog(_("Add mailbox"),
2100 _("Input the location of mailbox.\n"
2101 "If the existing mailbox is specified, it will be\n"
2102 "scanned automatically."),
2105 if (folder_find_from_path(path)) {
2106 alertpanel_error(_("The mailbox '%s' already exists."), path);
2110 folder = folder_new(folder_get_class_from_string("mh"),
2111 !strcmp(path, "Mail") ? _("Mailbox") :
2112 g_path_get_basename(path), path);
2115 if (folder->klass->create_tree(folder) < 0) {
2116 alertpanel_error(_("Creation of the mailbox failed.\n"
2117 "Maybe some files already exist, or you don't have the permission to write there."));
2118 folder_destroy(folder);
2123 folder_set_ui_func(folder, scan_tree_func, mainwin);
2124 folder_scan_tree(folder, TRUE);
2125 folder_set_ui_func(folder, NULL, NULL);
2128 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2130 SensitiveCond state = 0;
2131 SummarySelection selection;
2132 FolderItem *item = mainwin->summaryview->folder_item;
2133 GList *account_list = account_get_list();
2135 selection = summary_get_selection_type(mainwin->summaryview);
2137 if (mainwin->lock_count == 0)
2138 state |= M_UNLOCKED;
2139 if (selection != SUMMARY_NONE)
2140 state |= M_MSG_EXIST;
2141 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2143 /* if (item->folder->type != F_NEWS) */
2144 state |= M_ALLOW_DELETE;
2146 if (prefs_common.immediate_exec == 0
2147 && mainwin->lock_count == 0)
2148 state |= M_DELAY_EXEC;
2150 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2151 || selection != SUMMARY_NONE)
2152 state |= M_HIDE_READ_MSG;
2154 if (mainwin->summaryview->threaded)
2155 state |= M_THREADED;
2157 state |= M_UNTHREADED;
2158 if (selection == SUMMARY_SELECTED_SINGLE ||
2159 selection == SUMMARY_SELECTED_MULTIPLE)
2160 state |= M_TARGET_EXIST;
2161 if (selection == SUMMARY_SELECTED_SINGLE)
2162 state |= M_SINGLE_TARGET_EXIST;
2163 if (mainwin->summaryview->folder_item &&
2164 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2167 state |= M_NOT_NEWS;
2168 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2169 state |= M_ACTIONS_EXIST;
2171 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2172 state |= M_HAVE_QUEUED_MAILS;
2174 if (selection == SUMMARY_SELECTED_SINGLE &&
2176 (folder_has_parent_of_type(item, F_DRAFT) ||
2177 folder_has_parent_of_type(item, F_OUTBOX) ||
2178 folder_has_parent_of_type(item, F_QUEUE))))
2179 state |= M_ALLOW_REEDIT;
2181 state |= M_HAVE_ACCOUNT;
2183 for ( ; account_list != NULL; account_list = account_list->next) {
2184 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2185 state |= M_HAVE_NEWS_ACCOUNT;
2190 if (procmsg_spam_can_learn()) {
2191 state |= M_CAN_LEARN_SPAM;
2194 if (inc_is_active())
2195 state |= M_INC_ACTIVE;
2197 if (mainwin->summaryview->deleted > 0 ||
2198 mainwin->summaryview->moved > 0 ||
2199 mainwin->summaryview->copied > 0)
2200 state |= M_DELAY_EXEC;
2207 void main_window_set_menu_sensitive(MainWindow *mainwin)
2209 GtkItemFactory *ifactory = mainwin->menu_factory;
2210 SensitiveCond state;
2213 GtkWidget *menuitem;
2214 SummaryView *summaryview;
2219 static const struct {
2223 {"/File/Save as...", M_TARGET_EXIST},
2224 {"/File/Print..." , M_TARGET_EXIST},
2225 {"/File/Exit" , M_UNLOCKED},
2227 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
2228 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2230 {"/View/Sort" , M_EXEC},
2231 {"/View/Thread view" , M_EXEC},
2232 {"/View/Expand all threads" , M_MSG_EXIST},
2233 {"/View/Collapse all threads" , M_MSG_EXIST},
2234 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2235 {"/View/Go to/Previous message" , M_MSG_EXIST},
2236 {"/View/Go to/Next message" , M_MSG_EXIST},
2237 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2238 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2239 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2240 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2241 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2242 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2243 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2244 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2245 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2246 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2247 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2249 {"/Message/Receive/Get from current account"
2250 , M_HAVE_ACCOUNT|M_UNLOCKED},
2251 {"/Message/Receive/Get from all accounts"
2252 , M_HAVE_ACCOUNT|M_UNLOCKED},
2253 {"/Message/Receive/Cancel receiving"
2255 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2256 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2257 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2258 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2259 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2260 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2261 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2262 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2263 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2264 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2265 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2266 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2267 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2268 {"/Message/Mark" , M_TARGET_EXIST},
2269 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2270 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2271 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2272 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2273 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2274 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2275 {"/Message/Color label" , M_TARGET_EXIST},
2276 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2278 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2279 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2280 {"/Tools/Harvest addresses/from Messages..."
2282 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2283 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2284 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2285 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2286 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2287 {"/Tools/Execute" , M_DELAY_EXEC},
2288 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2290 {"/Configuration", M_UNLOCKED},
2295 state = main_window_get_current_state(mainwin);
2297 for (i = 0; entry[i].entry != NULL; i++) {
2298 sensitive = ((entry[i].cond & state) == entry[i].cond);
2299 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2302 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2304 /* search for separator */
2305 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2306 cur_item = cur_item->next) {
2307 if (GTK_BIN(cur_item->data)->child == NULL) {
2308 cur_item = cur_item->next;
2313 for (; cur_item != NULL; cur_item = cur_item->next) {
2314 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2315 (M_UNLOCKED & state) != 0);
2318 main_window_menu_callback_block(mainwin);
2320 #define SET_CHECK_MENU_ACTIVE(path, active) \
2322 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2323 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2326 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2327 messageview_is_visible(mainwin->messageview));
2329 summaryview = mainwin->summaryview;
2330 menu_path = "/View/Sort/Don't sort";
2332 switch (summaryview->sort_key) {
2333 case SORT_BY_NUMBER:
2334 menu_path = "/View/Sort/by number"; break;
2336 menu_path = "/View/Sort/by Size"; break;
2338 menu_path = "/View/Sort/by Date"; break;
2340 menu_path = "/View/Sort/by From"; break;
2342 menu_path = "/View/Sort/by To"; break;
2343 case SORT_BY_SUBJECT:
2344 menu_path = "/View/Sort/by Subject"; break;
2346 menu_path = "/View/Sort/by color label"; break;
2348 menu_path = "/View/Sort/by mark"; break;
2349 case SORT_BY_STATUS:
2350 menu_path = "/View/Sort/by status"; break;
2352 menu_path = "/View/Sort/by attachment"; break;
2354 menu_path = "/View/Sort/by score"; break;
2355 case SORT_BY_LOCKED:
2356 menu_path = "/View/Sort/by locked"; break;
2359 menu_path = "/View/Sort/Don't sort"; break;
2361 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2363 if (summaryview->sort_type == SORT_ASCENDING) {
2364 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2366 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2369 if (summaryview->sort_key != SORT_BY_NONE) {
2370 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2371 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2373 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2374 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2377 if (mainwin->messageview
2378 && mainwin->messageview->mimeview
2379 && mainwin->messageview->mimeview->textview)
2380 SET_CHECK_MENU_ACTIVE("/View/All headers",
2381 mainwin->messageview->mimeview->textview->show_all_headers);
2382 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2383 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2384 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2385 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2386 if (prefs_common.hide_quotes == 1)
2387 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2388 if (prefs_common.hide_quotes == 2)
2389 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2390 if (prefs_common.hide_quotes == 3)
2391 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2393 #undef SET_CHECK_MENU_ACTIVE
2395 main_window_menu_callback_unblock(mainwin);
2398 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2400 GtkItemFactory *ifactory;
2402 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2405 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2407 gtk_widget_set_sensitive (gtk_item_factory_get_item
2408 (ifactory,"/Message/Mailing-List"), TRUE);
2410 gtk_widget_set_sensitive (gtk_item_factory_get_item
2411 (ifactory,"/Message/Mailing-List"), FALSE);
2414 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2417 GtkWidget *menuitem;
2419 if (!msginfo || !msginfo->extradata) {
2420 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2421 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2422 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2423 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2424 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2425 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2429 /* Mailing list post */
2430 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2431 g_free(msginfo->extradata->list_post);
2432 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2434 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2436 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2438 /* Mailing list help */
2439 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2441 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2443 /* Mailing list subscribe */
2444 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2446 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2448 /* Mailing list unsubscribe */
2449 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2451 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2453 /* Mailing list view archive */
2454 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2456 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2458 /* Mailing list contact owner */
2459 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2461 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2466 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2468 GtkWidget *item, *menu;
2469 const gchar *url_pt ;
2470 gchar url_decoded[BUFFSIZE];
2471 GList *amenu, *alist;
2474 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2476 /* First delete old submenu */
2477 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2478 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2479 alist = amenu->next;
2480 item = GTK_WIDGET (amenu->data);
2481 gtk_widget_destroy (item);
2485 for (url_pt = list_header; url_pt && *url_pt;) {
2486 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2488 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2489 item = gtk_menu_item_new_with_label ((url_decoded));
2490 gtk_signal_connect (GTK_OBJECT(item), "activate",
2491 GTK_SIGNAL_FUNC(mailing_list_compose), NULL);
2493 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2494 !g_strncasecmp (url_decoded, "https:",6)) {
2496 item = gtk_menu_item_new_with_label ((url_decoded));
2497 gtk_signal_connect (GTK_OBJECT(item), "activate",
2498 GTK_SIGNAL_FUNC(mailing_list_open_uri), NULL);
2501 gtk_menu_append (GTK_MENU(menu), item);
2502 gtk_widget_show (item);
2508 gtk_widget_set_sensitive (menuitem, TRUE);
2510 gtk_widget_set_sensitive (menuitem, FALSE);
2516 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2518 gchar tmp[BUFFSIZE];
2524 *url_decoded = '\0';
2528 /* Ignore spaces, comments and tabs () */
2529 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2531 for (;*buf != ')' && *buf != 0x00; buf++);
2533 /* First non space and non comment must be a < */
2536 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2541 *url_decoded = '\0';
2546 *url_decoded = '\0';
2552 decode_uri (url_decoded, (const gchar *)tmp);
2554 /* Prepare the work for the next url in the list */
2555 /* after the closing bracket >, ignore space, comments and tabs */
2556 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2558 for (;*buf != ')' && *buf != 0x00; buf++);
2560 if (!buf || !*buf) {
2565 /* now first non space, non comment must be a comma */
2567 for (;*buf != 0x00; buf++);
2573 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2577 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2578 compose_new(NULL, mailto+7, NULL);
2581 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2586 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2587 open_uri (mailto, prefs_common.uri_cmd);
2590 void main_window_popup(MainWindow *mainwin)
2592 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2593 main_window_show(mainwin);
2595 gtkut_window_popup(mainwin->window);
2597 switch (mainwin->type) {
2598 case SEPARATE_FOLDER:
2599 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2601 case SEPARATE_MESSAGE:
2602 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2605 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2606 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2613 void main_window_show(MainWindow *mainwin)
2615 gtk_widget_show(mainwin->window);
2616 gtk_widget_show(mainwin->vbox_body);
2618 gtk_widget_set_uposition(mainwin->window,
2619 prefs_common.mainwin_x,
2620 prefs_common.mainwin_y);
2622 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2623 prefs_common.folderview_width,
2624 prefs_common.folderview_height);
2625 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2626 prefs_common.summaryview_width,
2627 prefs_common.summaryview_height);
2628 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2629 prefs_common.msgview_width,
2630 prefs_common.msgview_height);
2632 if (mainwin->type & SEPARATE_FOLDER) {
2633 GtkWidget *folderwin;
2635 folderwin = main_window_get_folder_window(mainwin);
2636 gtk_widget_show(folderwin);
2637 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2638 prefs_common.folderwin_y);
2641 if (mainwin->type & SEPARATE_MESSAGE) {
2642 GtkWidget *messagewin;
2644 messagewin = main_window_get_message_window(mainwin);
2645 gtk_widget_show(messagewin);
2646 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2647 prefs_common.main_msgwin_y);
2651 void main_window_hide(MainWindow *mainwin)
2653 main_window_get_size(mainwin);
2654 main_window_get_position(mainwin);
2656 gtk_widget_hide(mainwin->window);
2657 gtk_widget_hide(mainwin->vbox_body);
2659 if (mainwin->type & SEPARATE_FOLDER) {
2660 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2663 if (mainwin->type & SEPARATE_MESSAGE) {
2664 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2668 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2670 GtkWidget *folderwin = NULL;
2671 GtkWidget *messagewin = NULL;
2674 GtkWidget *vbox_body = mainwin->vbox_body;
2675 GtkItemFactory *ifactory = mainwin->menu_factory;
2676 GtkWidget *menuitem;
2677 GtkItemFactory *msgview_ifactory;
2679 debug_print("Setting widgets... ");
2681 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2682 prefs_common.folderview_width,
2683 prefs_common.folderview_height);
2684 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2685 prefs_common.summaryview_width,
2686 prefs_common.summaryview_height);
2687 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2688 prefs_common.msgview_width,
2689 prefs_common.msgview_height);
2691 /* create separated window(s) if needed */
2692 if (type & SEPARATE_FOLDER) {
2693 static GdkGeometry folderwin_geometry;
2695 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2696 gtk_window_set_title(GTK_WINDOW(folderwin),
2697 _("Sylpheed-Claws - Folder View"));
2699 gtk_window_move(GTK_WINDOW(folderwin),
2700 prefs_common.folderwin_x,
2701 prefs_common.folderwin_y);
2703 if (!folderwin_geometry.min_height) {
2704 folderwin_geometry.min_width = 320;
2705 folderwin_geometry.min_height = 200;
2707 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2708 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2710 gtk_widget_set_size_request(folderwin,
2711 prefs_common.folderview_width,
2712 prefs_common.folderview_height);
2714 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2717 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2718 G_CALLBACK(folder_window_close_cb),
2720 gtk_container_add(GTK_CONTAINER(folderwin),
2721 GTK_WIDGET_PTR(mainwin->folderview));
2722 gtk_widget_realize(folderwin);
2724 if (prefs_common.folderview_visible)
2725 gtk_widget_show(folderwin);
2728 if (type & SEPARATE_MESSAGE) {
2729 static GdkGeometry msgwin_geometry;
2731 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2732 gtk_window_set_title(GTK_WINDOW(messagewin),
2733 _("Sylpheed-Claws - Message View"));
2735 gtk_window_move(GTK_WINDOW(messagewin),
2736 prefs_common.main_msgwin_x,
2737 prefs_common.main_msgwin_y);
2739 if (!msgwin_geometry.min_height) {
2740 msgwin_geometry.min_width = 320;
2741 msgwin_geometry.min_height = 200;
2743 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2744 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2746 gtk_widget_set_size_request(messagewin,
2747 prefs_common.msgwin_width,
2748 prefs_common.msgwin_height);
2750 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2752 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2753 G_CALLBACK(message_window_close_cb),
2755 if (messageview_is_visible(mainwin->messageview))
2756 gtk_widget_show(messagewin);
2758 mainwin->messageview->statusbar = mainwin->statusbar;
2759 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2764 hpaned = gtk_hpaned_new();
2765 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2766 gtk_paned_add1(GTK_PANED(hpaned),
2767 GTK_WIDGET_PTR(mainwin->folderview));
2768 gtk_widget_show(hpaned);
2769 gtk_widget_queue_resize(hpaned);
2771 vpaned = gtk_vpaned_new();
2772 if (messageview_is_visible(mainwin->messageview)) {
2773 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2774 gtk_paned_add1(GTK_PANED(vpaned),
2775 GTK_WIDGET_PTR(mainwin->summaryview));
2777 gtk_paned_add2(GTK_PANED(hpaned),
2778 GTK_WIDGET_PTR(mainwin->summaryview));
2779 gtk_widget_ref(vpaned);
2781 gtk_paned_add2(GTK_PANED(vpaned),
2782 GTK_WIDGET_PTR(mainwin->messageview));
2783 gtk_widget_show(vpaned);
2784 gtk_widget_queue_resize(vpaned);
2786 mainwin->win.sep_none.hpaned = hpaned;
2787 mainwin->win.sep_none.vpaned = vpaned;
2789 /* remove headerview if not in prefs */
2790 headerview_set_visibility(mainwin->messageview->headerview,
2791 prefs_common.display_header_pane);
2793 case SEPARATE_FOLDER:
2794 vpaned = gtk_vpaned_new();
2795 if (messageview_is_visible(mainwin->messageview)) {
2796 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2798 gtk_paned_add1(GTK_PANED(vpaned),
2799 GTK_WIDGET_PTR(mainwin->summaryview));
2801 gtk_box_pack_start(GTK_BOX(vbox_body),
2802 GTK_WIDGET_PTR(mainwin->summaryview),
2804 gtk_widget_ref(vpaned);
2806 gtk_paned_add2(GTK_PANED(vpaned),
2807 GTK_WIDGET_PTR(mainwin->messageview));
2808 gtk_widget_show(vpaned);
2809 gtk_widget_queue_resize(vpaned);
2811 mainwin->win.sep_folder.folderwin = folderwin;
2812 mainwin->win.sep_folder.vpaned = vpaned;
2814 /* remove headerview if not in prefs */
2815 headerview_set_visibility(mainwin->messageview->headerview,
2816 prefs_common.display_header_pane);
2819 case SEPARATE_MESSAGE:
2820 hpaned = gtk_hpaned_new();
2821 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2822 gtk_paned_add1(GTK_PANED(hpaned),
2823 GTK_WIDGET_PTR(mainwin->folderview));
2824 gtk_paned_add2(GTK_PANED(hpaned),
2825 GTK_WIDGET_PTR(mainwin->summaryview));
2826 gtk_widget_show(hpaned);
2827 gtk_widget_queue_resize(hpaned);
2828 messageview_add_toolbar(mainwin->messageview, messagewin);
2829 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2830 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2832 mainwin->win.sep_message.messagewin = messagewin;
2833 mainwin->win.sep_message.hpaned = hpaned;
2835 gtk_widget_realize(messagewin);
2836 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2837 gtk_widget_show_all(messagewin);
2838 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2839 mainwin->messageview->handlebox,
2840 prefs_common.toolbar_style);
2842 /* remove headerview if not in prefs */
2843 headerview_set_visibility(mainwin->messageview->headerview,
2844 prefs_common.display_header_pane);
2848 messageview_add_toolbar(mainwin->messageview, messagewin);
2849 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2850 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2852 gtk_box_pack_start(GTK_BOX(vbox_body),
2853 GTK_WIDGET_PTR(mainwin->summaryview),
2856 mainwin->win.sep_both.folderwin = folderwin;
2857 mainwin->win.sep_both.messagewin = messagewin;
2859 gtk_widget_realize(messagewin);
2860 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2861 gtk_widget_show_all(messagewin);
2862 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2863 mainwin->messageview->handlebox,
2864 prefs_common.toolbar_style);
2866 /* remove headerview if not in prefs */
2867 headerview_set_visibility(mainwin->messageview->headerview,
2868 prefs_common.display_header_pane);
2873 if (messageview_is_visible(mainwin->messageview))
2874 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2875 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2877 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2878 GTK_ARROW_UP, GTK_SHADOW_OUT);
2880 gtk_window_move(GTK_WINDOW(mainwin->window),
2881 prefs_common.mainwin_x,
2882 prefs_common.mainwin_y);
2884 gtk_widget_queue_resize(vbox_body);
2885 gtk_widget_queue_resize(mainwin->vbox);
2886 gtk_widget_queue_resize(mainwin->window);
2887 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2888 * and mimeview icon list/ctree lose track of their visibility states */
2889 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2890 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2891 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2892 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2893 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2894 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2896 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2898 mainwin->type = type;
2901 /* toggle menu state */
2902 menuitem = gtk_item_factory_get_item
2903 (ifactory, "/View/Show or hide/Folder tree");
2904 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2905 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2906 prefs_common.folderview_visible);
2907 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2908 menuitem = gtk_item_factory_get_item
2909 (ifactory, "/View/Show or hide/Message view");
2910 gtk_check_menu_item_set_active
2911 (GTK_CHECK_MENU_ITEM(menuitem),
2912 messageview_is_visible(mainwin->messageview));
2914 menuitem = gtk_item_factory_get_item
2915 (ifactory, "/View/Separate folder tree");
2916 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2917 ((type & SEPARATE_FOLDER) != 0));
2918 menuitem = gtk_item_factory_get_item
2919 (ifactory, "/View/Separate message view");
2920 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2921 ((type & SEPARATE_MESSAGE) != 0));
2925 (G_OBJECT(folderwin), "size_allocate",
2926 G_CALLBACK(folder_window_size_allocate_cb),
2931 (G_OBJECT(messagewin), "size_allocate",
2932 G_CALLBACK(message_window_size_allocate_cb),
2936 debug_print("done.\n");
2939 void main_window_destroy_all(void)
2941 while (mainwin_list != NULL) {
2942 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2944 /* free toolbar stuff */
2945 toolbar_clear_list(TOOLBAR_MAIN);
2946 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2947 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2949 mainwin->folderview->mainwin = NULL;
2950 mainwin->summaryview->mainwin = NULL;
2951 mainwin->messageview->mainwin = NULL;
2953 g_free(mainwin->toolbar);
2956 mainwin_list = g_list_remove(mainwin_list, mainwin);
2958 g_list_free(mainwin_list);
2959 mainwin_list = NULL;
2962 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2965 gtk_widget_set_size_request(child, 1, -1);
2968 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2971 gtk_widget_set_size_request(child, -1, -1);
2974 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2977 MainWindow *mainwin = (MainWindow *)data;
2979 if (!event) return FALSE;
2981 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2982 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2985 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2986 menu_button_position, widget,
2987 event->button, event->time);
2992 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2995 MainWindow *mainwin = (MainWindow *)data;
2997 if (mainwin->lock_count == 0)
2998 app_exit_cb(data, 0, widget);
3003 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3006 MainWindow *mainwin = (MainWindow *)data;
3007 GtkWidget *menuitem;
3009 menuitem = gtk_item_factory_get_item
3010 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
3011 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3016 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3019 MainWindow *mainwin = (MainWindow *)data;
3020 GtkWidget *menuitem;
3022 menuitem = gtk_item_factory_get_item
3023 (mainwin->menu_factory, "/View/Show or hide/Message view");
3024 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3026 mainwin->messageview->statusbar = mainwin->statusbar;
3027 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3032 static void main_window_size_allocate_cb(GtkWidget *widget,
3033 GtkAllocation *allocation,
3036 MainWindow *mainwin = (MainWindow *)data;
3038 main_window_get_size(mainwin);
3041 static void folder_window_size_allocate_cb(GtkWidget *widget,
3042 GtkAllocation *allocation,
3045 MainWindow *mainwin = (MainWindow *)data;
3047 main_window_get_size(mainwin);
3050 static void message_window_size_allocate_cb(GtkWidget *widget,
3051 GtkAllocation *allocation,
3054 MainWindow *mainwin = (MainWindow *)data;
3056 main_window_get_size(mainwin);
3059 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3062 main_window_add_mailbox(mainwin);
3065 static void update_folderview_cb(MainWindow *mainwin, guint action,
3068 summary_show(mainwin->summaryview, NULL);
3069 folderview_check_new_all();
3072 static void foldersort_cb(MainWindow *mainwin, guint action,
3078 static void import_mbox_cb(MainWindow *mainwin, guint action,
3081 /* only notify if import has failed */
3082 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3083 alertpanel_error(_("Mbox import has failed."));
3087 static void export_mbox_cb(MainWindow *mainwin, guint action,
3090 /* only notify if export has failed */
3091 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3092 alertpanel_error(_("Export to mbox has failed."));
3096 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3099 /* only notify if export has failed */
3100 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3101 alertpanel_error(_("Export to mbox has failed."));
3105 static void empty_trash_cb(MainWindow *mainwin, guint action,
3108 main_window_empty_trash(mainwin, TRUE);
3111 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3113 summary_save_as(mainwin->summaryview);
3116 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3118 summary_print(mainwin->summaryview);
3121 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3123 if (prefs_common.confirm_on_exit) {
3124 if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
3125 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3126 != G_ALERTALTERNATE)
3128 manage_window_focus_in(mainwin->window, NULL, NULL);
3131 app_will_exit(widget, mainwin);
3134 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3137 summary_search(mainwin->summaryview);
3139 message_search(mainwin->messageview);
3142 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3144 prefs_common.show_searchbar = TRUE;
3145 summaryview_activate_quicksearch(mainwin->summaryview);
3148 static void toggle_folder_cb(MainWindow *mainwin, guint action,
3153 active = GTK_CHECK_MENU_ITEM(widget)->active;
3155 switch (mainwin->type) {
3157 case SEPARATE_MESSAGE:
3159 case SEPARATE_FOLDER:
3160 debug_print("separate folder\n");
3162 gtk_widget_show(mainwin->win.sep_folder.folderwin);
3164 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
3168 gtk_widget_show(mainwin->win.sep_both.folderwin);
3170 gtk_widget_hide(mainwin->win.sep_both.folderwin);
3174 prefs_common.folderview_visible = active;
3177 static void toggle_message_cb(MainWindow *mainwin, guint action,
3182 active = GTK_CHECK_MENU_ITEM(widget)->active;
3184 if (active != messageview_is_visible(mainwin->messageview))
3185 summary_toggle_view(mainwin->summaryview);
3188 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3191 toolbar_toggle(action, mainwin);
3194 void main_window_reply_cb(MainWindow *mainwin, guint action,
3197 MessageView *msgview = (MessageView*)mainwin->messageview;
3198 GSList *msginfo_list = NULL;
3200 g_return_if_fail(msgview != NULL);
3202 msginfo_list = summary_get_selection(mainwin->summaryview);
3203 g_return_if_fail(msginfo_list != NULL);
3204 compose_reply_from_messageview(msgview, msginfo_list, action);
3205 g_slist_free(msginfo_list);
3209 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3212 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3213 gtk_widget_show(mainwin->hbox_stat);
3214 prefs_common.show_statusbar = TRUE;
3216 gtk_widget_hide(mainwin->hbox_stat);
3217 prefs_common.show_statusbar = FALSE;
3221 static void separate_widget_cb(MainWindow *mainwin, guint action,
3226 if (GTK_CHECK_MENU_ITEM(widget)->active)
3227 type = mainwin->type | action;
3229 type = mainwin->type & ~action;
3231 main_window_separation_change(mainwin, type);
3233 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
3234 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
3237 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3240 offline_ask_sync = ask_sync;
3242 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3244 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3245 offline_ask_sync = TRUE;
3248 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3250 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3253 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3255 GList *folderlist = folder_get_list();
3256 gboolean found = FALSE;
3258 /* see if there are synchronised folders */
3259 for (; folderlist; folderlist = folderlist->next) {
3260 Folder *folder = (Folder *)folderlist->data;
3261 if (folder_want_synchronise(folder)) {
3270 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3271 _("Do you want to synchronise your folders now?"),
3272 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3275 folder_synchronise(NULL);
3278 static void online_switch_clicked (GtkButton *btn, gpointer data)
3280 MainWindow *mainwin;
3281 GtkItemFactory *ifactory;
3282 GtkCheckMenuItem *menuitem;
3284 mainwin = (MainWindow *) data;
3286 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3287 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3289 g_return_if_fail(mainwin != NULL);
3290 g_return_if_fail(menuitem != NULL);
3292 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3293 gtk_widget_hide (mainwin->online_switch);
3294 gtk_widget_show (mainwin->offline_switch);
3295 menuitem->active = TRUE;
3296 inc_autocheck_timer_remove();
3299 if (prefs_common.work_offline)
3301 mainwindow_check_synchronise(mainwin, TRUE);
3302 prefs_common.work_offline = TRUE;
3303 imap_disconnect_all();
3306 if (!prefs_common.work_offline)
3308 gtk_widget_hide (mainwin->offline_switch);
3309 gtk_widget_show (mainwin->online_switch);
3310 menuitem->active = FALSE;
3311 prefs_common.work_offline = FALSE;
3312 inc_autocheck_timer_set();
3313 refresh_resolvers();
3317 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3320 addressbook_open(NULL);
3323 static void log_window_show_cb(MainWindow *mainwin, guint action,
3326 log_window_show(mainwin->logwin);
3329 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3334 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3336 summary_move_to(mainwin->summaryview);
3339 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3341 summary_copy_to(mainwin->summaryview);
3344 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3346 summary_delete(mainwin->summaryview);
3349 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3351 summary_delete_trash(mainwin->summaryview);
3354 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3356 summary_cancel(mainwin->summaryview);
3359 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3361 summary_open_msg(mainwin->summaryview);
3364 static void view_source_cb(MainWindow *mainwin, guint action,
3367 summary_view_source(mainwin->summaryview);
3370 static void show_all_header_cb(MainWindow *mainwin, guint action,
3373 if (mainwin->menu_lock_count) return;
3374 mainwin->summaryview->messageview->all_headers =
3375 GTK_CHECK_MENU_ITEM(widget)->active;
3376 summary_display_msg_selected(mainwin->summaryview,
3377 GTK_CHECK_MENU_ITEM(widget)->active);
3380 #define SET_CHECK_MENU_ACTIVE(path, active) \
3382 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3383 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3386 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3389 GtkWidget *menuitem;
3390 GtkItemFactory *ifactory = mainwin->menu_factory;
3392 if (mainwin->menu_lock_count) return;
3394 prefs_common.hide_quotes =
3395 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3397 mainwin->menu_lock_count++;
3398 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3399 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3400 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3401 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3402 mainwin->menu_lock_count--;
3404 summary_redisplay_msg(mainwin->summaryview);
3407 #undef SET_CHECK_MENU_ACTIVE
3408 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3410 summary_mark(mainwin->summaryview);
3413 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3415 summary_unmark(mainwin->summaryview);
3418 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3421 summary_mark_as_unread(mainwin->summaryview);
3424 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3427 summary_mark_as_read(mainwin->summaryview);
3430 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3433 summary_mark_all_read(mainwin->summaryview);
3436 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3439 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3442 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3445 summary_ignore_thread(mainwin->summaryview);
3448 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3451 summary_unignore_thread(mainwin->summaryview);
3454 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3457 summary_msgs_lock(mainwin->summaryview);
3460 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3463 summary_msgs_unlock(mainwin->summaryview);
3467 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3469 summary_reedit(mainwin->summaryview);
3472 static void add_address_cb(MainWindow *mainwin, guint action,
3475 summary_add_address(mainwin->summaryview);
3478 static void set_charset_cb(MainWindow *mainwin, guint action,
3483 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3484 str = conv_get_charset_str((CharSet)action);
3486 g_free(mainwin->messageview->forced_charset);
3487 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3488 procmime_force_charset(str);
3490 summary_redisplay_msg(mainwin->summaryview);
3492 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3496 static void set_decode_cb(MainWindow *mainwin, guint action,
3499 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3500 mainwin->messageview->forced_encoding = (EncodingType)action;
3502 summary_redisplay_msg(mainwin->summaryview);
3504 debug_print("forced encoding: %d\n", action);
3508 static void hide_read_messages (MainWindow *mainwin, guint action,
3511 if (!mainwin->summaryview->folder_item
3512 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3514 summary_toggle_show_read_messages(mainwin->summaryview);
3517 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3519 gboolean threaded = FALSE;
3520 if (mainwin->menu_lock_count) return;
3521 if (!mainwin->summaryview->folder_item) return;
3523 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3525 mainwin->summaryview->folder_item->threaded = threaded;
3527 mainwin->summaryview->threaded = threaded;
3529 summary_show(mainwin->summaryview,
3530 mainwin->summaryview->folder_item);
3533 static void expand_threads_cb(MainWindow *mainwin, guint action,
3536 summary_expand_threads(mainwin->summaryview);
3539 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3542 summary_collapse_threads(mainwin->summaryview);
3545 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3548 prefs_summary_column_open();
3551 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3554 prefs_folder_column_open();
3557 static void sort_summary_cb(MainWindow *mainwin, guint action,
3560 FolderItem *item = mainwin->summaryview->folder_item;
3561 GtkWidget *menuitem;
3563 if (mainwin->menu_lock_count) return;
3565 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3566 menuitem = gtk_item_factory_get_item
3567 (mainwin->menu_factory, "/View/Sort/Ascending");
3568 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3569 GTK_CHECK_MENU_ITEM(menuitem)->active
3570 ? SORT_ASCENDING : SORT_DESCENDING);
3571 item->sort_key = action;
3575 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3578 FolderItem *item = mainwin->summaryview->folder_item;
3580 if (mainwin->menu_lock_count) return;
3582 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3583 summary_sort(mainwin->summaryview,
3584 item->sort_key, (FolderSortType)action);
3587 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3590 summary_attract_by_subject(mainwin->summaryview);
3593 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3598 item = folderview_get_selected_item(mainwin->folderview);
3600 main_window_cursor_wait(mainwin);
3601 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3603 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3604 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3606 STATUSBAR_POP(mainwin);
3607 main_window_cursor_normal(mainwin);
3617 static void deldup_all(FolderItem *item, gpointer _data)
3619 struct DelDupsData *data = _data;
3622 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3624 data->dups += result;
3629 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3632 struct DelDupsData data = {0, 0};
3634 folder_func_to_all_folders(deldup_all, &data);
3635 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3636 "Deleted %d duplicate messages in %d folders.\n",
3638 data.dups, data.folders);
3641 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3643 summary_filter(mainwin->summaryview, (gboolean)action);
3646 static void execute_summary_cb(MainWindow *mainwin, guint action,
3649 summary_execute(mainwin->summaryview);
3652 static void update_summary_cb(MainWindow *mainwin, guint action,
3656 FolderView *folderview = mainwin->folderview;
3658 if (!mainwin->summaryview->folder_item) return;
3659 if (!folderview->opened) return;
3661 folder_update_op_count();
3663 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3664 folderview->opened);
3667 folder_item_scan(fitem);
3668 summary_show(mainwin->summaryview, fitem);
3671 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3673 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3676 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3678 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3681 static void prev_unread_cb(MainWindow *mainwin, guint action,
3684 summary_select_prev_unread(mainwin->summaryview);
3687 static void next_unread_cb(MainWindow *mainwin, guint action,
3690 summary_select_next_unread(mainwin->summaryview);
3693 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3695 summary_select_prev_new(mainwin->summaryview);
3698 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3700 summary_select_next_new(mainwin->summaryview);
3703 static void prev_marked_cb(MainWindow *mainwin, guint action,
3706 summary_select_prev_marked(mainwin->summaryview);
3709 static void next_marked_cb(MainWindow *mainwin, guint action,
3712 summary_select_next_marked(mainwin->summaryview);
3715 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3718 summary_select_prev_labeled(mainwin->summaryview);
3721 static void next_labeled_cb(MainWindow *mainwin, guint action,
3724 summary_select_next_labeled(mainwin->summaryview);
3727 static void last_read_cb(MainWindow *mainwin, guint action,
3730 summary_select_last_read(mainwin->summaryview);
3733 static void parent_cb(MainWindow *mainwin, guint action,
3736 summary_select_parent(mainwin->summaryview);
3739 static void goto_folder_cb(MainWindow *mainwin, guint action,
3742 FolderItem *to_folder;
3744 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3747 folderview_select(mainwin->folderview, to_folder);
3750 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3753 folderview_select_next_unread(mainwin->folderview, FALSE);
3756 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3758 messageview_copy_clipboard(mainwin->messageview);
3761 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3763 MessageView *msgview = mainwin->messageview;
3765 if (messageview_is_visible(msgview) &&
3766 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3767 messageview_select_all(mainwin->messageview);
3769 summary_select_all(mainwin->summaryview);
3772 static void select_thread_cb(MainWindow *mainwin, guint action,
3775 summary_select_thread(mainwin->summaryview);
3778 static void create_filter_cb(MainWindow *mainwin, guint action,
3781 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3784 static void create_processing_cb(MainWindow *mainwin, guint action,
3787 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3790 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3793 prefs_filtering_open(&pre_global_processing,
3794 _("Processing rules to apply before folder rules"),
3795 MANUAL_ANCHOR_PROCESSING,
3799 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3802 prefs_filtering_open(&post_global_processing,
3803 _("Processing rules to apply after folder rules"),
3804 MANUAL_ANCHOR_PROCESSING,
3808 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3811 prefs_filtering_open(&filtering_rules,
3812 _("Filtering configuration"),
3813 MANUAL_ANCHOR_FILTERING,
3817 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3820 prefs_template_open();
3823 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3826 prefs_actions_open(mainwin);
3829 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3832 ssl_manager_open(mainwin);
3835 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3839 new_account_cb(mainwin, 0, widget);
3841 account_open(cur_account);
3845 static void new_account_cb(MainWindow *mainwin, guint action,
3848 account_edit_open();
3849 if (!compose_get_compose_list()) account_add();
3852 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3854 FolderItem *item = NULL;
3855 cur_account = (PrefsAccount *)data;
3857 if (!mainwindow_get_mainwindow())
3859 main_window_show_cur_account(mainwindow_get_mainwindow());
3860 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3861 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3862 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3863 item = folderview_get_selected_item(
3864 mainwindow_get_mainwindow()->folderview);
3866 toolbar_set_compose_button
3867 (mainwindow_get_mainwindow()->toolbar,
3868 FOLDER_TYPE(item->folder) == F_NEWS ?
3869 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3873 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3875 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3876 PrefsAccount *account = (PrefsAccount *)data;
3878 inc_account_mail(mainwin, account);
3881 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3883 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3884 PrefsAccount *account = (PrefsAccount *)data;
3885 FolderItem *item = mainwin->summaryview->folder_item;
3887 compose_new_with_folderitem(account, item, NULL);
3890 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3895 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3897 pluginwindow_create();
3900 static void manual_open_cb(MainWindow *mainwin, guint action,
3903 manual_open((ManualType)action, NULL);
3906 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3911 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3913 MainWindow *mainwin = (MainWindow *)data;
3917 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3918 LOCAL_FOLDER(folder)->rootpath,
3922 str = g_strdup_printf(_("Scanning folder %s ..."),
3923 LOCAL_FOLDER(folder)->rootpath);
3925 STATUSBAR_PUSH(mainwin, str);
3926 STATUSBAR_POP(mainwin);
3930 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3933 SummaryView *summary;
3935 g_return_val_if_fail(data, FALSE);
3936 if (!g_list_find(mainwin_list, data))
3938 summary = ((MainWindow *)data)->summaryview;
3939 g_return_val_if_fail(summary, FALSE);
3941 if (GTK_CLIST(summary->ctree)->selection &&
3942 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3948 #define BREAK_ON_MODIFIER_KEY() \
3949 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3951 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3954 MainWindow *mainwin = (MainWindow*) data;
3956 if (!mainwin || !event)
3959 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3961 lastkey = event->keyval;
3965 switch (event->keyval) {
3966 case GDK_Q: /* Quit */
3967 BREAK_ON_MODIFIER_KEY();
3969 app_exit_cb(mainwin, 0, NULL);
3972 if (mainwin->folderview && mainwin->summaryview
3973 && ((!mainwin->summaryview->displayed
3974 && !mainwin->summaryview->selected)
3975 || (mainwin->summaryview->folder_item
3976 && mainwin->summaryview->folder_item->total_msgs == 0))) {
3977 g_signal_stop_emission_by_name(G_OBJECT(widget),
3979 folderview_select_next_unread(mainwin->folderview, TRUE);
3988 #undef BREAK_ON_MODIFIER_KEY
3991 * Harvest addresses for selected folder.
3993 static void addr_harvest_cb( MainWindow *mainwin,
3997 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4001 * Harvest addresses for selected messages in summary view.
4003 static void addr_harvest_msg_cb( MainWindow *mainwin,
4007 summary_harvest_address( mainwin->summaryview );
4011 *\brief get a MainWindow
4013 *\return MainWindow * The first mainwindow in the mainwin_list
4015 MainWindow *mainwindow_get_mainwindow(void)
4017 if (mainwin_list && mainwin_list->data)
4018 return (MainWindow *)(mainwin_list->data);
4023 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4025 ProgressData *data = (ProgressData *) source;
4026 MainWindow *mainwin = (MainWindow *) userdata;
4028 switch (data->cmd) {
4029 case PROGRESS_COMMAND_START:
4030 case PROGRESS_COMMAND_STOP:
4031 gtk_progress_bar_set_fraction
4032 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4034 case PROGRESS_COMMAND_SET_PERCENTAGE:
4035 gtk_progress_bar_set_fraction
4036 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4039 while (gtk_events_pending()) gtk_main_iteration ();
4044 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4046 mainwindow_check_synchronise(mainwin, FALSE);
4049 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4051 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4054 void mainwindow_jump_to(const gchar *target)
4058 FolderItem *item = NULL;
4060 MainWindow *mainwin = mainwindow_get_mainwindow();
4066 printf(_("not initialized\n"));
4070 tmp = g_strdup(target);
4072 if ((p = strstr(tmp, "\r")) != NULL)
4074 if ((p = strstr(tmp, "\n")) != NULL)
4077 if ((item = folder_find_item_from_identifier(tmp))) {
4078 printf(_("selecting folder '%s'\n"), tmp);
4079 folderview_select(mainwin->folderview, item);
4080 main_window_popup(mainwin);
4085 msg = strrchr(tmp, G_DIR_SEPARATOR);
4088 if ((item = folder_find_item_from_identifier(tmp))) {
4089 printf(_("selecting folder '%s'\n"), tmp);
4090 folderview_select(mainwin->folderview, item);
4092 if (item && msg && atoi(msg)) {
4093 printf(_("selecting message %d\n"), atoi(msg));
4094 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4095 summary_display_msg_selected(mainwin->summaryview, FALSE);
4096 main_window_popup(mainwin);
4102 printf("'%s' not found\n", tmp);