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"
63 #include "prefs_common.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_folder_column.h"
69 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "ssl_manager.h"
85 #include "sslcertwindow.h"
86 #include "prefs_gtk.h"
87 #include "pluginwindow.h"
89 #include "progressindicator.h"
90 #include "localfolder.h"
91 #include "filtering.h"
92 #include "folderutils.h"
93 #include "foldersort.h"
94 #include "icon_legend.h"
96 #define AC_LABEL_WIDTH 240
98 /* list of all instantiated MainWindow */
99 static GList *mainwin_list = NULL;
101 static GdkCursor *watch_cursor;
103 static void main_window_menu_callback_block (MainWindow *mainwin);
104 static void main_window_menu_callback_unblock (MainWindow *mainwin);
106 static void main_window_show_cur_account (MainWindow *mainwin);
108 static void main_window_set_widgets (MainWindow *mainwin,
112 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
113 GdkEventButton *event,
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 move_to_cb (MainWindow *mainwin,
226 static void copy_to_cb (MainWindow *mainwin,
229 static void delete_cb (MainWindow *mainwin,
232 static void delete_trash_cb (MainWindow *mainwin,
236 static void cancel_cb (MainWindow *mainwin,
240 static void mark_cb (MainWindow *mainwin,
243 static void unmark_cb (MainWindow *mainwin,
247 static void mark_as_unread_cb (MainWindow *mainwin,
250 static void mark_as_read_cb (MainWindow *mainwin,
253 static void mark_all_read_cb (MainWindow *mainwin,
256 static void mark_as_spam_cb (MainWindow *mainwin,
260 static void reedit_cb (MainWindow *mainwin,
264 static void add_address_cb (MainWindow *mainwin,
268 static void set_charset_cb (MainWindow *mainwin,
272 static void set_decode_cb (MainWindow *mainwin,
276 static void hide_read_messages (MainWindow *mainwin,
280 static void thread_cb (MainWindow *mainwin,
283 static void expand_threads_cb (MainWindow *mainwin,
286 static void collapse_threads_cb (MainWindow *mainwin,
290 static void set_summary_display_item_cb (MainWindow *mainwin,
293 static void set_folder_display_item_cb (MainWindow *mainwin,
296 static void sort_summary_cb (MainWindow *mainwin,
299 static void sort_summary_type_cb (MainWindow *mainwin,
302 static void attract_by_subject_cb(MainWindow *mainwin,
306 static void delete_duplicated_cb (MainWindow *mainwin,
309 static void delete_duplicated_all_cb (MainWindow *mainwin,
312 static void filter_cb (MainWindow *mainwin,
315 static void execute_summary_cb (MainWindow *mainwin,
318 static void update_summary_cb (MainWindow *mainwin,
322 static void prev_cb (MainWindow *mainwin,
325 static void next_cb (MainWindow *mainwin,
328 static void next_unread_cb (MainWindow *mainwin,
331 static void prev_unread_cb (MainWindow *mainwin,
335 static void prev_new_cb (MainWindow *mainwin,
338 static void next_new_cb (MainWindow *mainwin,
341 static void prev_marked_cb (MainWindow *mainwin,
344 static void next_marked_cb (MainWindow *mainwin,
347 static void prev_labeled_cb (MainWindow *mainwin,
350 static void next_labeled_cb (MainWindow *mainwin,
354 static void goto_folder_cb (MainWindow *mainwin,
358 static void copy_cb (MainWindow *mainwin,
361 static void allsel_cb (MainWindow *mainwin,
364 static void select_thread_cb (MainWindow *mainwin,
368 static void create_filter_cb (MainWindow *mainwin,
371 static void create_processing_cb (MainWindow *mainwin,
375 static void prefs_template_open_cb (MainWindow *mainwin,
378 static void prefs_actions_open_cb (MainWindow *mainwin,
381 static void prefs_account_open_cb (MainWindow *mainwin,
385 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
389 static void prefs_post_processing_open_cb (MainWindow *mainwin,
393 static void prefs_filtering_open_cb (MainWindow *mainwin,
397 static void ssl_manager_open_cb (MainWindow *mainwin,
401 static void new_account_cb (MainWindow *mainwin,
405 static void account_selector_menu_cb (GtkMenuItem *menuitem,
407 static void account_receive_menu_cb (GtkMenuItem *menuitem,
410 static void prefs_open_cb (GtkMenuItem *menuitem,
412 static void plugins_open_cb (GtkMenuItem *menuitem,
415 static void online_switch_clicked(GtkButton *btn,
418 static void manual_open_cb (MainWindow *mainwin,
422 static void legend_open_cb (GtkMenuItem *menuitem,
425 static void scan_tree_func (Folder *folder,
429 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
431 static void addr_harvest_cb ( MainWindow *mainwin,
435 static void addr_harvest_msg_cb ( MainWindow *mainwin,
438 static void sync_cb ( MainWindow *mainwin,
442 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
443 GdkEventFocus *focus,
445 void main_window_reply_cb (MainWindow *mainwin,
448 gboolean mainwindow_progressindicator_hook (gpointer source,
450 #define SEPARATE_ACTION 500
451 static void mainwindow_quicksearch (MainWindow *mainwin,
455 static GtkItemFactoryEntry mainwin_entries[] =
457 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
458 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
459 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
460 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
461 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
462 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
463 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
464 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
465 {N_("/_File/Exp_ort selected to mbox file..."),
466 NULL, export_list_mbox_cb, 0, NULL},
467 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
468 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
469 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
470 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
471 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
472 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
473 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
474 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
475 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
476 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
477 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
479 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
480 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
481 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
482 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
483 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
484 {N_("/_Edit/_Find in current message..."),
485 "<control>F", search_cb, 0, NULL},
486 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
487 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
488 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
489 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
490 {N_("/_View/Show or hi_de/_Folder tree"),
491 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
492 {N_("/_View/Show or hi_de/_Message view"),
493 "V", toggle_message_cb, 0, "<ToggleItem>"},
494 {N_("/_View/Show or hi_de/_Toolbar"),
495 NULL, NULL, 0, "<Branch>"},
496 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
497 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
498 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
499 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
500 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
501 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
502 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
503 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
504 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
505 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
506 {N_("/_View/Show or hi_de/Status _bar"),
507 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
508 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
509 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
510 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
512 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
514 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
515 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
517 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
518 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
519 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
520 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
521 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
522 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
523 {N_("/_View/_Sort/by _color label"),
524 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
525 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
526 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
527 {N_("/_View/_Sort/by a_ttachment"),
528 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
529 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
530 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
531 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
532 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
534 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
535 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_View/_Sort/_Attract by subject"),
537 NULL, attract_by_subject_cb, 0, NULL},
538 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
539 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
540 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
541 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
543 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
546 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
547 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_View/_Go to/P_revious unread message"),
549 "<shift>P", prev_unread_cb, 0, NULL},
550 {N_("/_View/_Go to/N_ext unread message"),
551 "<shift>N", next_unread_cb, 0, NULL},
552 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
553 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
554 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
555 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_View/_Go to/Previous _marked message"),
557 NULL, prev_marked_cb, 0, NULL},
558 {N_("/_View/_Go to/Next m_arked message"),
559 NULL, next_marked_cb, 0, NULL},
560 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_View/_Go to/Previous _labeled message"),
562 NULL, prev_labeled_cb, 0, NULL},
563 {N_("/_View/_Go to/Next la_beled message"),
564 NULL, next_labeled_cb, 0, NULL},
565 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
567 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
569 #define ENC_SEPARATOR \
570 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
571 #define ENC_ACTION(action) \
572 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
574 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
575 {N_("/_View/Character _encoding/_Auto detect"),
576 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
577 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
579 ENC_ACTION(C_US_ASCII)},
580 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
581 ENC_ACTION(C_UTF_8)},
584 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
585 ENC_ACTION(C_ISO_8859_1)},
586 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
587 ENC_ACTION(C_ISO_8859_15)},
588 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
589 ENC_ACTION(C_WINDOWS_1252)},
592 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
593 ENC_ACTION(C_ISO_8859_2)},
596 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
597 ENC_ACTION(C_ISO_8859_13)},
598 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
599 ENC_ACTION(C_ISO_8859_4)},
602 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
603 ENC_ACTION(C_ISO_8859_7)},
606 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
607 ENC_ACTION(C_ISO_8859_8)},
608 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
609 ENC_ACTION(C_CP1255)},
612 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
613 ENC_ACTION(C_ISO_8859_6)},
614 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
615 ENC_ACTION(C_CP1256)},
618 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
619 ENC_ACTION(C_ISO_8859_9)},
622 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
623 ENC_ACTION(C_ISO_8859_5)},
624 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
625 ENC_ACTION(C_KOI8_R)},
626 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
627 ENC_ACTION(C_KOI8_U)},
628 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
629 ENC_ACTION(C_CP1251)},
632 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
633 ENC_ACTION(C_ISO_2022_JP)},
634 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
635 ENC_ACTION(C_ISO_2022_JP_2)},
636 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
637 ENC_ACTION(C_EUC_JP)},
638 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
639 ENC_ACTION(C_SHIFT_JIS)},
642 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
643 ENC_ACTION(C_GB2312)},
644 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
646 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
648 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
649 ENC_ACTION(C_EUC_TW)},
650 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
651 ENC_ACTION(C_ISO_2022_CN)},
654 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
655 ENC_ACTION(C_EUC_KR)},
656 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
657 ENC_ACTION(C_ISO_2022_KR)},
660 {N_("/_View/Character _encoding/Thai (TIS-620)"),
661 ENC_ACTION(C_TIS_620)},
662 {N_("/_View/Character _encoding/Thai (Windows-874)"),
663 ENC_ACTION(C_WINDOWS_874)},
668 #define DEC_SEPARATOR \
669 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
670 #define DEC_ACTION(action) \
671 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
672 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
673 {N_("/_View/Decode/_Auto detect"),
674 NULL, set_decode_cb, 0, "<RadioItem>"},
675 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
676 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
677 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
678 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
679 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
684 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
685 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
686 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
687 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
688 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
689 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
691 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
692 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
693 {N_("/_Message/Recei_ve/Get from _current account"),
694 "<control>I", inc_mail_cb, 0, NULL},
695 {N_("/_Message/Recei_ve/Get from _all accounts"),
696 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
697 {N_("/_Message/Recei_ve/Cancel receivin_g"),
698 NULL, inc_cancel_cb, 0, NULL},
699 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
701 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
703 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
704 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
705 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
706 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
707 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
708 {N_("/_Message/Repl_y to/mailing _list"),
709 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
710 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
711 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
712 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
713 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
714 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
715 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
716 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
717 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
718 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
719 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
720 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
721 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
722 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
723 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
724 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
725 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
726 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
727 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
728 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
729 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
731 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
732 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
733 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
735 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
736 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
737 {N_("/_Tools/Add sender to address boo_k"),
738 NULL, add_address_cb, 0, NULL},
739 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
740 {N_("/_Tools/_Harvest addresses/from _Folder..."),
741 NULL, addr_harvest_cb, 0, NULL},
742 {N_("/_Tools/_Harvest addresses/from _Messages..."),
743 NULL, addr_harvest_msg_cb, 0, NULL},
744 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
745 {N_("/_Tools/_Filter all messages in folder"),
746 NULL, filter_cb, 0, NULL},
747 {N_("/_Tools/Filter _selected messages"),
748 NULL, filter_cb, 1, NULL},
749 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
750 {N_("/_Tools/_Create filter rule/_Automatically"),
751 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
752 {N_("/_Tools/_Create filter rule/by _From"),
753 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
754 {N_("/_Tools/_Create filter rule/by _To"),
755 NULL, create_filter_cb, FILTER_BY_TO, NULL},
756 {N_("/_Tools/_Create filter rule/by _Subject"),
757 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
758 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
759 {N_("/_Tools/C_reate processing rule/_Automatically"),
760 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
761 {N_("/_Tools/C_reate processing rule/by _From"),
762 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
763 {N_("/_Tools/C_reate processing rule/by _To"),
764 NULL, create_processing_cb, FILTER_BY_TO, NULL},
765 {N_("/_Tools/C_reate processing rule/by _Subject"),
766 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
767 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
768 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
769 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
770 {N_("/_Tools/Ch_eck for new messages in all folders"),
771 NULL, update_folderview_cb, 0, NULL},
772 {N_("/_Tools/Delete du_plicated messages"),
773 NULL, NULL, 0, "<Branch>"},
774 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
775 NULL, delete_duplicated_cb, 0, NULL},
776 {N_("/_Tools/Delete du_plicated messages/In all folders"),
777 NULL, delete_duplicated_all_cb, 0, NULL},
778 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
779 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
781 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
782 {N_("/_Tools/SSL cer_tificates..."),
783 NULL, ssl_manager_open_cb, 0, NULL},
785 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
786 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
788 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
789 {N_("/_Configuration/C_hange current account"),
790 NULL, NULL, 0, "<Branch>"},
791 {N_("/_Configuration/_Preferences for current account..."),
792 NULL, prefs_account_open_cb, 0, NULL},
793 {N_("/_Configuration/Create _new account..."),
794 NULL, new_account_cb, 0, NULL},
795 {N_("/_Configuration/_Edit accounts..."),
796 NULL, account_edit_open, 0, NULL},
797 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
798 {N_("/_Configuration/P_references..."),
799 NULL, prefs_open_cb, 0, NULL},
800 {N_("/_Configuration/Pre-pr_ocessing..."),
801 NULL, prefs_pre_processing_open_cb, 0, NULL},
802 {N_("/_Configuration/Post-pro_cessing..."),
803 NULL, prefs_post_processing_open_cb, 0, NULL},
804 {N_("/_Configuration/_Filtering..."),
805 NULL, prefs_filtering_open_cb, 0, NULL},
806 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
807 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
808 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
810 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
811 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
812 {N_("/_Help/_Online User-contributed FAQ"),
813 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
814 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
815 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
816 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
819 static gboolean offline_ask_sync = TRUE;
821 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
827 MainWindow *mainwin = (MainWindow *)user_data;
829 if (mainwin->summaryview &&
830 mainwin->summaryview->quicksearch &&
831 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
832 (mod == 0 || mod == GDK_SHIFT_MASK)) {
833 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
839 MainWindow *main_window_create(SeparateType type)
845 GtkWidget *handlebox;
846 GtkWidget *vbox_body;
847 GtkWidget *hbox_stat;
848 GtkWidget *statusbar;
849 GtkWidget *progressbar;
850 GtkWidget *statuslabel;
851 GtkWidget *ac_button;
853 GtkWidget *online_pixmap;
854 GtkWidget *offline_pixmap;
855 GtkWidget *online_switch;
856 GtkWidget *offline_switch;
857 GtkTooltips *offline_tip;
858 GtkTooltips *online_tip;
859 GtkTooltips *sel_ac_tip;
861 FolderView *folderview;
862 SummaryView *summaryview;
863 MessageView *messageview;
864 GdkColormap *colormap;
867 GtkItemFactory *ifactory;
871 guint n_menu_entries;
873 static GdkGeometry geometry;
875 debug_print("Creating main window...\n");
876 mainwin = g_new0(MainWindow, 1);
879 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
880 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
881 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
883 if (!geometry.min_height) {
884 geometry.min_width = 320;
885 geometry.min_height = 200;
887 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
890 g_signal_connect(G_OBJECT(window), "delete_event",
891 G_CALLBACK(main_window_close_cb), mainwin);
892 MANAGE_WINDOW_SIGNALS_CONNECT(window);
893 g_signal_connect(G_OBJECT(window), "focus_in_event",
894 G_CALLBACK(mainwindow_focus_in_event),
896 g_signal_connect(G_OBJECT(window), "key_press_event",
897 G_CALLBACK(mainwindow_key_pressed), mainwin);
899 gtk_widget_realize(window);
900 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
903 gtkut_widget_set_app_icon(window);
905 vbox = gtk_vbox_new(FALSE, 0);
906 gtk_widget_show(vbox);
907 gtk_container_add(GTK_CONTAINER(window), vbox);
910 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
911 menubar = menubar_create(window, mainwin_entries,
912 n_menu_entries, "<Main>", mainwin);
913 gtk_widget_show(menubar);
914 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
915 ifactory = gtk_item_factory_from_widget(menubar);
917 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
919 if (prefs_common.toolbar_detachable) {
920 handlebox = gtk_handle_box_new();
921 gtk_widget_show(handlebox);
922 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
923 g_signal_connect(G_OBJECT(handlebox), "child_attached",
924 G_CALLBACK(toolbar_child_attached), mainwin);
925 g_signal_connect(G_OBJECT(handlebox), "child_detached",
926 G_CALLBACK(toolbar_child_detached), mainwin);
928 handlebox = gtk_hbox_new(FALSE, 0);
929 gtk_widget_show(handlebox);
930 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
932 /* link window to mainwin->window to avoid gdk warnings */
933 mainwin->window = window;
936 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
939 toolbar_set_learn_button
943 /* vbox that contains body */
944 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
945 gtk_widget_show(vbox_body);
946 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
947 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
949 hbox_stat = gtk_hbox_new(FALSE, 2);
950 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
952 statusbar = statusbar_create();
953 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
955 progressbar = gtk_progress_bar_new();
956 gtk_widget_set_size_request(progressbar, 120, 1);
957 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
959 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
960 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
961 online_tip = gtk_tooltips_new();
962 online_switch = gtk_button_new ();
963 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
964 _("You are online. Click the icon to go offline"), NULL);
965 offline_tip = gtk_tooltips_new();
966 offline_switch = gtk_button_new ();
967 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
968 _("You are offline. Click the icon to go online"),
970 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
971 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
972 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
973 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
974 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
975 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
976 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
977 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
979 statuslabel = gtk_label_new("");
980 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
982 sel_ac_tip = gtk_tooltips_new();
983 ac_button = gtk_button_new();
984 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
985 ac_button, _("Select account"), NULL);
986 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
987 gtk_widget_set_size_request(ac_button, -1, 0);
988 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
989 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
990 G_CALLBACK(ac_label_button_pressed), mainwin);
992 ac_label = gtk_label_new("");
993 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
995 gtk_widget_show_all(hbox_stat);
997 gtk_widget_hide(offline_switch);
999 mainwin->folderview = folderview = folderview_create();
1000 mainwin->summaryview = summaryview = summary_create();
1001 mainwin->messageview = messageview = messageview_create(mainwin);
1002 mainwin->logwin = log_window_create();
1004 folderview->mainwin = mainwin;
1005 folderview->summaryview = summaryview;
1007 summaryview->mainwin = mainwin;
1008 summaryview->folderview = folderview;
1009 summaryview->messageview = messageview;
1010 summaryview->window = window;
1012 messageview->statusbar = statusbar;
1013 mainwin->vbox = vbox;
1014 mainwin->menubar = menubar;
1015 mainwin->menu_factory = ifactory;
1016 mainwin->handlebox = handlebox;
1017 mainwin->vbox_body = vbox_body;
1018 mainwin->hbox_stat = hbox_stat;
1019 mainwin->statusbar = statusbar;
1020 mainwin->progressbar = progressbar;
1021 mainwin->statuslabel = statuslabel;
1022 mainwin->online_switch = online_switch;
1023 mainwin->online_pixmap = online_pixmap;
1024 mainwin->offline_pixmap = offline_pixmap;
1025 mainwin->ac_button = ac_button;
1026 mainwin->ac_label = ac_label;
1027 mainwin->offline_switch = offline_switch;
1029 /* set context IDs for status bar */
1030 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1031 (GTK_STATUSBAR(statusbar), "Main Window");
1032 mainwin->folderview_cid = gtk_statusbar_get_context_id
1033 (GTK_STATUSBAR(statusbar), "Folder View");
1034 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1035 (GTK_STATUSBAR(statusbar), "Summary View");
1036 mainwin->messageview_cid = gtk_statusbar_get_context_id
1037 (GTK_STATUSBAR(statusbar), "Message View");
1039 messageview->statusbar_cid = mainwin->messageview_cid;
1041 /* allocate colors for summary view and folder view */
1042 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1043 summaryview->color_marked.blue = (guint16)65535;
1045 summaryview->color_dim.red = summaryview->color_dim.green =
1046 summaryview->color_dim.blue = COLOR_DIM;
1048 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1049 &folderview->color_new);
1051 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1052 &folderview->color_op);
1054 summaryview->color_important.red = 0;
1055 summaryview->color_important.green = 0;
1056 summaryview->color_important.blue = (guint16)65535;
1058 color[0] = summaryview->color_marked;
1059 color[1] = summaryview->color_dim;
1060 color[2] = folderview->color_new;
1061 color[3] = folderview->color_op;
1063 colormap = gdk_drawable_get_colormap(window->window);
1064 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1065 for (i = 0; i < 4; i++) {
1066 if (success[i] == FALSE)
1067 g_warning("MainWindow: color allocation %d failed\n", i);
1070 debug_print("done.\n");
1072 messageview->visible = prefs_common.msgview_visible;
1074 main_window_set_widgets(mainwin, type);
1076 g_signal_connect(G_OBJECT(window), "size_allocate",
1077 G_CALLBACK(main_window_size_allocate_cb),
1080 /* set menu items */
1081 menuitem = gtk_item_factory_get_item
1082 (ifactory, "/View/Character encoding/Auto detect");
1083 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1085 switch (prefs_common.toolbar_style) {
1087 menuitem = gtk_item_factory_get_item
1088 (ifactory, "/View/Show or hide/Toolbar/Hide");
1091 menuitem = gtk_item_factory_get_item
1092 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1095 menuitem = gtk_item_factory_get_item
1096 (ifactory, "/View/Show or hide/Toolbar/Text only");
1099 menuitem = gtk_item_factory_get_item
1100 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1102 case TOOLBAR_BOTH_HORIZ:
1103 menuitem = gtk_item_factory_get_item
1105 "/View/Show or hide/Toolbar/Text beside icons");
1107 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1109 gtk_widget_hide(mainwin->hbox_stat);
1110 menuitem = gtk_item_factory_get_item
1111 (ifactory, "/View/Show or hide/Status bar");
1112 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1113 prefs_common.show_statusbar);
1115 /* set account selection menu */
1116 ac_menu = gtk_item_factory_get_widget
1117 (ifactory, "/Configuration/Change current account");
1118 mainwin->ac_menu = ac_menu;
1120 toolbar_main_set_sensitive(mainwin);
1122 /* create actions menu */
1123 main_window_update_actions_menu(mainwin);
1125 /* attach accel groups to main window */
1126 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1127 gtk_window_add_accel_group \
1129 gtk_item_factory_from_widget(menu)->accel_group); \
1130 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1132 G_CALLBACK(main_window_accel_activate), mainwin);
1135 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1137 /* connect the accelerators for equivalent
1138 menu items in different menus */
1139 menu_connect_identical_items();
1142 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1144 gtk_widget_show(mainwin->window);
1146 /* initialize views */
1147 folderview_init(folderview);
1148 summary_init(summaryview);
1149 messageview_init(messageview);
1150 log_window_init(mainwin->logwin);
1151 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1152 prefs_common.loglength);
1154 sslcertwindow_register_hook();
1156 mainwin->lock_count = 0;
1157 mainwin->menu_lock_count = 0;
1158 mainwin->cursor_count = 0;
1160 mainwin->progressindicator_hook =
1161 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1164 watch_cursor = gdk_cursor_new(GDK_WATCH);
1166 mainwin_list = g_list_append(mainwin_list, mainwin);
1168 /* init work_offline */
1169 if (prefs_common.work_offline)
1170 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1175 void main_window_destroy(MainWindow *mainwin)
1177 /* TODO : destroy other component */
1178 messageview_destroy(mainwin->messageview);
1179 mainwin->messageview = NULL;
1182 void main_window_update_actions_menu(MainWindow *mainwin)
1184 GtkItemFactory *ifactory;
1186 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1187 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1190 void main_window_cursor_wait(MainWindow *mainwin)
1193 if (mainwin->cursor_count == 0)
1194 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1196 mainwin->cursor_count++;
1201 void main_window_cursor_normal(MainWindow *mainwin)
1203 if (mainwin->cursor_count)
1204 mainwin->cursor_count--;
1206 if (mainwin->cursor_count == 0)
1207 gdk_window_set_cursor(mainwin->window->window, NULL);
1212 /* lock / unlock the user-interface */
1213 void main_window_lock(MainWindow *mainwin)
1215 if (mainwin->lock_count == 0)
1216 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1218 mainwin->lock_count++;
1220 main_window_set_menu_sensitive(mainwin);
1221 toolbar_main_set_sensitive(mainwin);
1224 void main_window_unlock(MainWindow *mainwin)
1226 if (mainwin->lock_count)
1227 mainwin->lock_count--;
1229 main_window_set_menu_sensitive(mainwin);
1230 toolbar_main_set_sensitive(mainwin);
1232 if (mainwin->lock_count == 0)
1233 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1236 static void main_window_menu_callback_block(MainWindow *mainwin)
1238 mainwin->menu_lock_count++;
1241 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1243 if (mainwin->menu_lock_count)
1244 mainwin->menu_lock_count--;
1247 static guint prefs_tag = 0;
1249 void main_window_reflect_prefs_all(void)
1251 main_window_reflect_prefs_all_real(FALSE);
1254 static gboolean reflect_prefs_timeout_cb(gpointer data)
1256 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1258 MainWindow *mainwin;
1261 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1262 mainwin = (MainWindow *)cur->data;
1264 main_window_show_cur_account(mainwin);
1265 main_window_set_menu_sensitive(mainwin);
1266 toolbar_main_set_sensitive(mainwin);
1269 if (pixmap_theme_changed) {
1270 toolbar_update(TOOLBAR_MAIN, mainwin);
1271 messageview_reflect_prefs_pixmap_theme();
1272 compose_reflect_prefs_pixmap_theme();
1273 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1274 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1276 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1277 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1278 mainwin->online_pixmap);
1279 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1280 gtk_widget_show(pixmap);
1281 mainwin->online_pixmap = pixmap;
1282 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1283 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1284 mainwin->offline_pixmap);
1285 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1286 gtk_widget_show(pixmap);
1287 mainwin->offline_pixmap = pixmap;
1290 headerview_set_font(mainwin->messageview->headerview);
1291 headerview_set_visibility(mainwin->messageview->headerview,
1292 prefs_common.display_header_pane);
1293 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1294 folderview_reflect_prefs();
1295 summary_reflect_prefs();
1296 summary_redisplay_msg(mainwin->summaryview);
1302 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1304 if (prefs_tag == 0 || pixmap_theme_changed) {
1305 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1306 GINT_TO_POINTER(pixmap_theme_changed));
1310 void main_window_set_summary_column(void)
1313 MainWindow *mainwin;
1315 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1316 mainwin = (MainWindow *)cur->data;
1317 summary_set_column_order(mainwin->summaryview);
1321 void main_window_set_folder_column(void)
1324 MainWindow *mainwin;
1326 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1327 mainwin = (MainWindow *)cur->data;
1328 folderview_set_column_order(mainwin->folderview);
1332 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1333 GList *account_list)
1335 GList *cur_ac, *cur_item;
1336 GtkWidget *menuitem;
1337 PrefsAccount *ac_prefs;
1339 /* destroy all previous menu item */
1340 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1341 while (cur_item != NULL) {
1342 GList *next = cur_item->next;
1343 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1347 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1348 ac_prefs = (PrefsAccount *)cur_ac->data;
1350 menuitem = gtk_menu_item_new_with_label
1351 (ac_prefs->account_name
1352 ? ac_prefs->account_name : _("Untitled"));
1353 gtk_widget_show(menuitem);
1354 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1355 g_signal_connect(G_OBJECT(menuitem), "activate",
1356 G_CALLBACK(account_selector_menu_cb),
1361 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1362 GList *account_list)
1364 GList *cur_ac, *cur_item;
1366 GtkWidget *menuitem;
1367 PrefsAccount *ac_prefs;
1369 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1370 "/Message/Receive");
1372 /* search for separator */
1373 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1374 cur_item = cur_item->next) {
1375 if (GTK_BIN(cur_item->data)->child == NULL) {
1376 cur_item = cur_item->next;
1381 /* destroy all previous menu item */
1382 while (cur_item != NULL) {
1383 GList *next = cur_item->next;
1384 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1388 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1389 ac_prefs = (PrefsAccount *)cur_ac->data;
1391 menuitem = gtk_menu_item_new_with_label
1392 (ac_prefs->account_name ? ac_prefs->account_name
1394 gtk_widget_show(menuitem);
1395 gtk_menu_append(GTK_MENU(menu), menuitem);
1396 g_signal_connect(G_OBJECT(menuitem), "activate",
1397 G_CALLBACK(account_receive_menu_cb),
1402 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1403 GList *account_list)
1405 GList *cur_ac, *cur_item;
1406 GtkWidget *menuitem;
1407 PrefsAccount *ac_prefs;
1408 GtkWidget *menu = NULL;
1410 if (mainwin->toolbar->getall_btn == NULL
1411 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1414 menu = mainwin->toolbar->getall_combo->menu;
1416 /* destroy all previous menu item */
1417 cur_item = GTK_MENU_SHELL(menu)->children;
1418 while (cur_item != NULL) {
1419 GList *next = cur_item->next;
1420 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1424 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1425 ac_prefs = (PrefsAccount *)cur_ac->data;
1427 menuitem = gtk_menu_item_new_with_label
1428 (ac_prefs->account_name
1429 ? ac_prefs->account_name : _("Untitled"));
1430 gtk_widget_show(menuitem);
1431 gtk_menu_append(GTK_MENU(menu), menuitem);
1432 g_signal_connect(G_OBJECT(menuitem), "activate",
1433 G_CALLBACK(account_receive_menu_cb),
1438 void main_window_set_account_menu(GList *account_list)
1441 MainWindow *mainwin;
1443 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1444 mainwin = (MainWindow *)cur->data;
1445 main_window_set_account_selector_menu(mainwin, account_list);
1446 main_window_set_account_receive_menu(mainwin, account_list);
1447 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1451 void main_window_set_account_menu_only_toolbar(GList *account_list)
1454 MainWindow *mainwin;
1456 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1457 mainwin = (MainWindow *)cur->data;
1458 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1462 static void main_window_show_cur_account(MainWindow *mainwin)
1467 ac_name = g_strdup(cur_account
1468 ? (cur_account->account_name
1469 ? cur_account->account_name : _("Untitled"))
1473 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1475 buf = g_strdup(PROG_VERSION);
1476 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1479 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1480 gtk_widget_queue_resize(mainwin->ac_button);
1485 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1487 switch (mainwin->type) {
1488 case SEPARATE_FOLDER:
1489 return mainwin->win.sep_folder.folderwin;
1491 return mainwin->win.sep_both.folderwin;
1497 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1499 switch (mainwin->type) {
1500 case SEPARATE_MESSAGE:
1501 return mainwin->win.sep_message.messagewin;
1503 return mainwin->win.sep_both.messagewin;
1509 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1511 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1512 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1513 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1514 GtkWidget *message_wid = mainwin->messageview->vbox;
1516 debug_print("Changing window separation type from %d to %d\n",
1517 mainwin->type, type);
1519 if (mainwin->type == type) return;
1521 /* remove widgets from those containers */
1522 gtk_widget_ref(folder_wid);
1523 gtk_widget_ref(summary_wid);
1524 gtk_widget_ref(message_wid);
1525 gtkut_container_remove
1526 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1527 gtkut_container_remove
1528 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1529 gtkut_container_remove
1530 (GTK_CONTAINER(message_wid->parent), message_wid);
1532 /* clean containers */
1533 switch (mainwin->type) {
1535 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1537 case SEPARATE_FOLDER:
1538 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1539 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1541 case SEPARATE_MESSAGE:
1542 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1543 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1546 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1547 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1551 gtk_widget_hide(mainwin->window);
1552 main_window_set_widgets(mainwin, type);
1553 gtk_widget_show(mainwin->window);
1555 gtk_widget_unref(folder_wid);
1556 gtk_widget_unref(summary_wid);
1557 gtk_widget_unref(message_wid);
1560 void main_window_toggle_message_view(MainWindow *mainwin)
1562 SummaryView *summaryview = mainwin->summaryview;
1563 union CompositeWin *cwin = &mainwin->win;
1564 GtkWidget *vpaned = NULL;
1565 GtkWidget *container = NULL;
1566 GtkWidget *msgwin = NULL;
1568 switch (mainwin->type) {
1570 vpaned = cwin->sep_none.vpaned;
1571 container = cwin->sep_none.hpaned;
1573 case SEPARATE_FOLDER:
1574 vpaned = cwin->sep_folder.vpaned;
1575 container = mainwin->vbox_body;
1577 case SEPARATE_MESSAGE:
1578 msgwin = mainwin->win.sep_message.messagewin;
1581 msgwin = mainwin->win.sep_both.messagewin;
1586 if (GTK_WIDGET_VISIBLE(msgwin)) {
1587 gtk_widget_hide(msgwin);
1588 mainwin->messageview->visible = FALSE;
1589 summaryview->displayed = NULL;
1591 gtk_widget_show(msgwin);
1592 mainwin->messageview->visible = TRUE;
1594 } else if (vpaned->parent != NULL) {
1595 mainwin->messageview->visible = FALSE;
1596 summaryview->displayed = NULL;
1597 gtk_widget_ref(vpaned);
1598 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1599 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1601 mainwin->messageview->visible = TRUE;
1602 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1603 gtk_container_add(GTK_CONTAINER(container), vpaned);
1604 gtk_widget_unref(vpaned);
1607 if (messageview_is_visible(mainwin->messageview))
1608 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1609 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1611 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1612 GTK_ARROW_UP, GTK_SHADOW_OUT);
1614 if (mainwin->messageview->visible == FALSE)
1615 messageview_clear(mainwin->messageview);
1617 main_window_set_menu_sensitive(mainwin);
1619 prefs_common.msgview_visible = mainwin->messageview->visible;
1621 gtk_widget_grab_focus(summaryview->ctree);
1624 void main_window_get_size(MainWindow *mainwin)
1626 GtkAllocation *allocation;
1628 if (mainwin_list == NULL || mainwin->messageview == NULL) {
1629 debug_print("called after messageview "
1630 "has been deallocated!\n");
1634 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1636 if (allocation->width > 1 && allocation->height > 1) {
1637 prefs_common.summaryview_width = allocation->width;
1639 if ((mainwin->type == SEPARATE_NONE ||
1640 mainwin->type == SEPARATE_FOLDER) &&
1641 messageview_is_visible(mainwin->messageview))
1642 prefs_common.summaryview_height = allocation->height;
1644 prefs_common.mainview_width = allocation->width;
1647 allocation = &mainwin->window->allocation;
1648 if (allocation->width > 1 && allocation->height > 1) {
1649 prefs_common.mainview_height = allocation->height;
1650 prefs_common.mainwin_width = allocation->width;
1651 prefs_common.mainwin_height = allocation->height;
1654 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1655 if (allocation->width > 1 && allocation->height > 1) {
1656 prefs_common.folderview_width = allocation->width;
1657 prefs_common.folderview_height = allocation->height;
1660 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1661 if (allocation->width > 1 && allocation->height > 1) {
1662 prefs_common.msgview_width = allocation->width;
1663 prefs_common.msgview_height = allocation->height;
1666 /* debug_print("summaryview size: %d x %d\n",
1667 prefs_common.summaryview_width,
1668 prefs_common.summaryview_height);
1669 debug_print("folderview size: %d x %d\n",
1670 prefs_common.folderview_width,
1671 prefs_common.folderview_height);
1672 debug_print("messageview size: %d x %d\n",
1673 prefs_common.msgview_width,
1674 prefs_common.msgview_height); */
1677 void main_window_get_position(MainWindow *mainwin)
1682 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1684 prefs_common.mainview_x = x;
1685 prefs_common.mainview_y = y;
1686 prefs_common.mainwin_x = x;
1687 prefs_common.mainwin_y = y;
1689 debug_print("main window position: %d, %d\n", x, y);
1691 window = main_window_get_folder_window(mainwin);
1693 gtkut_widget_get_uposition(window, &x, &y);
1694 prefs_common.folderwin_x = x;
1695 prefs_common.folderwin_y = y;
1696 debug_print("folder window position: %d, %d\n", x, y);
1698 window = main_window_get_message_window(mainwin);
1700 gtkut_widget_get_uposition(window, &x, &y);
1701 prefs_common.main_msgwin_x = x;
1702 prefs_common.main_msgwin_y = y;
1703 debug_print("message window position: %d, %d\n", x, y);
1707 void main_window_progress_on(MainWindow *mainwin)
1709 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1712 void main_window_progress_off(MainWindow *mainwin)
1714 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1715 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1718 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1722 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1723 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1724 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1725 (cur == 0 && total == 0) ? 0 :
1726 (gfloat)cur / (gfloat)total);
1729 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1732 if (alertpanel(_("Empty trash"),
1733 _("Delete all messages in trash folders?"),
1734 GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
1735 != G_ALERTALTERNATE)
1737 manage_window_focus_in(mainwin->window, NULL, NULL);
1740 procmsg_empty_all_trash();
1742 if (mainwin->summaryview->folder_item &&
1743 mainwin->summaryview->folder_item->stype == F_TRASH)
1744 gtk_widget_grab_focus(mainwin->folderview->ctree);
1747 void main_window_add_mailbox(MainWindow *mainwin)
1752 path = input_dialog(_("Add mailbox"),
1753 _("Input the location of mailbox.\n"
1754 "If the existing mailbox is specified, it will be\n"
1755 "scanned automatically."),
1758 if (folder_find_from_path(path)) {
1759 alertpanel_error(_("The mailbox '%s' already exists."), path);
1763 folder = folder_new(folder_get_class_from_string("mh"),
1764 !strcmp(path, "Mail") ? _("Mailbox") :
1765 g_path_get_basename(path), path);
1768 if (folder->klass->create_tree(folder) < 0) {
1769 alertpanel_error(_("Creation of the mailbox failed.\n"
1770 "Maybe some files already exist, or you don't have the permission to write there."));
1771 folder_destroy(folder);
1776 folder_set_ui_func(folder, scan_tree_func, mainwin);
1777 folder_scan_tree(folder, TRUE);
1778 folder_set_ui_func(folder, NULL, NULL);
1781 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1783 SensitiveCond state = 0;
1784 SummarySelection selection;
1785 FolderItem *item = mainwin->summaryview->folder_item;
1786 GList *account_list = account_get_list();
1788 selection = summary_get_selection_type(mainwin->summaryview);
1790 if (mainwin->lock_count == 0)
1791 state |= M_UNLOCKED;
1792 if (selection != SUMMARY_NONE)
1793 state |= M_MSG_EXIST;
1794 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1796 /* if (item->folder->type != F_NEWS) */
1797 state |= M_ALLOW_DELETE;
1799 if (prefs_common.immediate_exec == 0
1800 && mainwin->lock_count == 0)
1801 state |= M_DELAY_EXEC;
1803 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1804 || selection != SUMMARY_NONE)
1805 state |= M_HIDE_READ_MSG;
1807 if (mainwin->summaryview->threaded)
1808 state |= M_THREADED;
1810 state |= M_UNTHREADED;
1811 if (selection == SUMMARY_SELECTED_SINGLE ||
1812 selection == SUMMARY_SELECTED_MULTIPLE)
1813 state |= M_TARGET_EXIST;
1814 if (selection == SUMMARY_SELECTED_SINGLE)
1815 state |= M_SINGLE_TARGET_EXIST;
1816 if (mainwin->summaryview->folder_item &&
1817 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1820 state |= M_NOT_NEWS;
1821 if (selection == SUMMARY_SELECTED_SINGLE &&
1823 (folder_has_parent_of_type(item, F_DRAFT) ||
1824 folder_has_parent_of_type(item, F_OUTBOX) ||
1825 folder_has_parent_of_type(item, F_QUEUE))))
1826 state |= M_ALLOW_REEDIT;
1828 state |= M_HAVE_ACCOUNT;
1830 for ( ; account_list != NULL; account_list = account_list->next) {
1831 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1832 state |= M_HAVE_NEWS_ACCOUNT;
1837 if (procmsg_spam_can_learn()) {
1838 state |= M_CAN_LEARN_SPAM;
1841 if (inc_is_active())
1842 state |= M_INC_ACTIVE;
1844 if (mainwin->summaryview->deleted > 0 ||
1845 mainwin->summaryview->moved > 0 ||
1846 mainwin->summaryview->copied > 0)
1847 state |= M_DELAY_EXEC;
1854 void main_window_set_menu_sensitive(MainWindow *mainwin)
1856 GtkItemFactory *ifactory = mainwin->menu_factory;
1857 SensitiveCond state;
1860 GtkWidget *menuitem;
1861 SummaryView *summaryview;
1866 static const struct {
1870 {"/File/Save as...", M_TARGET_EXIST},
1871 {"/File/Print..." , M_TARGET_EXIST},
1872 {"/File/Exit" , M_UNLOCKED},
1874 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1876 {"/View/Sort" , M_EXEC},
1877 {"/View/Thread view" , M_EXEC},
1878 {"/View/Expand all threads" , M_MSG_EXIST},
1879 {"/View/Collapse all threads" , M_MSG_EXIST},
1880 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1881 {"/View/Go to/Previous message" , M_MSG_EXIST},
1882 {"/View/Go to/Next message" , M_MSG_EXIST},
1883 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
1884 {"/View/Go to/Previous new message" , M_MSG_EXIST},
1885 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
1886 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1887 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
1888 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1889 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1890 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1891 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1893 {"/Message/Receive/Get from current account"
1894 , M_HAVE_ACCOUNT|M_UNLOCKED},
1895 {"/Message/Receive/Get from all accounts"
1896 , M_HAVE_ACCOUNT|M_UNLOCKED},
1897 {"/Message/Receive/Cancel receiving"
1900 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1901 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1902 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1903 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1904 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1905 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1906 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1907 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
1908 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
1909 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
1910 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
1911 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
1912 {"/Message/Mark" , M_TARGET_EXIST},
1913 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
1914 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
1915 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1917 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1918 {"/Tools/Harvest addresses" , M_MSG_EXIST},
1919 {"/Tools/Harvest addresses/from Messages..."
1921 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
1922 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
1923 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1924 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1925 {"/Tools/Actions" , M_TARGET_EXIST},
1926 {"/Tools/Execute" , M_DELAY_EXEC},
1927 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
1929 {"/Configuration", M_UNLOCKED},
1934 state = main_window_get_current_state(mainwin);
1936 for (i = 0; entry[i].entry != NULL; i++) {
1937 sensitive = ((entry[i].cond & state) == entry[i].cond);
1938 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1941 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1943 /* search for separator */
1944 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1945 cur_item = cur_item->next) {
1946 if (GTK_BIN(cur_item->data)->child == NULL) {
1947 cur_item = cur_item->next;
1952 for (; cur_item != NULL; cur_item = cur_item->next) {
1953 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1954 (M_UNLOCKED & state) != 0);
1957 main_window_menu_callback_block(mainwin);
1959 #define SET_CHECK_MENU_ACTIVE(path, active) \
1961 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1962 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1965 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1966 messageview_is_visible(mainwin->messageview));
1968 summaryview = mainwin->summaryview;
1969 menu_path = "/View/Sort/Don't sort";
1971 switch (summaryview->sort_key) {
1972 case SORT_BY_NUMBER:
1973 menu_path = "/View/Sort/by number"; break;
1975 menu_path = "/View/Sort/by Size"; break;
1977 menu_path = "/View/Sort/by Date"; break;
1979 menu_path = "/View/Sort/by From"; break;
1981 menu_path = "/View/Sort/by To"; break;
1982 case SORT_BY_SUBJECT:
1983 menu_path = "/View/Sort/by Subject"; break;
1985 menu_path = "/View/Sort/by color label"; break;
1987 menu_path = "/View/Sort/by mark"; break;
1988 case SORT_BY_STATUS:
1989 menu_path = "/View/Sort/by status"; break;
1991 menu_path = "/View/Sort/by attachment"; break;
1993 menu_path = "/View/Sort/by score"; break;
1994 case SORT_BY_LOCKED:
1995 menu_path = "/View/Sort/by locked"; break;
1998 menu_path = "/View/Sort/Don't sort"; break;
2000 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2002 if (summaryview->sort_type == SORT_ASCENDING) {
2003 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2005 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2008 if (summaryview->sort_key != SORT_BY_NONE) {
2009 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2010 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2012 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2013 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2016 if (mainwin->messageview
2017 && mainwin->messageview->mimeview
2018 && mainwin->messageview->mimeview->textview)
2019 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
2020 mainwin->messageview->mimeview->textview->show_all_headers);
2021 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2023 #undef SET_CHECK_MENU_ACTIVE
2025 main_window_menu_callback_unblock(mainwin);
2028 void main_window_popup(MainWindow *mainwin)
2030 gtkut_window_popup(mainwin->window);
2032 switch (mainwin->type) {
2033 case SEPARATE_FOLDER:
2034 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2036 case SEPARATE_MESSAGE:
2037 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2040 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2041 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2048 void main_window_show(MainWindow *mainwin)
2050 gtk_widget_show(mainwin->window);
2051 gtk_widget_show(mainwin->vbox_body);
2053 gtk_widget_set_uposition(mainwin->window,
2054 prefs_common.mainwin_x,
2055 prefs_common.mainwin_y);
2057 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2058 prefs_common.folderview_width,
2059 prefs_common.folderview_height);
2060 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2061 prefs_common.summaryview_width,
2062 prefs_common.summaryview_height);
2063 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2064 prefs_common.msgview_width,
2065 prefs_common.msgview_height);
2067 if (mainwin->type & SEPARATE_FOLDER) {
2068 GtkWidget *folderwin;
2070 folderwin = main_window_get_folder_window(mainwin);
2071 gtk_widget_show(folderwin);
2072 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2073 prefs_common.folderwin_y);
2076 if (mainwin->type & SEPARATE_MESSAGE) {
2077 GtkWidget *messagewin;
2079 messagewin = main_window_get_message_window(mainwin);
2080 gtk_widget_show(messagewin);
2081 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2082 prefs_common.main_msgwin_y);
2086 void main_window_hide(MainWindow *mainwin)
2088 main_window_get_size(mainwin);
2089 main_window_get_position(mainwin);
2091 gtk_widget_hide(mainwin->window);
2092 gtk_widget_hide(mainwin->vbox_body);
2094 if (mainwin->type & SEPARATE_FOLDER) {
2095 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2098 if (mainwin->type & SEPARATE_MESSAGE) {
2099 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2103 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2105 GtkWidget *folderwin = NULL;
2106 GtkWidget *messagewin = NULL;
2109 GtkWidget *vbox_body = mainwin->vbox_body;
2110 GtkItemFactory *ifactory = mainwin->menu_factory;
2111 GtkWidget *menuitem;
2112 GtkItemFactory *msgview_ifactory;
2114 debug_print("Setting widgets... ");
2116 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2117 prefs_common.folderview_width,
2118 prefs_common.folderview_height);
2119 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2120 prefs_common.summaryview_width,
2121 prefs_common.summaryview_height);
2122 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2123 prefs_common.msgview_width,
2124 prefs_common.msgview_height);
2126 /* create separated window(s) if needed */
2127 if (type & SEPARATE_FOLDER) {
2128 static GdkGeometry folderwin_geometry;
2130 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2131 gtk_window_set_title(GTK_WINDOW(folderwin),
2132 _("Sylpheed-Claws - Folder View"));
2134 gtk_window_move(GTK_WINDOW(folderwin),
2135 prefs_common.folderwin_x,
2136 prefs_common.folderwin_y);
2138 if (!folderwin_geometry.min_height) {
2139 folderwin_geometry.min_width = 320;
2140 folderwin_geometry.min_height = 200;
2142 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2143 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2145 gtk_widget_set_size_request(folderwin,
2146 prefs_common.folderview_width,
2147 prefs_common.folderview_height);
2149 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2152 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2153 G_CALLBACK(folder_window_close_cb),
2155 gtk_container_add(GTK_CONTAINER(folderwin),
2156 GTK_WIDGET_PTR(mainwin->folderview));
2157 gtk_widget_realize(folderwin);
2159 if (prefs_common.folderview_visible)
2160 gtk_widget_show(folderwin);
2163 if (type & SEPARATE_MESSAGE) {
2164 static GdkGeometry msgwin_geometry;
2166 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2167 gtk_window_set_title(GTK_WINDOW(messagewin),
2168 _("Sylpheed-Claws - Message View"));
2170 gtk_window_move(GTK_WINDOW(messagewin),
2171 prefs_common.main_msgwin_x,
2172 prefs_common.main_msgwin_y);
2174 if (!msgwin_geometry.min_height) {
2175 msgwin_geometry.min_width = 320;
2176 msgwin_geometry.min_height = 200;
2178 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2179 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2181 gtk_widget_set_size_request(messagewin,
2182 prefs_common.msgwin_width,
2183 prefs_common.msgwin_height);
2185 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2187 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2188 G_CALLBACK(message_window_close_cb),
2190 if (messageview_is_visible(mainwin->messageview))
2191 gtk_widget_show(messagewin);
2193 mainwin->messageview->statusbar = mainwin->statusbar;
2194 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2199 hpaned = gtk_hpaned_new();
2200 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2201 gtk_paned_add1(GTK_PANED(hpaned),
2202 GTK_WIDGET_PTR(mainwin->folderview));
2203 gtk_widget_show(hpaned);
2204 gtk_widget_queue_resize(hpaned);
2206 vpaned = gtk_vpaned_new();
2207 if (messageview_is_visible(mainwin->messageview)) {
2208 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2209 gtk_paned_add1(GTK_PANED(vpaned),
2210 GTK_WIDGET_PTR(mainwin->summaryview));
2212 gtk_paned_add2(GTK_PANED(hpaned),
2213 GTK_WIDGET_PTR(mainwin->summaryview));
2214 gtk_widget_ref(vpaned);
2216 gtk_paned_add2(GTK_PANED(vpaned),
2217 GTK_WIDGET_PTR(mainwin->messageview));
2218 gtk_widget_show(vpaned);
2219 gtk_widget_queue_resize(vpaned);
2221 mainwin->win.sep_none.hpaned = hpaned;
2222 mainwin->win.sep_none.vpaned = vpaned;
2224 /* remove headerview if not in prefs */
2225 headerview_set_visibility(mainwin->messageview->headerview,
2226 prefs_common.display_header_pane);
2228 case SEPARATE_FOLDER:
2229 vpaned = gtk_vpaned_new();
2230 if (messageview_is_visible(mainwin->messageview)) {
2231 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2233 gtk_paned_add1(GTK_PANED(vpaned),
2234 GTK_WIDGET_PTR(mainwin->summaryview));
2236 gtk_box_pack_start(GTK_BOX(vbox_body),
2237 GTK_WIDGET_PTR(mainwin->summaryview),
2239 gtk_widget_ref(vpaned);
2241 gtk_paned_add2(GTK_PANED(vpaned),
2242 GTK_WIDGET_PTR(mainwin->messageview));
2243 gtk_widget_show(vpaned);
2244 gtk_widget_queue_resize(vpaned);
2246 mainwin->win.sep_folder.folderwin = folderwin;
2247 mainwin->win.sep_folder.vpaned = vpaned;
2249 /* remove headerview if not in prefs */
2250 headerview_set_visibility(mainwin->messageview->headerview,
2251 prefs_common.display_header_pane);
2254 case SEPARATE_MESSAGE:
2255 hpaned = gtk_hpaned_new();
2256 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2257 gtk_paned_add1(GTK_PANED(hpaned),
2258 GTK_WIDGET_PTR(mainwin->folderview));
2259 gtk_paned_add2(GTK_PANED(hpaned),
2260 GTK_WIDGET_PTR(mainwin->summaryview));
2261 gtk_widget_show(hpaned);
2262 gtk_widget_queue_resize(hpaned);
2263 messageview_add_toolbar(mainwin->messageview, messagewin);
2264 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2265 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2267 mainwin->win.sep_message.messagewin = messagewin;
2268 mainwin->win.sep_message.hpaned = hpaned;
2270 gtk_widget_realize(messagewin);
2271 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2272 gtk_widget_show_all(messagewin);
2273 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2274 mainwin->messageview->handlebox,
2275 prefs_common.toolbar_style);
2279 messageview_add_toolbar(mainwin->messageview, messagewin);
2280 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2281 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2283 gtk_box_pack_start(GTK_BOX(vbox_body),
2284 GTK_WIDGET_PTR(mainwin->summaryview),
2287 mainwin->win.sep_both.folderwin = folderwin;
2288 mainwin->win.sep_both.messagewin = messagewin;
2290 gtk_widget_realize(messagewin);
2291 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2292 gtk_widget_show_all(messagewin);
2293 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2294 mainwin->messageview->handlebox,
2295 prefs_common.toolbar_style);
2300 if (messageview_is_visible(mainwin->messageview))
2301 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2302 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2304 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2305 GTK_ARROW_UP, GTK_SHADOW_OUT);
2307 gtk_window_move(GTK_WINDOW(mainwin->window),
2308 prefs_common.mainwin_x,
2309 prefs_common.mainwin_y);
2311 gtk_widget_queue_resize(vbox_body);
2312 gtk_widget_queue_resize(mainwin->vbox);
2313 gtk_widget_queue_resize(mainwin->window);
2314 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2315 * and mimeview icon list/ctree lose track of their visibility states */
2316 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2317 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2318 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2319 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2320 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2321 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2323 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2325 mainwin->type = type;
2328 /* toggle menu state */
2329 menuitem = gtk_item_factory_get_item
2330 (ifactory, "/View/Show or hide/Folder tree");
2331 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2332 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2333 prefs_common.folderview_visible);
2334 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2335 menuitem = gtk_item_factory_get_item
2336 (ifactory, "/View/Show or hide/Message view");
2337 gtk_check_menu_item_set_active
2338 (GTK_CHECK_MENU_ITEM(menuitem),
2339 messageview_is_visible(mainwin->messageview));
2341 menuitem = gtk_item_factory_get_item
2342 (ifactory, "/View/Separate folder tree");
2343 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2344 ((type & SEPARATE_FOLDER) != 0));
2345 menuitem = gtk_item_factory_get_item
2346 (ifactory, "/View/Separate message view");
2347 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2348 ((type & SEPARATE_MESSAGE) != 0));
2352 (G_OBJECT(folderwin), "size_allocate",
2353 G_CALLBACK(folder_window_size_allocate_cb),
2358 (G_OBJECT(messagewin), "size_allocate",
2359 G_CALLBACK(message_window_size_allocate_cb),
2363 debug_print("done.\n");
2366 void main_window_destroy_all(void)
2368 while (mainwin_list != NULL) {
2369 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2371 /* free toolbar stuff */
2372 toolbar_clear_list(TOOLBAR_MAIN);
2373 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2374 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2376 mainwin->folderview->mainwin = NULL;
2377 mainwin->summaryview->mainwin = NULL;
2378 mainwin->messageview->mainwin = NULL;
2380 g_free(mainwin->toolbar);
2383 mainwin_list = g_list_remove(mainwin_list, mainwin);
2385 g_list_free(mainwin_list);
2386 mainwin_list = NULL;
2390 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2391 GdkEventButton *event,
2394 MainWindow *mainwin = (MainWindow *)data;
2396 if (!event) return FALSE;
2397 if (event->button != 3) return FALSE;
2399 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2400 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2403 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2404 menu_button_position, widget,
2405 event->button, event->time);
2411 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2414 gtk_widget_set_size_request(child, 1, -1);
2417 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2420 gtk_widget_set_size_request(child, -1, -1);
2423 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2426 MainWindow *mainwin = (MainWindow *)data;
2428 if (!event) return FALSE;
2430 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2431 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2434 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2435 menu_button_position, widget,
2436 event->button, event->time);
2441 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2444 MainWindow *mainwin = (MainWindow *)data;
2446 if (mainwin->lock_count == 0)
2447 app_exit_cb(data, 0, widget);
2452 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2455 MainWindow *mainwin = (MainWindow *)data;
2456 GtkWidget *menuitem;
2458 menuitem = gtk_item_factory_get_item
2459 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2460 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2465 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2468 MainWindow *mainwin = (MainWindow *)data;
2469 GtkWidget *menuitem;
2471 menuitem = gtk_item_factory_get_item
2472 (mainwin->menu_factory, "/View/Show or hide/Message view");
2473 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2475 mainwin->messageview->statusbar = mainwin->statusbar;
2476 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2481 static void main_window_size_allocate_cb(GtkWidget *widget,
2482 GtkAllocation *allocation,
2485 MainWindow *mainwin = (MainWindow *)data;
2487 main_window_get_size(mainwin);
2490 static void folder_window_size_allocate_cb(GtkWidget *widget,
2491 GtkAllocation *allocation,
2494 MainWindow *mainwin = (MainWindow *)data;
2496 main_window_get_size(mainwin);
2499 static void message_window_size_allocate_cb(GtkWidget *widget,
2500 GtkAllocation *allocation,
2503 MainWindow *mainwin = (MainWindow *)data;
2505 main_window_get_size(mainwin);
2508 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2511 main_window_add_mailbox(mainwin);
2514 static void update_folderview_cb(MainWindow *mainwin, guint action,
2517 summary_show(mainwin->summaryview, NULL);
2518 folderview_check_new_all();
2521 static void foldersort_cb(MainWindow *mainwin, guint action,
2527 static void import_mbox_cb(MainWindow *mainwin, guint action,
2530 import_mbox(mainwin->summaryview->folder_item);
2533 static void export_mbox_cb(MainWindow *mainwin, guint action,
2536 export_mbox(mainwin->summaryview->folder_item);
2539 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2542 summaryview_export_mbox_list(mainwin->summaryview);
2545 static void empty_trash_cb(MainWindow *mainwin, guint action,
2548 main_window_empty_trash(mainwin, TRUE);
2551 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2553 summary_save_as(mainwin->summaryview);
2556 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2558 summary_print(mainwin->summaryview);
2561 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2563 if (prefs_common.confirm_on_exit) {
2564 if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
2565 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
2566 != G_ALERTALTERNATE)
2568 manage_window_focus_in(mainwin->window, NULL, NULL);
2571 app_will_exit(widget, mainwin);
2574 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2577 summary_search(mainwin->summaryview);
2579 message_search(mainwin->messageview);
2582 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
2584 prefs_common.show_searchbar = TRUE;
2585 summaryview_activate_quicksearch(mainwin->summaryview);
2588 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2593 active = GTK_CHECK_MENU_ITEM(widget)->active;
2595 switch (mainwin->type) {
2597 case SEPARATE_MESSAGE:
2600 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2602 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2605 case SEPARATE_FOLDER:
2606 debug_print("separate folder\n");
2608 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2610 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2614 gtk_widget_show(mainwin->win.sep_both.folderwin);
2616 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2620 prefs_common.folderview_visible = active;
2623 static void toggle_message_cb(MainWindow *mainwin, guint action,
2628 active = GTK_CHECK_MENU_ITEM(widget)->active;
2630 if (active != messageview_is_visible(mainwin->messageview))
2631 summary_toggle_view(mainwin->summaryview);
2634 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2637 toolbar_toggle(action, mainwin);
2640 void main_window_reply_cb(MainWindow *mainwin, guint action,
2643 MessageView *msgview = (MessageView*)mainwin->messageview;
2644 GSList *msginfo_list = NULL;
2646 g_return_if_fail(msgview != NULL);
2648 msginfo_list = summary_get_selection(mainwin->summaryview);
2649 g_return_if_fail(msginfo_list != NULL);
2650 compose_reply_from_messageview(msgview, msginfo_list, action);
2651 g_slist_free(msginfo_list);
2655 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2658 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2659 gtk_widget_show(mainwin->hbox_stat);
2660 prefs_common.show_statusbar = TRUE;
2662 gtk_widget_hide(mainwin->hbox_stat);
2663 prefs_common.show_statusbar = FALSE;
2667 static void separate_widget_cb(MainWindow *mainwin, guint action,
2672 if (GTK_CHECK_MENU_ITEM(widget)->active)
2673 type = mainwin->type | action;
2675 type = mainwin->type & ~action;
2677 main_window_separation_change(mainwin, type);
2679 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2680 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2683 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
2686 offline_ask_sync = ask_sync;
2688 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2690 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2691 offline_ask_sync = TRUE;
2694 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2696 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
2699 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
2701 GList *folderlist = folder_get_list();
2702 gboolean found = FALSE;
2704 /* see if there are synchronised folders */
2705 for (; folderlist; folderlist = folderlist->next) {
2706 Folder *folder = (Folder *)folderlist->data;
2707 if (folder_want_synchronise(folder)) {
2716 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
2717 _("Do you want to synchronise your folders now?"),
2718 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
2721 folder_synchronise(NULL);
2724 static void online_switch_clicked (GtkButton *btn, gpointer data)
2726 MainWindow *mainwin;
2727 GtkItemFactory *ifactory;
2728 GtkCheckMenuItem *menuitem;
2730 mainwin = (MainWindow *) data;
2732 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2733 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2735 g_return_if_fail(mainwin != NULL);
2736 g_return_if_fail(menuitem != NULL);
2738 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2740 mainwindow_check_synchronise(mainwin, TRUE);
2741 gtk_widget_hide (mainwin->online_switch);
2742 gtk_widget_show (mainwin->offline_switch);
2743 menuitem->active = TRUE;
2744 prefs_common.work_offline = TRUE;
2745 inc_autocheck_timer_remove();
2748 gtk_widget_hide (mainwin->offline_switch);
2749 gtk_widget_show (mainwin->online_switch);
2750 menuitem->active = FALSE;
2751 prefs_common.work_offline = FALSE;
2752 inc_autocheck_timer_set();
2756 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2759 addressbook_open(NULL);
2762 static void log_window_show_cb(MainWindow *mainwin, guint action,
2765 log_window_show(mainwin->logwin);
2768 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2773 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2775 summary_move_to(mainwin->summaryview);
2778 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2780 summary_copy_to(mainwin->summaryview);
2783 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2785 summary_delete(mainwin->summaryview);
2788 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2790 summary_delete_trash(mainwin->summaryview);
2793 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2795 summary_cancel(mainwin->summaryview);
2798 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2800 summary_open_msg(mainwin->summaryview);
2803 static void view_source_cb(MainWindow *mainwin, guint action,
2806 summary_view_source(mainwin->summaryview);
2809 static void show_all_header_cb(MainWindow *mainwin, guint action,
2812 if (mainwin->menu_lock_count) return;
2813 mainwin->summaryview->messageview->all_headers =
2814 GTK_CHECK_MENU_ITEM(widget)->active;
2815 summary_display_msg_selected(mainwin->summaryview,
2816 GTK_CHECK_MENU_ITEM(widget)->active);
2819 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2821 summary_mark(mainwin->summaryview);
2824 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2826 summary_unmark(mainwin->summaryview);
2829 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2832 summary_mark_as_unread(mainwin->summaryview);
2835 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2838 summary_mark_as_read(mainwin->summaryview);
2841 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2844 summary_mark_all_read(mainwin->summaryview);
2847 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
2850 summary_mark_as_spam(mainwin->summaryview, action, NULL);
2853 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2855 summary_reedit(mainwin->summaryview);
2858 static void add_address_cb(MainWindow *mainwin, guint action,
2861 summary_add_address(mainwin->summaryview);
2864 static void set_charset_cb(MainWindow *mainwin, guint action,
2869 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2870 str = conv_get_charset_str((CharSet)action);
2872 g_free(mainwin->messageview->forced_charset);
2873 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2874 procmime_force_charset(str);
2876 summary_redisplay_msg(mainwin->summaryview);
2878 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2882 static void set_decode_cb(MainWindow *mainwin, guint action,
2885 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2886 mainwin->messageview->forced_encoding = (EncodingType)action;
2888 summary_redisplay_msg(mainwin->summaryview);
2890 debug_print("forced encoding: %d\n", action);
2894 static void hide_read_messages (MainWindow *mainwin, guint action,
2897 if (!mainwin->summaryview->folder_item
2898 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2900 summary_toggle_show_read_messages(mainwin->summaryview);
2903 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2905 if (mainwin->menu_lock_count) return;
2906 if (!mainwin->summaryview->folder_item) return;
2908 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2909 summary_thread_build(mainwin->summaryview);
2910 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2912 summary_unthread(mainwin->summaryview);
2913 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2917 static void expand_threads_cb(MainWindow *mainwin, guint action,
2920 summary_expand_threads(mainwin->summaryview);
2923 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2926 summary_collapse_threads(mainwin->summaryview);
2929 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
2932 prefs_summary_column_open();
2935 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
2938 prefs_folder_column_open();
2941 static void sort_summary_cb(MainWindow *mainwin, guint action,
2944 FolderItem *item = mainwin->summaryview->folder_item;
2945 GtkWidget *menuitem;
2947 if (mainwin->menu_lock_count) return;
2949 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2950 menuitem = gtk_item_factory_get_item
2951 (mainwin->menu_factory, "/View/Sort/Ascending");
2952 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2953 GTK_CHECK_MENU_ITEM(menuitem)->active
2954 ? SORT_ASCENDING : SORT_DESCENDING);
2955 item->sort_key = action;
2959 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2962 FolderItem *item = mainwin->summaryview->folder_item;
2964 if (mainwin->menu_lock_count) return;
2966 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2967 summary_sort(mainwin->summaryview,
2968 item->sort_key, (FolderSortType)action);
2971 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2974 summary_attract_by_subject(mainwin->summaryview);
2977 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2982 item = folderview_get_selected_item(mainwin->folderview);
2984 main_window_cursor_wait(mainwin);
2985 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2987 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2988 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2990 STATUSBAR_POP(mainwin);
2991 main_window_cursor_normal(mainwin);
3001 static void deldup_all(FolderItem *item, gpointer _data)
3003 struct DelDupsData *data = _data;
3006 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3008 data->dups += result;
3013 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3016 struct DelDupsData data = {0, 0};
3018 folder_func_to_all_folders(deldup_all, &data);
3019 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3020 "Deleted %d duplicate messages in %d folders.\n",
3022 data.dups, data.folders);
3025 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3027 summary_filter(mainwin->summaryview, (gboolean)action);
3030 static void execute_summary_cb(MainWindow *mainwin, guint action,
3033 summary_execute(mainwin->summaryview);
3036 static void update_summary_cb(MainWindow *mainwin, guint action,
3040 FolderView *folderview = mainwin->folderview;
3042 if (!mainwin->summaryview->folder_item) return;
3043 if (!folderview->opened) return;
3045 folder_update_op_count();
3047 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3048 folderview->opened);
3051 folder_item_scan(fitem);
3052 summary_show(mainwin->summaryview, fitem);
3055 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3057 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3060 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3062 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3065 static void prev_unread_cb(MainWindow *mainwin, guint action,
3068 summary_select_prev_unread(mainwin->summaryview);
3071 static void next_unread_cb(MainWindow *mainwin, guint action,
3074 summary_select_next_unread(mainwin->summaryview);
3077 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3079 summary_select_prev_new(mainwin->summaryview);
3082 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3084 summary_select_next_new(mainwin->summaryview);
3087 static void prev_marked_cb(MainWindow *mainwin, guint action,
3090 summary_select_prev_marked(mainwin->summaryview);
3093 static void next_marked_cb(MainWindow *mainwin, guint action,
3096 summary_select_next_marked(mainwin->summaryview);
3099 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3102 summary_select_prev_labeled(mainwin->summaryview);
3105 static void next_labeled_cb(MainWindow *mainwin, guint action,
3108 summary_select_next_labeled(mainwin->summaryview);
3111 static void goto_folder_cb(MainWindow *mainwin, guint action,
3114 FolderItem *to_folder;
3116 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3119 folderview_select(mainwin->folderview, to_folder);
3122 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3124 messageview_copy_clipboard(mainwin->messageview);
3127 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3129 MessageView *msgview = mainwin->messageview;
3131 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3132 summary_select_all(mainwin->summaryview);
3133 else if (messageview_is_visible(msgview) &&
3134 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3135 messageview_select_all(mainwin->messageview);
3138 static void select_thread_cb(MainWindow *mainwin, guint action,
3141 summary_select_thread(mainwin->summaryview);
3144 static void create_filter_cb(MainWindow *mainwin, guint action,
3147 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3150 static void create_processing_cb(MainWindow *mainwin, guint action,
3153 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3156 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3159 prefs_filtering_open(&pre_global_processing,
3160 _("Processing rules to apply before folder rules"),
3164 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3167 prefs_filtering_open(&post_global_processing,
3168 _("Processing rules to apply after folder rules"),
3172 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3175 prefs_filtering_open(&filtering_rules,
3176 _("Filtering configuration"),
3180 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3183 prefs_template_open();
3186 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3189 prefs_actions_open(mainwin);
3192 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3195 ssl_manager_open(mainwin);
3198 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3202 new_account_cb(mainwin, 0, widget);
3204 account_open(cur_account);
3208 static void new_account_cb(MainWindow *mainwin, guint action,
3211 account_edit_open();
3212 if (!compose_get_compose_list()) account_add();
3215 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3217 FolderItem *item = NULL;
3218 cur_account = (PrefsAccount *)data;
3220 if (!mainwindow_get_mainwindow())
3222 main_window_show_cur_account(mainwindow_get_mainwindow());
3223 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3224 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3225 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3226 item = folderview_get_selected_item(
3227 mainwindow_get_mainwindow()->folderview);
3229 toolbar_set_compose_button
3230 (mainwindow_get_mainwindow()->toolbar,
3231 FOLDER_TYPE(item->folder) == F_NEWS ?
3232 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3236 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3238 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3239 PrefsAccount *account = (PrefsAccount *)data;
3241 inc_account_mail(mainwin, account);
3244 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3249 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3251 pluginwindow_create();
3254 static void manual_open_cb(MainWindow *mainwin, guint action,
3257 manual_open((ManualType)action);
3260 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3265 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3267 MainWindow *mainwin = (MainWindow *)data;
3271 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3272 LOCAL_FOLDER(folder)->rootpath,
3276 str = g_strdup_printf(_("Scanning folder %s ..."),
3277 LOCAL_FOLDER(folder)->rootpath);
3279 STATUSBAR_PUSH(mainwin, str);
3280 STATUSBAR_POP(mainwin);
3284 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3287 SummaryView *summary;
3289 g_return_val_if_fail(data, FALSE);
3290 summary = ((MainWindow *)data)->summaryview;
3291 g_return_val_if_fail(summary, FALSE);
3293 if (GTK_CLIST(summary->ctree)->selection &&
3294 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3300 #define BREAK_ON_MODIFIER_KEY() \
3301 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3303 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3306 MainWindow *mainwin = (MainWindow*) data;
3308 if (!mainwin || !event)
3311 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3314 switch (event->keyval) {
3315 case GDK_Q: /* Quit */
3316 BREAK_ON_MODIFIER_KEY();
3318 app_exit_cb(mainwin, 0, NULL);
3321 if (mainwin->folderview && mainwin->summaryview
3322 && !mainwin->summaryview->displayed) {
3323 summary_lock(mainwin->summaryview);
3324 folderview_select_next_unread(mainwin->folderview);
3325 summary_unlock(mainwin->summaryview);
3334 #undef BREAK_ON_MODIFIER_KEY
3337 * Harvest addresses for selected folder.
3339 static void addr_harvest_cb( MainWindow *mainwin,
3343 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3347 * Harvest addresses for selected messages in summary view.
3349 static void addr_harvest_msg_cb( MainWindow *mainwin,
3353 summary_harvest_address( mainwin->summaryview );
3357 *\brief get a MainWindow
3359 *\return MainWindow * The first mainwindow in the mainwin_list
3361 MainWindow *mainwindow_get_mainwindow(void)
3363 if (mainwin_list && mainwin_list->data)
3364 return (MainWindow *)(mainwin_list->data);
3369 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3371 ProgressData *data = (ProgressData *) source;
3372 MainWindow *mainwin = (MainWindow *) userdata;
3374 switch (data->cmd) {
3375 case PROGRESS_COMMAND_START:
3376 case PROGRESS_COMMAND_STOP:
3377 gtk_progress_bar_set_fraction
3378 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3380 case PROGRESS_COMMAND_SET_PERCENTAGE:
3381 gtk_progress_bar_set_fraction
3382 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3385 while (gtk_events_pending()) gtk_main_iteration ();
3390 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3392 mainwindow_check_synchronise(mainwin, FALSE);
3395 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
3397 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);