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/Show 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(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 folderview->mainwin = mainwin;
1264 folderview->summaryview = summaryview;
1266 summaryview->mainwin = mainwin;
1267 summaryview->folderview = folderview;
1268 summaryview->messageview = messageview;
1269 summaryview->window = window;
1271 messageview->statusbar = statusbar;
1272 mainwin->vbox = vbox;
1273 mainwin->menubar = menubar;
1274 mainwin->menu_factory = ifactory;
1275 mainwin->handlebox = handlebox;
1276 mainwin->vbox_body = vbox_body;
1277 mainwin->hbox_stat = hbox_stat;
1278 mainwin->statusbar = statusbar;
1279 mainwin->progressbar = progressbar;
1280 mainwin->statuslabel = statuslabel;
1281 mainwin->online_switch = online_switch;
1282 mainwin->online_pixmap = online_pixmap;
1283 mainwin->offline_pixmap = offline_pixmap;
1284 mainwin->ac_button = ac_button;
1285 mainwin->ac_label = ac_label;
1286 mainwin->offline_switch = offline_switch;
1288 /* set context IDs for status bar */
1289 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1290 (GTK_STATUSBAR(statusbar), "Main Window");
1291 mainwin->folderview_cid = gtk_statusbar_get_context_id
1292 (GTK_STATUSBAR(statusbar), "Folder View");
1293 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1294 (GTK_STATUSBAR(statusbar), "Summary View");
1295 mainwin->messageview_cid = gtk_statusbar_get_context_id
1296 (GTK_STATUSBAR(statusbar), "Message View");
1298 messageview->statusbar_cid = mainwin->messageview_cid;
1300 /* allocate colors for summary view and folder view */
1301 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1302 summaryview->color_marked.blue = (guint16)65535;
1304 summaryview->color_dim.red = summaryview->color_dim.green =
1305 summaryview->color_dim.blue = COLOR_DIM;
1307 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1308 &folderview->color_new);
1310 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1311 &folderview->color_op);
1313 summaryview->color_important.red = 0;
1314 summaryview->color_important.green = 0;
1315 summaryview->color_important.blue = (guint16)65535;
1317 color[0] = summaryview->color_marked;
1318 color[1] = summaryview->color_dim;
1319 color[2] = folderview->color_new;
1320 color[3] = folderview->color_op;
1322 colormap = gdk_drawable_get_colormap(window->window);
1323 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1324 for (i = 0; i < 4; i++) {
1325 if (success[i] == FALSE)
1326 g_warning("MainWindow: color allocation %d failed\n", i);
1329 debug_print("done.\n");
1331 messageview->visible = prefs_common.msgview_visible;
1333 main_window_set_widgets(mainwin, type);
1335 g_signal_connect(G_OBJECT(window), "size_allocate",
1336 G_CALLBACK(main_window_size_allocate_cb),
1339 /* set menu items */
1340 menuitem = gtk_item_factory_get_item
1341 (ifactory, "/View/Character encoding/Auto detect");
1342 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1344 switch (prefs_common.toolbar_style) {
1346 menuitem = gtk_item_factory_get_item
1347 (ifactory, "/View/Show or hide/Toolbar/Hide");
1350 menuitem = gtk_item_factory_get_item
1351 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1354 menuitem = gtk_item_factory_get_item
1355 (ifactory, "/View/Show or hide/Toolbar/Text only");
1358 menuitem = gtk_item_factory_get_item
1359 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1361 case TOOLBAR_BOTH_HORIZ:
1362 menuitem = gtk_item_factory_get_item
1364 "/View/Show or hide/Toolbar/Text beside icons");
1366 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1368 gtk_widget_hide(mainwin->hbox_stat);
1369 menuitem = gtk_item_factory_get_item
1370 (ifactory, "/View/Show or hide/Status bar");
1371 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1372 prefs_common.show_statusbar);
1374 /* set account selection menu */
1375 ac_menu = gtk_item_factory_get_widget
1376 (ifactory, "/Configuration/Change current account");
1377 mainwin->ac_menu = ac_menu;
1379 toolbar_main_set_sensitive(mainwin);
1381 /* create actions menu */
1382 main_window_update_actions_menu(mainwin);
1384 main_create_mailing_list_menu (mainwin, NULL);
1386 /* attach accel groups to main window */
1387 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1388 gtk_window_add_accel_group \
1390 gtk_item_factory_from_widget(menu)->accel_group); \
1391 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1393 G_CALLBACK(main_window_accel_activate), mainwin);
1396 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1398 /* connect the accelerators for equivalent
1399 menu items in different menus */
1400 menu_connect_identical_items();
1403 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1405 gtk_widget_show(mainwin->window);
1407 /* initialize views */
1408 folderview_init(folderview);
1409 summary_init(summaryview);
1410 messageview_init(messageview);
1411 log_window_init(mainwin->logwin);
1412 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1413 prefs_common.loglength);
1415 sslcertwindow_register_hook();
1417 mainwin->lock_count = 0;
1418 mainwin->menu_lock_count = 0;
1419 mainwin->cursor_count = 0;
1421 mainwin->progressindicator_hook =
1422 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1425 watch_cursor = gdk_cursor_new(GDK_WATCH);
1427 hand_cursor = gdk_cursor_new(GDK_HAND2);
1429 mainwin_list = g_list_append(mainwin_list, mainwin);
1431 /* init work_offline */
1432 if (prefs_common.work_offline)
1433 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1435 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1440 void main_window_destroy(MainWindow *mainwin)
1442 /* TODO : destroy other component */
1443 messageview_destroy(mainwin->messageview);
1444 mainwin->messageview = NULL;
1447 void main_window_update_actions_menu(MainWindow *mainwin)
1449 GtkItemFactory *ifactory;
1451 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1452 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1455 void main_window_cursor_wait(MainWindow *mainwin)
1458 if (mainwin->cursor_count == 0) {
1459 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1460 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1463 mainwin->cursor_count++;
1468 void main_window_cursor_normal(MainWindow *mainwin)
1470 if (mainwin->cursor_count)
1471 mainwin->cursor_count--;
1473 if (mainwin->cursor_count == 0) {
1474 gdk_window_set_cursor(mainwin->window->window, NULL);
1475 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1480 /* lock / unlock the user-interface */
1481 void main_window_lock(MainWindow *mainwin)
1483 if (mainwin->lock_count == 0)
1484 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1486 mainwin->lock_count++;
1488 main_window_set_menu_sensitive(mainwin);
1489 toolbar_main_set_sensitive(mainwin);
1492 void main_window_unlock(MainWindow *mainwin)
1494 if (mainwin->lock_count)
1495 mainwin->lock_count--;
1497 main_window_set_menu_sensitive(mainwin);
1498 toolbar_main_set_sensitive(mainwin);
1500 if (mainwin->lock_count == 0)
1501 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1504 static void main_window_menu_callback_block(MainWindow *mainwin)
1506 mainwin->menu_lock_count++;
1509 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1511 if (mainwin->menu_lock_count)
1512 mainwin->menu_lock_count--;
1515 static guint prefs_tag = 0;
1517 void main_window_reflect_prefs_all(void)
1519 main_window_reflect_prefs_all_real(FALSE);
1522 static gboolean reflect_prefs_timeout_cb(gpointer data)
1524 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1526 MainWindow *mainwin;
1529 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1530 mainwin = (MainWindow *)cur->data;
1532 main_window_show_cur_account(mainwin);
1533 main_window_set_menu_sensitive(mainwin);
1534 toolbar_main_set_sensitive(mainwin);
1537 if (pixmap_theme_changed) {
1538 toolbar_update(TOOLBAR_MAIN, mainwin);
1539 messageview_reflect_prefs_pixmap_theme();
1540 compose_reflect_prefs_pixmap_theme();
1541 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1542 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1544 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1545 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1546 mainwin->online_pixmap);
1547 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1548 gtk_widget_show(pixmap);
1549 mainwin->online_pixmap = pixmap;
1550 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1551 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1552 mainwin->offline_pixmap);
1553 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1554 gtk_widget_show(pixmap);
1555 mainwin->offline_pixmap = pixmap;
1558 headerview_set_font(mainwin->messageview->headerview);
1559 headerview_set_visibility(mainwin->messageview->headerview,
1560 prefs_common.display_header_pane);
1561 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1562 folderview_reflect_prefs();
1563 summary_reflect_prefs();
1564 summary_redisplay_msg(mainwin->summaryview);
1570 void main_window_reflect_prefs_all_now(void)
1572 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1575 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1580 /* re-create colorlabel submenu */
1581 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1582 g_return_if_fail(menu != NULL);
1584 /* clear items. get item pointers. */
1585 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1586 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1588 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1589 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1593 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1595 if (prefs_tag == 0 || pixmap_theme_changed) {
1596 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1597 GINT_TO_POINTER(pixmap_theme_changed));
1601 void main_window_set_summary_column(void)
1604 MainWindow *mainwin;
1606 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1607 mainwin = (MainWindow *)cur->data;
1608 summary_set_column_order(mainwin->summaryview);
1612 void main_window_set_folder_column(void)
1615 MainWindow *mainwin;
1617 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1618 mainwin = (MainWindow *)cur->data;
1619 folderview_set_column_order(mainwin->folderview);
1623 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1624 GList *account_list)
1626 GList *cur_ac, *cur_item;
1627 GtkWidget *menuitem;
1628 PrefsAccount *ac_prefs;
1630 /* destroy all previous menu item */
1631 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1632 while (cur_item != NULL) {
1633 GList *next = cur_item->next;
1634 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1638 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1639 ac_prefs = (PrefsAccount *)cur_ac->data;
1641 menuitem = gtk_menu_item_new_with_label
1642 (ac_prefs->account_name
1643 ? ac_prefs->account_name : _("Untitled"));
1644 gtk_widget_show(menuitem);
1645 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1646 g_signal_connect(G_OBJECT(menuitem), "activate",
1647 G_CALLBACK(account_selector_menu_cb),
1652 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1653 GList *account_list)
1655 GList *cur_ac, *cur_item;
1657 GtkWidget *menuitem;
1658 PrefsAccount *ac_prefs;
1660 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1661 "/Message/Receive");
1663 /* search for separator */
1664 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1665 cur_item = cur_item->next) {
1666 if (GTK_BIN(cur_item->data)->child == NULL) {
1667 cur_item = cur_item->next;
1672 /* destroy all previous menu item */
1673 while (cur_item != NULL) {
1674 GList *next = cur_item->next;
1675 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1679 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1680 ac_prefs = (PrefsAccount *)cur_ac->data;
1682 menuitem = gtk_menu_item_new_with_label
1683 (ac_prefs->account_name ? ac_prefs->account_name
1685 gtk_widget_show(menuitem);
1686 gtk_menu_append(GTK_MENU(menu), menuitem);
1687 g_signal_connect(G_OBJECT(menuitem), "activate",
1688 G_CALLBACK(account_receive_menu_cb),
1693 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1694 GList *account_list)
1696 GList *cur_ac, *cur_item;
1697 GtkWidget *menuitem;
1698 PrefsAccount *ac_prefs;
1699 GtkWidget *menu = NULL;
1701 if (mainwin->toolbar->getall_btn == NULL
1702 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1705 menu = mainwin->toolbar->getall_combo->menu;
1707 /* destroy all previous menu item */
1708 cur_item = GTK_MENU_SHELL(menu)->children;
1709 while (cur_item != NULL) {
1710 GList *next = cur_item->next;
1711 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1715 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1716 ac_prefs = (PrefsAccount *)cur_ac->data;
1718 menuitem = gtk_menu_item_new_with_label
1719 (ac_prefs->account_name
1720 ? ac_prefs->account_name : _("Untitled"));
1721 gtk_widget_show(menuitem);
1722 gtk_menu_append(GTK_MENU(menu), menuitem);
1723 g_signal_connect(G_OBJECT(menuitem), "activate",
1724 G_CALLBACK(account_receive_menu_cb),
1729 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1730 GList *account_list)
1732 GList *cur_ac, *cur_item;
1733 GtkWidget *menuitem;
1734 PrefsAccount *ac_prefs;
1735 GtkWidget *menu = NULL;
1737 if (mainwin->toolbar->compose_mail_btn == NULL
1738 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1741 menu = mainwin->toolbar->compose_combo->menu;
1743 /* destroy all previous menu item */
1744 cur_item = GTK_MENU_SHELL(menu)->children;
1745 while (cur_item != NULL) {
1746 GList *next = cur_item->next;
1747 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1751 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1752 ac_prefs = (PrefsAccount *)cur_ac->data;
1754 menuitem = gtk_menu_item_new_with_label
1755 (ac_prefs->account_name
1756 ? ac_prefs->account_name : _("Untitled"));
1757 gtk_widget_show(menuitem);
1758 gtk_menu_append(GTK_MENU(menu), menuitem);
1759 g_signal_connect(G_OBJECT(menuitem), "activate",
1760 G_CALLBACK(account_compose_menu_cb),
1765 void main_window_set_account_menu(GList *account_list)
1768 MainWindow *mainwin;
1770 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1771 mainwin = (MainWindow *)cur->data;
1772 main_window_set_account_selector_menu(mainwin, account_list);
1773 main_window_set_account_receive_menu(mainwin, account_list);
1774 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1775 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1779 void main_window_set_account_menu_only_toolbar(GList *account_list)
1782 MainWindow *mainwin;
1784 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1785 mainwin = (MainWindow *)cur->data;
1786 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1787 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1791 static void main_window_show_cur_account(MainWindow *mainwin)
1796 ac_name = g_strdup(cur_account
1797 ? (cur_account->account_name
1798 ? cur_account->account_name : _("Untitled"))
1802 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1804 buf = g_strdup(PROG_VERSION);
1805 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1808 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1809 gtk_widget_queue_resize(mainwin->ac_button);
1814 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1816 switch (mainwin->type) {
1817 case SEPARATE_FOLDER:
1818 return mainwin->win.sep_folder.folderwin;
1820 return mainwin->win.sep_both.folderwin;
1826 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1828 switch (mainwin->type) {
1829 case SEPARATE_MESSAGE:
1830 return mainwin->win.sep_message.messagewin;
1832 return mainwin->win.sep_both.messagewin;
1838 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1840 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1841 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1842 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1843 GtkWidget *message_wid = mainwin->messageview->vbox;
1845 debug_print("Changing window separation type from %d to %d\n",
1846 mainwin->type, type);
1848 if (mainwin->type == type) return;
1850 /* remove widgets from those containers */
1851 gtk_widget_ref(folder_wid);
1852 gtk_widget_ref(summary_wid);
1853 gtk_widget_ref(message_wid);
1854 gtkut_container_remove
1855 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1856 gtkut_container_remove
1857 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1858 gtkut_container_remove
1859 (GTK_CONTAINER(message_wid->parent), message_wid);
1861 /* clean containers */
1862 switch (mainwin->type) {
1864 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1866 case SEPARATE_FOLDER:
1867 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1868 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1870 case SEPARATE_MESSAGE:
1871 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1872 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1875 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1876 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1880 gtk_widget_hide(mainwin->window);
1881 main_window_set_widgets(mainwin, type);
1882 gtk_widget_show(mainwin->window);
1884 gtk_widget_unref(folder_wid);
1885 gtk_widget_unref(summary_wid);
1886 gtk_widget_unref(message_wid);
1889 void main_window_toggle_message_view(MainWindow *mainwin)
1891 SummaryView *summaryview = mainwin->summaryview;
1892 union CompositeWin *cwin = &mainwin->win;
1893 GtkWidget *vpaned = NULL;
1894 GtkWidget *container = NULL;
1895 GtkWidget *msgwin = NULL;
1897 switch (mainwin->type) {
1899 vpaned = cwin->sep_none.vpaned;
1900 container = cwin->sep_none.hpaned;
1902 case SEPARATE_FOLDER:
1903 vpaned = cwin->sep_folder.vpaned;
1904 container = mainwin->vbox_body;
1906 case SEPARATE_MESSAGE:
1907 msgwin = mainwin->win.sep_message.messagewin;
1910 msgwin = mainwin->win.sep_both.messagewin;
1915 if (GTK_WIDGET_VISIBLE(msgwin)) {
1916 gtk_widget_hide(msgwin);
1917 mainwin->messageview->visible = FALSE;
1918 summaryview->displayed = NULL;
1920 gtk_widget_show(msgwin);
1921 mainwin->messageview->visible = TRUE;
1923 } else if (vpaned->parent != NULL) {
1924 mainwin->messageview->visible = FALSE;
1925 summaryview->displayed = NULL;
1926 gtk_widget_ref(vpaned);
1927 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1928 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1930 mainwin->messageview->visible = TRUE;
1931 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1932 gtk_container_add(GTK_CONTAINER(container), vpaned);
1933 gtk_widget_unref(vpaned);
1936 if (messageview_is_visible(mainwin->messageview))
1937 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1938 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1940 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1941 GTK_ARROW_UP, GTK_SHADOW_OUT);
1943 if (mainwin->messageview->visible == FALSE)
1944 messageview_clear(mainwin->messageview);
1946 main_window_set_menu_sensitive(mainwin);
1948 prefs_common.msgview_visible = mainwin->messageview->visible;
1950 gtk_widget_grab_focus(summaryview->ctree);
1953 void main_window_get_size(MainWindow *mainwin)
1955 GtkAllocation *allocation;
1957 if (mainwin_list == NULL || mainwin->messageview == NULL) {
1958 debug_print("called after messageview "
1959 "has been deallocated!\n");
1963 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1965 if (allocation->width > 1 && allocation->height > 1) {
1966 prefs_common.summaryview_width = allocation->width;
1968 if ((mainwin->type == SEPARATE_NONE ||
1969 mainwin->type == SEPARATE_FOLDER) &&
1970 messageview_is_visible(mainwin->messageview))
1971 prefs_common.summaryview_height = allocation->height;
1973 prefs_common.mainview_width = allocation->width;
1976 allocation = &mainwin->window->allocation;
1977 if (allocation->width > 1 && allocation->height > 1) {
1978 prefs_common.mainview_height = allocation->height;
1979 prefs_common.mainwin_width = allocation->width;
1980 prefs_common.mainwin_height = allocation->height;
1983 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1984 if (allocation->width > 1 && allocation->height > 1) {
1985 prefs_common.folderview_width = allocation->width;
1986 prefs_common.folderview_height = allocation->height;
1989 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1990 if (allocation->width > 1 && allocation->height > 1) {
1991 prefs_common.msgview_width = allocation->width;
1992 prefs_common.msgview_height = allocation->height;
1995 /* debug_print("summaryview size: %d x %d\n",
1996 prefs_common.summaryview_width,
1997 prefs_common.summaryview_height);
1998 debug_print("folderview size: %d x %d\n",
1999 prefs_common.folderview_width,
2000 prefs_common.folderview_height);
2001 debug_print("messageview size: %d x %d\n",
2002 prefs_common.msgview_width,
2003 prefs_common.msgview_height); */
2006 void main_window_get_position(MainWindow *mainwin)
2011 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2013 prefs_common.mainview_x = x;
2014 prefs_common.mainview_y = y;
2015 prefs_common.mainwin_x = x;
2016 prefs_common.mainwin_y = y;
2018 debug_print("main window position: %d, %d\n", x, y);
2020 window = main_window_get_folder_window(mainwin);
2022 gtkut_widget_get_uposition(window, &x, &y);
2023 prefs_common.folderwin_x = x;
2024 prefs_common.folderwin_y = y;
2025 debug_print("folder window position: %d, %d\n", x, y);
2027 window = main_window_get_message_window(mainwin);
2029 gtkut_widget_get_uposition(window, &x, &y);
2030 prefs_common.main_msgwin_x = x;
2031 prefs_common.main_msgwin_y = y;
2032 debug_print("message window position: %d, %d\n", x, y);
2036 void main_window_progress_on(MainWindow *mainwin)
2038 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2041 void main_window_progress_off(MainWindow *mainwin)
2043 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2044 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2047 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2051 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2052 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2053 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2054 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2057 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2060 if (alertpanel(_("Empty trash"),
2061 _("Delete all messages in trash folders?"),
2062 GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
2063 != G_ALERTALTERNATE)
2065 manage_window_focus_in(mainwin->window, NULL, NULL);
2068 procmsg_empty_all_trash();
2070 if (mainwin->summaryview->folder_item &&
2071 mainwin->summaryview->folder_item->stype == F_TRASH)
2072 gtk_widget_grab_focus(mainwin->folderview->ctree);
2075 void main_window_add_mailbox(MainWindow *mainwin)
2080 path = input_dialog(_("Add mailbox"),
2081 _("Input the location of mailbox.\n"
2082 "If the existing mailbox is specified, it will be\n"
2083 "scanned automatically."),
2086 if (folder_find_from_path(path)) {
2087 alertpanel_error(_("The mailbox '%s' already exists."), path);
2091 folder = folder_new(folder_get_class_from_string("mh"),
2092 !strcmp(path, "Mail") ? _("Mailbox") :
2093 g_path_get_basename(path), path);
2096 if (folder->klass->create_tree(folder) < 0) {
2097 alertpanel_error(_("Creation of the mailbox failed.\n"
2098 "Maybe some files already exist, or you don't have the permission to write there."));
2099 folder_destroy(folder);
2104 folder_set_ui_func(folder, scan_tree_func, mainwin);
2105 folder_scan_tree(folder, TRUE);
2106 folder_set_ui_func(folder, NULL, NULL);
2109 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2111 SensitiveCond state = 0;
2112 SummarySelection selection;
2113 FolderItem *item = mainwin->summaryview->folder_item;
2114 GList *account_list = account_get_list();
2116 selection = summary_get_selection_type(mainwin->summaryview);
2118 if (mainwin->lock_count == 0)
2119 state |= M_UNLOCKED;
2120 if (selection != SUMMARY_NONE)
2121 state |= M_MSG_EXIST;
2122 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2124 /* if (item->folder->type != F_NEWS) */
2125 state |= M_ALLOW_DELETE;
2127 if (prefs_common.immediate_exec == 0
2128 && mainwin->lock_count == 0)
2129 state |= M_DELAY_EXEC;
2131 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2132 || selection != SUMMARY_NONE)
2133 state |= M_HIDE_READ_MSG;
2135 if (mainwin->summaryview->threaded)
2136 state |= M_THREADED;
2138 state |= M_UNTHREADED;
2139 if (selection == SUMMARY_SELECTED_SINGLE ||
2140 selection == SUMMARY_SELECTED_MULTIPLE)
2141 state |= M_TARGET_EXIST;
2142 if (selection == SUMMARY_SELECTED_SINGLE)
2143 state |= M_SINGLE_TARGET_EXIST;
2144 if (mainwin->summaryview->folder_item &&
2145 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2148 state |= M_NOT_NEWS;
2149 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2150 state |= M_ACTIONS_EXIST;
2152 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2153 state |= M_HAVE_QUEUED_MAILS;
2155 if (selection == SUMMARY_SELECTED_SINGLE &&
2157 (folder_has_parent_of_type(item, F_DRAFT) ||
2158 folder_has_parent_of_type(item, F_OUTBOX) ||
2159 folder_has_parent_of_type(item, F_QUEUE))))
2160 state |= M_ALLOW_REEDIT;
2162 state |= M_HAVE_ACCOUNT;
2164 for ( ; account_list != NULL; account_list = account_list->next) {
2165 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2166 state |= M_HAVE_NEWS_ACCOUNT;
2171 if (procmsg_spam_can_learn()) {
2172 state |= M_CAN_LEARN_SPAM;
2175 if (inc_is_active())
2176 state |= M_INC_ACTIVE;
2178 if (mainwin->summaryview->deleted > 0 ||
2179 mainwin->summaryview->moved > 0 ||
2180 mainwin->summaryview->copied > 0)
2181 state |= M_DELAY_EXEC;
2188 void main_window_set_menu_sensitive(MainWindow *mainwin)
2190 GtkItemFactory *ifactory = mainwin->menu_factory;
2191 SensitiveCond state;
2194 GtkWidget *menuitem;
2195 SummaryView *summaryview;
2200 static const struct {
2204 {"/File/Save as...", M_TARGET_EXIST},
2205 {"/File/Print..." , M_TARGET_EXIST},
2206 {"/File/Exit" , M_UNLOCKED},
2208 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
2210 {"/View/Sort" , M_EXEC},
2211 {"/View/Thread view" , M_EXEC},
2212 {"/View/Expand all threads" , M_MSG_EXIST},
2213 {"/View/Collapse all threads" , M_MSG_EXIST},
2214 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2215 {"/View/Go to/Previous message" , M_MSG_EXIST},
2216 {"/View/Go to/Next message" , M_MSG_EXIST},
2217 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2218 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2219 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2220 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2221 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2222 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2223 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2224 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2225 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
2226 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2227 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2229 {"/Message/Receive/Get from current account"
2230 , M_HAVE_ACCOUNT|M_UNLOCKED},
2231 {"/Message/Receive/Get from all accounts"
2232 , M_HAVE_ACCOUNT|M_UNLOCKED},
2233 {"/Message/Receive/Cancel receiving"
2235 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2236 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2237 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2238 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2239 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2240 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2241 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2242 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2243 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2244 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2245 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2246 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2247 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2248 {"/Message/Mark" , M_TARGET_EXIST},
2249 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2250 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2251 {"/Message/Color label" , M_TARGET_EXIST},
2252 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2254 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2255 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2256 {"/Tools/Harvest addresses/from Messages..."
2258 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2259 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2260 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2261 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2262 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2263 {"/Tools/Execute" , M_DELAY_EXEC},
2264 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2266 {"/Configuration", M_UNLOCKED},
2271 state = main_window_get_current_state(mainwin);
2273 for (i = 0; entry[i].entry != NULL; i++) {
2274 sensitive = ((entry[i].cond & state) == entry[i].cond);
2275 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2278 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2280 /* search for separator */
2281 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2282 cur_item = cur_item->next) {
2283 if (GTK_BIN(cur_item->data)->child == NULL) {
2284 cur_item = cur_item->next;
2289 for (; cur_item != NULL; cur_item = cur_item->next) {
2290 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2291 (M_UNLOCKED & state) != 0);
2294 main_window_menu_callback_block(mainwin);
2296 #define SET_CHECK_MENU_ACTIVE(path, active) \
2298 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2299 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2302 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2303 messageview_is_visible(mainwin->messageview));
2305 summaryview = mainwin->summaryview;
2306 menu_path = "/View/Sort/Don't sort";
2308 switch (summaryview->sort_key) {
2309 case SORT_BY_NUMBER:
2310 menu_path = "/View/Sort/by number"; break;
2312 menu_path = "/View/Sort/by Size"; break;
2314 menu_path = "/View/Sort/by Date"; break;
2316 menu_path = "/View/Sort/by From"; break;
2318 menu_path = "/View/Sort/by To"; break;
2319 case SORT_BY_SUBJECT:
2320 menu_path = "/View/Sort/by Subject"; break;
2322 menu_path = "/View/Sort/by color label"; break;
2324 menu_path = "/View/Sort/by mark"; break;
2325 case SORT_BY_STATUS:
2326 menu_path = "/View/Sort/by status"; break;
2328 menu_path = "/View/Sort/by attachment"; break;
2330 menu_path = "/View/Sort/by score"; break;
2331 case SORT_BY_LOCKED:
2332 menu_path = "/View/Sort/by locked"; break;
2335 menu_path = "/View/Sort/Don't sort"; break;
2337 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2339 if (summaryview->sort_type == SORT_ASCENDING) {
2340 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2342 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2345 if (summaryview->sort_key != SORT_BY_NONE) {
2346 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2347 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2349 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2350 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2353 if (mainwin->messageview
2354 && mainwin->messageview->mimeview
2355 && mainwin->messageview->mimeview->textview)
2356 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
2357 mainwin->messageview->mimeview->textview->show_all_headers);
2358 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2359 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2360 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2361 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2362 if (prefs_common.hide_quotes == 1)
2363 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2364 if (prefs_common.hide_quotes == 2)
2365 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2366 if (prefs_common.hide_quotes == 3)
2367 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2369 #undef SET_CHECK_MENU_ACTIVE
2371 main_window_menu_callback_unblock(mainwin);
2374 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2376 GtkItemFactory *ifactory;
2378 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2381 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2383 gtk_widget_set_sensitive (gtk_item_factory_get_item
2384 (ifactory,"/Message/Mailing-List"), TRUE);
2386 gtk_widget_set_sensitive (gtk_item_factory_get_item
2387 (ifactory,"/Message/Mailing-List"), FALSE);
2390 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2393 GtkWidget *menuitem;
2395 if (!msginfo || !msginfo->extradata) {
2396 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2397 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2398 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2399 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2400 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2401 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2405 /* Mailing list post */
2406 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2407 g_free(msginfo->extradata->list_post);
2408 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2410 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2412 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2414 /* Mailing list help */
2415 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2417 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2419 /* Mailing list subscribe */
2420 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2422 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2424 /* Mailing list unsubscribe */
2425 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2427 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2429 /* Mailing list view archive */
2430 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2432 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2434 /* Mailing list contact owner */
2435 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2437 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2442 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2444 GtkWidget *item, *menu;
2445 const gchar *url_pt ;
2446 gchar url_decoded[BUFFSIZE];
2447 GList *amenu, *alist;
2450 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2452 /* First delete old submenu */
2453 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2454 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2455 alist = amenu->next;
2456 item = GTK_WIDGET (amenu->data);
2457 gtk_widget_destroy (item);
2461 for (url_pt = list_header; url_pt && *url_pt;) {
2462 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2464 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2465 item = gtk_menu_item_new_with_label ((url_decoded));
2466 gtk_signal_connect (GTK_OBJECT(item), "activate",
2467 GTK_SIGNAL_FUNC(mailing_list_compose), NULL);
2469 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2470 !g_strncasecmp (url_decoded, "https:",6)) {
2472 item = gtk_menu_item_new_with_label ((url_decoded));
2473 gtk_signal_connect (GTK_OBJECT(item), "activate",
2474 GTK_SIGNAL_FUNC(mailing_list_open_uri), NULL);
2477 gtk_menu_append (GTK_MENU(menu), item);
2478 gtk_widget_show (item);
2484 gtk_widget_set_sensitive (menuitem, TRUE);
2486 gtk_widget_set_sensitive (menuitem, FALSE);
2492 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2494 gchar tmp[BUFFSIZE];
2500 *url_decoded = '\0';
2504 /* Ignore spaces, comments and tabs () */
2505 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2507 for (;*buf != ')' && *buf != 0x00; buf++);
2509 /* First non space and non comment must be a < */
2512 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2517 *url_decoded = '\0';
2522 *url_decoded = '\0';
2528 decode_uri (url_decoded, (const gchar *)tmp);
2530 /* Prepare the work for the next url in the list */
2531 /* after the closing bracket >, ignore space, comments and tabs */
2532 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2534 for (;*buf != ')' && *buf != 0x00; buf++);
2536 if (!buf || !*buf) {
2541 /* now first non space, non comment must be a comma */
2543 for (;*buf != 0x00; buf++);
2549 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2553 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2554 compose_new(NULL, mailto+7, NULL);
2557 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2562 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2563 open_uri (mailto, prefs_common.uri_cmd);
2566 void main_window_popup(MainWindow *mainwin)
2568 gtkut_window_popup(mainwin->window);
2570 switch (mainwin->type) {
2571 case SEPARATE_FOLDER:
2572 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2574 case SEPARATE_MESSAGE:
2575 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2578 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2579 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2586 void main_window_show(MainWindow *mainwin)
2588 gtk_widget_show(mainwin->window);
2589 gtk_widget_show(mainwin->vbox_body);
2591 gtk_widget_set_uposition(mainwin->window,
2592 prefs_common.mainwin_x,
2593 prefs_common.mainwin_y);
2595 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2596 prefs_common.folderview_width,
2597 prefs_common.folderview_height);
2598 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2599 prefs_common.summaryview_width,
2600 prefs_common.summaryview_height);
2601 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2602 prefs_common.msgview_width,
2603 prefs_common.msgview_height);
2605 if (mainwin->type & SEPARATE_FOLDER) {
2606 GtkWidget *folderwin;
2608 folderwin = main_window_get_folder_window(mainwin);
2609 gtk_widget_show(folderwin);
2610 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2611 prefs_common.folderwin_y);
2614 if (mainwin->type & SEPARATE_MESSAGE) {
2615 GtkWidget *messagewin;
2617 messagewin = main_window_get_message_window(mainwin);
2618 gtk_widget_show(messagewin);
2619 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2620 prefs_common.main_msgwin_y);
2624 void main_window_hide(MainWindow *mainwin)
2626 main_window_get_size(mainwin);
2627 main_window_get_position(mainwin);
2629 gtk_widget_hide(mainwin->window);
2630 gtk_widget_hide(mainwin->vbox_body);
2632 if (mainwin->type & SEPARATE_FOLDER) {
2633 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2636 if (mainwin->type & SEPARATE_MESSAGE) {
2637 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2641 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2643 GtkWidget *folderwin = NULL;
2644 GtkWidget *messagewin = NULL;
2647 GtkWidget *vbox_body = mainwin->vbox_body;
2648 GtkItemFactory *ifactory = mainwin->menu_factory;
2649 GtkWidget *menuitem;
2650 GtkItemFactory *msgview_ifactory;
2652 debug_print("Setting widgets... ");
2654 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2655 prefs_common.folderview_width,
2656 prefs_common.folderview_height);
2657 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2658 prefs_common.summaryview_width,
2659 prefs_common.summaryview_height);
2660 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2661 prefs_common.msgview_width,
2662 prefs_common.msgview_height);
2664 /* create separated window(s) if needed */
2665 if (type & SEPARATE_FOLDER) {
2666 static GdkGeometry folderwin_geometry;
2668 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2669 gtk_window_set_title(GTK_WINDOW(folderwin),
2670 _("Sylpheed-Claws - Folder View"));
2672 gtk_window_move(GTK_WINDOW(folderwin),
2673 prefs_common.folderwin_x,
2674 prefs_common.folderwin_y);
2676 if (!folderwin_geometry.min_height) {
2677 folderwin_geometry.min_width = 320;
2678 folderwin_geometry.min_height = 200;
2680 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2681 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2683 gtk_widget_set_size_request(folderwin,
2684 prefs_common.folderview_width,
2685 prefs_common.folderview_height);
2687 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2690 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2691 G_CALLBACK(folder_window_close_cb),
2693 gtk_container_add(GTK_CONTAINER(folderwin),
2694 GTK_WIDGET_PTR(mainwin->folderview));
2695 gtk_widget_realize(folderwin);
2697 if (prefs_common.folderview_visible)
2698 gtk_widget_show(folderwin);
2701 if (type & SEPARATE_MESSAGE) {
2702 static GdkGeometry msgwin_geometry;
2704 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2705 gtk_window_set_title(GTK_WINDOW(messagewin),
2706 _("Sylpheed-Claws - Message View"));
2708 gtk_window_move(GTK_WINDOW(messagewin),
2709 prefs_common.main_msgwin_x,
2710 prefs_common.main_msgwin_y);
2712 if (!msgwin_geometry.min_height) {
2713 msgwin_geometry.min_width = 320;
2714 msgwin_geometry.min_height = 200;
2716 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2717 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2719 gtk_widget_set_size_request(messagewin,
2720 prefs_common.msgwin_width,
2721 prefs_common.msgwin_height);
2723 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2725 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2726 G_CALLBACK(message_window_close_cb),
2728 if (messageview_is_visible(mainwin->messageview))
2729 gtk_widget_show(messagewin);
2731 mainwin->messageview->statusbar = mainwin->statusbar;
2732 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2737 hpaned = gtk_hpaned_new();
2738 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2739 gtk_paned_add1(GTK_PANED(hpaned),
2740 GTK_WIDGET_PTR(mainwin->folderview));
2741 gtk_widget_show(hpaned);
2742 gtk_widget_queue_resize(hpaned);
2744 vpaned = gtk_vpaned_new();
2745 if (messageview_is_visible(mainwin->messageview)) {
2746 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2747 gtk_paned_add1(GTK_PANED(vpaned),
2748 GTK_WIDGET_PTR(mainwin->summaryview));
2750 gtk_paned_add2(GTK_PANED(hpaned),
2751 GTK_WIDGET_PTR(mainwin->summaryview));
2752 gtk_widget_ref(vpaned);
2754 gtk_paned_add2(GTK_PANED(vpaned),
2755 GTK_WIDGET_PTR(mainwin->messageview));
2756 gtk_widget_show(vpaned);
2757 gtk_widget_queue_resize(vpaned);
2759 mainwin->win.sep_none.hpaned = hpaned;
2760 mainwin->win.sep_none.vpaned = vpaned;
2762 /* remove headerview if not in prefs */
2763 headerview_set_visibility(mainwin->messageview->headerview,
2764 prefs_common.display_header_pane);
2766 case SEPARATE_FOLDER:
2767 vpaned = gtk_vpaned_new();
2768 if (messageview_is_visible(mainwin->messageview)) {
2769 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2771 gtk_paned_add1(GTK_PANED(vpaned),
2772 GTK_WIDGET_PTR(mainwin->summaryview));
2774 gtk_box_pack_start(GTK_BOX(vbox_body),
2775 GTK_WIDGET_PTR(mainwin->summaryview),
2777 gtk_widget_ref(vpaned);
2779 gtk_paned_add2(GTK_PANED(vpaned),
2780 GTK_WIDGET_PTR(mainwin->messageview));
2781 gtk_widget_show(vpaned);
2782 gtk_widget_queue_resize(vpaned);
2784 mainwin->win.sep_folder.folderwin = folderwin;
2785 mainwin->win.sep_folder.vpaned = vpaned;
2787 /* remove headerview if not in prefs */
2788 headerview_set_visibility(mainwin->messageview->headerview,
2789 prefs_common.display_header_pane);
2792 case SEPARATE_MESSAGE:
2793 hpaned = gtk_hpaned_new();
2794 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2795 gtk_paned_add1(GTK_PANED(hpaned),
2796 GTK_WIDGET_PTR(mainwin->folderview));
2797 gtk_paned_add2(GTK_PANED(hpaned),
2798 GTK_WIDGET_PTR(mainwin->summaryview));
2799 gtk_widget_show(hpaned);
2800 gtk_widget_queue_resize(hpaned);
2801 messageview_add_toolbar(mainwin->messageview, messagewin);
2802 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2803 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2805 mainwin->win.sep_message.messagewin = messagewin;
2806 mainwin->win.sep_message.hpaned = hpaned;
2808 gtk_widget_realize(messagewin);
2809 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2810 gtk_widget_show_all(messagewin);
2811 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2812 mainwin->messageview->handlebox,
2813 prefs_common.toolbar_style);
2815 /* remove headerview if not in prefs */
2816 headerview_set_visibility(mainwin->messageview->headerview,
2817 prefs_common.display_header_pane);
2821 messageview_add_toolbar(mainwin->messageview, messagewin);
2822 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2823 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2825 gtk_box_pack_start(GTK_BOX(vbox_body),
2826 GTK_WIDGET_PTR(mainwin->summaryview),
2829 mainwin->win.sep_both.folderwin = folderwin;
2830 mainwin->win.sep_both.messagewin = messagewin;
2832 gtk_widget_realize(messagewin);
2833 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2834 gtk_widget_show_all(messagewin);
2835 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2836 mainwin->messageview->handlebox,
2837 prefs_common.toolbar_style);
2839 /* remove headerview if not in prefs */
2840 headerview_set_visibility(mainwin->messageview->headerview,
2841 prefs_common.display_header_pane);
2846 if (messageview_is_visible(mainwin->messageview))
2847 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2848 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2850 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2851 GTK_ARROW_UP, GTK_SHADOW_OUT);
2853 gtk_window_move(GTK_WINDOW(mainwin->window),
2854 prefs_common.mainwin_x,
2855 prefs_common.mainwin_y);
2857 gtk_widget_queue_resize(vbox_body);
2858 gtk_widget_queue_resize(mainwin->vbox);
2859 gtk_widget_queue_resize(mainwin->window);
2860 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2861 * and mimeview icon list/ctree lose track of their visibility states */
2862 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2863 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2864 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2865 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2866 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2867 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2869 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2871 mainwin->type = type;
2874 /* toggle menu state */
2875 menuitem = gtk_item_factory_get_item
2876 (ifactory, "/View/Show or hide/Folder tree");
2877 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2878 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2879 prefs_common.folderview_visible);
2880 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2881 menuitem = gtk_item_factory_get_item
2882 (ifactory, "/View/Show or hide/Message view");
2883 gtk_check_menu_item_set_active
2884 (GTK_CHECK_MENU_ITEM(menuitem),
2885 messageview_is_visible(mainwin->messageview));
2887 menuitem = gtk_item_factory_get_item
2888 (ifactory, "/View/Separate folder tree");
2889 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2890 ((type & SEPARATE_FOLDER) != 0));
2891 menuitem = gtk_item_factory_get_item
2892 (ifactory, "/View/Separate message view");
2893 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2894 ((type & SEPARATE_MESSAGE) != 0));
2898 (G_OBJECT(folderwin), "size_allocate",
2899 G_CALLBACK(folder_window_size_allocate_cb),
2904 (G_OBJECT(messagewin), "size_allocate",
2905 G_CALLBACK(message_window_size_allocate_cb),
2909 debug_print("done.\n");
2912 void main_window_destroy_all(void)
2914 while (mainwin_list != NULL) {
2915 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2917 /* free toolbar stuff */
2918 toolbar_clear_list(TOOLBAR_MAIN);
2919 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2920 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2922 mainwin->folderview->mainwin = NULL;
2923 mainwin->summaryview->mainwin = NULL;
2924 mainwin->messageview->mainwin = NULL;
2926 g_free(mainwin->toolbar);
2929 mainwin_list = g_list_remove(mainwin_list, mainwin);
2931 g_list_free(mainwin_list);
2932 mainwin_list = NULL;
2935 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2938 gtk_widget_set_size_request(child, 1, -1);
2941 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2944 gtk_widget_set_size_request(child, -1, -1);
2947 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2950 MainWindow *mainwin = (MainWindow *)data;
2952 if (!event) return FALSE;
2954 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2955 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2958 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2959 menu_button_position, widget,
2960 event->button, event->time);
2965 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2968 MainWindow *mainwin = (MainWindow *)data;
2970 if (mainwin->lock_count == 0)
2971 app_exit_cb(data, 0, widget);
2976 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2979 MainWindow *mainwin = (MainWindow *)data;
2980 GtkWidget *menuitem;
2982 menuitem = gtk_item_factory_get_item
2983 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2984 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2989 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2992 MainWindow *mainwin = (MainWindow *)data;
2993 GtkWidget *menuitem;
2995 menuitem = gtk_item_factory_get_item
2996 (mainwin->menu_factory, "/View/Show or hide/Message view");
2997 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2999 mainwin->messageview->statusbar = mainwin->statusbar;
3000 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3005 static void main_window_size_allocate_cb(GtkWidget *widget,
3006 GtkAllocation *allocation,
3009 MainWindow *mainwin = (MainWindow *)data;
3011 main_window_get_size(mainwin);
3014 static void folder_window_size_allocate_cb(GtkWidget *widget,
3015 GtkAllocation *allocation,
3018 MainWindow *mainwin = (MainWindow *)data;
3020 main_window_get_size(mainwin);
3023 static void message_window_size_allocate_cb(GtkWidget *widget,
3024 GtkAllocation *allocation,
3027 MainWindow *mainwin = (MainWindow *)data;
3029 main_window_get_size(mainwin);
3032 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3035 main_window_add_mailbox(mainwin);
3038 static void update_folderview_cb(MainWindow *mainwin, guint action,
3041 summary_show(mainwin->summaryview, NULL);
3042 folderview_check_new_all();
3045 static void foldersort_cb(MainWindow *mainwin, guint action,
3051 static void import_mbox_cb(MainWindow *mainwin, guint action,
3054 /* only notify if import has failed */
3055 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3056 alertpanel_error(_("Mbox import has failed."));
3060 static void export_mbox_cb(MainWindow *mainwin, guint action,
3063 /* only notify if export has failed */
3064 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3065 alertpanel_error(_("Export to mbox has failed."));
3069 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3072 /* only notify if export has failed */
3073 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3074 alertpanel_error(_("Export to mbox has failed."));
3078 static void empty_trash_cb(MainWindow *mainwin, guint action,
3081 main_window_empty_trash(mainwin, TRUE);
3084 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3086 summary_save_as(mainwin->summaryview);
3089 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3091 summary_print(mainwin->summaryview);
3094 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3096 if (prefs_common.confirm_on_exit) {
3097 if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
3098 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3099 != G_ALERTALTERNATE)
3101 manage_window_focus_in(mainwin->window, NULL, NULL);
3104 app_will_exit(widget, mainwin);
3107 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3110 summary_search(mainwin->summaryview);
3112 message_search(mainwin->messageview);
3115 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3117 prefs_common.show_searchbar = TRUE;
3118 summaryview_activate_quicksearch(mainwin->summaryview);
3121 static void toggle_folder_cb(MainWindow *mainwin, guint action,
3126 active = GTK_CHECK_MENU_ITEM(widget)->active;
3128 switch (mainwin->type) {
3130 case SEPARATE_MESSAGE:
3132 case SEPARATE_FOLDER:
3133 debug_print("separate folder\n");
3135 gtk_widget_show(mainwin->win.sep_folder.folderwin);
3137 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
3141 gtk_widget_show(mainwin->win.sep_both.folderwin);
3143 gtk_widget_hide(mainwin->win.sep_both.folderwin);
3147 prefs_common.folderview_visible = active;
3150 static void toggle_message_cb(MainWindow *mainwin, guint action,
3155 active = GTK_CHECK_MENU_ITEM(widget)->active;
3157 if (active != messageview_is_visible(mainwin->messageview))
3158 summary_toggle_view(mainwin->summaryview);
3161 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3164 toolbar_toggle(action, mainwin);
3167 void main_window_reply_cb(MainWindow *mainwin, guint action,
3170 MessageView *msgview = (MessageView*)mainwin->messageview;
3171 GSList *msginfo_list = NULL;
3173 g_return_if_fail(msgview != NULL);
3175 msginfo_list = summary_get_selection(mainwin->summaryview);
3176 g_return_if_fail(msginfo_list != NULL);
3177 compose_reply_from_messageview(msgview, msginfo_list, action);
3178 g_slist_free(msginfo_list);
3182 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3185 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3186 gtk_widget_show(mainwin->hbox_stat);
3187 prefs_common.show_statusbar = TRUE;
3189 gtk_widget_hide(mainwin->hbox_stat);
3190 prefs_common.show_statusbar = FALSE;
3194 static void separate_widget_cb(MainWindow *mainwin, guint action,
3199 if (GTK_CHECK_MENU_ITEM(widget)->active)
3200 type = mainwin->type | action;
3202 type = mainwin->type & ~action;
3204 main_window_separation_change(mainwin, type);
3206 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
3207 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
3210 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3213 offline_ask_sync = ask_sync;
3215 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3217 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3218 offline_ask_sync = TRUE;
3221 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3223 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3226 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3228 GList *folderlist = folder_get_list();
3229 gboolean found = FALSE;
3231 /* see if there are synchronised folders */
3232 for (; folderlist; folderlist = folderlist->next) {
3233 Folder *folder = (Folder *)folderlist->data;
3234 if (folder_want_synchronise(folder)) {
3243 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3244 _("Do you want to synchronise your folders now?"),
3245 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3248 folder_synchronise(NULL);
3251 static void online_switch_clicked (GtkButton *btn, gpointer data)
3253 MainWindow *mainwin;
3254 GtkItemFactory *ifactory;
3255 GtkCheckMenuItem *menuitem;
3257 mainwin = (MainWindow *) data;
3259 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3260 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3262 g_return_if_fail(mainwin != NULL);
3263 g_return_if_fail(menuitem != NULL);
3265 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3266 gtk_widget_hide (mainwin->online_switch);
3267 gtk_widget_show (mainwin->offline_switch);
3268 menuitem->active = TRUE;
3269 inc_autocheck_timer_remove();
3272 if (prefs_common.work_offline)
3274 mainwindow_check_synchronise(mainwin, TRUE);
3275 prefs_common.work_offline = TRUE;
3276 imap_disconnect_all();
3279 if (!prefs_common.work_offline)
3281 gtk_widget_hide (mainwin->offline_switch);
3282 gtk_widget_show (mainwin->online_switch);
3283 menuitem->active = FALSE;
3284 prefs_common.work_offline = FALSE;
3285 inc_autocheck_timer_set();
3286 refresh_resolvers();
3290 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3293 addressbook_open(NULL);
3296 static void log_window_show_cb(MainWindow *mainwin, guint action,
3299 log_window_show(mainwin->logwin);
3302 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3307 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3309 summary_move_to(mainwin->summaryview);
3312 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3314 summary_copy_to(mainwin->summaryview);
3317 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3319 summary_delete(mainwin->summaryview);
3322 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3324 summary_delete_trash(mainwin->summaryview);
3327 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3329 summary_cancel(mainwin->summaryview);
3332 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3334 summary_open_msg(mainwin->summaryview);
3337 static void view_source_cb(MainWindow *mainwin, guint action,
3340 summary_view_source(mainwin->summaryview);
3343 static void show_all_header_cb(MainWindow *mainwin, guint action,
3346 if (mainwin->menu_lock_count) return;
3347 mainwin->summaryview->messageview->all_headers =
3348 GTK_CHECK_MENU_ITEM(widget)->active;
3349 summary_display_msg_selected(mainwin->summaryview,
3350 GTK_CHECK_MENU_ITEM(widget)->active);
3353 #define SET_CHECK_MENU_ACTIVE(path, active) \
3355 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3356 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3359 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3362 GtkWidget *menuitem;
3363 GtkItemFactory *ifactory = mainwin->menu_factory;
3365 if (mainwin->menu_lock_count) return;
3367 prefs_common.hide_quotes =
3368 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3370 mainwin->menu_lock_count++;
3371 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3372 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3373 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3374 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3375 mainwin->menu_lock_count--;
3377 summary_redisplay_msg(mainwin->summaryview);
3380 #undef SET_CHECK_MENU_ACTIVE
3381 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3383 summary_mark(mainwin->summaryview);
3386 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3388 summary_unmark(mainwin->summaryview);
3391 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3394 summary_mark_as_unread(mainwin->summaryview);
3397 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3400 summary_mark_as_read(mainwin->summaryview);
3403 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3406 summary_mark_all_read(mainwin->summaryview);
3409 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3412 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3415 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3417 summary_reedit(mainwin->summaryview);
3420 static void add_address_cb(MainWindow *mainwin, guint action,
3423 summary_add_address(mainwin->summaryview);
3426 static void set_charset_cb(MainWindow *mainwin, guint action,
3431 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3432 str = conv_get_charset_str((CharSet)action);
3434 g_free(mainwin->messageview->forced_charset);
3435 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3436 procmime_force_charset(str);
3438 summary_redisplay_msg(mainwin->summaryview);
3440 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3444 static void set_decode_cb(MainWindow *mainwin, guint action,
3447 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3448 mainwin->messageview->forced_encoding = (EncodingType)action;
3450 summary_redisplay_msg(mainwin->summaryview);
3452 debug_print("forced encoding: %d\n", action);
3456 static void hide_read_messages (MainWindow *mainwin, guint action,
3459 if (!mainwin->summaryview->folder_item
3460 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3462 summary_toggle_show_read_messages(mainwin->summaryview);
3465 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3467 gboolean threaded = FALSE;
3468 if (mainwin->menu_lock_count) return;
3469 if (!mainwin->summaryview->folder_item) return;
3471 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3473 mainwin->summaryview->folder_item->threaded = threaded;
3475 mainwin->summaryview->threaded = threaded;
3477 summary_show(mainwin->summaryview,
3478 mainwin->summaryview->folder_item);
3481 static void expand_threads_cb(MainWindow *mainwin, guint action,
3484 summary_expand_threads(mainwin->summaryview);
3487 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3490 summary_collapse_threads(mainwin->summaryview);
3493 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3496 prefs_summary_column_open();
3499 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3502 prefs_folder_column_open();
3505 static void sort_summary_cb(MainWindow *mainwin, guint action,
3508 FolderItem *item = mainwin->summaryview->folder_item;
3509 GtkWidget *menuitem;
3511 if (mainwin->menu_lock_count) return;
3513 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3514 menuitem = gtk_item_factory_get_item
3515 (mainwin->menu_factory, "/View/Sort/Ascending");
3516 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3517 GTK_CHECK_MENU_ITEM(menuitem)->active
3518 ? SORT_ASCENDING : SORT_DESCENDING);
3519 item->sort_key = action;
3523 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3526 FolderItem *item = mainwin->summaryview->folder_item;
3528 if (mainwin->menu_lock_count) return;
3530 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3531 summary_sort(mainwin->summaryview,
3532 item->sort_key, (FolderSortType)action);
3535 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3538 summary_attract_by_subject(mainwin->summaryview);
3541 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3546 item = folderview_get_selected_item(mainwin->folderview);
3548 main_window_cursor_wait(mainwin);
3549 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3551 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3552 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3554 STATUSBAR_POP(mainwin);
3555 main_window_cursor_normal(mainwin);
3565 static void deldup_all(FolderItem *item, gpointer _data)
3567 struct DelDupsData *data = _data;
3570 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3572 data->dups += result;
3577 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3580 struct DelDupsData data = {0, 0};
3582 folder_func_to_all_folders(deldup_all, &data);
3583 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3584 "Deleted %d duplicate messages in %d folders.\n",
3586 data.dups, data.folders);
3589 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3591 summary_filter(mainwin->summaryview, (gboolean)action);
3594 static void execute_summary_cb(MainWindow *mainwin, guint action,
3597 summary_execute(mainwin->summaryview);
3600 static void update_summary_cb(MainWindow *mainwin, guint action,
3604 FolderView *folderview = mainwin->folderview;
3606 if (!mainwin->summaryview->folder_item) return;
3607 if (!folderview->opened) return;
3609 folder_update_op_count();
3611 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3612 folderview->opened);
3615 folder_item_scan(fitem);
3616 summary_show(mainwin->summaryview, fitem);
3619 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3621 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3624 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3626 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3629 static void prev_unread_cb(MainWindow *mainwin, guint action,
3632 summary_select_prev_unread(mainwin->summaryview);
3635 static void next_unread_cb(MainWindow *mainwin, guint action,
3638 summary_select_next_unread(mainwin->summaryview);
3641 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3643 summary_select_prev_new(mainwin->summaryview);
3646 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3648 summary_select_next_new(mainwin->summaryview);
3651 static void prev_marked_cb(MainWindow *mainwin, guint action,
3654 summary_select_prev_marked(mainwin->summaryview);
3657 static void next_marked_cb(MainWindow *mainwin, guint action,
3660 summary_select_next_marked(mainwin->summaryview);
3663 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3666 summary_select_prev_labeled(mainwin->summaryview);
3669 static void next_labeled_cb(MainWindow *mainwin, guint action,
3672 summary_select_next_labeled(mainwin->summaryview);
3675 static void last_read_cb(MainWindow *mainwin, guint action,
3678 summary_select_last_read(mainwin->summaryview);
3681 static void parent_cb(MainWindow *mainwin, guint action,
3684 summary_select_parent(mainwin->summaryview);
3687 static void goto_folder_cb(MainWindow *mainwin, guint action,
3690 FolderItem *to_folder;
3692 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3695 folderview_select(mainwin->folderview, to_folder);
3698 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3701 folderview_select_next_unread(mainwin->folderview, FALSE);
3704 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3706 messageview_copy_clipboard(mainwin->messageview);
3709 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3711 MessageView *msgview = mainwin->messageview;
3713 if (messageview_is_visible(msgview) &&
3714 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3715 messageview_select_all(mainwin->messageview);
3717 summary_select_all(mainwin->summaryview);
3720 static void select_thread_cb(MainWindow *mainwin, guint action,
3723 summary_select_thread(mainwin->summaryview);
3726 static void create_filter_cb(MainWindow *mainwin, guint action,
3729 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3732 static void create_processing_cb(MainWindow *mainwin, guint action,
3735 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3738 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3741 prefs_filtering_open(&pre_global_processing,
3742 _("Processing rules to apply before folder rules"),
3743 MANUAL_ANCHOR_PROCESSING,
3747 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3750 prefs_filtering_open(&post_global_processing,
3751 _("Processing rules to apply after folder rules"),
3752 MANUAL_ANCHOR_PROCESSING,
3756 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3759 prefs_filtering_open(&filtering_rules,
3760 _("Filtering configuration"),
3761 MANUAL_ANCHOR_FILTERING,
3765 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3768 prefs_template_open();
3771 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3774 prefs_actions_open(mainwin);
3777 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3780 ssl_manager_open(mainwin);
3783 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3787 new_account_cb(mainwin, 0, widget);
3789 account_open(cur_account);
3793 static void new_account_cb(MainWindow *mainwin, guint action,
3796 account_edit_open();
3797 if (!compose_get_compose_list()) account_add();
3800 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3802 FolderItem *item = NULL;
3803 cur_account = (PrefsAccount *)data;
3805 if (!mainwindow_get_mainwindow())
3807 main_window_show_cur_account(mainwindow_get_mainwindow());
3808 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3809 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3810 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3811 item = folderview_get_selected_item(
3812 mainwindow_get_mainwindow()->folderview);
3814 toolbar_set_compose_button
3815 (mainwindow_get_mainwindow()->toolbar,
3816 FOLDER_TYPE(item->folder) == F_NEWS ?
3817 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3821 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3823 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3824 PrefsAccount *account = (PrefsAccount *)data;
3826 inc_account_mail(mainwin, account);
3829 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3831 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3832 PrefsAccount *account = (PrefsAccount *)data;
3833 FolderItem *item = mainwin->summaryview->folder_item;
3835 compose_new_with_folderitem(account, item);
3838 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3843 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3845 pluginwindow_create();
3848 static void manual_open_cb(MainWindow *mainwin, guint action,
3851 manual_open((ManualType)action, NULL);
3854 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3859 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3861 MainWindow *mainwin = (MainWindow *)data;
3865 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3866 LOCAL_FOLDER(folder)->rootpath,
3870 str = g_strdup_printf(_("Scanning folder %s ..."),
3871 LOCAL_FOLDER(folder)->rootpath);
3873 STATUSBAR_PUSH(mainwin, str);
3874 STATUSBAR_POP(mainwin);
3878 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3881 SummaryView *summary;
3883 g_return_val_if_fail(data, FALSE);
3884 if (!g_list_find(mainwin_list, data))
3886 summary = ((MainWindow *)data)->summaryview;
3887 g_return_val_if_fail(summary, FALSE);
3889 if (GTK_CLIST(summary->ctree)->selection &&
3890 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3896 #define BREAK_ON_MODIFIER_KEY() \
3897 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3899 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3902 MainWindow *mainwin = (MainWindow*) data;
3904 if (!mainwin || !event)
3907 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3909 lastkey = event->keyval;
3913 switch (event->keyval) {
3914 case GDK_Q: /* Quit */
3915 BREAK_ON_MODIFIER_KEY();
3917 app_exit_cb(mainwin, 0, NULL);
3920 if (mainwin->folderview && mainwin->summaryview
3921 && ((!mainwin->summaryview->displayed
3922 && !mainwin->summaryview->selected)
3923 || (mainwin->summaryview->folder_item
3924 && mainwin->summaryview->folder_item->total_msgs == 0))) {
3925 g_signal_stop_emission_by_name(G_OBJECT(widget),
3927 folderview_select_next_unread(mainwin->folderview, TRUE);
3936 #undef BREAK_ON_MODIFIER_KEY
3939 * Harvest addresses for selected folder.
3941 static void addr_harvest_cb( MainWindow *mainwin,
3945 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3949 * Harvest addresses for selected messages in summary view.
3951 static void addr_harvest_msg_cb( MainWindow *mainwin,
3955 summary_harvest_address( mainwin->summaryview );
3959 *\brief get a MainWindow
3961 *\return MainWindow * The first mainwindow in the mainwin_list
3963 MainWindow *mainwindow_get_mainwindow(void)
3965 if (mainwin_list && mainwin_list->data)
3966 return (MainWindow *)(mainwin_list->data);
3971 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3973 ProgressData *data = (ProgressData *) source;
3974 MainWindow *mainwin = (MainWindow *) userdata;
3976 switch (data->cmd) {
3977 case PROGRESS_COMMAND_START:
3978 case PROGRESS_COMMAND_STOP:
3979 gtk_progress_bar_set_fraction
3980 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3982 case PROGRESS_COMMAND_SET_PERCENTAGE:
3983 gtk_progress_bar_set_fraction
3984 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3987 while (gtk_events_pending()) gtk_main_iteration ();
3992 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3994 mainwindow_check_synchronise(mainwin, FALSE);
3997 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
3999 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4002 void mainwindow_jump_to(const gchar *target)
4006 FolderItem *item = NULL;
4008 MainWindow *mainwin = mainwindow_get_mainwindow();
4014 printf(_("not initialized\n"));
4018 tmp = g_strdup(target);
4020 if ((p = strstr(tmp, "\r")) != NULL)
4022 if ((p = strstr(tmp, "\n")) != NULL)
4025 if ((item = folder_find_item_from_identifier(tmp))) {
4026 printf(_("selecting folder '%s'\n"), tmp);
4027 folderview_select(mainwin->folderview, item);
4028 main_window_popup(mainwin);
4033 msg = strrchr(tmp, G_DIR_SEPARATOR);
4036 if ((item = folder_find_item_from_identifier(tmp))) {
4037 printf(_("selecting folder '%s'\n"), tmp);
4038 folderview_select(mainwin->folderview, item);
4040 if (item && msg && atoi(msg)) {
4041 printf(_("selecting message %d\n"), atoi(msg));
4042 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4043 summary_display_msg_selected(mainwin->summaryview, FALSE);
4044 main_window_popup(mainwin);
4050 printf("'%s' not found\n", tmp);