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 reedit_cb (MainWindow *mainwin,
268 static void add_address_cb (MainWindow *mainwin,
272 static void set_charset_cb (MainWindow *mainwin,
276 static void set_decode_cb (MainWindow *mainwin,
280 static void hide_read_messages (MainWindow *mainwin,
284 static void thread_cb (MainWindow *mainwin,
287 static void expand_threads_cb (MainWindow *mainwin,
290 static void collapse_threads_cb (MainWindow *mainwin,
294 static void set_summary_display_item_cb (MainWindow *mainwin,
297 static void set_folder_display_item_cb (MainWindow *mainwin,
300 static void sort_summary_cb (MainWindow *mainwin,
303 static void sort_summary_type_cb (MainWindow *mainwin,
306 static void attract_by_subject_cb(MainWindow *mainwin,
310 static void delete_duplicated_cb (MainWindow *mainwin,
313 static void delete_duplicated_all_cb (MainWindow *mainwin,
316 static void filter_cb (MainWindow *mainwin,
319 static void execute_summary_cb (MainWindow *mainwin,
322 static void update_summary_cb (MainWindow *mainwin,
326 static void prev_cb (MainWindow *mainwin,
329 static void next_cb (MainWindow *mainwin,
332 static void next_unread_cb (MainWindow *mainwin,
335 static void prev_unread_cb (MainWindow *mainwin,
339 static void prev_new_cb (MainWindow *mainwin,
342 static void next_new_cb (MainWindow *mainwin,
345 static void prev_marked_cb (MainWindow *mainwin,
348 static void next_marked_cb (MainWindow *mainwin,
351 static void prev_labeled_cb (MainWindow *mainwin,
354 static void next_labeled_cb (MainWindow *mainwin,
357 static void last_read_cb (MainWindow *mainwin,
360 static void parent_cb (MainWindow *mainwin,
364 static void goto_folder_cb (MainWindow *mainwin,
367 static void goto_unread_folder_cb(MainWindow *mainwin,
371 static void copy_cb (MainWindow *mainwin,
374 static void allsel_cb (MainWindow *mainwin,
377 static void select_thread_cb (MainWindow *mainwin,
381 static void create_filter_cb (MainWindow *mainwin,
384 static void create_processing_cb (MainWindow *mainwin,
388 static void prefs_template_open_cb (MainWindow *mainwin,
391 static void prefs_actions_open_cb (MainWindow *mainwin,
394 static void prefs_account_open_cb (MainWindow *mainwin,
398 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
402 static void prefs_post_processing_open_cb (MainWindow *mainwin,
406 static void prefs_filtering_open_cb (MainWindow *mainwin,
410 static void ssl_manager_open_cb (MainWindow *mainwin,
414 static void new_account_cb (MainWindow *mainwin,
418 static void account_selector_menu_cb (GtkMenuItem *menuitem,
420 static void account_receive_menu_cb (GtkMenuItem *menuitem,
422 static void account_compose_menu_cb (GtkMenuItem *menuitem,
425 static void prefs_open_cb (GtkMenuItem *menuitem,
427 static void plugins_open_cb (GtkMenuItem *menuitem,
430 static void online_switch_clicked(GtkButton *btn,
433 static void manual_open_cb (MainWindow *mainwin,
437 static void legend_open_cb (GtkMenuItem *menuitem,
440 static void scan_tree_func (Folder *folder,
444 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
446 static void addr_harvest_cb ( MainWindow *mainwin,
450 static void addr_harvest_msg_cb ( MainWindow *mainwin,
453 static void sync_cb ( MainWindow *mainwin,
457 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
458 GdkEventFocus *focus,
460 void main_window_reply_cb (MainWindow *mainwin,
463 gboolean mainwindow_progressindicator_hook (gpointer source,
466 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
469 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
471 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
473 static void mailing_list_compose(GtkWidget *w, gpointer *data);
475 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
476 #define SEPARATE_ACTION 500
477 static void mainwindow_quicksearch (MainWindow *mainwin,
481 static GtkItemFactoryEntry mainwin_entries[] =
483 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
484 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
485 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
486 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
488 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
490 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
491 {N_("/_File/Exp_ort selected to mbox file..."),
492 NULL, export_list_mbox_cb, 0, NULL},
493 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
495 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
497 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
498 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
500 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
501 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
502 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
503 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
505 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
506 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
507 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
508 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
509 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_Edit/_Find in current message..."),
511 "<control>F", search_cb, 0, NULL},
512 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
513 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
514 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
516 {N_("/_View/Show or hi_de/_Folder tree"),
517 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
518 {N_("/_View/Show or hi_de/_Message view"),
519 "V", toggle_message_cb, 0, "<ToggleItem>"},
520 {N_("/_View/Show or hi_de/_Toolbar"),
521 NULL, NULL, 0, "<Branch>"},
522 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
523 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
524 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
525 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
526 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
527 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
528 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
529 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
530 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
531 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
532 {N_("/_View/Show or hi_de/Status _bar"),
533 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
534 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
536 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
538 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
540 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
541 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
542 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
543 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
544 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
545 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
546 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
547 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
548 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
549 {N_("/_View/_Sort/by _color label"),
550 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
551 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
552 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
553 {N_("/_View/_Sort/by a_ttachment"),
554 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
555 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
556 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
557 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
558 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
559 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
560 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
561 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
562 {N_("/_View/_Sort/_Attract by subject"),
563 NULL, attract_by_subject_cb, 0, NULL},
564 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
565 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
566 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
567 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
569 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
570 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
571 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
572 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
573 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_View/_Go to/P_revious unread message"),
575 "<shift>P", prev_unread_cb, 0, NULL},
576 {N_("/_View/_Go to/N_ext unread message"),
577 "<shift>N", next_unread_cb, 0, NULL},
578 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
579 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
580 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
581 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
582 {N_("/_View/_Go to/Previous _marked message"),
583 NULL, prev_marked_cb, 0, NULL},
584 {N_("/_View/_Go to/Next m_arked message"),
585 NULL, next_marked_cb, 0, NULL},
586 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_View/_Go to/Previous _labeled message"),
588 NULL, prev_labeled_cb, 0, NULL},
589 {N_("/_View/_Go to/Next la_beled message"),
590 NULL, next_labeled_cb, 0, NULL},
591 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_View/_Go to/Last read message"),
593 NULL, last_read_cb, 0, NULL},
594 {N_("/_View/_Go to/Parent message"),
595 "<control>Up", parent_cb, 0, NULL},
596 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
597 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
598 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
599 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
601 #define ENC_SEPARATOR \
602 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
603 #define ENC_ACTION(action) \
604 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
606 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
607 {N_("/_View/Character _encoding/_Auto detect"),
608 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
609 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
611 ENC_ACTION(C_US_ASCII)},
612 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
613 ENC_ACTION(C_UTF_8)},
616 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
617 ENC_ACTION(C_ISO_8859_1)},
618 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
619 ENC_ACTION(C_ISO_8859_15)},
620 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
621 ENC_ACTION(C_WINDOWS_1252)},
624 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
625 ENC_ACTION(C_ISO_8859_2)},
628 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
629 ENC_ACTION(C_ISO_8859_13)},
630 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
631 ENC_ACTION(C_ISO_8859_4)},
634 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
635 ENC_ACTION(C_ISO_8859_7)},
638 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
639 ENC_ACTION(C_ISO_8859_8)},
640 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
641 ENC_ACTION(C_CP1255)},
644 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
645 ENC_ACTION(C_ISO_8859_6)},
646 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
647 ENC_ACTION(C_CP1256)},
650 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
651 ENC_ACTION(C_ISO_8859_9)},
654 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
655 ENC_ACTION(C_ISO_8859_5)},
656 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
657 ENC_ACTION(C_KOI8_R)},
658 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
659 ENC_ACTION(C_KOI8_U)},
660 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
661 ENC_ACTION(C_CP1251)},
664 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
665 ENC_ACTION(C_ISO_2022_JP)},
666 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
667 ENC_ACTION(C_ISO_2022_JP_2)},
668 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
669 ENC_ACTION(C_EUC_JP)},
670 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
671 ENC_ACTION(C_SHIFT_JIS)},
674 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
675 ENC_ACTION(C_GB2312)},
676 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
678 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
680 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
681 ENC_ACTION(C_EUC_TW)},
682 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
683 ENC_ACTION(C_ISO_2022_CN)},
686 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
687 ENC_ACTION(C_EUC_KR)},
688 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
689 ENC_ACTION(C_ISO_2022_KR)},
692 {N_("/_View/Character _encoding/Thai (TIS-620)"),
693 ENC_ACTION(C_TIS_620)},
694 {N_("/_View/Character _encoding/Thai (Windows-874)"),
695 ENC_ACTION(C_WINDOWS_874)},
700 #define DEC_SEPARATOR \
701 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
702 #define DEC_ACTION(action) \
703 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
704 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
705 {N_("/_View/Decode/_Auto detect"),
706 NULL, set_decode_cb, 0, "<RadioItem>"},
707 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
709 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
710 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
711 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
716 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
718 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
719 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
720 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
721 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
722 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
723 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
724 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
725 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
727 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
728 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
729 {N_("/_Message/Recei_ve/Get from _current account"),
730 "<control>I", inc_mail_cb, 0, NULL},
731 {N_("/_Message/Recei_ve/Get from _all accounts"),
732 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
733 {N_("/_Message/Recei_ve/Cancel receivin_g"),
734 NULL, inc_cancel_cb, 0, NULL},
735 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
736 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
737 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
738 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
739 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
740 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
741 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
742 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
743 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
744 {N_("/_Message/Repl_y to/mailing _list"),
745 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
746 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
747 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
748 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
749 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
750 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
752 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
753 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
754 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
755 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
756 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
758 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
760 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
762 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
763 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
764 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
765 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
766 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
767 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
768 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
769 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
770 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
771 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
772 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
773 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
774 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
775 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
776 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
777 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
778 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
779 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
781 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
782 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
783 {N_("/_Tools/Add sender to address boo_k"),
784 NULL, add_address_cb, 0, NULL},
785 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
786 {N_("/_Tools/_Harvest addresses/from _Folder..."),
787 NULL, addr_harvest_cb, 0, NULL},
788 {N_("/_Tools/_Harvest addresses/from _Messages..."),
789 NULL, addr_harvest_msg_cb, 0, NULL},
790 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
791 {N_("/_Tools/_Filter all messages in folder"),
792 NULL, filter_cb, 0, NULL},
793 {N_("/_Tools/Filter _selected messages"),
794 NULL, filter_cb, 1, NULL},
795 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
796 {N_("/_Tools/_Create filter rule/_Automatically"),
797 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
798 {N_("/_Tools/_Create filter rule/by _From"),
799 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
800 {N_("/_Tools/_Create filter rule/by _To"),
801 NULL, create_filter_cb, FILTER_BY_TO, NULL},
802 {N_("/_Tools/_Create filter rule/by _Subject"),
803 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
804 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
805 {N_("/_Tools/C_reate processing rule/_Automatically"),
806 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
807 {N_("/_Tools/C_reate processing rule/by _From"),
808 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
809 {N_("/_Tools/C_reate processing rule/by _To"),
810 NULL, create_processing_cb, FILTER_BY_TO, NULL},
811 {N_("/_Tools/C_reate processing rule/by _Subject"),
812 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
813 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
814 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
815 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
816 {N_("/_Tools/Ch_eck for new messages in all folders"),
817 NULL, update_folderview_cb, 0, NULL},
818 {N_("/_Tools/Delete du_plicated messages"),
819 NULL, NULL, 0, "<Branch>"},
820 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
821 NULL, delete_duplicated_cb, 0, NULL},
822 {N_("/_Tools/Delete du_plicated messages/In all folders"),
823 NULL, delete_duplicated_all_cb, 0, NULL},
824 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
825 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
827 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
828 {N_("/_Tools/SSL cer_tificates..."),
829 NULL, ssl_manager_open_cb, 0, NULL},
831 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
832 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
834 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
835 {N_("/_Configuration/C_hange current account"),
836 NULL, NULL, 0, "<Branch>"},
837 {N_("/_Configuration/_Preferences for current account..."),
838 NULL, prefs_account_open_cb, 0, NULL},
839 {N_("/_Configuration/Create _new account..."),
840 NULL, new_account_cb, 0, NULL},
841 {N_("/_Configuration/_Edit accounts..."),
842 NULL, account_edit_open, 0, NULL},
843 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
844 {N_("/_Configuration/P_references..."),
845 NULL, prefs_open_cb, 0, NULL},
846 {N_("/_Configuration/Pre-pr_ocessing..."),
847 NULL, prefs_pre_processing_open_cb, 0, NULL},
848 {N_("/_Configuration/Post-pro_cessing..."),
849 NULL, prefs_post_processing_open_cb, 0, NULL},
850 {N_("/_Configuration/_Filtering..."),
851 NULL, prefs_filtering_open_cb, 0, NULL},
852 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
853 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
854 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
856 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
857 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
858 {N_("/_Help/_Online User-contributed FAQ"),
859 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
860 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
861 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
862 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
865 static gboolean offline_ask_sync = TRUE;
866 static guint lastkey;
868 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
874 MainWindow *mainwin = (MainWindow *)user_data;
876 if (mainwin->summaryview &&
877 mainwin->summaryview->quicksearch &&
878 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
879 (mod == 0 || mod == GDK_SHIFT_MASK)) {
880 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
886 #define N_COLOR_LABELS colorlabel_get_color_count()
888 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
893 GtkCheckMenuItem **items;
897 mainwin = (MainWindow *)data;
898 g_return_if_fail(mainwin != NULL);
900 sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
903 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
904 g_return_if_fail(menu != NULL);
906 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
908 /* NOTE: don't return prematurely because we set the "dont_toggle"
909 * state for check menu items */
910 g_object_set_data(G_OBJECT(menu), "dont_toggle",
913 /* clear items. get item pointers. */
914 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
915 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
916 gtk_check_menu_item_set_active
917 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
918 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
923 if (n == (N_COLOR_LABELS + 1)) {
924 /* iterate all messages and set the state of the appropriate
926 for (; sel != NULL; sel = sel->next) {
930 msginfo = gtk_ctree_node_get_row_data
931 (GTK_CTREE(mainwin->summaryview->ctree),
932 GTK_CTREE_NODE(sel->data));
934 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
935 if (!items[clabel]->active)
936 gtk_check_menu_item_set_active
937 (items[clabel], TRUE);
941 g_warning("invalid number of color elements (%d)\n", n);
943 /* reset "dont_toggle" state */
944 g_object_set_data(G_OBJECT(menu), "dont_toggle",
948 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
951 guint color = GPOINTER_TO_UINT(data);
954 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
955 g_return_if_fail(mainwin != NULL);
957 /* "dont_toggle" state set? */
958 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
962 summary_set_colorlabel(mainwin->summaryview, color, NULL);
965 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
967 GtkWidget *label_menuitem;
972 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
973 "/Message/Color label");
974 g_signal_connect(G_OBJECT(label_menuitem), "activate",
975 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
977 gtk_widget_show(label_menuitem);
979 menu = gtk_menu_new();
981 /* create sub items. for the menu item activation callback we pass the
982 * index of label_colors[] as data parameter. for the None color we
983 * pass an invalid (high) value. also we attach a data pointer so we
984 * can always get back the Mainwindow pointer. */
986 item = gtk_check_menu_item_new_with_label(_("None"));
987 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
988 g_signal_connect(G_OBJECT(item), "activate",
989 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
990 GUINT_TO_POINTER(0));
991 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
992 gtk_widget_show(item);
994 gtk_widget_add_accelerator(item, "activate",
995 mainwin->menu_factory->accel_group,
996 GDK_0, GDK_CONTROL_MASK,
997 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
999 item = gtk_menu_item_new();
1000 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1001 gtk_widget_show(item);
1003 /* create pixmap/label menu items */
1004 for (i = 0; i < N_COLOR_LABELS; i++) {
1005 item = colorlabel_create_check_color_menu_item(
1006 i, refresh, MAINWIN_COLORMENU);
1007 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1008 g_signal_connect(G_OBJECT(item), "activate",
1009 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1010 GUINT_TO_POINTER(i + 1));
1011 g_object_set_data(G_OBJECT(item), "mainwin",
1013 gtk_widget_show(item);
1014 gtk_widget_add_accelerator(item, "activate",
1015 mainwin->menu_factory->accel_group,
1016 GDK_1+i, GDK_CONTROL_MASK,
1017 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1020 gtk_widget_show(menu);
1021 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1022 mainwin->colorlabel_menu = menu;
1025 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1026 MainWindow *mainwindow)
1028 if (evt && evt->button == 1) {
1029 log_window_show_error(mainwindow->logwin);
1030 gtk_widget_hide(mainwindow->warning_btn);
1035 static gboolean warning_visi_notify(GtkWidget *widget,
1036 GdkEventVisibility *event,
1037 MainWindow *mainwindow)
1039 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1043 static gboolean warning_leave_notify(GtkWidget *widget,
1044 GdkEventCrossing *event,
1045 MainWindow *mainwindow)
1047 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1051 static gboolean warning_enter_notify(GtkWidget *widget,
1052 GdkEventCrossing *event,
1053 MainWindow *mainwindow)
1055 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1059 void mainwindow_show_error(void)
1061 MainWindow *mainwin = mainwindow_get_mainwindow();
1062 gtk_widget_show(mainwin->warning_btn);
1065 void mainwindow_clear_error(MainWindow *mainwin)
1067 gtk_widget_hide(mainwin->warning_btn);
1070 MainWindow *main_window_create(SeparateType type)
1072 MainWindow *mainwin;
1076 GtkWidget *handlebox;
1077 GtkWidget *vbox_body;
1078 GtkWidget *hbox_stat;
1079 GtkWidget *statusbar;
1080 GtkWidget *progressbar;
1081 GtkWidget *statuslabel;
1082 GtkWidget *ac_button;
1083 GtkWidget *ac_label;
1084 GtkWidget *online_pixmap;
1085 GtkWidget *offline_pixmap;
1086 GtkWidget *online_switch;
1087 GtkWidget *offline_switch;
1089 GtkWidget *warning_icon;
1090 GtkWidget *warning_btn;
1092 FolderView *folderview;
1093 SummaryView *summaryview;
1094 MessageView *messageview;
1095 GdkColormap *colormap;
1097 gboolean success[4];
1098 GtkItemFactory *ifactory;
1100 GtkWidget *menuitem;
1102 guint n_menu_entries;
1104 static GdkGeometry geometry;
1106 debug_print("Creating main window...\n");
1107 mainwin = g_new0(MainWindow, 1);
1110 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1111 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1112 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1114 if (!geometry.min_height) {
1115 geometry.min_width = 320;
1116 geometry.min_height = 200;
1118 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1121 g_signal_connect(G_OBJECT(window), "delete_event",
1122 G_CALLBACK(main_window_close_cb), mainwin);
1123 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1124 g_signal_connect(G_OBJECT(window), "focus_in_event",
1125 G_CALLBACK(mainwindow_focus_in_event),
1127 g_signal_connect(G_OBJECT(window), "key_press_event",
1128 G_CALLBACK(mainwindow_key_pressed), mainwin);
1130 gtk_widget_realize(window);
1131 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1134 gtkut_widget_set_app_icon(window);
1136 vbox = gtk_vbox_new(FALSE, 0);
1137 gtk_widget_show(vbox);
1138 gtk_container_add(GTK_CONTAINER(window), vbox);
1141 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1142 menubar = menubar_create(window, mainwin_entries,
1143 n_menu_entries, "<Main>", mainwin);
1144 gtk_widget_show(menubar);
1145 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1146 ifactory = gtk_item_factory_from_widget(menubar);
1148 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1149 main_create_mailing_list_menu (mainwin, NULL); */
1151 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1153 if (prefs_common.toolbar_detachable) {
1154 handlebox = gtk_handle_box_new();
1155 gtk_widget_show(handlebox);
1156 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1157 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1158 G_CALLBACK(toolbar_child_attached), mainwin);
1159 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1160 G_CALLBACK(toolbar_child_detached), mainwin);
1162 handlebox = gtk_hbox_new(FALSE, 0);
1163 gtk_widget_show(handlebox);
1164 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1166 /* link window to mainwin->window to avoid gdk warnings */
1167 mainwin->window = window;
1169 /* create toolbar */
1170 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1173 toolbar_set_learn_button
1177 /* vbox that contains body */
1178 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1179 gtk_widget_show(vbox_body);
1180 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1181 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1183 hbox_stat = gtk_hbox_new(FALSE, 2);
1184 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1186 tips = gtk_tooltips_new();
1188 warning_icon = gtk_image_new_from_stock
1189 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1190 warning_btn = gtk_event_box_new();
1191 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1193 mainwin->warning_btn = warning_btn;
1195 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1196 G_CALLBACK(warning_icon_pressed),
1197 (gpointer) mainwin);
1198 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1199 G_CALLBACK(warning_visi_notify), mainwin);
1200 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1201 G_CALLBACK(warning_visi_notify), mainwin);
1202 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1203 G_CALLBACK(warning_leave_notify), mainwin);
1204 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1205 G_CALLBACK(warning_enter_notify), mainwin);
1207 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1209 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1210 _("Some error(s) happened. Click here to view log."), NULL);
1211 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1213 statusbar = statusbar_create();
1214 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1216 progressbar = gtk_progress_bar_new();
1217 gtk_widget_set_size_request(progressbar, 120, 1);
1218 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1220 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1221 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1222 online_switch = gtk_button_new ();
1223 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1224 _("You are online. Click the icon to go offline"), NULL);
1225 offline_switch = gtk_button_new ();
1226 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1227 _("You are offline. Click the icon to go online"),
1229 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1230 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1231 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1232 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1233 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1234 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1235 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1236 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1238 statuslabel = gtk_label_new("");
1239 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1241 ac_button = gtk_button_new();
1242 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1243 ac_button, _("Select account"), NULL);
1244 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1245 gtk_widget_set_size_request(ac_button, -1, 0);
1246 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1247 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1248 G_CALLBACK(ac_label_button_pressed), mainwin);
1250 ac_label = gtk_label_new("");
1251 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1253 gtk_widget_show_all(hbox_stat);
1255 gtk_widget_hide(offline_switch);
1256 gtk_widget_hide(warning_btn);
1258 mainwin->folderview = folderview = folderview_create();
1259 mainwin->summaryview = summaryview = summary_create();
1260 mainwin->messageview = messageview = messageview_create(mainwin);
1261 mainwin->logwin = log_window_create();
1263 log_window_init(mainwin->logwin);
1264 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1265 prefs_common.loglength);
1267 folderview->mainwin = mainwin;
1268 folderview->summaryview = summaryview;
1270 summaryview->mainwin = mainwin;
1271 summaryview->folderview = folderview;
1272 summaryview->messageview = messageview;
1273 summaryview->window = window;
1275 messageview->statusbar = statusbar;
1276 mainwin->vbox = vbox;
1277 mainwin->menubar = menubar;
1278 mainwin->menu_factory = ifactory;
1279 mainwin->handlebox = handlebox;
1280 mainwin->vbox_body = vbox_body;
1281 mainwin->hbox_stat = hbox_stat;
1282 mainwin->statusbar = statusbar;
1283 mainwin->progressbar = progressbar;
1284 mainwin->statuslabel = statuslabel;
1285 mainwin->online_switch = online_switch;
1286 mainwin->online_pixmap = online_pixmap;
1287 mainwin->offline_pixmap = offline_pixmap;
1288 mainwin->ac_button = ac_button;
1289 mainwin->ac_label = ac_label;
1290 mainwin->offline_switch = offline_switch;
1292 /* set context IDs for status bar */
1293 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1294 (GTK_STATUSBAR(statusbar), "Main Window");
1295 mainwin->folderview_cid = gtk_statusbar_get_context_id
1296 (GTK_STATUSBAR(statusbar), "Folder View");
1297 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1298 (GTK_STATUSBAR(statusbar), "Summary View");
1299 mainwin->messageview_cid = gtk_statusbar_get_context_id
1300 (GTK_STATUSBAR(statusbar), "Message View");
1302 messageview->statusbar_cid = mainwin->messageview_cid;
1304 /* allocate colors for summary view and folder view */
1305 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1306 summaryview->color_marked.blue = (guint16)65535;
1308 summaryview->color_dim.red = summaryview->color_dim.green =
1309 summaryview->color_dim.blue = COLOR_DIM;
1311 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1312 &folderview->color_new);
1314 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1315 &folderview->color_op);
1317 summaryview->color_important.red = 0;
1318 summaryview->color_important.green = 0;
1319 summaryview->color_important.blue = (guint16)65535;
1321 color[0] = summaryview->color_marked;
1322 color[1] = summaryview->color_dim;
1323 color[2] = folderview->color_new;
1324 color[3] = folderview->color_op;
1326 colormap = gdk_drawable_get_colormap(window->window);
1327 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1328 for (i = 0; i < 4; i++) {
1329 if (success[i] == FALSE)
1330 g_warning("MainWindow: color allocation %d failed\n", i);
1333 debug_print("done.\n");
1335 messageview->visible = prefs_common.msgview_visible;
1337 main_window_set_widgets(mainwin, type);
1339 g_signal_connect(G_OBJECT(window), "size_allocate",
1340 G_CALLBACK(main_window_size_allocate_cb),
1343 /* set menu items */
1344 menuitem = gtk_item_factory_get_item
1345 (ifactory, "/View/Character encoding/Auto detect");
1346 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1348 switch (prefs_common.toolbar_style) {
1350 menuitem = gtk_item_factory_get_item
1351 (ifactory, "/View/Show or hide/Toolbar/Hide");
1354 menuitem = gtk_item_factory_get_item
1355 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1358 menuitem = gtk_item_factory_get_item
1359 (ifactory, "/View/Show or hide/Toolbar/Text only");
1362 menuitem = gtk_item_factory_get_item
1363 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1365 case TOOLBAR_BOTH_HORIZ:
1366 menuitem = gtk_item_factory_get_item
1368 "/View/Show or hide/Toolbar/Text beside icons");
1370 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1372 gtk_widget_hide(mainwin->hbox_stat);
1373 menuitem = gtk_item_factory_get_item
1374 (ifactory, "/View/Show or hide/Status bar");
1375 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1376 prefs_common.show_statusbar);
1378 /* set account selection menu */
1379 ac_menu = gtk_item_factory_get_widget
1380 (ifactory, "/Configuration/Change current account");
1381 mainwin->ac_menu = ac_menu;
1383 toolbar_main_set_sensitive(mainwin);
1385 /* create actions menu */
1386 main_window_update_actions_menu(mainwin);
1388 main_create_mailing_list_menu (mainwin, NULL);
1390 /* attach accel groups to main window */
1391 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1392 gtk_window_add_accel_group \
1394 gtk_item_factory_from_widget(menu)->accel_group); \
1395 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1397 G_CALLBACK(main_window_accel_activate), mainwin);
1400 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1402 /* connect the accelerators for equivalent
1403 menu items in different menus */
1404 menu_connect_identical_items();
1407 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1409 gtk_widget_show(mainwin->window);
1411 /* initialize views */
1412 folderview_init(folderview);
1413 summary_init(summaryview);
1414 messageview_init(messageview);
1416 sslcertwindow_register_hook();
1418 mainwin->lock_count = 0;
1419 mainwin->menu_lock_count = 0;
1420 mainwin->cursor_count = 0;
1422 mainwin->progressindicator_hook =
1423 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1426 watch_cursor = gdk_cursor_new(GDK_WATCH);
1428 hand_cursor = gdk_cursor_new(GDK_HAND2);
1430 mainwin_list = g_list_append(mainwin_list, mainwin);
1432 /* init work_offline */
1433 if (prefs_common.work_offline)
1434 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1436 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1441 void main_window_destroy(MainWindow *mainwin)
1443 /* TODO : destroy other component */
1444 messageview_destroy(mainwin->messageview);
1445 mainwin->messageview = NULL;
1448 void main_window_update_actions_menu(MainWindow *mainwin)
1450 GtkItemFactory *ifactory;
1452 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1453 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1456 void main_window_cursor_wait(MainWindow *mainwin)
1459 if (mainwin->cursor_count == 0) {
1460 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1461 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1464 mainwin->cursor_count++;
1469 void main_window_cursor_normal(MainWindow *mainwin)
1471 if (mainwin->cursor_count)
1472 mainwin->cursor_count--;
1474 if (mainwin->cursor_count == 0) {
1475 gdk_window_set_cursor(mainwin->window->window, NULL);
1476 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1481 /* lock / unlock the user-interface */
1482 void main_window_lock(MainWindow *mainwin)
1484 if (mainwin->lock_count == 0)
1485 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1487 mainwin->lock_count++;
1489 main_window_set_menu_sensitive(mainwin);
1490 toolbar_main_set_sensitive(mainwin);
1493 void main_window_unlock(MainWindow *mainwin)
1495 if (mainwin->lock_count)
1496 mainwin->lock_count--;
1498 main_window_set_menu_sensitive(mainwin);
1499 toolbar_main_set_sensitive(mainwin);
1501 if (mainwin->lock_count == 0)
1502 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1505 static void main_window_menu_callback_block(MainWindow *mainwin)
1507 mainwin->menu_lock_count++;
1510 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1512 if (mainwin->menu_lock_count)
1513 mainwin->menu_lock_count--;
1516 static guint prefs_tag = 0;
1518 void main_window_reflect_prefs_all(void)
1520 main_window_reflect_prefs_all_real(FALSE);
1523 static gboolean reflect_prefs_timeout_cb(gpointer data)
1525 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1527 MainWindow *mainwin;
1530 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1531 mainwin = (MainWindow *)cur->data;
1533 main_window_show_cur_account(mainwin);
1534 main_window_set_menu_sensitive(mainwin);
1535 toolbar_main_set_sensitive(mainwin);
1538 if (pixmap_theme_changed) {
1539 toolbar_update(TOOLBAR_MAIN, mainwin);
1540 messageview_reflect_prefs_pixmap_theme();
1541 compose_reflect_prefs_pixmap_theme();
1542 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1543 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1545 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1546 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1547 mainwin->online_pixmap);
1548 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1549 gtk_widget_show(pixmap);
1550 mainwin->online_pixmap = pixmap;
1551 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1552 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1553 mainwin->offline_pixmap);
1554 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1555 gtk_widget_show(pixmap);
1556 mainwin->offline_pixmap = pixmap;
1559 headerview_set_font(mainwin->messageview->headerview);
1560 headerview_set_visibility(mainwin->messageview->headerview,
1561 prefs_common.display_header_pane);
1562 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1563 folderview_reflect_prefs();
1564 summary_reflect_prefs();
1565 summary_redisplay_msg(mainwin->summaryview);
1571 void main_window_reflect_prefs_all_now(void)
1573 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1576 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1581 /* re-create colorlabel submenu */
1582 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1583 g_return_if_fail(menu != NULL);
1585 /* clear items. get item pointers. */
1586 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1587 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1589 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1590 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1594 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1596 if (prefs_tag == 0 || pixmap_theme_changed) {
1597 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1598 GINT_TO_POINTER(pixmap_theme_changed));
1602 void main_window_set_summary_column(void)
1605 MainWindow *mainwin;
1607 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1608 mainwin = (MainWindow *)cur->data;
1609 summary_set_column_order(mainwin->summaryview);
1613 void main_window_set_folder_column(void)
1616 MainWindow *mainwin;
1618 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1619 mainwin = (MainWindow *)cur->data;
1620 folderview_set_column_order(mainwin->folderview);
1624 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1625 GList *account_list)
1627 GList *cur_ac, *cur_item;
1628 GtkWidget *menuitem;
1629 PrefsAccount *ac_prefs;
1631 /* destroy all previous menu item */
1632 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1633 while (cur_item != NULL) {
1634 GList *next = cur_item->next;
1635 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1639 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1640 ac_prefs = (PrefsAccount *)cur_ac->data;
1642 menuitem = gtk_menu_item_new_with_label
1643 (ac_prefs->account_name
1644 ? ac_prefs->account_name : _("Untitled"));
1645 gtk_widget_show(menuitem);
1646 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1647 g_signal_connect(G_OBJECT(menuitem), "activate",
1648 G_CALLBACK(account_selector_menu_cb),
1653 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1654 GList *account_list)
1656 GList *cur_ac, *cur_item;
1658 GtkWidget *menuitem;
1659 PrefsAccount *ac_prefs;
1661 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1662 "/Message/Receive");
1664 /* search for separator */
1665 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1666 cur_item = cur_item->next) {
1667 if (GTK_BIN(cur_item->data)->child == NULL) {
1668 cur_item = cur_item->next;
1673 /* destroy all previous menu item */
1674 while (cur_item != NULL) {
1675 GList *next = cur_item->next;
1676 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1680 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1681 ac_prefs = (PrefsAccount *)cur_ac->data;
1683 menuitem = gtk_menu_item_new_with_label
1684 (ac_prefs->account_name ? ac_prefs->account_name
1686 gtk_widget_show(menuitem);
1687 gtk_menu_append(GTK_MENU(menu), menuitem);
1688 g_signal_connect(G_OBJECT(menuitem), "activate",
1689 G_CALLBACK(account_receive_menu_cb),
1694 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1695 GList *account_list)
1697 GList *cur_ac, *cur_item;
1698 GtkWidget *menuitem;
1699 PrefsAccount *ac_prefs;
1700 GtkWidget *menu = NULL;
1702 if (mainwin->toolbar->getall_btn == NULL
1703 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1706 menu = mainwin->toolbar->getall_combo->menu;
1708 /* destroy all previous menu item */
1709 cur_item = GTK_MENU_SHELL(menu)->children;
1710 while (cur_item != NULL) {
1711 GList *next = cur_item->next;
1712 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1716 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1717 ac_prefs = (PrefsAccount *)cur_ac->data;
1719 menuitem = gtk_menu_item_new_with_label
1720 (ac_prefs->account_name
1721 ? ac_prefs->account_name : _("Untitled"));
1722 gtk_widget_show(menuitem);
1723 gtk_menu_append(GTK_MENU(menu), menuitem);
1724 g_signal_connect(G_OBJECT(menuitem), "activate",
1725 G_CALLBACK(account_receive_menu_cb),
1730 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1731 GList *account_list)
1733 GList *cur_ac, *cur_item;
1734 GtkWidget *menuitem;
1735 PrefsAccount *ac_prefs;
1736 GtkWidget *menu = NULL;
1738 if (mainwin->toolbar->compose_mail_btn == NULL
1739 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1742 menu = mainwin->toolbar->compose_combo->menu;
1744 /* destroy all previous menu item */
1745 cur_item = GTK_MENU_SHELL(menu)->children;
1746 while (cur_item != NULL) {
1747 GList *next = cur_item->next;
1748 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1752 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1753 ac_prefs = (PrefsAccount *)cur_ac->data;
1755 menuitem = gtk_menu_item_new_with_label
1756 (ac_prefs->account_name
1757 ? ac_prefs->account_name : _("Untitled"));
1758 gtk_widget_show(menuitem);
1759 gtk_menu_append(GTK_MENU(menu), menuitem);
1760 g_signal_connect(G_OBJECT(menuitem), "activate",
1761 G_CALLBACK(account_compose_menu_cb),
1766 void main_window_set_account_menu(GList *account_list)
1769 MainWindow *mainwin;
1771 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1772 mainwin = (MainWindow *)cur->data;
1773 main_window_set_account_selector_menu(mainwin, account_list);
1774 main_window_set_account_receive_menu(mainwin, account_list);
1775 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1776 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1780 void main_window_set_account_menu_only_toolbar(GList *account_list)
1783 MainWindow *mainwin;
1785 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1786 mainwin = (MainWindow *)cur->data;
1787 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1788 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1792 static void main_window_show_cur_account(MainWindow *mainwin)
1797 ac_name = g_strdup(cur_account
1798 ? (cur_account->account_name
1799 ? cur_account->account_name : _("Untitled"))
1803 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1805 buf = g_strdup(PROG_VERSION);
1806 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1809 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1810 gtk_widget_queue_resize(mainwin->ac_button);
1815 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1817 switch (mainwin->type) {
1818 case SEPARATE_FOLDER:
1819 return mainwin->win.sep_folder.folderwin;
1821 return mainwin->win.sep_both.folderwin;
1827 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1829 switch (mainwin->type) {
1830 case SEPARATE_MESSAGE:
1831 return mainwin->win.sep_message.messagewin;
1833 return mainwin->win.sep_both.messagewin;
1839 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1841 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1842 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1843 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1844 GtkWidget *message_wid = mainwin->messageview->vbox;
1846 debug_print("Changing window separation type from %d to %d\n",
1847 mainwin->type, type);
1849 if (mainwin->type == type) return;
1851 /* remove widgets from those containers */
1852 gtk_widget_ref(folder_wid);
1853 gtk_widget_ref(summary_wid);
1854 gtk_widget_ref(message_wid);
1855 gtkut_container_remove
1856 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1857 gtkut_container_remove
1858 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1859 gtkut_container_remove
1860 (GTK_CONTAINER(message_wid->parent), message_wid);
1862 /* clean containers */
1863 switch (mainwin->type) {
1865 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1867 case SEPARATE_FOLDER:
1868 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1869 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1871 case SEPARATE_MESSAGE:
1872 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1873 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1876 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1877 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1881 gtk_widget_hide(mainwin->window);
1882 main_window_set_widgets(mainwin, type);
1883 gtk_widget_show(mainwin->window);
1885 gtk_widget_unref(folder_wid);
1886 gtk_widget_unref(summary_wid);
1887 gtk_widget_unref(message_wid);
1890 void main_window_toggle_message_view(MainWindow *mainwin)
1892 SummaryView *summaryview = mainwin->summaryview;
1893 union CompositeWin *cwin = &mainwin->win;
1894 GtkWidget *vpaned = NULL;
1895 GtkWidget *container = NULL;
1896 GtkWidget *msgwin = NULL;
1898 switch (mainwin->type) {
1900 vpaned = cwin->sep_none.vpaned;
1901 container = cwin->sep_none.hpaned;
1903 case SEPARATE_FOLDER:
1904 vpaned = cwin->sep_folder.vpaned;
1905 container = mainwin->vbox_body;
1907 case SEPARATE_MESSAGE:
1908 msgwin = mainwin->win.sep_message.messagewin;
1911 msgwin = mainwin->win.sep_both.messagewin;
1916 if (GTK_WIDGET_VISIBLE(msgwin)) {
1917 gtk_widget_hide(msgwin);
1918 mainwin->messageview->visible = FALSE;
1919 summaryview->displayed = NULL;
1921 gtk_widget_show(msgwin);
1922 mainwin->messageview->visible = TRUE;
1924 } else if (vpaned->parent != NULL) {
1925 mainwin->messageview->visible = FALSE;
1926 summaryview->displayed = NULL;
1927 gtk_widget_ref(vpaned);
1928 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1929 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1931 mainwin->messageview->visible = TRUE;
1932 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1933 gtk_container_add(GTK_CONTAINER(container), vpaned);
1934 gtk_widget_unref(vpaned);
1937 if (messageview_is_visible(mainwin->messageview))
1938 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1939 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1941 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1942 GTK_ARROW_UP, GTK_SHADOW_OUT);
1944 if (mainwin->messageview->visible == FALSE)
1945 messageview_clear(mainwin->messageview);
1947 main_window_set_menu_sensitive(mainwin);
1949 prefs_common.msgview_visible = mainwin->messageview->visible;
1951 gtk_widget_grab_focus(summaryview->ctree);
1954 void main_window_get_size(MainWindow *mainwin)
1956 GtkAllocation *allocation;
1958 if (mainwin_list == NULL || mainwin->messageview == NULL) {
1959 debug_print("called after messageview "
1960 "has been deallocated!\n");
1964 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1966 if (allocation->width > 1 && allocation->height > 1) {
1967 prefs_common.summaryview_width = allocation->width;
1969 if ((mainwin->type == SEPARATE_NONE ||
1970 mainwin->type == SEPARATE_FOLDER) &&
1971 messageview_is_visible(mainwin->messageview))
1972 prefs_common.summaryview_height = allocation->height;
1974 prefs_common.mainview_width = allocation->width;
1977 allocation = &mainwin->window->allocation;
1978 if (allocation->width > 1 && allocation->height > 1) {
1979 prefs_common.mainview_height = allocation->height;
1980 prefs_common.mainwin_width = allocation->width;
1981 prefs_common.mainwin_height = allocation->height;
1984 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1985 if (allocation->width > 1 && allocation->height > 1) {
1986 prefs_common.folderview_width = allocation->width;
1987 prefs_common.folderview_height = allocation->height;
1990 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1991 if (allocation->width > 1 && allocation->height > 1) {
1992 prefs_common.msgview_width = allocation->width;
1993 prefs_common.msgview_height = allocation->height;
1996 /* debug_print("summaryview size: %d x %d\n",
1997 prefs_common.summaryview_width,
1998 prefs_common.summaryview_height);
1999 debug_print("folderview size: %d x %d\n",
2000 prefs_common.folderview_width,
2001 prefs_common.folderview_height);
2002 debug_print("messageview size: %d x %d\n",
2003 prefs_common.msgview_width,
2004 prefs_common.msgview_height); */
2007 void main_window_get_position(MainWindow *mainwin)
2012 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2014 prefs_common.mainview_x = x;
2015 prefs_common.mainview_y = y;
2016 prefs_common.mainwin_x = x;
2017 prefs_common.mainwin_y = y;
2019 debug_print("main window position: %d, %d\n", x, y);
2021 window = main_window_get_folder_window(mainwin);
2023 gtkut_widget_get_uposition(window, &x, &y);
2024 prefs_common.folderwin_x = x;
2025 prefs_common.folderwin_y = y;
2026 debug_print("folder window position: %d, %d\n", x, y);
2028 window = main_window_get_message_window(mainwin);
2030 gtkut_widget_get_uposition(window, &x, &y);
2031 prefs_common.main_msgwin_x = x;
2032 prefs_common.main_msgwin_y = y;
2033 debug_print("message window position: %d, %d\n", x, y);
2037 void main_window_progress_on(MainWindow *mainwin)
2039 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2042 void main_window_progress_off(MainWindow *mainwin)
2044 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2045 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2048 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2052 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2053 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2054 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2055 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2058 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2061 if (alertpanel(_("Empty trash"),
2062 _("Delete all messages in trash folders?"),
2063 GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
2064 != G_ALERTALTERNATE)
2066 manage_window_focus_in(mainwin->window, NULL, NULL);
2069 procmsg_empty_all_trash();
2071 if (mainwin->summaryview->folder_item &&
2072 mainwin->summaryview->folder_item->stype == F_TRASH)
2073 gtk_widget_grab_focus(mainwin->folderview->ctree);
2076 void main_window_add_mailbox(MainWindow *mainwin)
2081 path = input_dialog(_("Add mailbox"),
2082 _("Input the location of mailbox.\n"
2083 "If the existing mailbox is specified, it will be\n"
2084 "scanned automatically."),
2087 if (folder_find_from_path(path)) {
2088 alertpanel_error(_("The mailbox '%s' already exists."), path);
2092 folder = folder_new(folder_get_class_from_string("mh"),
2093 !strcmp(path, "Mail") ? _("Mailbox") :
2094 g_path_get_basename(path), path);
2097 if (folder->klass->create_tree(folder) < 0) {
2098 alertpanel_error(_("Creation of the mailbox failed.\n"
2099 "Maybe some files already exist, or you don't have the permission to write there."));
2100 folder_destroy(folder);
2105 folder_set_ui_func(folder, scan_tree_func, mainwin);
2106 folder_scan_tree(folder, TRUE);
2107 folder_set_ui_func(folder, NULL, NULL);
2110 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2112 SensitiveCond state = 0;
2113 SummarySelection selection;
2114 FolderItem *item = mainwin->summaryview->folder_item;
2115 GList *account_list = account_get_list();
2117 selection = summary_get_selection_type(mainwin->summaryview);
2119 if (mainwin->lock_count == 0)
2120 state |= M_UNLOCKED;
2121 if (selection != SUMMARY_NONE)
2122 state |= M_MSG_EXIST;
2123 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2125 /* if (item->folder->type != F_NEWS) */
2126 state |= M_ALLOW_DELETE;
2128 if (prefs_common.immediate_exec == 0
2129 && mainwin->lock_count == 0)
2130 state |= M_DELAY_EXEC;
2132 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2133 || selection != SUMMARY_NONE)
2134 state |= M_HIDE_READ_MSG;
2136 if (mainwin->summaryview->threaded)
2137 state |= M_THREADED;
2139 state |= M_UNTHREADED;
2140 if (selection == SUMMARY_SELECTED_SINGLE ||
2141 selection == SUMMARY_SELECTED_MULTIPLE)
2142 state |= M_TARGET_EXIST;
2143 if (selection == SUMMARY_SELECTED_SINGLE)
2144 state |= M_SINGLE_TARGET_EXIST;
2145 if (mainwin->summaryview->folder_item &&
2146 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2149 state |= M_NOT_NEWS;
2150 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2151 state |= M_ACTIONS_EXIST;
2153 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2154 state |= M_HAVE_QUEUED_MAILS;
2156 if (selection == SUMMARY_SELECTED_SINGLE &&
2158 (folder_has_parent_of_type(item, F_DRAFT) ||
2159 folder_has_parent_of_type(item, F_OUTBOX) ||
2160 folder_has_parent_of_type(item, F_QUEUE))))
2161 state |= M_ALLOW_REEDIT;
2163 state |= M_HAVE_ACCOUNT;
2165 for ( ; account_list != NULL; account_list = account_list->next) {
2166 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2167 state |= M_HAVE_NEWS_ACCOUNT;
2172 if (procmsg_spam_can_learn()) {
2173 state |= M_CAN_LEARN_SPAM;
2176 if (inc_is_active())
2177 state |= M_INC_ACTIVE;
2179 if (mainwin->summaryview->deleted > 0 ||
2180 mainwin->summaryview->moved > 0 ||
2181 mainwin->summaryview->copied > 0)
2182 state |= M_DELAY_EXEC;
2189 void main_window_set_menu_sensitive(MainWindow *mainwin)
2191 GtkItemFactory *ifactory = mainwin->menu_factory;
2192 SensitiveCond state;
2195 GtkWidget *menuitem;
2196 SummaryView *summaryview;
2201 static const struct {
2205 {"/File/Save as...", M_TARGET_EXIST},
2206 {"/File/Print..." , M_TARGET_EXIST},
2207 {"/File/Exit" , M_UNLOCKED},
2209 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
2210 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2212 {"/View/Sort" , M_EXEC},
2213 {"/View/Thread view" , M_EXEC},
2214 {"/View/Expand all threads" , M_MSG_EXIST},
2215 {"/View/Collapse all threads" , M_MSG_EXIST},
2216 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2217 {"/View/Go to/Previous message" , M_MSG_EXIST},
2218 {"/View/Go to/Next message" , M_MSG_EXIST},
2219 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2220 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2221 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2222 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2223 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2224 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2225 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2226 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2227 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2228 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2229 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2231 {"/Message/Receive/Get from current account"
2232 , M_HAVE_ACCOUNT|M_UNLOCKED},
2233 {"/Message/Receive/Get from all accounts"
2234 , M_HAVE_ACCOUNT|M_UNLOCKED},
2235 {"/Message/Receive/Cancel receiving"
2237 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2238 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2239 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2240 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2241 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2242 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2243 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2244 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2245 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2246 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2247 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2248 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2249 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2250 {"/Message/Mark" , M_TARGET_EXIST},
2251 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2252 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2253 {"/Message/Color label" , M_TARGET_EXIST},
2254 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2256 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2257 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2258 {"/Tools/Harvest addresses/from Messages..."
2260 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2261 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2262 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2263 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2264 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2265 {"/Tools/Execute" , M_DELAY_EXEC},
2266 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2268 {"/Configuration", M_UNLOCKED},
2273 state = main_window_get_current_state(mainwin);
2275 for (i = 0; entry[i].entry != NULL; i++) {
2276 sensitive = ((entry[i].cond & state) == entry[i].cond);
2277 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2280 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2282 /* search for separator */
2283 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2284 cur_item = cur_item->next) {
2285 if (GTK_BIN(cur_item->data)->child == NULL) {
2286 cur_item = cur_item->next;
2291 for (; cur_item != NULL; cur_item = cur_item->next) {
2292 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2293 (M_UNLOCKED & state) != 0);
2296 main_window_menu_callback_block(mainwin);
2298 #define SET_CHECK_MENU_ACTIVE(path, active) \
2300 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2301 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2304 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2305 messageview_is_visible(mainwin->messageview));
2307 summaryview = mainwin->summaryview;
2308 menu_path = "/View/Sort/Don't sort";
2310 switch (summaryview->sort_key) {
2311 case SORT_BY_NUMBER:
2312 menu_path = "/View/Sort/by number"; break;
2314 menu_path = "/View/Sort/by Size"; break;
2316 menu_path = "/View/Sort/by Date"; break;
2318 menu_path = "/View/Sort/by From"; break;
2320 menu_path = "/View/Sort/by To"; break;
2321 case SORT_BY_SUBJECT:
2322 menu_path = "/View/Sort/by Subject"; break;
2324 menu_path = "/View/Sort/by color label"; break;
2326 menu_path = "/View/Sort/by mark"; break;
2327 case SORT_BY_STATUS:
2328 menu_path = "/View/Sort/by status"; break;
2330 menu_path = "/View/Sort/by attachment"; break;
2332 menu_path = "/View/Sort/by score"; break;
2333 case SORT_BY_LOCKED:
2334 menu_path = "/View/Sort/by locked"; break;
2337 menu_path = "/View/Sort/Don't sort"; break;
2339 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2341 if (summaryview->sort_type == SORT_ASCENDING) {
2342 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2344 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2347 if (summaryview->sort_key != SORT_BY_NONE) {
2348 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2349 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2351 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2352 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2355 if (mainwin->messageview
2356 && mainwin->messageview->mimeview
2357 && mainwin->messageview->mimeview->textview)
2358 SET_CHECK_MENU_ACTIVE("/View/All headers",
2359 mainwin->messageview->mimeview->textview->show_all_headers);
2360 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2361 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2362 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2363 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2364 if (prefs_common.hide_quotes == 1)
2365 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2366 if (prefs_common.hide_quotes == 2)
2367 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2368 if (prefs_common.hide_quotes == 3)
2369 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2371 #undef SET_CHECK_MENU_ACTIVE
2373 main_window_menu_callback_unblock(mainwin);
2376 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2378 GtkItemFactory *ifactory;
2380 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2383 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2385 gtk_widget_set_sensitive (gtk_item_factory_get_item
2386 (ifactory,"/Message/Mailing-List"), TRUE);
2388 gtk_widget_set_sensitive (gtk_item_factory_get_item
2389 (ifactory,"/Message/Mailing-List"), FALSE);
2392 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2395 GtkWidget *menuitem;
2397 if (!msginfo || !msginfo->extradata) {
2398 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2399 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2400 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2401 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2402 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2403 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2407 /* Mailing list post */
2408 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2409 g_free(msginfo->extradata->list_post);
2410 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2412 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2414 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2416 /* Mailing list help */
2417 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2419 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2421 /* Mailing list subscribe */
2422 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2424 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2426 /* Mailing list unsubscribe */
2427 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2429 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2431 /* Mailing list view archive */
2432 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2434 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2436 /* Mailing list contact owner */
2437 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2439 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2444 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2446 GtkWidget *item, *menu;
2447 const gchar *url_pt ;
2448 gchar url_decoded[BUFFSIZE];
2449 GList *amenu, *alist;
2452 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2454 /* First delete old submenu */
2455 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2456 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2457 alist = amenu->next;
2458 item = GTK_WIDGET (amenu->data);
2459 gtk_widget_destroy (item);
2463 for (url_pt = list_header; url_pt && *url_pt;) {
2464 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2466 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2467 item = gtk_menu_item_new_with_label ((url_decoded));
2468 gtk_signal_connect (GTK_OBJECT(item), "activate",
2469 GTK_SIGNAL_FUNC(mailing_list_compose), NULL);
2471 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2472 !g_strncasecmp (url_decoded, "https:",6)) {
2474 item = gtk_menu_item_new_with_label ((url_decoded));
2475 gtk_signal_connect (GTK_OBJECT(item), "activate",
2476 GTK_SIGNAL_FUNC(mailing_list_open_uri), NULL);
2479 gtk_menu_append (GTK_MENU(menu), item);
2480 gtk_widget_show (item);
2486 gtk_widget_set_sensitive (menuitem, TRUE);
2488 gtk_widget_set_sensitive (menuitem, FALSE);
2494 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2496 gchar tmp[BUFFSIZE];
2502 *url_decoded = '\0';
2506 /* Ignore spaces, comments and tabs () */
2507 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2509 for (;*buf != ')' && *buf != 0x00; buf++);
2511 /* First non space and non comment must be a < */
2514 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2519 *url_decoded = '\0';
2524 *url_decoded = '\0';
2530 decode_uri (url_decoded, (const gchar *)tmp);
2532 /* Prepare the work for the next url in the list */
2533 /* after the closing bracket >, ignore space, comments and tabs */
2534 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2536 for (;*buf != ')' && *buf != 0x00; buf++);
2538 if (!buf || !*buf) {
2543 /* now first non space, non comment must be a comma */
2545 for (;*buf != 0x00; buf++);
2551 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2555 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2556 compose_new(NULL, mailto+7, NULL);
2559 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2564 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2565 open_uri (mailto, prefs_common.uri_cmd);
2568 void main_window_popup(MainWindow *mainwin)
2570 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2571 main_window_show(mainwin);
2573 gtkut_window_popup(mainwin->window);
2575 switch (mainwin->type) {
2576 case SEPARATE_FOLDER:
2577 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2579 case SEPARATE_MESSAGE:
2580 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2583 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2584 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2591 void main_window_show(MainWindow *mainwin)
2593 gtk_widget_show(mainwin->window);
2594 gtk_widget_show(mainwin->vbox_body);
2596 gtk_widget_set_uposition(mainwin->window,
2597 prefs_common.mainwin_x,
2598 prefs_common.mainwin_y);
2600 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2601 prefs_common.folderview_width,
2602 prefs_common.folderview_height);
2603 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2604 prefs_common.summaryview_width,
2605 prefs_common.summaryview_height);
2606 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2607 prefs_common.msgview_width,
2608 prefs_common.msgview_height);
2610 if (mainwin->type & SEPARATE_FOLDER) {
2611 GtkWidget *folderwin;
2613 folderwin = main_window_get_folder_window(mainwin);
2614 gtk_widget_show(folderwin);
2615 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2616 prefs_common.folderwin_y);
2619 if (mainwin->type & SEPARATE_MESSAGE) {
2620 GtkWidget *messagewin;
2622 messagewin = main_window_get_message_window(mainwin);
2623 gtk_widget_show(messagewin);
2624 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2625 prefs_common.main_msgwin_y);
2629 void main_window_hide(MainWindow *mainwin)
2631 main_window_get_size(mainwin);
2632 main_window_get_position(mainwin);
2634 gtk_widget_hide(mainwin->window);
2635 gtk_widget_hide(mainwin->vbox_body);
2637 if (mainwin->type & SEPARATE_FOLDER) {
2638 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2641 if (mainwin->type & SEPARATE_MESSAGE) {
2642 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2646 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2648 GtkWidget *folderwin = NULL;
2649 GtkWidget *messagewin = NULL;
2652 GtkWidget *vbox_body = mainwin->vbox_body;
2653 GtkItemFactory *ifactory = mainwin->menu_factory;
2654 GtkWidget *menuitem;
2655 GtkItemFactory *msgview_ifactory;
2657 debug_print("Setting widgets... ");
2659 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2660 prefs_common.folderview_width,
2661 prefs_common.folderview_height);
2662 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2663 prefs_common.summaryview_width,
2664 prefs_common.summaryview_height);
2665 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2666 prefs_common.msgview_width,
2667 prefs_common.msgview_height);
2669 /* create separated window(s) if needed */
2670 if (type & SEPARATE_FOLDER) {
2671 static GdkGeometry folderwin_geometry;
2673 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2674 gtk_window_set_title(GTK_WINDOW(folderwin),
2675 _("Sylpheed-Claws - Folder View"));
2677 gtk_window_move(GTK_WINDOW(folderwin),
2678 prefs_common.folderwin_x,
2679 prefs_common.folderwin_y);
2681 if (!folderwin_geometry.min_height) {
2682 folderwin_geometry.min_width = 320;
2683 folderwin_geometry.min_height = 200;
2685 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2686 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2688 gtk_widget_set_size_request(folderwin,
2689 prefs_common.folderview_width,
2690 prefs_common.folderview_height);
2692 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2695 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2696 G_CALLBACK(folder_window_close_cb),
2698 gtk_container_add(GTK_CONTAINER(folderwin),
2699 GTK_WIDGET_PTR(mainwin->folderview));
2700 gtk_widget_realize(folderwin);
2702 if (prefs_common.folderview_visible)
2703 gtk_widget_show(folderwin);
2706 if (type & SEPARATE_MESSAGE) {
2707 static GdkGeometry msgwin_geometry;
2709 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2710 gtk_window_set_title(GTK_WINDOW(messagewin),
2711 _("Sylpheed-Claws - Message View"));
2713 gtk_window_move(GTK_WINDOW(messagewin),
2714 prefs_common.main_msgwin_x,
2715 prefs_common.main_msgwin_y);
2717 if (!msgwin_geometry.min_height) {
2718 msgwin_geometry.min_width = 320;
2719 msgwin_geometry.min_height = 200;
2721 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2722 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2724 gtk_widget_set_size_request(messagewin,
2725 prefs_common.msgwin_width,
2726 prefs_common.msgwin_height);
2728 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2730 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2731 G_CALLBACK(message_window_close_cb),
2733 if (messageview_is_visible(mainwin->messageview))
2734 gtk_widget_show(messagewin);
2736 mainwin->messageview->statusbar = mainwin->statusbar;
2737 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2742 hpaned = gtk_hpaned_new();
2743 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2744 gtk_paned_add1(GTK_PANED(hpaned),
2745 GTK_WIDGET_PTR(mainwin->folderview));
2746 gtk_widget_show(hpaned);
2747 gtk_widget_queue_resize(hpaned);
2749 vpaned = gtk_vpaned_new();
2750 if (messageview_is_visible(mainwin->messageview)) {
2751 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2752 gtk_paned_add1(GTK_PANED(vpaned),
2753 GTK_WIDGET_PTR(mainwin->summaryview));
2755 gtk_paned_add2(GTK_PANED(hpaned),
2756 GTK_WIDGET_PTR(mainwin->summaryview));
2757 gtk_widget_ref(vpaned);
2759 gtk_paned_add2(GTK_PANED(vpaned),
2760 GTK_WIDGET_PTR(mainwin->messageview));
2761 gtk_widget_show(vpaned);
2762 gtk_widget_queue_resize(vpaned);
2764 mainwin->win.sep_none.hpaned = hpaned;
2765 mainwin->win.sep_none.vpaned = vpaned;
2767 /* remove headerview if not in prefs */
2768 headerview_set_visibility(mainwin->messageview->headerview,
2769 prefs_common.display_header_pane);
2771 case SEPARATE_FOLDER:
2772 vpaned = gtk_vpaned_new();
2773 if (messageview_is_visible(mainwin->messageview)) {
2774 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2776 gtk_paned_add1(GTK_PANED(vpaned),
2777 GTK_WIDGET_PTR(mainwin->summaryview));
2779 gtk_box_pack_start(GTK_BOX(vbox_body),
2780 GTK_WIDGET_PTR(mainwin->summaryview),
2782 gtk_widget_ref(vpaned);
2784 gtk_paned_add2(GTK_PANED(vpaned),
2785 GTK_WIDGET_PTR(mainwin->messageview));
2786 gtk_widget_show(vpaned);
2787 gtk_widget_queue_resize(vpaned);
2789 mainwin->win.sep_folder.folderwin = folderwin;
2790 mainwin->win.sep_folder.vpaned = vpaned;
2792 /* remove headerview if not in prefs */
2793 headerview_set_visibility(mainwin->messageview->headerview,
2794 prefs_common.display_header_pane);
2797 case SEPARATE_MESSAGE:
2798 hpaned = gtk_hpaned_new();
2799 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2800 gtk_paned_add1(GTK_PANED(hpaned),
2801 GTK_WIDGET_PTR(mainwin->folderview));
2802 gtk_paned_add2(GTK_PANED(hpaned),
2803 GTK_WIDGET_PTR(mainwin->summaryview));
2804 gtk_widget_show(hpaned);
2805 gtk_widget_queue_resize(hpaned);
2806 messageview_add_toolbar(mainwin->messageview, messagewin);
2807 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2808 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2810 mainwin->win.sep_message.messagewin = messagewin;
2811 mainwin->win.sep_message.hpaned = hpaned;
2813 gtk_widget_realize(messagewin);
2814 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2815 gtk_widget_show_all(messagewin);
2816 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2817 mainwin->messageview->handlebox,
2818 prefs_common.toolbar_style);
2820 /* remove headerview if not in prefs */
2821 headerview_set_visibility(mainwin->messageview->headerview,
2822 prefs_common.display_header_pane);
2826 messageview_add_toolbar(mainwin->messageview, messagewin);
2827 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2828 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2830 gtk_box_pack_start(GTK_BOX(vbox_body),
2831 GTK_WIDGET_PTR(mainwin->summaryview),
2834 mainwin->win.sep_both.folderwin = folderwin;
2835 mainwin->win.sep_both.messagewin = messagewin;
2837 gtk_widget_realize(messagewin);
2838 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2839 gtk_widget_show_all(messagewin);
2840 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2841 mainwin->messageview->handlebox,
2842 prefs_common.toolbar_style);
2844 /* remove headerview if not in prefs */
2845 headerview_set_visibility(mainwin->messageview->headerview,
2846 prefs_common.display_header_pane);
2851 if (messageview_is_visible(mainwin->messageview))
2852 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2853 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2855 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2856 GTK_ARROW_UP, GTK_SHADOW_OUT);
2858 gtk_window_move(GTK_WINDOW(mainwin->window),
2859 prefs_common.mainwin_x,
2860 prefs_common.mainwin_y);
2862 gtk_widget_queue_resize(vbox_body);
2863 gtk_widget_queue_resize(mainwin->vbox);
2864 gtk_widget_queue_resize(mainwin->window);
2865 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2866 * and mimeview icon list/ctree lose track of their visibility states */
2867 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2868 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2869 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2870 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2871 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2872 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2874 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2876 mainwin->type = type;
2879 /* toggle menu state */
2880 menuitem = gtk_item_factory_get_item
2881 (ifactory, "/View/Show or hide/Folder tree");
2882 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2883 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2884 prefs_common.folderview_visible);
2885 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2886 menuitem = gtk_item_factory_get_item
2887 (ifactory, "/View/Show or hide/Message view");
2888 gtk_check_menu_item_set_active
2889 (GTK_CHECK_MENU_ITEM(menuitem),
2890 messageview_is_visible(mainwin->messageview));
2892 menuitem = gtk_item_factory_get_item
2893 (ifactory, "/View/Separate folder tree");
2894 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2895 ((type & SEPARATE_FOLDER) != 0));
2896 menuitem = gtk_item_factory_get_item
2897 (ifactory, "/View/Separate message view");
2898 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2899 ((type & SEPARATE_MESSAGE) != 0));
2903 (G_OBJECT(folderwin), "size_allocate",
2904 G_CALLBACK(folder_window_size_allocate_cb),
2909 (G_OBJECT(messagewin), "size_allocate",
2910 G_CALLBACK(message_window_size_allocate_cb),
2914 debug_print("done.\n");
2917 void main_window_destroy_all(void)
2919 while (mainwin_list != NULL) {
2920 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2922 /* free toolbar stuff */
2923 toolbar_clear_list(TOOLBAR_MAIN);
2924 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2925 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2927 mainwin->folderview->mainwin = NULL;
2928 mainwin->summaryview->mainwin = NULL;
2929 mainwin->messageview->mainwin = NULL;
2931 g_free(mainwin->toolbar);
2934 mainwin_list = g_list_remove(mainwin_list, mainwin);
2936 g_list_free(mainwin_list);
2937 mainwin_list = NULL;
2940 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2943 gtk_widget_set_size_request(child, 1, -1);
2946 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2949 gtk_widget_set_size_request(child, -1, -1);
2952 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2955 MainWindow *mainwin = (MainWindow *)data;
2957 if (!event) return FALSE;
2959 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2960 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2963 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2964 menu_button_position, widget,
2965 event->button, event->time);
2970 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2973 MainWindow *mainwin = (MainWindow *)data;
2975 if (mainwin->lock_count == 0)
2976 app_exit_cb(data, 0, widget);
2981 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2984 MainWindow *mainwin = (MainWindow *)data;
2985 GtkWidget *menuitem;
2987 menuitem = gtk_item_factory_get_item
2988 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2989 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2994 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2997 MainWindow *mainwin = (MainWindow *)data;
2998 GtkWidget *menuitem;
3000 menuitem = gtk_item_factory_get_item
3001 (mainwin->menu_factory, "/View/Show or hide/Message view");
3002 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3004 mainwin->messageview->statusbar = mainwin->statusbar;
3005 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3010 static void main_window_size_allocate_cb(GtkWidget *widget,
3011 GtkAllocation *allocation,
3014 MainWindow *mainwin = (MainWindow *)data;
3016 main_window_get_size(mainwin);
3019 static void folder_window_size_allocate_cb(GtkWidget *widget,
3020 GtkAllocation *allocation,
3023 MainWindow *mainwin = (MainWindow *)data;
3025 main_window_get_size(mainwin);
3028 static void message_window_size_allocate_cb(GtkWidget *widget,
3029 GtkAllocation *allocation,
3032 MainWindow *mainwin = (MainWindow *)data;
3034 main_window_get_size(mainwin);
3037 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3040 main_window_add_mailbox(mainwin);
3043 static void update_folderview_cb(MainWindow *mainwin, guint action,
3046 summary_show(mainwin->summaryview, NULL);
3047 folderview_check_new_all();
3050 static void foldersort_cb(MainWindow *mainwin, guint action,
3056 static void import_mbox_cb(MainWindow *mainwin, guint action,
3059 /* only notify if import has failed */
3060 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3061 alertpanel_error(_("Mbox import has failed."));
3065 static void export_mbox_cb(MainWindow *mainwin, guint action,
3068 /* only notify if export has failed */
3069 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3070 alertpanel_error(_("Export to mbox has failed."));
3074 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3077 /* only notify if export has failed */
3078 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3079 alertpanel_error(_("Export to mbox has failed."));
3083 static void empty_trash_cb(MainWindow *mainwin, guint action,
3086 main_window_empty_trash(mainwin, TRUE);
3089 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3091 summary_save_as(mainwin->summaryview);
3094 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3096 summary_print(mainwin->summaryview);
3099 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3101 if (prefs_common.confirm_on_exit) {
3102 if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
3103 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3104 != G_ALERTALTERNATE)
3106 manage_window_focus_in(mainwin->window, NULL, NULL);
3109 app_will_exit(widget, mainwin);
3112 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3115 summary_search(mainwin->summaryview);
3117 message_search(mainwin->messageview);
3120 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3122 prefs_common.show_searchbar = TRUE;
3123 summaryview_activate_quicksearch(mainwin->summaryview);
3126 static void toggle_folder_cb(MainWindow *mainwin, guint action,
3131 active = GTK_CHECK_MENU_ITEM(widget)->active;
3133 switch (mainwin->type) {
3135 case SEPARATE_MESSAGE:
3137 case SEPARATE_FOLDER:
3138 debug_print("separate folder\n");
3140 gtk_widget_show(mainwin->win.sep_folder.folderwin);
3142 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
3146 gtk_widget_show(mainwin->win.sep_both.folderwin);
3148 gtk_widget_hide(mainwin->win.sep_both.folderwin);
3152 prefs_common.folderview_visible = active;
3155 static void toggle_message_cb(MainWindow *mainwin, guint action,
3160 active = GTK_CHECK_MENU_ITEM(widget)->active;
3162 if (active != messageview_is_visible(mainwin->messageview))
3163 summary_toggle_view(mainwin->summaryview);
3166 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3169 toolbar_toggle(action, mainwin);
3172 void main_window_reply_cb(MainWindow *mainwin, guint action,
3175 MessageView *msgview = (MessageView*)mainwin->messageview;
3176 GSList *msginfo_list = NULL;
3178 g_return_if_fail(msgview != NULL);
3180 msginfo_list = summary_get_selection(mainwin->summaryview);
3181 g_return_if_fail(msginfo_list != NULL);
3182 compose_reply_from_messageview(msgview, msginfo_list, action);
3183 g_slist_free(msginfo_list);
3187 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3190 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3191 gtk_widget_show(mainwin->hbox_stat);
3192 prefs_common.show_statusbar = TRUE;
3194 gtk_widget_hide(mainwin->hbox_stat);
3195 prefs_common.show_statusbar = FALSE;
3199 static void separate_widget_cb(MainWindow *mainwin, guint action,
3204 if (GTK_CHECK_MENU_ITEM(widget)->active)
3205 type = mainwin->type | action;
3207 type = mainwin->type & ~action;
3209 main_window_separation_change(mainwin, type);
3211 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
3212 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
3215 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3218 offline_ask_sync = ask_sync;
3220 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3222 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3223 offline_ask_sync = TRUE;
3226 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3228 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3231 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3233 GList *folderlist = folder_get_list();
3234 gboolean found = FALSE;
3236 /* see if there are synchronised folders */
3237 for (; folderlist; folderlist = folderlist->next) {
3238 Folder *folder = (Folder *)folderlist->data;
3239 if (folder_want_synchronise(folder)) {
3248 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3249 _("Do you want to synchronise your folders now?"),
3250 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3253 folder_synchronise(NULL);
3256 static void online_switch_clicked (GtkButton *btn, gpointer data)
3258 MainWindow *mainwin;
3259 GtkItemFactory *ifactory;
3260 GtkCheckMenuItem *menuitem;
3262 mainwin = (MainWindow *) data;
3264 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3265 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3267 g_return_if_fail(mainwin != NULL);
3268 g_return_if_fail(menuitem != NULL);
3270 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3271 gtk_widget_hide (mainwin->online_switch);
3272 gtk_widget_show (mainwin->offline_switch);
3273 menuitem->active = TRUE;
3274 inc_autocheck_timer_remove();
3277 if (prefs_common.work_offline)
3279 mainwindow_check_synchronise(mainwin, TRUE);
3280 prefs_common.work_offline = TRUE;
3281 imap_disconnect_all();
3284 if (!prefs_common.work_offline)
3286 gtk_widget_hide (mainwin->offline_switch);
3287 gtk_widget_show (mainwin->online_switch);
3288 menuitem->active = FALSE;
3289 prefs_common.work_offline = FALSE;
3290 inc_autocheck_timer_set();
3291 refresh_resolvers();
3295 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3298 addressbook_open(NULL);
3301 static void log_window_show_cb(MainWindow *mainwin, guint action,
3304 log_window_show(mainwin->logwin);
3307 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3312 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3314 summary_move_to(mainwin->summaryview);
3317 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3319 summary_copy_to(mainwin->summaryview);
3322 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3324 summary_delete(mainwin->summaryview);
3327 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3329 summary_delete_trash(mainwin->summaryview);
3332 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3334 summary_cancel(mainwin->summaryview);
3337 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3339 summary_open_msg(mainwin->summaryview);
3342 static void view_source_cb(MainWindow *mainwin, guint action,
3345 summary_view_source(mainwin->summaryview);
3348 static void show_all_header_cb(MainWindow *mainwin, guint action,
3351 if (mainwin->menu_lock_count) return;
3352 mainwin->summaryview->messageview->all_headers =
3353 GTK_CHECK_MENU_ITEM(widget)->active;
3354 summary_display_msg_selected(mainwin->summaryview,
3355 GTK_CHECK_MENU_ITEM(widget)->active);
3358 #define SET_CHECK_MENU_ACTIVE(path, active) \
3360 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3361 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3364 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3367 GtkWidget *menuitem;
3368 GtkItemFactory *ifactory = mainwin->menu_factory;
3370 if (mainwin->menu_lock_count) return;
3372 prefs_common.hide_quotes =
3373 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3375 mainwin->menu_lock_count++;
3376 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3377 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3378 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3379 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3380 mainwin->menu_lock_count--;
3382 summary_redisplay_msg(mainwin->summaryview);
3385 #undef SET_CHECK_MENU_ACTIVE
3386 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3388 summary_mark(mainwin->summaryview);
3391 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3393 summary_unmark(mainwin->summaryview);
3396 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3399 summary_mark_as_unread(mainwin->summaryview);
3402 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3405 summary_mark_as_read(mainwin->summaryview);
3408 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3411 summary_mark_all_read(mainwin->summaryview);
3414 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3417 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3420 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3422 summary_reedit(mainwin->summaryview);
3425 static void add_address_cb(MainWindow *mainwin, guint action,
3428 summary_add_address(mainwin->summaryview);
3431 static void set_charset_cb(MainWindow *mainwin, guint action,
3436 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3437 str = conv_get_charset_str((CharSet)action);
3439 g_free(mainwin->messageview->forced_charset);
3440 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3441 procmime_force_charset(str);
3443 summary_redisplay_msg(mainwin->summaryview);
3445 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3449 static void set_decode_cb(MainWindow *mainwin, guint action,
3452 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3453 mainwin->messageview->forced_encoding = (EncodingType)action;
3455 summary_redisplay_msg(mainwin->summaryview);
3457 debug_print("forced encoding: %d\n", action);
3461 static void hide_read_messages (MainWindow *mainwin, guint action,
3464 if (!mainwin->summaryview->folder_item
3465 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3467 summary_toggle_show_read_messages(mainwin->summaryview);
3470 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3472 gboolean threaded = FALSE;
3473 if (mainwin->menu_lock_count) return;
3474 if (!mainwin->summaryview->folder_item) return;
3476 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3478 mainwin->summaryview->folder_item->threaded = threaded;
3480 mainwin->summaryview->threaded = threaded;
3482 summary_show(mainwin->summaryview,
3483 mainwin->summaryview->folder_item);
3486 static void expand_threads_cb(MainWindow *mainwin, guint action,
3489 summary_expand_threads(mainwin->summaryview);
3492 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3495 summary_collapse_threads(mainwin->summaryview);
3498 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3501 prefs_summary_column_open();
3504 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3507 prefs_folder_column_open();
3510 static void sort_summary_cb(MainWindow *mainwin, guint action,
3513 FolderItem *item = mainwin->summaryview->folder_item;
3514 GtkWidget *menuitem;
3516 if (mainwin->menu_lock_count) return;
3518 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3519 menuitem = gtk_item_factory_get_item
3520 (mainwin->menu_factory, "/View/Sort/Ascending");
3521 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3522 GTK_CHECK_MENU_ITEM(menuitem)->active
3523 ? SORT_ASCENDING : SORT_DESCENDING);
3524 item->sort_key = action;
3528 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3531 FolderItem *item = mainwin->summaryview->folder_item;
3533 if (mainwin->menu_lock_count) return;
3535 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3536 summary_sort(mainwin->summaryview,
3537 item->sort_key, (FolderSortType)action);
3540 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3543 summary_attract_by_subject(mainwin->summaryview);
3546 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3551 item = folderview_get_selected_item(mainwin->folderview);
3553 main_window_cursor_wait(mainwin);
3554 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3556 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3557 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3559 STATUSBAR_POP(mainwin);
3560 main_window_cursor_normal(mainwin);
3570 static void deldup_all(FolderItem *item, gpointer _data)
3572 struct DelDupsData *data = _data;
3575 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3577 data->dups += result;
3582 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3585 struct DelDupsData data = {0, 0};
3587 folder_func_to_all_folders(deldup_all, &data);
3588 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3589 "Deleted %d duplicate messages in %d folders.\n",
3591 data.dups, data.folders);
3594 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3596 summary_filter(mainwin->summaryview, (gboolean)action);
3599 static void execute_summary_cb(MainWindow *mainwin, guint action,
3602 summary_execute(mainwin->summaryview);
3605 static void update_summary_cb(MainWindow *mainwin, guint action,
3609 FolderView *folderview = mainwin->folderview;
3611 if (!mainwin->summaryview->folder_item) return;
3612 if (!folderview->opened) return;
3614 folder_update_op_count();
3616 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3617 folderview->opened);
3620 folder_item_scan(fitem);
3621 summary_show(mainwin->summaryview, fitem);
3624 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3626 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3629 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3631 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3634 static void prev_unread_cb(MainWindow *mainwin, guint action,
3637 summary_select_prev_unread(mainwin->summaryview);
3640 static void next_unread_cb(MainWindow *mainwin, guint action,
3643 summary_select_next_unread(mainwin->summaryview);
3646 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3648 summary_select_prev_new(mainwin->summaryview);
3651 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3653 summary_select_next_new(mainwin->summaryview);
3656 static void prev_marked_cb(MainWindow *mainwin, guint action,
3659 summary_select_prev_marked(mainwin->summaryview);
3662 static void next_marked_cb(MainWindow *mainwin, guint action,
3665 summary_select_next_marked(mainwin->summaryview);
3668 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3671 summary_select_prev_labeled(mainwin->summaryview);
3674 static void next_labeled_cb(MainWindow *mainwin, guint action,
3677 summary_select_next_labeled(mainwin->summaryview);
3680 static void last_read_cb(MainWindow *mainwin, guint action,
3683 summary_select_last_read(mainwin->summaryview);
3686 static void parent_cb(MainWindow *mainwin, guint action,
3689 summary_select_parent(mainwin->summaryview);
3692 static void goto_folder_cb(MainWindow *mainwin, guint action,
3695 FolderItem *to_folder;
3697 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3700 folderview_select(mainwin->folderview, to_folder);
3703 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3706 folderview_select_next_unread(mainwin->folderview, FALSE);
3709 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3711 messageview_copy_clipboard(mainwin->messageview);
3714 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3716 MessageView *msgview = mainwin->messageview;
3718 if (messageview_is_visible(msgview) &&
3719 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3720 messageview_select_all(mainwin->messageview);
3722 summary_select_all(mainwin->summaryview);
3725 static void select_thread_cb(MainWindow *mainwin, guint action,
3728 summary_select_thread(mainwin->summaryview);
3731 static void create_filter_cb(MainWindow *mainwin, guint action,
3734 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3737 static void create_processing_cb(MainWindow *mainwin, guint action,
3740 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3743 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3746 prefs_filtering_open(&pre_global_processing,
3747 _("Processing rules to apply before folder rules"),
3748 MANUAL_ANCHOR_PROCESSING,
3752 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3755 prefs_filtering_open(&post_global_processing,
3756 _("Processing rules to apply after folder rules"),
3757 MANUAL_ANCHOR_PROCESSING,
3761 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3764 prefs_filtering_open(&filtering_rules,
3765 _("Filtering configuration"),
3766 MANUAL_ANCHOR_FILTERING,
3770 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3773 prefs_template_open();
3776 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3779 prefs_actions_open(mainwin);
3782 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3785 ssl_manager_open(mainwin);
3788 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3792 new_account_cb(mainwin, 0, widget);
3794 account_open(cur_account);
3798 static void new_account_cb(MainWindow *mainwin, guint action,
3801 account_edit_open();
3802 if (!compose_get_compose_list()) account_add();
3805 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3807 FolderItem *item = NULL;
3808 cur_account = (PrefsAccount *)data;
3810 if (!mainwindow_get_mainwindow())
3812 main_window_show_cur_account(mainwindow_get_mainwindow());
3813 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3814 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3815 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3816 item = folderview_get_selected_item(
3817 mainwindow_get_mainwindow()->folderview);
3819 toolbar_set_compose_button
3820 (mainwindow_get_mainwindow()->toolbar,
3821 FOLDER_TYPE(item->folder) == F_NEWS ?
3822 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3826 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3828 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3829 PrefsAccount *account = (PrefsAccount *)data;
3831 inc_account_mail(mainwin, account);
3834 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3836 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3837 PrefsAccount *account = (PrefsAccount *)data;
3838 FolderItem *item = mainwin->summaryview->folder_item;
3840 compose_new_with_folderitem(account, item);
3843 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3848 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3850 pluginwindow_create();
3853 static void manual_open_cb(MainWindow *mainwin, guint action,
3856 manual_open((ManualType)action, NULL);
3859 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3864 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3866 MainWindow *mainwin = (MainWindow *)data;
3870 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3871 LOCAL_FOLDER(folder)->rootpath,
3875 str = g_strdup_printf(_("Scanning folder %s ..."),
3876 LOCAL_FOLDER(folder)->rootpath);
3878 STATUSBAR_PUSH(mainwin, str);
3879 STATUSBAR_POP(mainwin);
3883 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3886 SummaryView *summary;
3888 g_return_val_if_fail(data, FALSE);
3889 if (!g_list_find(mainwin_list, data))
3891 summary = ((MainWindow *)data)->summaryview;
3892 g_return_val_if_fail(summary, FALSE);
3894 if (GTK_CLIST(summary->ctree)->selection &&
3895 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3901 #define BREAK_ON_MODIFIER_KEY() \
3902 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3904 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3907 MainWindow *mainwin = (MainWindow*) data;
3909 if (!mainwin || !event)
3912 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3914 lastkey = event->keyval;
3918 switch (event->keyval) {
3919 case GDK_Q: /* Quit */
3920 BREAK_ON_MODIFIER_KEY();
3922 app_exit_cb(mainwin, 0, NULL);
3925 if (mainwin->folderview && mainwin->summaryview
3926 && ((!mainwin->summaryview->displayed
3927 && !mainwin->summaryview->selected)
3928 || (mainwin->summaryview->folder_item
3929 && mainwin->summaryview->folder_item->total_msgs == 0))) {
3930 g_signal_stop_emission_by_name(G_OBJECT(widget),
3932 folderview_select_next_unread(mainwin->folderview, TRUE);
3941 #undef BREAK_ON_MODIFIER_KEY
3944 * Harvest addresses for selected folder.
3946 static void addr_harvest_cb( MainWindow *mainwin,
3950 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3954 * Harvest addresses for selected messages in summary view.
3956 static void addr_harvest_msg_cb( MainWindow *mainwin,
3960 summary_harvest_address( mainwin->summaryview );
3964 *\brief get a MainWindow
3966 *\return MainWindow * The first mainwindow in the mainwin_list
3968 MainWindow *mainwindow_get_mainwindow(void)
3970 if (mainwin_list && mainwin_list->data)
3971 return (MainWindow *)(mainwin_list->data);
3976 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3978 ProgressData *data = (ProgressData *) source;
3979 MainWindow *mainwin = (MainWindow *) userdata;
3981 switch (data->cmd) {
3982 case PROGRESS_COMMAND_START:
3983 case PROGRESS_COMMAND_STOP:
3984 gtk_progress_bar_set_fraction
3985 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3987 case PROGRESS_COMMAND_SET_PERCENTAGE:
3988 gtk_progress_bar_set_fraction
3989 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3992 while (gtk_events_pending()) gtk_main_iteration ();
3997 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3999 mainwindow_check_synchronise(mainwin, FALSE);
4002 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4004 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4007 void mainwindow_jump_to(const gchar *target)
4011 FolderItem *item = NULL;
4013 MainWindow *mainwin = mainwindow_get_mainwindow();
4019 printf(_("not initialized\n"));
4023 tmp = g_strdup(target);
4025 if ((p = strstr(tmp, "\r")) != NULL)
4027 if ((p = strstr(tmp, "\n")) != NULL)
4030 if ((item = folder_find_item_from_identifier(tmp))) {
4031 printf(_("selecting folder '%s'\n"), tmp);
4032 folderview_select(mainwin->folderview, item);
4033 main_window_popup(mainwin);
4038 msg = strrchr(tmp, G_DIR_SEPARATOR);
4041 if ((item = folder_find_item_from_identifier(tmp))) {
4042 printf(_("selecting folder '%s'\n"), tmp);
4043 folderview_select(mainwin->folderview, item);
4045 if (item && msg && atoi(msg)) {
4046 printf(_("selecting message %d\n"), atoi(msg));
4047 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4048 summary_display_msg_selected(mainwin->summaryview, FALSE);
4049 main_window_popup(mainwin);
4055 printf("'%s' not found\n", tmp);