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 static gboolean mainwindow_log_error(gpointer source, gpointer data)
1061 LogText *logtext = (LogText *) source;
1062 MainWindow *mainwin = (MainWindow *) data;
1063 if (logtext->type != LOG_ERROR)
1066 gtk_widget_show(mainwin->warning_btn);
1071 MainWindow *main_window_create(SeparateType type)
1073 MainWindow *mainwin;
1077 GtkWidget *handlebox;
1078 GtkWidget *vbox_body;
1079 GtkWidget *hbox_stat;
1080 GtkWidget *statusbar;
1081 GtkWidget *progressbar;
1082 GtkWidget *statuslabel;
1083 GtkWidget *ac_button;
1084 GtkWidget *ac_label;
1085 GtkWidget *online_pixmap;
1086 GtkWidget *offline_pixmap;
1087 GtkWidget *online_switch;
1088 GtkWidget *offline_switch;
1090 GtkWidget *warning_icon;
1091 GtkWidget *warning_btn;
1093 FolderView *folderview;
1094 SummaryView *summaryview;
1095 MessageView *messageview;
1096 GdkColormap *colormap;
1098 gboolean success[4];
1099 GtkItemFactory *ifactory;
1101 GtkWidget *menuitem;
1103 guint n_menu_entries;
1105 static GdkGeometry geometry;
1107 debug_print("Creating main window...\n");
1108 mainwin = g_new0(MainWindow, 1);
1111 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1112 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1113 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1115 if (!geometry.min_height) {
1116 geometry.min_width = 320;
1117 geometry.min_height = 200;
1119 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1122 g_signal_connect(G_OBJECT(window), "delete_event",
1123 G_CALLBACK(main_window_close_cb), mainwin);
1124 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1125 g_signal_connect(G_OBJECT(window), "focus_in_event",
1126 G_CALLBACK(mainwindow_focus_in_event),
1128 g_signal_connect(G_OBJECT(window), "key_press_event",
1129 G_CALLBACK(mainwindow_key_pressed), mainwin);
1131 gtk_widget_realize(window);
1132 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1135 gtkut_widget_set_app_icon(window);
1137 vbox = gtk_vbox_new(FALSE, 0);
1138 gtk_widget_show(vbox);
1139 gtk_container_add(GTK_CONTAINER(window), vbox);
1142 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1143 menubar = menubar_create(window, mainwin_entries,
1144 n_menu_entries, "<Main>", mainwin);
1145 gtk_widget_show(menubar);
1146 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1147 ifactory = gtk_item_factory_from_widget(menubar);
1149 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1150 main_create_mailing_list_menu (mainwin, NULL); */
1152 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1154 if (prefs_common.toolbar_detachable) {
1155 handlebox = gtk_handle_box_new();
1156 gtk_widget_show(handlebox);
1157 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1158 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1159 G_CALLBACK(toolbar_child_attached), mainwin);
1160 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1161 G_CALLBACK(toolbar_child_detached), mainwin);
1163 handlebox = gtk_hbox_new(FALSE, 0);
1164 gtk_widget_show(handlebox);
1165 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1167 /* link window to mainwin->window to avoid gdk warnings */
1168 mainwin->window = window;
1170 /* create toolbar */
1171 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1174 toolbar_set_learn_button
1178 /* vbox that contains body */
1179 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1180 gtk_widget_show(vbox_body);
1181 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1182 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1184 hbox_stat = gtk_hbox_new(FALSE, 2);
1185 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1187 tips = gtk_tooltips_new();
1189 warning_icon = gtk_image_new_from_stock
1190 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1191 warning_btn = gtk_event_box_new();
1192 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1194 mainwin->warning_btn = warning_btn;
1196 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1197 G_CALLBACK(warning_icon_pressed),
1198 (gpointer) mainwin);
1199 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1200 G_CALLBACK(warning_visi_notify), mainwin);
1201 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1202 G_CALLBACK(warning_visi_notify), mainwin);
1203 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1204 G_CALLBACK(warning_leave_notify), mainwin);
1205 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1206 G_CALLBACK(warning_enter_notify), mainwin);
1208 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1210 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1211 _("Some error(s) happened. Click here to view log."), NULL);
1212 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1214 hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, mainwindow_log_error, mainwin);
1216 statusbar = statusbar_create();
1217 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1219 progressbar = gtk_progress_bar_new();
1220 gtk_widget_set_size_request(progressbar, 120, 1);
1221 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1223 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1224 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1225 online_switch = gtk_button_new ();
1226 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1227 _("You are online. Click the icon to go offline"), NULL);
1228 offline_switch = gtk_button_new ();
1229 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1230 _("You are offline. Click the icon to go online"),
1232 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1233 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1234 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1235 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1236 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1237 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1238 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1239 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1241 statuslabel = gtk_label_new("");
1242 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1244 ac_button = gtk_button_new();
1245 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1246 ac_button, _("Select account"), NULL);
1247 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1248 gtk_widget_set_size_request(ac_button, -1, 0);
1249 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1250 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1251 G_CALLBACK(ac_label_button_pressed), mainwin);
1253 ac_label = gtk_label_new("");
1254 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1256 gtk_widget_show_all(hbox_stat);
1258 gtk_widget_hide(offline_switch);
1259 gtk_widget_hide(warning_btn);
1261 mainwin->folderview = folderview = folderview_create();
1262 mainwin->summaryview = summaryview = summary_create();
1263 mainwin->messageview = messageview = messageview_create(mainwin);
1264 mainwin->logwin = log_window_create();
1266 folderview->mainwin = mainwin;
1267 folderview->summaryview = summaryview;
1269 summaryview->mainwin = mainwin;
1270 summaryview->folderview = folderview;
1271 summaryview->messageview = messageview;
1272 summaryview->window = window;
1274 messageview->statusbar = statusbar;
1275 mainwin->vbox = vbox;
1276 mainwin->menubar = menubar;
1277 mainwin->menu_factory = ifactory;
1278 mainwin->handlebox = handlebox;
1279 mainwin->vbox_body = vbox_body;
1280 mainwin->hbox_stat = hbox_stat;
1281 mainwin->statusbar = statusbar;
1282 mainwin->progressbar = progressbar;
1283 mainwin->statuslabel = statuslabel;
1284 mainwin->online_switch = online_switch;
1285 mainwin->online_pixmap = online_pixmap;
1286 mainwin->offline_pixmap = offline_pixmap;
1287 mainwin->ac_button = ac_button;
1288 mainwin->ac_label = ac_label;
1289 mainwin->offline_switch = offline_switch;
1291 /* set context IDs for status bar */
1292 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1293 (GTK_STATUSBAR(statusbar), "Main Window");
1294 mainwin->folderview_cid = gtk_statusbar_get_context_id
1295 (GTK_STATUSBAR(statusbar), "Folder View");
1296 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1297 (GTK_STATUSBAR(statusbar), "Summary View");
1298 mainwin->messageview_cid = gtk_statusbar_get_context_id
1299 (GTK_STATUSBAR(statusbar), "Message View");
1301 messageview->statusbar_cid = mainwin->messageview_cid;
1303 /* allocate colors for summary view and folder view */
1304 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1305 summaryview->color_marked.blue = (guint16)65535;
1307 summaryview->color_dim.red = summaryview->color_dim.green =
1308 summaryview->color_dim.blue = COLOR_DIM;
1310 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1311 &folderview->color_new);
1313 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1314 &folderview->color_op);
1316 summaryview->color_important.red = 0;
1317 summaryview->color_important.green = 0;
1318 summaryview->color_important.blue = (guint16)65535;
1320 color[0] = summaryview->color_marked;
1321 color[1] = summaryview->color_dim;
1322 color[2] = folderview->color_new;
1323 color[3] = folderview->color_op;
1325 colormap = gdk_drawable_get_colormap(window->window);
1326 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1327 for (i = 0; i < 4; i++) {
1328 if (success[i] == FALSE)
1329 g_warning("MainWindow: color allocation %d failed\n", i);
1332 debug_print("done.\n");
1334 messageview->visible = prefs_common.msgview_visible;
1336 main_window_set_widgets(mainwin, type);
1338 g_signal_connect(G_OBJECT(window), "size_allocate",
1339 G_CALLBACK(main_window_size_allocate_cb),
1342 /* set menu items */
1343 menuitem = gtk_item_factory_get_item
1344 (ifactory, "/View/Character encoding/Auto detect");
1345 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1347 switch (prefs_common.toolbar_style) {
1349 menuitem = gtk_item_factory_get_item
1350 (ifactory, "/View/Show or hide/Toolbar/Hide");
1353 menuitem = gtk_item_factory_get_item
1354 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1357 menuitem = gtk_item_factory_get_item
1358 (ifactory, "/View/Show or hide/Toolbar/Text only");
1361 menuitem = gtk_item_factory_get_item
1362 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1364 case TOOLBAR_BOTH_HORIZ:
1365 menuitem = gtk_item_factory_get_item
1367 "/View/Show or hide/Toolbar/Text beside icons");
1369 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1371 gtk_widget_hide(mainwin->hbox_stat);
1372 menuitem = gtk_item_factory_get_item
1373 (ifactory, "/View/Show or hide/Status bar");
1374 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1375 prefs_common.show_statusbar);
1377 /* set account selection menu */
1378 ac_menu = gtk_item_factory_get_widget
1379 (ifactory, "/Configuration/Change current account");
1380 mainwin->ac_menu = ac_menu;
1382 toolbar_main_set_sensitive(mainwin);
1384 /* create actions menu */
1385 main_window_update_actions_menu(mainwin);
1387 main_create_mailing_list_menu (mainwin, NULL);
1389 /* attach accel groups to main window */
1390 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1391 gtk_window_add_accel_group \
1393 gtk_item_factory_from_widget(menu)->accel_group); \
1394 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1396 G_CALLBACK(main_window_accel_activate), mainwin);
1399 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1401 /* connect the accelerators for equivalent
1402 menu items in different menus */
1403 menu_connect_identical_items();
1406 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1408 gtk_widget_show(mainwin->window);
1410 /* initialize views */
1411 folderview_init(folderview);
1412 summary_init(summaryview);
1413 messageview_init(messageview);
1414 log_window_init(mainwin->logwin);
1415 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1416 prefs_common.loglength);
1418 sslcertwindow_register_hook();
1420 mainwin->lock_count = 0;
1421 mainwin->menu_lock_count = 0;
1422 mainwin->cursor_count = 0;
1424 mainwin->progressindicator_hook =
1425 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1428 watch_cursor = gdk_cursor_new(GDK_WATCH);
1430 hand_cursor = gdk_cursor_new(GDK_HAND2);
1432 mainwin_list = g_list_append(mainwin_list, mainwin);
1434 /* init work_offline */
1435 if (prefs_common.work_offline)
1436 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1438 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1443 void main_window_destroy(MainWindow *mainwin)
1445 /* TODO : destroy other component */
1446 messageview_destroy(mainwin->messageview);
1447 mainwin->messageview = NULL;
1450 void main_window_update_actions_menu(MainWindow *mainwin)
1452 GtkItemFactory *ifactory;
1454 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1455 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1458 void main_window_cursor_wait(MainWindow *mainwin)
1461 if (mainwin->cursor_count == 0) {
1462 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1463 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1466 mainwin->cursor_count++;
1471 void main_window_cursor_normal(MainWindow *mainwin)
1473 if (mainwin->cursor_count)
1474 mainwin->cursor_count--;
1476 if (mainwin->cursor_count == 0) {
1477 gdk_window_set_cursor(mainwin->window->window, NULL);
1478 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1483 /* lock / unlock the user-interface */
1484 void main_window_lock(MainWindow *mainwin)
1486 if (mainwin->lock_count == 0)
1487 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1489 mainwin->lock_count++;
1491 main_window_set_menu_sensitive(mainwin);
1492 toolbar_main_set_sensitive(mainwin);
1495 void main_window_unlock(MainWindow *mainwin)
1497 if (mainwin->lock_count)
1498 mainwin->lock_count--;
1500 main_window_set_menu_sensitive(mainwin);
1501 toolbar_main_set_sensitive(mainwin);
1503 if (mainwin->lock_count == 0)
1504 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1507 static void main_window_menu_callback_block(MainWindow *mainwin)
1509 mainwin->menu_lock_count++;
1512 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1514 if (mainwin->menu_lock_count)
1515 mainwin->menu_lock_count--;
1518 static guint prefs_tag = 0;
1520 void main_window_reflect_prefs_all(void)
1522 main_window_reflect_prefs_all_real(FALSE);
1525 static gboolean reflect_prefs_timeout_cb(gpointer data)
1527 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1529 MainWindow *mainwin;
1532 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1533 mainwin = (MainWindow *)cur->data;
1535 main_window_show_cur_account(mainwin);
1536 main_window_set_menu_sensitive(mainwin);
1537 toolbar_main_set_sensitive(mainwin);
1540 if (pixmap_theme_changed) {
1541 toolbar_update(TOOLBAR_MAIN, mainwin);
1542 messageview_reflect_prefs_pixmap_theme();
1543 compose_reflect_prefs_pixmap_theme();
1544 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1545 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1547 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1548 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1549 mainwin->online_pixmap);
1550 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1551 gtk_widget_show(pixmap);
1552 mainwin->online_pixmap = pixmap;
1553 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1554 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1555 mainwin->offline_pixmap);
1556 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1557 gtk_widget_show(pixmap);
1558 mainwin->offline_pixmap = pixmap;
1561 headerview_set_font(mainwin->messageview->headerview);
1562 headerview_set_visibility(mainwin->messageview->headerview,
1563 prefs_common.display_header_pane);
1564 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1565 folderview_reflect_prefs();
1566 summary_reflect_prefs();
1567 summary_redisplay_msg(mainwin->summaryview);
1573 void main_window_reflect_prefs_all_now(void)
1575 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1578 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1583 /* re-create colorlabel submenu */
1584 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1585 g_return_if_fail(menu != NULL);
1587 /* clear items. get item pointers. */
1588 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1589 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1591 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1592 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1596 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1598 if (prefs_tag == 0 || pixmap_theme_changed) {
1599 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1600 GINT_TO_POINTER(pixmap_theme_changed));
1604 void main_window_set_summary_column(void)
1607 MainWindow *mainwin;
1609 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1610 mainwin = (MainWindow *)cur->data;
1611 summary_set_column_order(mainwin->summaryview);
1615 void main_window_set_folder_column(void)
1618 MainWindow *mainwin;
1620 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1621 mainwin = (MainWindow *)cur->data;
1622 folderview_set_column_order(mainwin->folderview);
1626 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1627 GList *account_list)
1629 GList *cur_ac, *cur_item;
1630 GtkWidget *menuitem;
1631 PrefsAccount *ac_prefs;
1633 /* destroy all previous menu item */
1634 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1635 while (cur_item != NULL) {
1636 GList *next = cur_item->next;
1637 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1641 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1642 ac_prefs = (PrefsAccount *)cur_ac->data;
1644 menuitem = gtk_menu_item_new_with_label
1645 (ac_prefs->account_name
1646 ? ac_prefs->account_name : _("Untitled"));
1647 gtk_widget_show(menuitem);
1648 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1649 g_signal_connect(G_OBJECT(menuitem), "activate",
1650 G_CALLBACK(account_selector_menu_cb),
1655 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1656 GList *account_list)
1658 GList *cur_ac, *cur_item;
1660 GtkWidget *menuitem;
1661 PrefsAccount *ac_prefs;
1663 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1664 "/Message/Receive");
1666 /* search for separator */
1667 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1668 cur_item = cur_item->next) {
1669 if (GTK_BIN(cur_item->data)->child == NULL) {
1670 cur_item = cur_item->next;
1675 /* destroy all previous menu item */
1676 while (cur_item != NULL) {
1677 GList *next = cur_item->next;
1678 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1682 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1683 ac_prefs = (PrefsAccount *)cur_ac->data;
1685 menuitem = gtk_menu_item_new_with_label
1686 (ac_prefs->account_name ? ac_prefs->account_name
1688 gtk_widget_show(menuitem);
1689 gtk_menu_append(GTK_MENU(menu), menuitem);
1690 g_signal_connect(G_OBJECT(menuitem), "activate",
1691 G_CALLBACK(account_receive_menu_cb),
1696 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1697 GList *account_list)
1699 GList *cur_ac, *cur_item;
1700 GtkWidget *menuitem;
1701 PrefsAccount *ac_prefs;
1702 GtkWidget *menu = NULL;
1704 if (mainwin->toolbar->getall_btn == NULL
1705 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1708 menu = mainwin->toolbar->getall_combo->menu;
1710 /* destroy all previous menu item */
1711 cur_item = GTK_MENU_SHELL(menu)->children;
1712 while (cur_item != NULL) {
1713 GList *next = cur_item->next;
1714 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1718 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1719 ac_prefs = (PrefsAccount *)cur_ac->data;
1721 menuitem = gtk_menu_item_new_with_label
1722 (ac_prefs->account_name
1723 ? ac_prefs->account_name : _("Untitled"));
1724 gtk_widget_show(menuitem);
1725 gtk_menu_append(GTK_MENU(menu), menuitem);
1726 g_signal_connect(G_OBJECT(menuitem), "activate",
1727 G_CALLBACK(account_receive_menu_cb),
1732 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1733 GList *account_list)
1735 GList *cur_ac, *cur_item;
1736 GtkWidget *menuitem;
1737 PrefsAccount *ac_prefs;
1738 GtkWidget *menu = NULL;
1740 if (mainwin->toolbar->compose_mail_btn == NULL
1741 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1744 menu = mainwin->toolbar->compose_combo->menu;
1746 /* destroy all previous menu item */
1747 cur_item = GTK_MENU_SHELL(menu)->children;
1748 while (cur_item != NULL) {
1749 GList *next = cur_item->next;
1750 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1754 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1755 ac_prefs = (PrefsAccount *)cur_ac->data;
1757 menuitem = gtk_menu_item_new_with_label
1758 (ac_prefs->account_name
1759 ? ac_prefs->account_name : _("Untitled"));
1760 gtk_widget_show(menuitem);
1761 gtk_menu_append(GTK_MENU(menu), menuitem);
1762 g_signal_connect(G_OBJECT(menuitem), "activate",
1763 G_CALLBACK(account_compose_menu_cb),
1768 void main_window_set_account_menu(GList *account_list)
1771 MainWindow *mainwin;
1773 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1774 mainwin = (MainWindow *)cur->data;
1775 main_window_set_account_selector_menu(mainwin, account_list);
1776 main_window_set_account_receive_menu(mainwin, account_list);
1777 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1778 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1782 void main_window_set_account_menu_only_toolbar(GList *account_list)
1785 MainWindow *mainwin;
1787 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1788 mainwin = (MainWindow *)cur->data;
1789 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1790 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1794 static void main_window_show_cur_account(MainWindow *mainwin)
1799 ac_name = g_strdup(cur_account
1800 ? (cur_account->account_name
1801 ? cur_account->account_name : _("Untitled"))
1805 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1807 buf = g_strdup(PROG_VERSION);
1808 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1811 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1812 gtk_widget_queue_resize(mainwin->ac_button);
1817 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1819 switch (mainwin->type) {
1820 case SEPARATE_FOLDER:
1821 return mainwin->win.sep_folder.folderwin;
1823 return mainwin->win.sep_both.folderwin;
1829 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1831 switch (mainwin->type) {
1832 case SEPARATE_MESSAGE:
1833 return mainwin->win.sep_message.messagewin;
1835 return mainwin->win.sep_both.messagewin;
1841 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1843 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1844 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1845 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1846 GtkWidget *message_wid = mainwin->messageview->vbox;
1848 debug_print("Changing window separation type from %d to %d\n",
1849 mainwin->type, type);
1851 if (mainwin->type == type) return;
1853 /* remove widgets from those containers */
1854 gtk_widget_ref(folder_wid);
1855 gtk_widget_ref(summary_wid);
1856 gtk_widget_ref(message_wid);
1857 gtkut_container_remove
1858 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1859 gtkut_container_remove
1860 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1861 gtkut_container_remove
1862 (GTK_CONTAINER(message_wid->parent), message_wid);
1864 /* clean containers */
1865 switch (mainwin->type) {
1867 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1869 case SEPARATE_FOLDER:
1870 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1871 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1873 case SEPARATE_MESSAGE:
1874 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1875 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1878 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1879 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1883 gtk_widget_hide(mainwin->window);
1884 main_window_set_widgets(mainwin, type);
1885 gtk_widget_show(mainwin->window);
1887 gtk_widget_unref(folder_wid);
1888 gtk_widget_unref(summary_wid);
1889 gtk_widget_unref(message_wid);
1892 void main_window_toggle_message_view(MainWindow *mainwin)
1894 SummaryView *summaryview = mainwin->summaryview;
1895 union CompositeWin *cwin = &mainwin->win;
1896 GtkWidget *vpaned = NULL;
1897 GtkWidget *container = NULL;
1898 GtkWidget *msgwin = NULL;
1900 switch (mainwin->type) {
1902 vpaned = cwin->sep_none.vpaned;
1903 container = cwin->sep_none.hpaned;
1905 case SEPARATE_FOLDER:
1906 vpaned = cwin->sep_folder.vpaned;
1907 container = mainwin->vbox_body;
1909 case SEPARATE_MESSAGE:
1910 msgwin = mainwin->win.sep_message.messagewin;
1913 msgwin = mainwin->win.sep_both.messagewin;
1918 if (GTK_WIDGET_VISIBLE(msgwin)) {
1919 gtk_widget_hide(msgwin);
1920 mainwin->messageview->visible = FALSE;
1921 summaryview->displayed = NULL;
1923 gtk_widget_show(msgwin);
1924 mainwin->messageview->visible = TRUE;
1926 } else if (vpaned->parent != NULL) {
1927 mainwin->messageview->visible = FALSE;
1928 summaryview->displayed = NULL;
1929 gtk_widget_ref(vpaned);
1930 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1931 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1933 mainwin->messageview->visible = TRUE;
1934 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1935 gtk_container_add(GTK_CONTAINER(container), vpaned);
1936 gtk_widget_unref(vpaned);
1939 if (messageview_is_visible(mainwin->messageview))
1940 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1941 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1943 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1944 GTK_ARROW_UP, GTK_SHADOW_OUT);
1946 if (mainwin->messageview->visible == FALSE)
1947 messageview_clear(mainwin->messageview);
1949 main_window_set_menu_sensitive(mainwin);
1951 prefs_common.msgview_visible = mainwin->messageview->visible;
1953 gtk_widget_grab_focus(summaryview->ctree);
1956 void main_window_get_size(MainWindow *mainwin)
1958 GtkAllocation *allocation;
1960 if (mainwin_list == NULL || mainwin->messageview == NULL) {
1961 debug_print("called after messageview "
1962 "has been deallocated!\n");
1966 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1968 if (allocation->width > 1 && allocation->height > 1) {
1969 prefs_common.summaryview_width = allocation->width;
1971 if ((mainwin->type == SEPARATE_NONE ||
1972 mainwin->type == SEPARATE_FOLDER) &&
1973 messageview_is_visible(mainwin->messageview))
1974 prefs_common.summaryview_height = allocation->height;
1976 prefs_common.mainview_width = allocation->width;
1979 allocation = &mainwin->window->allocation;
1980 if (allocation->width > 1 && allocation->height > 1) {
1981 prefs_common.mainview_height = allocation->height;
1982 prefs_common.mainwin_width = allocation->width;
1983 prefs_common.mainwin_height = allocation->height;
1986 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1987 if (allocation->width > 1 && allocation->height > 1) {
1988 prefs_common.folderview_width = allocation->width;
1989 prefs_common.folderview_height = allocation->height;
1992 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1993 if (allocation->width > 1 && allocation->height > 1) {
1994 prefs_common.msgview_width = allocation->width;
1995 prefs_common.msgview_height = allocation->height;
1998 /* debug_print("summaryview size: %d x %d\n",
1999 prefs_common.summaryview_width,
2000 prefs_common.summaryview_height);
2001 debug_print("folderview size: %d x %d\n",
2002 prefs_common.folderview_width,
2003 prefs_common.folderview_height);
2004 debug_print("messageview size: %d x %d\n",
2005 prefs_common.msgview_width,
2006 prefs_common.msgview_height); */
2009 void main_window_get_position(MainWindow *mainwin)
2014 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2016 prefs_common.mainview_x = x;
2017 prefs_common.mainview_y = y;
2018 prefs_common.mainwin_x = x;
2019 prefs_common.mainwin_y = y;
2021 debug_print("main window position: %d, %d\n", x, y);
2023 window = main_window_get_folder_window(mainwin);
2025 gtkut_widget_get_uposition(window, &x, &y);
2026 prefs_common.folderwin_x = x;
2027 prefs_common.folderwin_y = y;
2028 debug_print("folder window position: %d, %d\n", x, y);
2030 window = main_window_get_message_window(mainwin);
2032 gtkut_widget_get_uposition(window, &x, &y);
2033 prefs_common.main_msgwin_x = x;
2034 prefs_common.main_msgwin_y = y;
2035 debug_print("message window position: %d, %d\n", x, y);
2039 void main_window_progress_on(MainWindow *mainwin)
2041 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2044 void main_window_progress_off(MainWindow *mainwin)
2046 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2047 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2050 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2054 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2055 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2056 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2057 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2060 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2063 if (alertpanel(_("Empty trash"),
2064 _("Delete all messages in trash folders?"),
2065 GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
2066 != G_ALERTALTERNATE)
2068 manage_window_focus_in(mainwin->window, NULL, NULL);
2071 procmsg_empty_all_trash();
2073 if (mainwin->summaryview->folder_item &&
2074 mainwin->summaryview->folder_item->stype == F_TRASH)
2075 gtk_widget_grab_focus(mainwin->folderview->ctree);
2078 void main_window_add_mailbox(MainWindow *mainwin)
2083 path = input_dialog(_("Add mailbox"),
2084 _("Input the location of mailbox.\n"
2085 "If the existing mailbox is specified, it will be\n"
2086 "scanned automatically."),
2089 if (folder_find_from_path(path)) {
2090 alertpanel_error(_("The mailbox '%s' already exists."), path);
2094 folder = folder_new(folder_get_class_from_string("mh"),
2095 !strcmp(path, "Mail") ? _("Mailbox") :
2096 g_path_get_basename(path), path);
2099 if (folder->klass->create_tree(folder) < 0) {
2100 alertpanel_error(_("Creation of the mailbox failed.\n"
2101 "Maybe some files already exist, or you don't have the permission to write there."));
2102 folder_destroy(folder);
2107 folder_set_ui_func(folder, scan_tree_func, mainwin);
2108 folder_scan_tree(folder, TRUE);
2109 folder_set_ui_func(folder, NULL, NULL);
2112 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2114 SensitiveCond state = 0;
2115 SummarySelection selection;
2116 FolderItem *item = mainwin->summaryview->folder_item;
2117 GList *account_list = account_get_list();
2119 selection = summary_get_selection_type(mainwin->summaryview);
2121 if (mainwin->lock_count == 0)
2122 state |= M_UNLOCKED;
2123 if (selection != SUMMARY_NONE)
2124 state |= M_MSG_EXIST;
2125 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2127 /* if (item->folder->type != F_NEWS) */
2128 state |= M_ALLOW_DELETE;
2130 if (prefs_common.immediate_exec == 0
2131 && mainwin->lock_count == 0)
2132 state |= M_DELAY_EXEC;
2134 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2135 || selection != SUMMARY_NONE)
2136 state |= M_HIDE_READ_MSG;
2138 if (mainwin->summaryview->threaded)
2139 state |= M_THREADED;
2141 state |= M_UNTHREADED;
2142 if (selection == SUMMARY_SELECTED_SINGLE ||
2143 selection == SUMMARY_SELECTED_MULTIPLE)
2144 state |= M_TARGET_EXIST;
2145 if (selection == SUMMARY_SELECTED_SINGLE)
2146 state |= M_SINGLE_TARGET_EXIST;
2147 if (mainwin->summaryview->folder_item &&
2148 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2151 state |= M_NOT_NEWS;
2152 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2153 state |= M_ACTIONS_EXIST;
2155 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2156 state |= M_HAVE_QUEUED_MAILS;
2158 if (selection == SUMMARY_SELECTED_SINGLE &&
2160 (folder_has_parent_of_type(item, F_DRAFT) ||
2161 folder_has_parent_of_type(item, F_OUTBOX) ||
2162 folder_has_parent_of_type(item, F_QUEUE))))
2163 state |= M_ALLOW_REEDIT;
2165 state |= M_HAVE_ACCOUNT;
2167 for ( ; account_list != NULL; account_list = account_list->next) {
2168 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2169 state |= M_HAVE_NEWS_ACCOUNT;
2174 if (procmsg_spam_can_learn()) {
2175 state |= M_CAN_LEARN_SPAM;
2178 if (inc_is_active())
2179 state |= M_INC_ACTIVE;
2181 if (mainwin->summaryview->deleted > 0 ||
2182 mainwin->summaryview->moved > 0 ||
2183 mainwin->summaryview->copied > 0)
2184 state |= M_DELAY_EXEC;
2191 void main_window_set_menu_sensitive(MainWindow *mainwin)
2193 GtkItemFactory *ifactory = mainwin->menu_factory;
2194 SensitiveCond state;
2197 GtkWidget *menuitem;
2198 SummaryView *summaryview;
2203 static const struct {
2207 {"/File/Save as...", M_TARGET_EXIST},
2208 {"/File/Print..." , M_TARGET_EXIST},
2209 {"/File/Exit" , M_UNLOCKED},
2211 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
2213 {"/View/Sort" , M_EXEC},
2214 {"/View/Thread view" , M_EXEC},
2215 {"/View/Expand all threads" , M_MSG_EXIST},
2216 {"/View/Collapse all threads" , M_MSG_EXIST},
2217 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2218 {"/View/Go to/Previous message" , M_MSG_EXIST},
2219 {"/View/Go to/Next message" , M_MSG_EXIST},
2220 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2221 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2222 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2223 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2224 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2225 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2226 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2227 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2228 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
2229 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2230 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2232 {"/Message/Receive/Get from current account"
2233 , M_HAVE_ACCOUNT|M_UNLOCKED},
2234 {"/Message/Receive/Get from all accounts"
2235 , M_HAVE_ACCOUNT|M_UNLOCKED},
2236 {"/Message/Receive/Cancel receiving"
2238 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2239 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2240 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2241 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2242 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2243 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2244 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2245 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2246 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2247 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2248 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2249 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2250 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2251 {"/Message/Mark" , M_TARGET_EXIST},
2252 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2253 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2254 {"/Message/Color label" , M_TARGET_EXIST},
2255 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2257 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2258 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2259 {"/Tools/Harvest addresses/from Messages..."
2261 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2262 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2263 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2264 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2265 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2266 {"/Tools/Execute" , M_DELAY_EXEC},
2267 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2269 {"/Configuration", M_UNLOCKED},
2274 state = main_window_get_current_state(mainwin);
2276 for (i = 0; entry[i].entry != NULL; i++) {
2277 sensitive = ((entry[i].cond & state) == entry[i].cond);
2278 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2281 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2283 /* search for separator */
2284 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2285 cur_item = cur_item->next) {
2286 if (GTK_BIN(cur_item->data)->child == NULL) {
2287 cur_item = cur_item->next;
2292 for (; cur_item != NULL; cur_item = cur_item->next) {
2293 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2294 (M_UNLOCKED & state) != 0);
2297 main_window_menu_callback_block(mainwin);
2299 #define SET_CHECK_MENU_ACTIVE(path, active) \
2301 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2302 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2305 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2306 messageview_is_visible(mainwin->messageview));
2308 summaryview = mainwin->summaryview;
2309 menu_path = "/View/Sort/Don't sort";
2311 switch (summaryview->sort_key) {
2312 case SORT_BY_NUMBER:
2313 menu_path = "/View/Sort/by number"; break;
2315 menu_path = "/View/Sort/by Size"; break;
2317 menu_path = "/View/Sort/by Date"; break;
2319 menu_path = "/View/Sort/by From"; break;
2321 menu_path = "/View/Sort/by To"; break;
2322 case SORT_BY_SUBJECT:
2323 menu_path = "/View/Sort/by Subject"; break;
2325 menu_path = "/View/Sort/by color label"; break;
2327 menu_path = "/View/Sort/by mark"; break;
2328 case SORT_BY_STATUS:
2329 menu_path = "/View/Sort/by status"; break;
2331 menu_path = "/View/Sort/by attachment"; break;
2333 menu_path = "/View/Sort/by score"; break;
2334 case SORT_BY_LOCKED:
2335 menu_path = "/View/Sort/by locked"; break;
2338 menu_path = "/View/Sort/Don't sort"; break;
2340 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2342 if (summaryview->sort_type == SORT_ASCENDING) {
2343 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2345 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2348 if (summaryview->sort_key != SORT_BY_NONE) {
2349 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2350 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2352 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2353 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2356 if (mainwin->messageview
2357 && mainwin->messageview->mimeview
2358 && mainwin->messageview->mimeview->textview)
2359 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
2360 mainwin->messageview->mimeview->textview->show_all_headers);
2361 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2362 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2363 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2364 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2365 if (prefs_common.hide_quotes == 1)
2366 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2367 if (prefs_common.hide_quotes == 2)
2368 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2369 if (prefs_common.hide_quotes == 3)
2370 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2372 #undef SET_CHECK_MENU_ACTIVE
2374 main_window_menu_callback_unblock(mainwin);
2377 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2379 GtkItemFactory *ifactory;
2381 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2384 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2386 gtk_widget_set_sensitive (gtk_item_factory_get_item
2387 (ifactory,"/Message/Mailing-List"), TRUE);
2389 gtk_widget_set_sensitive (gtk_item_factory_get_item
2390 (ifactory,"/Message/Mailing-List"), FALSE);
2393 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2396 GtkWidget *menuitem;
2398 if (!msginfo || !msginfo->extradata) {
2399 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2400 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2401 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2402 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2403 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2404 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2408 /* Mailing list post */
2409 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2410 g_free(msginfo->extradata->list_post);
2411 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2413 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2415 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2417 /* Mailing list help */
2418 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2420 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2422 /* Mailing list subscribe */
2423 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2425 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2427 /* Mailing list unsubscribe */
2428 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2430 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2432 /* Mailing list view archive */
2433 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2435 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2437 /* Mailing list contact owner */
2438 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2440 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2445 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2447 GtkWidget *item, *menu;
2448 const gchar *url_pt ;
2449 gchar url_decoded[BUFFSIZE];
2450 GList *amenu, *alist;
2453 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2455 /* First delete old submenu */
2456 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2457 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2458 alist = amenu->next;
2459 item = GTK_WIDGET (amenu->data);
2460 gtk_widget_destroy (item);
2464 for (url_pt = list_header; url_pt && *url_pt;) {
2465 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2467 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2468 item = gtk_menu_item_new_with_label ((url_decoded));
2469 gtk_signal_connect (GTK_OBJECT(item), "activate",
2470 GTK_SIGNAL_FUNC(mailing_list_compose), NULL);
2472 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2473 !g_strncasecmp (url_decoded, "https:",6)) {
2475 item = gtk_menu_item_new_with_label ((url_decoded));
2476 gtk_signal_connect (GTK_OBJECT(item), "activate",
2477 GTK_SIGNAL_FUNC(mailing_list_open_uri), NULL);
2480 gtk_menu_append (GTK_MENU(menu), item);
2481 gtk_widget_show (item);
2487 gtk_widget_set_sensitive (menuitem, TRUE);
2489 gtk_widget_set_sensitive (menuitem, FALSE);
2495 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2497 gchar tmp[BUFFSIZE];
2503 *url_decoded = '\0';
2507 /* Ignore spaces, comments and tabs () */
2508 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2510 for (;*buf != ')' && *buf != 0x00; buf++);
2512 /* First non space and non comment must be a < */
2515 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2520 *url_decoded = '\0';
2525 *url_decoded = '\0';
2531 decode_uri (url_decoded, (const gchar *)tmp);
2533 /* Prepare the work for the next url in the list */
2534 /* after the closing bracket >, ignore space, comments and tabs */
2535 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2537 for (;*buf != ')' && *buf != 0x00; buf++);
2539 if (!buf || !*buf) {
2544 /* now first non space, non comment must be a comma */
2546 for (;*buf != 0x00; buf++);
2552 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2556 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2557 compose_new(NULL, mailto+7, NULL);
2560 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2565 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2566 open_uri (mailto, prefs_common.uri_cmd);
2569 void main_window_popup(MainWindow *mainwin)
2571 gtkut_window_popup(mainwin->window);
2573 switch (mainwin->type) {
2574 case SEPARATE_FOLDER:
2575 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2577 case SEPARATE_MESSAGE:
2578 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2581 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2582 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2589 void main_window_show(MainWindow *mainwin)
2591 gtk_widget_show(mainwin->window);
2592 gtk_widget_show(mainwin->vbox_body);
2594 gtk_widget_set_uposition(mainwin->window,
2595 prefs_common.mainwin_x,
2596 prefs_common.mainwin_y);
2598 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2599 prefs_common.folderview_width,
2600 prefs_common.folderview_height);
2601 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2602 prefs_common.summaryview_width,
2603 prefs_common.summaryview_height);
2604 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2605 prefs_common.msgview_width,
2606 prefs_common.msgview_height);
2608 if (mainwin->type & SEPARATE_FOLDER) {
2609 GtkWidget *folderwin;
2611 folderwin = main_window_get_folder_window(mainwin);
2612 gtk_widget_show(folderwin);
2613 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2614 prefs_common.folderwin_y);
2617 if (mainwin->type & SEPARATE_MESSAGE) {
2618 GtkWidget *messagewin;
2620 messagewin = main_window_get_message_window(mainwin);
2621 gtk_widget_show(messagewin);
2622 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2623 prefs_common.main_msgwin_y);
2627 void main_window_hide(MainWindow *mainwin)
2629 main_window_get_size(mainwin);
2630 main_window_get_position(mainwin);
2632 gtk_widget_hide(mainwin->window);
2633 gtk_widget_hide(mainwin->vbox_body);
2635 if (mainwin->type & SEPARATE_FOLDER) {
2636 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2639 if (mainwin->type & SEPARATE_MESSAGE) {
2640 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2644 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2646 GtkWidget *folderwin = NULL;
2647 GtkWidget *messagewin = NULL;
2650 GtkWidget *vbox_body = mainwin->vbox_body;
2651 GtkItemFactory *ifactory = mainwin->menu_factory;
2652 GtkWidget *menuitem;
2653 GtkItemFactory *msgview_ifactory;
2655 debug_print("Setting widgets... ");
2657 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2658 prefs_common.folderview_width,
2659 prefs_common.folderview_height);
2660 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2661 prefs_common.summaryview_width,
2662 prefs_common.summaryview_height);
2663 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2664 prefs_common.msgview_width,
2665 prefs_common.msgview_height);
2667 /* create separated window(s) if needed */
2668 if (type & SEPARATE_FOLDER) {
2669 static GdkGeometry folderwin_geometry;
2671 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2672 gtk_window_set_title(GTK_WINDOW(folderwin),
2673 _("Sylpheed-Claws - Folder View"));
2675 gtk_window_move(GTK_WINDOW(folderwin),
2676 prefs_common.folderwin_x,
2677 prefs_common.folderwin_y);
2679 if (!folderwin_geometry.min_height) {
2680 folderwin_geometry.min_width = 320;
2681 folderwin_geometry.min_height = 200;
2683 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2684 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2686 gtk_widget_set_size_request(folderwin,
2687 prefs_common.folderview_width,
2688 prefs_common.folderview_height);
2690 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2693 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2694 G_CALLBACK(folder_window_close_cb),
2696 gtk_container_add(GTK_CONTAINER(folderwin),
2697 GTK_WIDGET_PTR(mainwin->folderview));
2698 gtk_widget_realize(folderwin);
2700 if (prefs_common.folderview_visible)
2701 gtk_widget_show(folderwin);
2704 if (type & SEPARATE_MESSAGE) {
2705 static GdkGeometry msgwin_geometry;
2707 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2708 gtk_window_set_title(GTK_WINDOW(messagewin),
2709 _("Sylpheed-Claws - Message View"));
2711 gtk_window_move(GTK_WINDOW(messagewin),
2712 prefs_common.main_msgwin_x,
2713 prefs_common.main_msgwin_y);
2715 if (!msgwin_geometry.min_height) {
2716 msgwin_geometry.min_width = 320;
2717 msgwin_geometry.min_height = 200;
2719 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2720 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2722 gtk_widget_set_size_request(messagewin,
2723 prefs_common.msgwin_width,
2724 prefs_common.msgwin_height);
2726 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2728 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2729 G_CALLBACK(message_window_close_cb),
2731 if (messageview_is_visible(mainwin->messageview))
2732 gtk_widget_show(messagewin);
2734 mainwin->messageview->statusbar = mainwin->statusbar;
2735 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2740 hpaned = gtk_hpaned_new();
2741 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2742 gtk_paned_add1(GTK_PANED(hpaned),
2743 GTK_WIDGET_PTR(mainwin->folderview));
2744 gtk_widget_show(hpaned);
2745 gtk_widget_queue_resize(hpaned);
2747 vpaned = gtk_vpaned_new();
2748 if (messageview_is_visible(mainwin->messageview)) {
2749 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2750 gtk_paned_add1(GTK_PANED(vpaned),
2751 GTK_WIDGET_PTR(mainwin->summaryview));
2753 gtk_paned_add2(GTK_PANED(hpaned),
2754 GTK_WIDGET_PTR(mainwin->summaryview));
2755 gtk_widget_ref(vpaned);
2757 gtk_paned_add2(GTK_PANED(vpaned),
2758 GTK_WIDGET_PTR(mainwin->messageview));
2759 gtk_widget_show(vpaned);
2760 gtk_widget_queue_resize(vpaned);
2762 mainwin->win.sep_none.hpaned = hpaned;
2763 mainwin->win.sep_none.vpaned = vpaned;
2765 /* remove headerview if not in prefs */
2766 headerview_set_visibility(mainwin->messageview->headerview,
2767 prefs_common.display_header_pane);
2769 case SEPARATE_FOLDER:
2770 vpaned = gtk_vpaned_new();
2771 if (messageview_is_visible(mainwin->messageview)) {
2772 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2774 gtk_paned_add1(GTK_PANED(vpaned),
2775 GTK_WIDGET_PTR(mainwin->summaryview));
2777 gtk_box_pack_start(GTK_BOX(vbox_body),
2778 GTK_WIDGET_PTR(mainwin->summaryview),
2780 gtk_widget_ref(vpaned);
2782 gtk_paned_add2(GTK_PANED(vpaned),
2783 GTK_WIDGET_PTR(mainwin->messageview));
2784 gtk_widget_show(vpaned);
2785 gtk_widget_queue_resize(vpaned);
2787 mainwin->win.sep_folder.folderwin = folderwin;
2788 mainwin->win.sep_folder.vpaned = vpaned;
2790 /* remove headerview if not in prefs */
2791 headerview_set_visibility(mainwin->messageview->headerview,
2792 prefs_common.display_header_pane);
2795 case SEPARATE_MESSAGE:
2796 hpaned = gtk_hpaned_new();
2797 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2798 gtk_paned_add1(GTK_PANED(hpaned),
2799 GTK_WIDGET_PTR(mainwin->folderview));
2800 gtk_paned_add2(GTK_PANED(hpaned),
2801 GTK_WIDGET_PTR(mainwin->summaryview));
2802 gtk_widget_show(hpaned);
2803 gtk_widget_queue_resize(hpaned);
2804 messageview_add_toolbar(mainwin->messageview, messagewin);
2805 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2806 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2808 mainwin->win.sep_message.messagewin = messagewin;
2809 mainwin->win.sep_message.hpaned = hpaned;
2811 gtk_widget_realize(messagewin);
2812 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2813 gtk_widget_show_all(messagewin);
2814 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2815 mainwin->messageview->handlebox,
2816 prefs_common.toolbar_style);
2818 /* remove headerview if not in prefs */
2819 headerview_set_visibility(mainwin->messageview->headerview,
2820 prefs_common.display_header_pane);
2824 messageview_add_toolbar(mainwin->messageview, messagewin);
2825 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2826 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2828 gtk_box_pack_start(GTK_BOX(vbox_body),
2829 GTK_WIDGET_PTR(mainwin->summaryview),
2832 mainwin->win.sep_both.folderwin = folderwin;
2833 mainwin->win.sep_both.messagewin = messagewin;
2835 gtk_widget_realize(messagewin);
2836 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2837 gtk_widget_show_all(messagewin);
2838 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2839 mainwin->messageview->handlebox,
2840 prefs_common.toolbar_style);
2842 /* remove headerview if not in prefs */
2843 headerview_set_visibility(mainwin->messageview->headerview,
2844 prefs_common.display_header_pane);
2849 if (messageview_is_visible(mainwin->messageview))
2850 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2851 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2853 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2854 GTK_ARROW_UP, GTK_SHADOW_OUT);
2856 gtk_window_move(GTK_WINDOW(mainwin->window),
2857 prefs_common.mainwin_x,
2858 prefs_common.mainwin_y);
2860 gtk_widget_queue_resize(vbox_body);
2861 gtk_widget_queue_resize(mainwin->vbox);
2862 gtk_widget_queue_resize(mainwin->window);
2863 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2864 * and mimeview icon list/ctree lose track of their visibility states */
2865 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2866 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2867 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2868 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2869 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2870 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2872 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2874 mainwin->type = type;
2877 /* toggle menu state */
2878 menuitem = gtk_item_factory_get_item
2879 (ifactory, "/View/Show or hide/Folder tree");
2880 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2881 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2882 prefs_common.folderview_visible);
2883 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2884 menuitem = gtk_item_factory_get_item
2885 (ifactory, "/View/Show or hide/Message view");
2886 gtk_check_menu_item_set_active
2887 (GTK_CHECK_MENU_ITEM(menuitem),
2888 messageview_is_visible(mainwin->messageview));
2890 menuitem = gtk_item_factory_get_item
2891 (ifactory, "/View/Separate folder tree");
2892 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2893 ((type & SEPARATE_FOLDER) != 0));
2894 menuitem = gtk_item_factory_get_item
2895 (ifactory, "/View/Separate message view");
2896 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2897 ((type & SEPARATE_MESSAGE) != 0));
2901 (G_OBJECT(folderwin), "size_allocate",
2902 G_CALLBACK(folder_window_size_allocate_cb),
2907 (G_OBJECT(messagewin), "size_allocate",
2908 G_CALLBACK(message_window_size_allocate_cb),
2912 debug_print("done.\n");
2915 void main_window_destroy_all(void)
2917 while (mainwin_list != NULL) {
2918 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2920 /* free toolbar stuff */
2921 toolbar_clear_list(TOOLBAR_MAIN);
2922 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2923 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2925 mainwin->folderview->mainwin = NULL;
2926 mainwin->summaryview->mainwin = NULL;
2927 mainwin->messageview->mainwin = NULL;
2929 g_free(mainwin->toolbar);
2932 mainwin_list = g_list_remove(mainwin_list, mainwin);
2934 g_list_free(mainwin_list);
2935 mainwin_list = NULL;
2938 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2941 gtk_widget_set_size_request(child, 1, -1);
2944 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2947 gtk_widget_set_size_request(child, -1, -1);
2950 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2953 MainWindow *mainwin = (MainWindow *)data;
2955 if (!event) return FALSE;
2957 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2958 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2961 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2962 menu_button_position, widget,
2963 event->button, event->time);
2968 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2971 MainWindow *mainwin = (MainWindow *)data;
2973 if (mainwin->lock_count == 0)
2974 app_exit_cb(data, 0, widget);
2979 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2982 MainWindow *mainwin = (MainWindow *)data;
2983 GtkWidget *menuitem;
2985 menuitem = gtk_item_factory_get_item
2986 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2987 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2992 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2995 MainWindow *mainwin = (MainWindow *)data;
2996 GtkWidget *menuitem;
2998 menuitem = gtk_item_factory_get_item
2999 (mainwin->menu_factory, "/View/Show or hide/Message view");
3000 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3002 mainwin->messageview->statusbar = mainwin->statusbar;
3003 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3008 static void main_window_size_allocate_cb(GtkWidget *widget,
3009 GtkAllocation *allocation,
3012 MainWindow *mainwin = (MainWindow *)data;
3014 main_window_get_size(mainwin);
3017 static void folder_window_size_allocate_cb(GtkWidget *widget,
3018 GtkAllocation *allocation,
3021 MainWindow *mainwin = (MainWindow *)data;
3023 main_window_get_size(mainwin);
3026 static void message_window_size_allocate_cb(GtkWidget *widget,
3027 GtkAllocation *allocation,
3030 MainWindow *mainwin = (MainWindow *)data;
3032 main_window_get_size(mainwin);
3035 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3038 main_window_add_mailbox(mainwin);
3041 static void update_folderview_cb(MainWindow *mainwin, guint action,
3044 summary_show(mainwin->summaryview, NULL);
3045 folderview_check_new_all();
3048 static void foldersort_cb(MainWindow *mainwin, guint action,
3054 static void import_mbox_cb(MainWindow *mainwin, guint action,
3057 /* only notify if import has failed */
3058 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3059 alertpanel_error(_("Mbox import has failed."));
3063 static void export_mbox_cb(MainWindow *mainwin, guint action,
3066 /* only notify if export has failed */
3067 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3068 alertpanel_error(_("Export to mbox has failed."));
3072 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3075 /* only notify if export has failed */
3076 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3077 alertpanel_error(_("Export to mbox has failed."));
3081 static void empty_trash_cb(MainWindow *mainwin, guint action,
3084 main_window_empty_trash(mainwin, TRUE);
3087 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3089 summary_save_as(mainwin->summaryview);
3092 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3094 summary_print(mainwin->summaryview);
3097 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3099 if (prefs_common.confirm_on_exit) {
3100 if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
3101 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3102 != G_ALERTALTERNATE)
3104 manage_window_focus_in(mainwin->window, NULL, NULL);
3107 app_will_exit(widget, mainwin);
3110 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3113 summary_search(mainwin->summaryview);
3115 message_search(mainwin->messageview);
3118 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3120 prefs_common.show_searchbar = TRUE;
3121 summaryview_activate_quicksearch(mainwin->summaryview);
3124 static void toggle_folder_cb(MainWindow *mainwin, guint action,
3129 active = GTK_CHECK_MENU_ITEM(widget)->active;
3131 switch (mainwin->type) {
3133 case SEPARATE_MESSAGE:
3135 case SEPARATE_FOLDER:
3136 debug_print("separate folder\n");
3138 gtk_widget_show(mainwin->win.sep_folder.folderwin);
3140 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
3144 gtk_widget_show(mainwin->win.sep_both.folderwin);
3146 gtk_widget_hide(mainwin->win.sep_both.folderwin);
3150 prefs_common.folderview_visible = active;
3153 static void toggle_message_cb(MainWindow *mainwin, guint action,
3158 active = GTK_CHECK_MENU_ITEM(widget)->active;
3160 if (active != messageview_is_visible(mainwin->messageview))
3161 summary_toggle_view(mainwin->summaryview);
3164 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3167 toolbar_toggle(action, mainwin);
3170 void main_window_reply_cb(MainWindow *mainwin, guint action,
3173 MessageView *msgview = (MessageView*)mainwin->messageview;
3174 GSList *msginfo_list = NULL;
3176 g_return_if_fail(msgview != NULL);
3178 msginfo_list = summary_get_selection(mainwin->summaryview);
3179 g_return_if_fail(msginfo_list != NULL);
3180 compose_reply_from_messageview(msgview, msginfo_list, action);
3181 g_slist_free(msginfo_list);
3185 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3188 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3189 gtk_widget_show(mainwin->hbox_stat);
3190 prefs_common.show_statusbar = TRUE;
3192 gtk_widget_hide(mainwin->hbox_stat);
3193 prefs_common.show_statusbar = FALSE;
3197 static void separate_widget_cb(MainWindow *mainwin, guint action,
3202 if (GTK_CHECK_MENU_ITEM(widget)->active)
3203 type = mainwin->type | action;
3205 type = mainwin->type & ~action;
3207 main_window_separation_change(mainwin, type);
3209 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
3210 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
3213 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3216 offline_ask_sync = ask_sync;
3218 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3220 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3221 offline_ask_sync = TRUE;
3224 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3226 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3229 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3231 GList *folderlist = folder_get_list();
3232 gboolean found = FALSE;
3234 /* see if there are synchronised folders */
3235 for (; folderlist; folderlist = folderlist->next) {
3236 Folder *folder = (Folder *)folderlist->data;
3237 if (folder_want_synchronise(folder)) {
3246 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3247 _("Do you want to synchronise your folders now?"),
3248 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3251 folder_synchronise(NULL);
3254 static void online_switch_clicked (GtkButton *btn, gpointer data)
3256 MainWindow *mainwin;
3257 GtkItemFactory *ifactory;
3258 GtkCheckMenuItem *menuitem;
3260 mainwin = (MainWindow *) data;
3262 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3263 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3265 g_return_if_fail(mainwin != NULL);
3266 g_return_if_fail(menuitem != NULL);
3268 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3269 gtk_widget_hide (mainwin->online_switch);
3270 gtk_widget_show (mainwin->offline_switch);
3271 menuitem->active = TRUE;
3272 inc_autocheck_timer_remove();
3275 if (prefs_common.work_offline)
3277 mainwindow_check_synchronise(mainwin, TRUE);
3278 prefs_common.work_offline = TRUE;
3279 imap_disconnect_all();
3282 if (!prefs_common.work_offline)
3284 gtk_widget_hide (mainwin->offline_switch);
3285 gtk_widget_show (mainwin->online_switch);
3286 menuitem->active = FALSE;
3287 prefs_common.work_offline = FALSE;
3288 inc_autocheck_timer_set();
3289 refresh_resolvers();
3293 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3296 addressbook_open(NULL);
3299 static void log_window_show_cb(MainWindow *mainwin, guint action,
3302 log_window_show(mainwin->logwin);
3305 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3310 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3312 summary_move_to(mainwin->summaryview);
3315 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3317 summary_copy_to(mainwin->summaryview);
3320 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3322 summary_delete(mainwin->summaryview);
3325 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3327 summary_delete_trash(mainwin->summaryview);
3330 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3332 summary_cancel(mainwin->summaryview);
3335 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3337 summary_open_msg(mainwin->summaryview);
3340 static void view_source_cb(MainWindow *mainwin, guint action,
3343 summary_view_source(mainwin->summaryview);
3346 static void show_all_header_cb(MainWindow *mainwin, guint action,
3349 if (mainwin->menu_lock_count) return;
3350 mainwin->summaryview->messageview->all_headers =
3351 GTK_CHECK_MENU_ITEM(widget)->active;
3352 summary_display_msg_selected(mainwin->summaryview,
3353 GTK_CHECK_MENU_ITEM(widget)->active);
3356 #define SET_CHECK_MENU_ACTIVE(path, active) \
3358 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3359 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3362 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3365 GtkWidget *menuitem;
3366 GtkItemFactory *ifactory = mainwin->menu_factory;
3368 if (mainwin->menu_lock_count) return;
3370 prefs_common.hide_quotes =
3371 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3373 mainwin->menu_lock_count++;
3374 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3375 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3376 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3377 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3378 mainwin->menu_lock_count--;
3380 summary_redisplay_msg(mainwin->summaryview);
3383 #undef SET_CHECK_MENU_ACTIVE
3384 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3386 summary_mark(mainwin->summaryview);
3389 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3391 summary_unmark(mainwin->summaryview);
3394 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3397 summary_mark_as_unread(mainwin->summaryview);
3400 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3403 summary_mark_as_read(mainwin->summaryview);
3406 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3409 summary_mark_all_read(mainwin->summaryview);
3412 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3415 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3418 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3420 summary_reedit(mainwin->summaryview);
3423 static void add_address_cb(MainWindow *mainwin, guint action,
3426 summary_add_address(mainwin->summaryview);
3429 static void set_charset_cb(MainWindow *mainwin, guint action,
3434 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3435 str = conv_get_charset_str((CharSet)action);
3437 g_free(mainwin->messageview->forced_charset);
3438 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3439 procmime_force_charset(str);
3441 summary_redisplay_msg(mainwin->summaryview);
3443 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3447 static void set_decode_cb(MainWindow *mainwin, guint action,
3450 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3451 mainwin->messageview->forced_encoding = (EncodingType)action;
3453 summary_redisplay_msg(mainwin->summaryview);
3455 debug_print("forced encoding: %d\n", action);
3459 static void hide_read_messages (MainWindow *mainwin, guint action,
3462 if (!mainwin->summaryview->folder_item
3463 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3465 summary_toggle_show_read_messages(mainwin->summaryview);
3468 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3470 gboolean threaded = FALSE;
3471 if (mainwin->menu_lock_count) return;
3472 if (!mainwin->summaryview->folder_item) return;
3474 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3476 mainwin->summaryview->folder_item->threaded = threaded;
3478 mainwin->summaryview->threaded = threaded;
3480 summary_show(mainwin->summaryview,
3481 mainwin->summaryview->folder_item);
3484 static void expand_threads_cb(MainWindow *mainwin, guint action,
3487 summary_expand_threads(mainwin->summaryview);
3490 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3493 summary_collapse_threads(mainwin->summaryview);
3496 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3499 prefs_summary_column_open();
3502 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3505 prefs_folder_column_open();
3508 static void sort_summary_cb(MainWindow *mainwin, guint action,
3511 FolderItem *item = mainwin->summaryview->folder_item;
3512 GtkWidget *menuitem;
3514 if (mainwin->menu_lock_count) return;
3516 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3517 menuitem = gtk_item_factory_get_item
3518 (mainwin->menu_factory, "/View/Sort/Ascending");
3519 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3520 GTK_CHECK_MENU_ITEM(menuitem)->active
3521 ? SORT_ASCENDING : SORT_DESCENDING);
3522 item->sort_key = action;
3526 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3529 FolderItem *item = mainwin->summaryview->folder_item;
3531 if (mainwin->menu_lock_count) return;
3533 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3534 summary_sort(mainwin->summaryview,
3535 item->sort_key, (FolderSortType)action);
3538 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3541 summary_attract_by_subject(mainwin->summaryview);
3544 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3549 item = folderview_get_selected_item(mainwin->folderview);
3551 main_window_cursor_wait(mainwin);
3552 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3554 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3555 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3557 STATUSBAR_POP(mainwin);
3558 main_window_cursor_normal(mainwin);
3568 static void deldup_all(FolderItem *item, gpointer _data)
3570 struct DelDupsData *data = _data;
3573 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3575 data->dups += result;
3580 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3583 struct DelDupsData data = {0, 0};
3585 folder_func_to_all_folders(deldup_all, &data);
3586 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3587 "Deleted %d duplicate messages in %d folders.\n",
3589 data.dups, data.folders);
3592 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3594 summary_filter(mainwin->summaryview, (gboolean)action);
3597 static void execute_summary_cb(MainWindow *mainwin, guint action,
3600 summary_execute(mainwin->summaryview);
3603 static void update_summary_cb(MainWindow *mainwin, guint action,
3607 FolderView *folderview = mainwin->folderview;
3609 if (!mainwin->summaryview->folder_item) return;
3610 if (!folderview->opened) return;
3612 folder_update_op_count();
3614 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3615 folderview->opened);
3618 folder_item_scan(fitem);
3619 summary_show(mainwin->summaryview, fitem);
3622 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3624 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3627 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3629 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3632 static void prev_unread_cb(MainWindow *mainwin, guint action,
3635 summary_select_prev_unread(mainwin->summaryview);
3638 static void next_unread_cb(MainWindow *mainwin, guint action,
3641 summary_select_next_unread(mainwin->summaryview);
3644 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3646 summary_select_prev_new(mainwin->summaryview);
3649 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3651 summary_select_next_new(mainwin->summaryview);
3654 static void prev_marked_cb(MainWindow *mainwin, guint action,
3657 summary_select_prev_marked(mainwin->summaryview);
3660 static void next_marked_cb(MainWindow *mainwin, guint action,
3663 summary_select_next_marked(mainwin->summaryview);
3666 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3669 summary_select_prev_labeled(mainwin->summaryview);
3672 static void next_labeled_cb(MainWindow *mainwin, guint action,
3675 summary_select_next_labeled(mainwin->summaryview);
3678 static void last_read_cb(MainWindow *mainwin, guint action,
3681 summary_select_last_read(mainwin->summaryview);
3684 static void parent_cb(MainWindow *mainwin, guint action,
3687 summary_select_parent(mainwin->summaryview);
3690 static void goto_folder_cb(MainWindow *mainwin, guint action,
3693 FolderItem *to_folder;
3695 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3698 folderview_select(mainwin->folderview, to_folder);
3701 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3704 folderview_select_next_unread(mainwin->folderview, FALSE);
3707 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3709 messageview_copy_clipboard(mainwin->messageview);
3712 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3714 MessageView *msgview = mainwin->messageview;
3716 if (messageview_is_visible(msgview) &&
3717 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3718 messageview_select_all(mainwin->messageview);
3720 summary_select_all(mainwin->summaryview);
3723 static void select_thread_cb(MainWindow *mainwin, guint action,
3726 summary_select_thread(mainwin->summaryview);
3729 static void create_filter_cb(MainWindow *mainwin, guint action,
3732 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3735 static void create_processing_cb(MainWindow *mainwin, guint action,
3738 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3741 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3744 prefs_filtering_open(&pre_global_processing,
3745 _("Processing rules to apply before folder rules"),
3746 MANUAL_ANCHOR_PROCESSING,
3750 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3753 prefs_filtering_open(&post_global_processing,
3754 _("Processing rules to apply after folder rules"),
3755 MANUAL_ANCHOR_PROCESSING,
3759 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3762 prefs_filtering_open(&filtering_rules,
3763 _("Filtering configuration"),
3764 MANUAL_ANCHOR_FILTERING,
3768 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3771 prefs_template_open();
3774 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3777 prefs_actions_open(mainwin);
3780 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3783 ssl_manager_open(mainwin);
3786 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3790 new_account_cb(mainwin, 0, widget);
3792 account_open(cur_account);
3796 static void new_account_cb(MainWindow *mainwin, guint action,
3799 account_edit_open();
3800 if (!compose_get_compose_list()) account_add();
3803 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3805 FolderItem *item = NULL;
3806 cur_account = (PrefsAccount *)data;
3808 if (!mainwindow_get_mainwindow())
3810 main_window_show_cur_account(mainwindow_get_mainwindow());
3811 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3812 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3813 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3814 item = folderview_get_selected_item(
3815 mainwindow_get_mainwindow()->folderview);
3817 toolbar_set_compose_button
3818 (mainwindow_get_mainwindow()->toolbar,
3819 FOLDER_TYPE(item->folder) == F_NEWS ?
3820 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3824 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3826 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3827 PrefsAccount *account = (PrefsAccount *)data;
3829 inc_account_mail(mainwin, account);
3832 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3834 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3835 PrefsAccount *account = (PrefsAccount *)data;
3836 FolderItem *item = mainwin->summaryview->folder_item;
3838 compose_new_with_folderitem(account, item);
3841 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3846 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3848 pluginwindow_create();
3851 static void manual_open_cb(MainWindow *mainwin, guint action,
3854 manual_open((ManualType)action, NULL);
3857 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3862 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3864 MainWindow *mainwin = (MainWindow *)data;
3868 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3869 LOCAL_FOLDER(folder)->rootpath,
3873 str = g_strdup_printf(_("Scanning folder %s ..."),
3874 LOCAL_FOLDER(folder)->rootpath);
3876 STATUSBAR_PUSH(mainwin, str);
3877 STATUSBAR_POP(mainwin);
3881 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3884 SummaryView *summary;
3886 g_return_val_if_fail(data, FALSE);
3887 if (!g_list_find(mainwin_list, data))
3889 summary = ((MainWindow *)data)->summaryview;
3890 g_return_val_if_fail(summary, FALSE);
3892 if (GTK_CLIST(summary->ctree)->selection &&
3893 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3899 #define BREAK_ON_MODIFIER_KEY() \
3900 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3902 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3905 MainWindow *mainwin = (MainWindow*) data;
3907 if (!mainwin || !event)
3910 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3912 lastkey = event->keyval;
3916 switch (event->keyval) {
3917 case GDK_Q: /* Quit */
3918 BREAK_ON_MODIFIER_KEY();
3920 app_exit_cb(mainwin, 0, NULL);
3923 if (mainwin->folderview && mainwin->summaryview
3924 && ((!mainwin->summaryview->displayed
3925 && !mainwin->summaryview->selected)
3926 || (mainwin->summaryview->folder_item
3927 && mainwin->summaryview->folder_item->total_msgs == 0))) {
3928 g_signal_stop_emission_by_name(G_OBJECT(widget),
3930 folderview_select_next_unread(mainwin->folderview, TRUE);
3939 #undef BREAK_ON_MODIFIER_KEY
3942 * Harvest addresses for selected folder.
3944 static void addr_harvest_cb( MainWindow *mainwin,
3948 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3952 * Harvest addresses for selected messages in summary view.
3954 static void addr_harvest_msg_cb( MainWindow *mainwin,
3958 summary_harvest_address( mainwin->summaryview );
3962 *\brief get a MainWindow
3964 *\return MainWindow * The first mainwindow in the mainwin_list
3966 MainWindow *mainwindow_get_mainwindow(void)
3968 if (mainwin_list && mainwin_list->data)
3969 return (MainWindow *)(mainwin_list->data);
3974 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3976 ProgressData *data = (ProgressData *) source;
3977 MainWindow *mainwin = (MainWindow *) userdata;
3979 switch (data->cmd) {
3980 case PROGRESS_COMMAND_START:
3981 case PROGRESS_COMMAND_STOP:
3982 gtk_progress_bar_set_fraction
3983 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3985 case PROGRESS_COMMAND_SET_PERCENTAGE:
3986 gtk_progress_bar_set_fraction
3987 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3990 while (gtk_events_pending()) gtk_main_iteration ();
3995 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3997 mainwindow_check_synchronise(mainwin, FALSE);
4000 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4002 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4005 void mainwindow_jump_to(const gchar *target)
4009 FolderItem *item = NULL;
4011 MainWindow *mainwin = mainwindow_get_mainwindow();
4017 printf(_("not initialized\n"));
4021 tmp = g_strdup(target);
4023 if ((p = strstr(tmp, "\r")) != NULL)
4025 if ((p = strstr(tmp, "\n")) != NULL)
4028 if ((item = folder_find_item_from_identifier(tmp))) {
4029 printf(_("selecting folder '%s'\n"), tmp);
4030 folderview_select(mainwin->folderview, item);
4031 main_window_popup(mainwin);
4036 msg = strrchr(tmp, G_DIR_SEPARATOR);
4039 if ((item = folder_find_item_from_identifier(tmp))) {
4040 printf(_("selecting folder '%s'\n"), tmp);
4041 folderview_select(mainwin->folderview, item);
4043 if (item && msg && atoi(msg)) {
4044 printf(_("selecting message %d\n"), atoi(msg));
4045 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4046 summary_display_msg_selected(mainwin->summaryview, FALSE);
4047 main_window_popup(mainwin);
4053 printf("'%s' not found\n", tmp);