2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
42 #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_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "ssl_manager.h"
84 #include "sslcertwindow.h"
85 #include "prefs_gtk.h"
86 #include "pluginwindow.h"
88 #include "progressindicator.h"
89 #include "localfolder.h"
90 #include "filtering.h"
91 #include "folderutils.h"
92 #include "foldersort.h"
94 #define AC_LABEL_WIDTH 240
96 /* list of all instantiated MainWindow */
97 static GList *mainwin_list = NULL;
99 static GdkCursor *watch_cursor;
101 static void main_window_menu_callback_block (MainWindow *mainwin);
102 static void main_window_menu_callback_unblock (MainWindow *mainwin);
104 static void main_window_show_cur_account (MainWindow *mainwin);
106 static void main_window_set_widgets (MainWindow *mainwin,
110 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
111 GdkEventButton *event,
115 static void toolbar_child_attached (GtkWidget *widget,
118 static void toolbar_child_detached (GtkWidget *widget,
122 static gboolean ac_label_button_pressed (GtkWidget *widget,
123 GdkEventButton *event,
125 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
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 empty_trash_cb (MainWindow *mainwin,
167 static void save_as_cb (MainWindow *mainwin,
170 static void print_cb (MainWindow *mainwin,
173 static void app_exit_cb (MainWindow *mainwin,
177 static void search_cb (MainWindow *mainwin,
181 static void toggle_folder_cb (MainWindow *mainwin,
184 static void toggle_message_cb (MainWindow *mainwin,
187 static void toggle_toolbar_cb (MainWindow *mainwin,
190 static void toggle_statusbar_cb (MainWindow *mainwin,
193 static void separate_widget_cb (MainWindow *mainwin,
197 static void addressbook_open_cb (MainWindow *mainwin,
200 static void log_window_show_cb (MainWindow *mainwin,
204 static void inc_cancel_cb (MainWindow *mainwin,
208 static void open_msg_cb (MainWindow *mainwin,
212 static void view_source_cb (MainWindow *mainwin,
216 static void show_all_header_cb (MainWindow *mainwin,
220 static void move_to_cb (MainWindow *mainwin,
223 static void copy_to_cb (MainWindow *mainwin,
226 static void delete_cb (MainWindow *mainwin,
230 static void cancel_cb (MainWindow *mainwin,
234 static void mark_cb (MainWindow *mainwin,
237 static void unmark_cb (MainWindow *mainwin,
241 static void mark_as_unread_cb (MainWindow *mainwin,
244 static void mark_as_read_cb (MainWindow *mainwin,
247 static void mark_all_read_cb (MainWindow *mainwin,
251 static void reedit_cb (MainWindow *mainwin,
255 static void add_address_cb (MainWindow *mainwin,
259 static void set_charset_cb (MainWindow *mainwin,
263 static void set_decode_cb (MainWindow *mainwin,
267 static void hide_read_messages (MainWindow *mainwin,
271 static void thread_cb (MainWindow *mainwin,
274 static void expand_threads_cb (MainWindow *mainwin,
277 static void collapse_threads_cb (MainWindow *mainwin,
281 static void set_display_item_cb (MainWindow *mainwin,
284 static void sort_summary_cb (MainWindow *mainwin,
287 static void sort_summary_type_cb (MainWindow *mainwin,
290 static void attract_by_subject_cb(MainWindow *mainwin,
294 static void delete_duplicated_cb (MainWindow *mainwin,
297 static void delete_duplicated_all_cb (MainWindow *mainwin,
300 static void filter_cb (MainWindow *mainwin,
303 static void execute_summary_cb (MainWindow *mainwin,
306 static void update_summary_cb (MainWindow *mainwin,
310 static void prev_cb (MainWindow *mainwin,
313 static void next_cb (MainWindow *mainwin,
316 static void next_unread_cb (MainWindow *mainwin,
319 static void prev_unread_cb (MainWindow *mainwin,
323 static void prev_new_cb (MainWindow *mainwin,
326 static void next_new_cb (MainWindow *mainwin,
329 static void prev_marked_cb (MainWindow *mainwin,
332 static void next_marked_cb (MainWindow *mainwin,
335 static void prev_labeled_cb (MainWindow *mainwin,
338 static void next_labeled_cb (MainWindow *mainwin,
342 static void goto_folder_cb (MainWindow *mainwin,
346 static void copy_cb (MainWindow *mainwin,
349 static void allsel_cb (MainWindow *mainwin,
352 static void select_thread_cb (MainWindow *mainwin,
356 static void create_filter_cb (MainWindow *mainwin,
359 static void create_processing_cb (MainWindow *mainwin,
363 static void prefs_common_open_cb (MainWindow *mainwin,
366 static void prefs_template_open_cb (MainWindow *mainwin,
369 static void prefs_actions_open_cb (MainWindow *mainwin,
372 static void prefs_account_open_cb (MainWindow *mainwin,
376 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
380 static void prefs_post_processing_open_cb (MainWindow *mainwin,
384 static void prefs_filtering_open_cb (MainWindow *mainwin,
388 static void ssl_manager_open_cb (MainWindow *mainwin,
392 static void new_account_cb (MainWindow *mainwin,
396 static void account_selector_menu_cb (GtkMenuItem *menuitem,
398 static void account_receive_menu_cb (GtkMenuItem *menuitem,
401 static void prefs_open_cb (GtkMenuItem *menuitem,
403 static void plugins_open_cb (GtkMenuItem *menuitem,
406 static void online_switch_clicked(GtkButton *btn,
409 static void manual_open_cb (MainWindow *mainwin,
413 static void scan_tree_func (Folder *folder,
417 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
419 static void addr_harvest_cb ( MainWindow *mainwin,
423 static void addr_harvest_msg_cb ( MainWindow *mainwin,
427 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
428 GdkEventFocus *focus,
430 void main_window_reply_cb (MainWindow *mainwin,
433 gboolean mainwindow_progressindicator_hook (gpointer source,
435 #define SEPARATE_ACTION 500
437 static GtkItemFactoryEntry mainwin_entries[] =
439 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
440 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
441 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
442 {N_("/_File/Change folder order"), NULL, foldersort_cb, 0, NULL},
443 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
444 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
445 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
446 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
447 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
448 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
449 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
450 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
451 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
452 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
453 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
455 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
456 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
457 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
458 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
459 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
460 {N_("/_Edit/_Find in current message..."),
461 "<control>F", search_cb, 0, NULL},
462 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
463 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
464 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
465 {N_("/_View/Show or hi_de/_Folder tree"),
466 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
467 {N_("/_View/Show or hi_de/_Message view"),
468 "V", toggle_message_cb, 0, "<ToggleItem>"},
469 {N_("/_View/Show or hi_de/_Toolbar"),
470 NULL, NULL, 0, "<Branch>"},
471 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
472 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
473 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
474 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
475 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
476 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
477 {N_("/_View/Show or hi_de/_Toolbar/_None"),
478 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
479 {N_("/_View/Show or hi_de/Status _bar"),
480 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
481 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
482 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
483 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
484 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
486 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
487 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
488 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
489 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
490 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
491 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
492 {N_("/_View/_Sort/by _color label"),
493 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
494 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
495 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
496 {N_("/_View/_Sort/by a_ttachment"),
497 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
498 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
499 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
500 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
501 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
503 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
504 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
505 {N_("/_View/_Sort/_Attract by subject"),
506 NULL, attract_by_subject_cb, 0, NULL},
507 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
508 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
509 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
510 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
511 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
513 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
516 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
517 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/_Go to/P_rev unread message"),
519 "<shift>P", prev_unread_cb, 0, NULL},
520 {N_("/_View/_Go to/N_ext unread message"),
521 "<shift>N", next_unread_cb, 0, NULL},
522 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
524 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
525 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_View/_Go to/Prev _marked message"),
527 NULL, prev_marked_cb, 0, NULL},
528 {N_("/_View/_Go to/Next m_arked message"),
529 NULL, next_marked_cb, 0, NULL},
530 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_View/_Go to/Prev _labeled message"),
532 NULL, prev_labeled_cb, 0, NULL},
533 {N_("/_View/_Go to/Next la_beled message"),
534 NULL, next_labeled_cb, 0, NULL},
535 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
537 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
539 #define CODESET_SEPARATOR \
540 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
541 #define CODESET_ACTION(action) \
542 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
544 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_View/_Code set/_Auto detect"),
546 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
547 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
549 CODESET_ACTION(C_US_ASCII)},
552 {N_("/_View/_Code set/Unicode (_UTF-8)"),
553 CODESET_ACTION(C_UTF_8)},
556 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
557 CODESET_ACTION(C_ISO_8859_1)},
558 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
559 CODESET_ACTION(C_ISO_8859_15)},
562 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
563 CODESET_ACTION(C_ISO_8859_2)},
565 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
566 CODESET_ACTION(C_ISO_8859_13)},
567 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
568 CODESET_ACTION(C_ISO_8859_4)},
570 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
571 CODESET_ACTION(C_ISO_8859_7)},
573 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
574 CODESET_ACTION(C_ISO_8859_9)},
576 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
577 CODESET_ACTION(C_ISO_8859_5)},
578 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
579 CODESET_ACTION(C_KOI8_R)},
580 {N_("/_View/_Code set/Cyrillic (KOI8-U)"),
581 CODESET_ACTION(C_KOI8_U)},
582 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
583 CODESET_ACTION(C_WINDOWS_1251)},
586 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
587 CODESET_ACTION(C_ISO_2022_JP)},
589 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
590 CODESET_ACTION(C_ISO_2022_JP_2)},
592 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
593 CODESET_ACTION(C_EUC_JP)},
594 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
595 CODESET_ACTION(C_SHIFT_JIS)},
598 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
599 CODESET_ACTION(C_GB2312)},
600 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
601 CODESET_ACTION(C_BIG5)},
602 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
603 CODESET_ACTION(C_EUC_TW)},
604 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
605 CODESET_ACTION(C_ISO_2022_CN)},
607 {N_("/_View/_Code set/Korean (EUC-_KR)"),
608 CODESET_ACTION(C_EUC_KR)},
609 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
610 CODESET_ACTION(C_ISO_2022_KR)},
612 {N_("/_View/_Code set/Thai (TIS-620)"),
613 CODESET_ACTION(C_TIS_620)},
614 {N_("/_View/_Code set/Thai (Windows-874)"),
615 CODESET_ACTION(C_WINDOWS_874)},
618 #undef CODESET_SEPARATOR
619 #undef CODESET_ACTION
621 #define DECODE_SEPARATOR \
622 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
623 #define DECODE_ACTION(action) \
624 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
625 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
626 {N_("/_View/Decode/_Auto detect"),
627 NULL, set_decode_cb, 0, "<RadioItem>"},
628 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
629 {N_("/_View/Decode/_8bit"), DECODE_ACTION(ENC_8BIT)},
630 {N_("/_View/Decode/_Quoted printable"), DECODE_ACTION(ENC_QUOTED_PRINTABLE)},
631 {N_("/_View/Decode/_Base64"), DECODE_ACTION(ENC_BASE64)},
632 {N_("/_View/Decode/_Uuencode"), DECODE_ACTION(ENC_X_UUENCODE)},
634 #undef DECODE_SEPARATOR
637 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
639 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
640 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
641 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
642 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
644 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
645 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
646 {N_("/_Message/Recei_ve/Get from _current account"),
647 "<control>I", inc_mail_cb, 0, NULL},
648 {N_("/_Message/Recei_ve/Get from _all accounts"),
649 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
650 {N_("/_Message/Recei_ve/Cancel receivin_g"),
651 NULL, inc_cancel_cb, 0, NULL},
652 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
654 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
655 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
656 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
657 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
658 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
659 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
660 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
661 {N_("/_Message/Repl_y to/mailing _list"),
662 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
663 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
664 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
665 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
666 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
667 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
669 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
670 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
671 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
672 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
674 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
675 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
676 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
677 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
678 {N_("/_Message/_Mark/Mark as rea_d"),
679 NULL, mark_as_read_cb, 0, NULL},
680 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
681 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
682 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
684 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
685 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
686 {N_("/_Tools/Add sender to address boo_k"),
687 NULL, add_address_cb, 0, NULL},
688 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
689 {N_("/_Tools/_Harvest addresses/from _Folder..."),
690 NULL, addr_harvest_cb, 0, NULL},
691 {N_("/_Tools/_Harvest addresses/from _Messages..."),
692 NULL, addr_harvest_msg_cb, 0, NULL},
693 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
694 {N_("/_Tools/_Filter all messages in folder"),
695 NULL, filter_cb, 0, NULL},
696 {N_("/_Tools/Filter _selected messages"),
697 NULL, filter_cb, 1, NULL},
698 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
699 {N_("/_Tools/_Create filter rule/_Automatically"),
700 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
701 {N_("/_Tools/_Create filter rule/by _From"),
702 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
703 {N_("/_Tools/_Create filter rule/by _To"),
704 NULL, create_filter_cb, FILTER_BY_TO, NULL},
705 {N_("/_Tools/_Create filter rule/by _Subject"),
706 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
707 {N_("/_Tools/_Create processing rule"), NULL, NULL, 0, "<Branch>"},
708 {N_("/_Tools/_Create processing rule/_Automatically"),
709 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
710 {N_("/_Tools/_Create processing rule/by _From"),
711 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
712 {N_("/_Tools/_Create processing rule/by _To"),
713 NULL, create_processing_cb, FILTER_BY_TO, NULL},
714 {N_("/_Tools/_Create processing rule/by _Subject"),
715 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
716 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
719 {N_("/_Tools/_Check for new messages in all folders"),
720 NULL, update_folderview_cb, 0, NULL},
721 {N_("/_Tools/Delete du_plicated messages"),
722 NULL, NULL, 0, "<Branch>"},
723 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
724 NULL, delete_duplicated_cb, 0, NULL},
725 {N_("/_Tools/Delete du_plicated messages/In all folders"),
726 NULL, delete_duplicated_all_cb, 0, NULL},
727 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
730 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
731 {N_("/_Tools/SSL certi_ficates..."),
732 NULL, ssl_manager_open_cb, 0, NULL},
734 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
735 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
737 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_Configuration/C_hange current account"),
739 NULL, NULL, 0, "<Branch>"},
740 {N_("/_Configuration/_Preferences for current account..."),
741 NULL, prefs_account_open_cb, 0, NULL},
742 {N_("/_Configuration/Create _new account..."),
743 NULL, new_account_cb, 0, NULL},
744 {N_("/_Configuration/_Edit accounts..."),
745 NULL, account_edit_open, 0, NULL},
746 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
747 {N_("/_Configuration/_Common preferences..."),
748 NULL, prefs_common_open_cb, 0, NULL},
749 {N_("/_Configuration/Pre-processing..."),
750 NULL, prefs_pre_processing_open_cb, 0, NULL},
751 {N_("/_Configuration/Post-processing..."),
752 NULL, prefs_post_processing_open_cb, 0, NULL},
753 {N_("/_Configuration/_Filtering..."),
754 NULL, prefs_filtering_open_cb, 0, NULL},
755 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
756 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
757 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
758 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
760 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
761 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
762 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
763 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
764 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
765 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
766 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
767 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
768 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
769 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
770 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
773 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
779 MainWindow *mainwin = (MainWindow *)user_data;
781 if (mainwin->summaryview &&
782 mainwin->summaryview->quicksearch &&
783 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
784 (mod == 0 || mod == GDK_SHIFT_MASK)) {
785 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
791 MainWindow *main_window_create(SeparateType type)
797 GtkWidget *handlebox;
798 GtkWidget *vbox_body;
799 GtkWidget *hbox_stat;
800 GtkWidget *statusbar;
801 GtkWidget *progressbar;
802 GtkWidget *statuslabel;
803 GtkWidget *ac_button;
805 GtkWidget *online_pixmap;
806 GtkWidget *offline_pixmap;
807 GtkWidget *online_switch;
808 GtkWidget *offline_switch;
809 GtkTooltips *offline_tip;
810 GtkTooltips *online_tip;
811 GtkTooltips *sel_ac_tip;
813 FolderView *folderview;
814 SummaryView *summaryview;
815 MessageView *messageview;
816 GdkColormap *colormap;
819 GtkItemFactory *ifactory;
823 guint n_menu_entries;
824 gboolean hide_messageview = FALSE;
826 static GdkGeometry geometry;
828 debug_print("Creating main window...\n");
829 mainwin = g_new0(MainWindow, 1);
832 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
833 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
834 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
836 if (!geometry.min_height) {
837 geometry.min_width = 320;
838 geometry.min_height = 200;
840 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
843 g_signal_connect(G_OBJECT(window), "delete_event",
844 G_CALLBACK(main_window_close_cb), mainwin);
845 MANAGE_WINDOW_SIGNALS_CONNECT(window);
846 g_signal_connect(G_OBJECT(window), "focus_in_event",
847 G_CALLBACK(mainwindow_focus_in_event),
849 g_signal_connect(G_OBJECT(window), "key_press_event",
850 G_CALLBACK(mainwindow_key_pressed), mainwin);
852 gtk_widget_realize(window);
853 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
856 gtkut_widget_set_app_icon(window);
858 vbox = gtk_vbox_new(FALSE, 0);
859 gtk_widget_show(vbox);
860 gtk_container_add(GTK_CONTAINER(window), vbox);
863 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
864 menubar = menubar_create(window, mainwin_entries,
865 n_menu_entries, "<Main>", mainwin);
866 gtk_widget_show(menubar);
867 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
868 ifactory = gtk_item_factory_from_widget(menubar);
870 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
871 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
873 handlebox = gtk_handle_box_new();
874 gtk_widget_show(handlebox);
875 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
876 g_signal_connect(G_OBJECT(handlebox), "child_attached",
877 G_CALLBACK(toolbar_child_attached), mainwin);
878 g_signal_connect(G_OBJECT(handlebox), "child_detached",
879 G_CALLBACK(toolbar_child_detached), mainwin);
881 /* link window to mainwin->window to avoid gdk warnings */
882 mainwin->window = window;
885 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
889 /* vbox that contains body */
890 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
891 gtk_widget_show(vbox_body);
892 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
893 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
895 hbox_stat = gtk_hbox_new(FALSE, 2);
896 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
898 statusbar = statusbar_create();
899 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
901 progressbar = gtk_progress_bar_new();
902 gtk_widget_set_size_request(progressbar, 120, 1);
903 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
905 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
906 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
907 online_tip = gtk_tooltips_new();
908 online_switch = gtk_button_new ();
909 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
910 _("You are online. Click the icon to go offline"), NULL);
911 offline_tip = gtk_tooltips_new();
912 offline_switch = gtk_button_new ();
913 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
914 _("You are offline. Click the icon to go online"),
916 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
917 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
918 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
919 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
920 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
921 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
922 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
923 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
925 statuslabel = gtk_label_new("");
926 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
928 sel_ac_tip = gtk_tooltips_new();
929 ac_button = gtk_button_new();
930 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
931 ac_button, _("Select account"), NULL);
932 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
933 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
934 gtk_widget_set_size_request(ac_button, -1, 0);
935 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
936 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
937 G_CALLBACK(ac_label_button_pressed), mainwin);
939 ac_label = gtk_label_new("");
940 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
942 gtk_widget_show_all(hbox_stat);
944 gtk_widget_hide(offline_switch);
946 mainwin->folderview = folderview = folderview_create();
947 mainwin->summaryview = summaryview = summary_create();
948 mainwin->messageview = messageview = messageview_create(mainwin);
949 mainwin->logwin = log_window_create();
951 folderview->mainwin = mainwin;
952 folderview->summaryview = summaryview;
954 summaryview->mainwin = mainwin;
955 summaryview->folderview = folderview;
956 summaryview->messageview = messageview;
957 summaryview->window = window;
959 messageview->statusbar = statusbar;
960 mainwin->vbox = vbox;
961 mainwin->menubar = menubar;
962 mainwin->menu_factory = ifactory;
963 mainwin->handlebox = handlebox;
964 mainwin->vbox_body = vbox_body;
965 mainwin->hbox_stat = hbox_stat;
966 mainwin->statusbar = statusbar;
967 mainwin->progressbar = progressbar;
968 mainwin->statuslabel = statuslabel;
969 mainwin->online_switch = online_switch;
970 mainwin->online_pixmap = online_pixmap;
971 mainwin->offline_pixmap = offline_pixmap;
972 mainwin->ac_button = ac_button;
973 mainwin->ac_label = ac_label;
974 mainwin->offline_switch = offline_switch;
976 /* set context IDs for status bar */
977 mainwin->mainwin_cid = gtk_statusbar_get_context_id
978 (GTK_STATUSBAR(statusbar), "Main Window");
979 mainwin->folderview_cid = gtk_statusbar_get_context_id
980 (GTK_STATUSBAR(statusbar), "Folder View");
981 mainwin->summaryview_cid = gtk_statusbar_get_context_id
982 (GTK_STATUSBAR(statusbar), "Summary View");
983 mainwin->messageview_cid = gtk_statusbar_get_context_id
984 (GTK_STATUSBAR(statusbar), "Message View");
986 messageview->statusbar_cid = mainwin->messageview_cid;
988 /* allocate colors for summary view and folder view */
989 summaryview->color_marked.red = summaryview->color_marked.green = 0;
990 summaryview->color_marked.blue = (guint16)65535;
992 summaryview->color_dim.red = summaryview->color_dim.green =
993 summaryview->color_dim.blue = COLOR_DIM;
995 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
996 &folderview->color_new);
998 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
999 &folderview->color_op);
1001 summaryview->color_important.red = 0;
1002 summaryview->color_important.green = 0;
1003 summaryview->color_important.blue = (guint16)65535;
1005 color[0] = summaryview->color_marked;
1006 color[1] = summaryview->color_dim;
1007 color[2] = folderview->color_new;
1008 color[3] = folderview->color_op;
1010 colormap = gdk_window_get_colormap(window->window);
1011 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1012 for (i = 0; i < 4; i++) {
1013 if (success[i] == FALSE)
1014 g_warning("MainWindow: color allocation %d failed\n", i);
1017 debug_print("done.\n");
1019 messageview->visible = prefs_common.msgview_visible;
1020 hide_messageview = !messageview->visible;
1022 main_window_set_widgets(mainwin, type);
1024 g_signal_connect(G_OBJECT(window), "size_allocate",
1025 G_CALLBACK(main_window_size_allocate_cb),
1028 /* set menu items */
1029 menuitem = gtk_item_factory_get_item
1030 (ifactory, "/View/Code set/Auto detect");
1031 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1033 switch (prefs_common.toolbar_style) {
1035 menuitem = gtk_item_factory_get_item
1036 (ifactory, "/View/Show or hide/Toolbar/None");
1039 menuitem = gtk_item_factory_get_item
1040 (ifactory, "/View/Show or hide/Toolbar/Icon");
1043 menuitem = gtk_item_factory_get_item
1044 (ifactory, "/View/Show or hide/Toolbar/Text");
1047 menuitem = gtk_item_factory_get_item
1048 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1050 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1052 gtk_widget_hide(mainwin->hbox_stat);
1053 menuitem = gtk_item_factory_get_item
1054 (ifactory, "/View/Show or hide/Status bar");
1055 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1056 prefs_common.show_statusbar);
1058 /* set account selection menu */
1059 ac_menu = gtk_item_factory_get_widget
1060 (ifactory, "/Configuration/Change current account");
1061 g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1062 G_CALLBACK(ac_menu_popup_closed), mainwin);
1063 mainwin->ac_menu = ac_menu;
1065 toolbar_main_set_sensitive(mainwin);
1067 /* create actions menu */
1068 main_window_update_actions_menu(mainwin);
1070 /* attach accel groups to main window */
1071 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1072 gtk_window_add_accel_group \
1074 gtk_item_factory_from_widget(menu)->accel_group); \
1075 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1077 G_CALLBACK(main_window_accel_activate), mainwin);
1080 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1082 /* connect the accelerators for equivalent
1083 menu items in different menus */
1084 menu_connect_identical_items();
1088 /* show main window */
1089 gtk_widget_show(mainwin->window);
1091 /* initialize views */
1092 folderview_init(folderview);
1093 summary_init(summaryview);
1094 messageview_init(messageview);
1095 log_window_init(mainwin->logwin);
1096 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1097 prefs_common.loglength);
1099 sslcertwindow_register_hook();
1101 mainwin->lock_count = 0;
1102 mainwin->menu_lock_count = 0;
1103 mainwin->cursor_count = 0;
1105 mainwin->progressindicator_hook =
1106 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1109 watch_cursor = gdk_cursor_new(GDK_WATCH);
1111 mainwin_list = g_list_append(mainwin_list, mainwin);
1113 /* init work_offline */
1114 if (prefs_common.work_offline)
1115 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1117 if (mainwin->type == SEPARATE_NONE && hide_messageview)
1118 main_window_toggle_message_view(mainwin);
1123 void main_window_destroy(MainWindow *mainwin)
1125 /* TODO : destroy other component */
1126 messageview_destroy(mainwin->messageview);
1129 void main_window_update_actions_menu(MainWindow *mainwin)
1131 GtkItemFactory *ifactory;
1133 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1134 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1137 void main_window_cursor_wait(MainWindow *mainwin)
1140 if (mainwin->cursor_count == 0)
1141 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1143 mainwin->cursor_count++;
1148 void main_window_cursor_normal(MainWindow *mainwin)
1150 if (mainwin->cursor_count)
1151 mainwin->cursor_count--;
1153 if (mainwin->cursor_count == 0)
1154 gdk_window_set_cursor(mainwin->window->window, NULL);
1159 /* lock / unlock the user-interface */
1160 void main_window_lock(MainWindow *mainwin)
1162 if (mainwin->lock_count == 0)
1163 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1165 mainwin->lock_count++;
1167 main_window_set_menu_sensitive(mainwin);
1168 toolbar_main_set_sensitive(mainwin);
1171 void main_window_unlock(MainWindow *mainwin)
1173 if (mainwin->lock_count)
1174 mainwin->lock_count--;
1176 main_window_set_menu_sensitive(mainwin);
1177 toolbar_main_set_sensitive(mainwin);
1179 if (mainwin->lock_count == 0)
1180 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1183 static void main_window_menu_callback_block(MainWindow *mainwin)
1185 mainwin->menu_lock_count++;
1188 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1190 if (mainwin->menu_lock_count)
1191 mainwin->menu_lock_count--;
1194 void main_window_reflect_prefs_all(void)
1196 main_window_reflect_prefs_all_real(FALSE);
1199 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1202 MainWindow *mainwin;
1205 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1206 mainwin = (MainWindow *)cur->data;
1208 main_window_show_cur_account(mainwin);
1209 main_window_set_menu_sensitive(mainwin);
1210 toolbar_main_set_sensitive(mainwin);
1213 if (pixmap_theme_changed) {
1214 toolbar_update(TOOLBAR_MAIN, mainwin);
1215 messageview_reflect_prefs_pixmap_theme();
1216 compose_reflect_prefs_pixmap_theme();
1217 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1218 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1220 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1221 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1222 mainwin->online_pixmap);
1223 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1224 gtk_widget_show(pixmap);
1225 mainwin->online_pixmap = pixmap;
1226 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1227 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1228 mainwin->offline_pixmap);
1229 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1230 gtk_widget_show(pixmap);
1231 mainwin->offline_pixmap = pixmap;
1234 summary_redisplay_msg(mainwin->summaryview);
1235 headerview_set_visibility(mainwin->messageview->headerview,
1236 prefs_common.display_header_pane);
1240 void main_window_set_summary_column(void)
1243 MainWindow *mainwin;
1245 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1246 mainwin = (MainWindow *)cur->data;
1247 summary_set_column_order(mainwin->summaryview);
1251 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1252 GList *account_list)
1254 GList *cur_ac, *cur_item;
1255 GtkWidget *menuitem;
1256 PrefsAccount *ac_prefs;
1258 /* destroy all previous menu item */
1259 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1260 while (cur_item != NULL) {
1261 GList *next = cur_item->next;
1262 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1266 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1267 ac_prefs = (PrefsAccount *)cur_ac->data;
1269 menuitem = gtk_menu_item_new_with_label
1270 (ac_prefs->account_name
1271 ? ac_prefs->account_name : _("Untitled"));
1272 gtk_widget_show(menuitem);
1273 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1274 g_signal_connect(G_OBJECT(menuitem), "activate",
1275 G_CALLBACK(account_selector_menu_cb),
1280 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1281 GList *account_list)
1283 GList *cur_ac, *cur_item;
1285 GtkWidget *menuitem;
1286 PrefsAccount *ac_prefs;
1288 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1289 "/Message/Receive");
1291 /* search for separator */
1292 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1293 cur_item = cur_item->next) {
1294 if (GTK_BIN(cur_item->data)->child == NULL) {
1295 cur_item = cur_item->next;
1300 /* destroy all previous menu item */
1301 while (cur_item != NULL) {
1302 GList *next = cur_item->next;
1303 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1307 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1308 ac_prefs = (PrefsAccount *)cur_ac->data;
1310 menuitem = gtk_menu_item_new_with_label
1311 (ac_prefs->account_name ? ac_prefs->account_name
1313 gtk_widget_show(menuitem);
1314 gtk_menu_append(GTK_MENU(menu), menuitem);
1315 g_signal_connect(G_OBJECT(menuitem), "activate",
1316 G_CALLBACK(account_receive_menu_cb),
1321 void main_window_set_account_menu(GList *account_list)
1324 MainWindow *mainwin;
1326 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1327 mainwin = (MainWindow *)cur->data;
1328 main_window_set_account_selector_menu(mainwin, account_list);
1329 main_window_set_account_receive_menu(mainwin, account_list);
1333 static void main_window_show_cur_account(MainWindow *mainwin)
1338 ac_name = g_strdup(cur_account
1339 ? (cur_account->account_name
1340 ? cur_account->account_name : _("Untitled"))
1344 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1346 buf = g_strdup(PROG_VERSION);
1347 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1350 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1351 gtk_widget_queue_resize(mainwin->ac_button);
1356 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1358 switch (mainwin->type) {
1359 case SEPARATE_FOLDER:
1360 return mainwin->win.sep_folder.folderwin;
1362 return mainwin->win.sep_both.folderwin;
1368 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1370 switch (mainwin->type) {
1371 case SEPARATE_MESSAGE:
1372 return mainwin->win.sep_message.messagewin;
1374 return mainwin->win.sep_both.messagewin;
1380 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1382 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1383 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1384 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1385 GtkWidget *message_wid = mainwin->messageview->vbox;
1387 debug_print("Changing window separation type from %d to %d\n",
1388 mainwin->type, type);
1390 if (mainwin->type == type) return;
1392 /* remove widgets from those containers */
1393 gtk_widget_ref(folder_wid);
1394 gtk_widget_ref(summary_wid);
1395 gtk_widget_ref(message_wid);
1396 gtkut_container_remove
1397 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1398 gtkut_container_remove
1399 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1400 gtkut_container_remove
1401 (GTK_CONTAINER(message_wid->parent), message_wid);
1403 /* clean containers */
1404 switch (mainwin->type) {
1406 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1408 case SEPARATE_FOLDER:
1409 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1410 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1412 case SEPARATE_MESSAGE:
1413 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1414 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1417 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1418 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1422 gtk_widget_hide(mainwin->window);
1423 main_window_set_widgets(mainwin, type);
1424 gtk_widget_show(mainwin->window);
1426 gtk_widget_unref(folder_wid);
1427 gtk_widget_unref(summary_wid);
1428 gtk_widget_unref(message_wid);
1431 void main_window_toggle_message_view(MainWindow *mainwin)
1433 SummaryView *summaryview = mainwin->summaryview;
1434 union CompositeWin *cwin = &mainwin->win;
1435 GtkWidget *vpaned = NULL;
1436 GtkWidget *container = NULL;
1437 GtkWidget *msgwin = NULL;
1439 switch (mainwin->type) {
1441 vpaned = cwin->sep_none.vpaned;
1442 container = cwin->sep_none.hpaned;
1444 case SEPARATE_FOLDER:
1445 vpaned = cwin->sep_folder.vpaned;
1446 container = mainwin->vbox_body;
1448 case SEPARATE_MESSAGE:
1449 msgwin = mainwin->win.sep_message.messagewin;
1452 msgwin = mainwin->win.sep_both.messagewin;
1457 if (GTK_WIDGET_VISIBLE(msgwin)) {
1458 gtk_widget_hide(msgwin);
1459 mainwin->messageview->visible = FALSE;
1460 summaryview->displayed = NULL;
1462 gtk_widget_show(msgwin);
1463 mainwin->messageview->visible = TRUE;
1465 } else if (vpaned->parent != NULL) {
1466 mainwin->messageview->visible = FALSE;
1467 summaryview->displayed = NULL;
1468 gtk_widget_ref(vpaned);
1469 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1470 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1471 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1472 GTK_ARROW_UP, GTK_SHADOW_OUT);
1474 mainwin->messageview->visible = TRUE;
1475 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1476 gtk_container_add(GTK_CONTAINER(container), vpaned);
1477 gtk_widget_unref(vpaned);
1478 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1479 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1482 if (mainwin->messageview->visible == FALSE)
1483 messageview_clear(mainwin->messageview);
1485 main_window_set_menu_sensitive(mainwin);
1487 prefs_common.msgview_visible = mainwin->messageview->visible;
1489 gtk_widget_grab_focus(summaryview->ctree);
1492 void main_window_get_size(MainWindow *mainwin)
1494 GtkAllocation *allocation;
1496 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1498 if (allocation->width > 1 && allocation->height > 1) {
1499 prefs_common.summaryview_width = allocation->width;
1501 if ((mainwin->type == SEPARATE_NONE ||
1502 mainwin->type == SEPARATE_FOLDER) &&
1503 messageview_is_visible(mainwin->messageview))
1504 prefs_common.summaryview_height = allocation->height;
1506 prefs_common.mainview_width = allocation->width;
1509 allocation = &mainwin->window->allocation;
1510 if (allocation->width > 1 && allocation->height > 1) {
1511 prefs_common.mainview_height = allocation->height;
1512 prefs_common.mainwin_width = allocation->width;
1513 prefs_common.mainwin_height = allocation->height;
1516 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1517 if (allocation->width > 1 && allocation->height > 1) {
1518 prefs_common.folderview_width = allocation->width;
1519 prefs_common.folderview_height = allocation->height;
1522 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1523 if (allocation->width > 1 && allocation->height > 1) {
1524 prefs_common.msgview_width = allocation->width;
1525 prefs_common.msgview_height = allocation->height;
1528 /* debug_print("summaryview size: %d x %d\n",
1529 prefs_common.summaryview_width,
1530 prefs_common.summaryview_height);
1531 debug_print("folderview size: %d x %d\n",
1532 prefs_common.folderview_width,
1533 prefs_common.folderview_height);
1534 debug_print("messageview size: %d x %d\n",
1535 prefs_common.msgview_width,
1536 prefs_common.msgview_height); */
1539 void main_window_get_position(MainWindow *mainwin)
1544 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1546 prefs_common.mainview_x = x;
1547 prefs_common.mainview_y = y;
1548 prefs_common.mainwin_x = x;
1549 prefs_common.mainwin_y = y;
1551 debug_print("main window position: %d, %d\n", x, y);
1553 window = main_window_get_folder_window(mainwin);
1555 gtkut_widget_get_uposition(window, &x, &y);
1556 prefs_common.folderwin_x = x;
1557 prefs_common.folderwin_y = y;
1558 debug_print("folder window position: %d, %d\n", x, y);
1560 window = main_window_get_message_window(mainwin);
1562 gtkut_widget_get_uposition(window, &x, &y);
1563 prefs_common.main_msgwin_x = x;
1564 prefs_common.main_msgwin_y = y;
1565 debug_print("message window position: %d, %d\n", x, y);
1569 void main_window_progress_on(MainWindow *mainwin)
1571 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1574 void main_window_progress_off(MainWindow *mainwin)
1576 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1577 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1580 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1584 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1585 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1586 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1587 (cur == 0 && total == 0) ? 0 :
1588 (gfloat)cur / (gfloat)total);
1591 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1597 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1598 folder = FOLDER(list->data);
1599 if (folder && folder->trash && folder->trash->total_msgs > 0)
1603 if (!has_trash) return;
1606 if (alertpanel(_("Empty trash"),
1607 _("Empty all messages in trash?"),
1608 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1610 manage_window_focus_in(mainwin->window, NULL, NULL);
1613 procmsg_empty_trash();
1615 if (mainwin->summaryview->folder_item &&
1616 mainwin->summaryview->folder_item->stype == F_TRASH)
1617 gtk_widget_grab_focus(mainwin->folderview->ctree);
1620 void main_window_add_mailbox(MainWindow *mainwin)
1625 path = input_dialog(_("Add mailbox"),
1626 _("Input the location of mailbox.\n"
1627 "If the existing mailbox is specified, it will be\n"
1628 "scanned automatically."),
1631 if (folder_find_from_path(path)) {
1632 alertpanel_error(_("The mailbox `%s' already exists."), path);
1636 folder = folder_new(folder_get_class_from_string("mh"),
1637 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1641 if (folder->klass->create_tree(folder) < 0) {
1642 alertpanel_error(_("Creation of the mailbox failed.\n"
1643 "Maybe some files already exist, or you don't have the permission to write there."));
1644 folder_destroy(folder);
1649 folder_set_ui_func(folder, scan_tree_func, mainwin);
1650 folder_scan_tree(folder);
1651 folder_set_ui_func(folder, NULL, NULL);
1654 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1656 SensitiveCond state = 0;
1657 SummarySelection selection;
1658 FolderItem *item = mainwin->summaryview->folder_item;
1659 GList *account_list = account_get_list();
1661 selection = summary_get_selection_type(mainwin->summaryview);
1663 if (mainwin->lock_count == 0)
1664 state |= M_UNLOCKED;
1665 if (selection != SUMMARY_NONE)
1666 state |= M_MSG_EXIST;
1667 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1669 /* if (item->folder->type != F_NEWS) */
1670 state |= M_ALLOW_DELETE;
1672 if (prefs_common.immediate_exec == 0
1673 && mainwin->lock_count == 0)
1674 state |= M_DELAY_EXEC;
1676 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1677 || selection != SUMMARY_NONE)
1678 state |= M_HIDE_READ_MSG;
1680 if (mainwin->summaryview->threaded)
1681 state |= M_THREADED;
1683 state |= M_UNTHREADED;
1684 if (selection == SUMMARY_SELECTED_SINGLE ||
1685 selection == SUMMARY_SELECTED_MULTIPLE)
1686 state |= M_TARGET_EXIST;
1687 if (selection == SUMMARY_SELECTED_SINGLE)
1688 state |= M_SINGLE_TARGET_EXIST;
1689 if (mainwin->summaryview->folder_item &&
1690 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1693 state |= M_NOT_NEWS;
1694 if (selection == SUMMARY_SELECTED_SINGLE &&
1696 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1697 item->stype == F_QUEUE)))
1698 state |= M_ALLOW_REEDIT;
1700 state |= M_HAVE_ACCOUNT;
1702 for ( ; account_list != NULL; account_list = account_list->next) {
1703 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1704 state |= M_HAVE_NEWS_ACCOUNT;
1709 if (inc_is_active())
1710 state |= M_INC_ACTIVE;
1717 void main_window_set_menu_sensitive(MainWindow *mainwin)
1719 GtkItemFactory *ifactory = mainwin->menu_factory;
1720 SensitiveCond state;
1723 GtkWidget *menuitem;
1724 SummaryView *summaryview;
1729 static const struct {
1733 {"/File/Add mailbox" , M_UNLOCKED},
1735 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1736 {"/File/Change folder order" , M_UNLOCKED},
1737 {"/File/Export to mbox file..." , M_UNLOCKED},
1738 {"/File/Empty all Trash folders" , M_UNLOCKED},
1739 {"/File/Work offline" , M_UNLOCKED},
1741 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1742 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1743 /* {"/File/Close" , M_UNLOCKED}, */
1744 {"/File/Exit" , M_UNLOCKED},
1746 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1748 {"/View/Sort" , M_EXEC},
1749 {"/View/Thread view" , M_EXEC},
1750 {"/View/Expand all threads" , M_MSG_EXIST},
1751 {"/View/Collapse all threads" , M_MSG_EXIST},
1752 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1753 {"/View/Go to/Prev message" , M_MSG_EXIST},
1754 {"/View/Go to/Next message" , M_MSG_EXIST},
1755 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1756 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1757 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1758 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1759 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1760 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1761 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1762 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1763 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1765 {"/Message/Receive/Get from current account"
1766 , M_HAVE_ACCOUNT|M_UNLOCKED},
1767 {"/Message/Receive/Get from all accounts"
1768 , M_HAVE_ACCOUNT|M_UNLOCKED},
1769 {"/Message/Receive/Cancel receiving"
1772 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1773 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1774 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1775 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1776 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1777 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1778 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1779 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1780 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1781 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1782 {"/Message/Mark" , M_TARGET_EXIST},
1783 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1785 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1786 {"/Tools/Harvest addresses" , M_UNLOCKED},
1787 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1788 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1789 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1790 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1791 {"/Tools/Execute" , M_DELAY_EXEC},
1792 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1794 {"/Configuration", M_UNLOCKED},
1799 state = main_window_get_current_state(mainwin);
1801 for (i = 0; entry[i].entry != NULL; i++) {
1802 sensitive = ((entry[i].cond & state) == entry[i].cond);
1803 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1806 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1808 /* search for separator */
1809 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1810 cur_item = cur_item->next) {
1811 if (GTK_BIN(cur_item->data)->child == NULL) {
1812 cur_item = cur_item->next;
1817 for (; cur_item != NULL; cur_item = cur_item->next) {
1818 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1819 (M_UNLOCKED & state) != 0);
1822 main_window_menu_callback_block(mainwin);
1824 #define SET_CHECK_MENU_ACTIVE(path, active) \
1826 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1827 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1830 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1831 messageview_is_visible(mainwin->messageview));
1833 summaryview = mainwin->summaryview;
1834 menu_path = "/View/Sort/Don't sort";
1836 switch (summaryview->sort_key) {
1837 case SORT_BY_NUMBER:
1838 menu_path = "/View/Sort/by number"; break;
1840 menu_path = "/View/Sort/by size"; break;
1842 menu_path = "/View/Sort/by date"; break;
1844 menu_path = "/View/Sort/by from"; break;
1846 menu_path = "/View/Sort/by recipient"; break;
1847 case SORT_BY_SUBJECT:
1848 menu_path = "/View/Sort/by subject"; break;
1850 menu_path = "/View/Sort/by color label"; break;
1852 menu_path = "/View/Sort/by mark"; break;
1853 case SORT_BY_STATUS:
1854 menu_path = "/View/Sort/by status"; break;
1856 menu_path = "/View/Sort/by attachment"; break;
1858 menu_path = "/View/Sort/by score"; break;
1859 case SORT_BY_LOCKED:
1860 menu_path = "/View/Sort/by locked"; break;
1863 menu_path = "/View/Sort/Don't sort"; break;
1865 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1867 if (summaryview->sort_type == SORT_ASCENDING) {
1868 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1870 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1873 if (summaryview->sort_key != SORT_BY_NONE) {
1874 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1875 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1877 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1878 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1881 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1882 mainwin->messageview->mimeview->textview->show_all_headers);
1883 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1885 #undef SET_CHECK_MENU_ACTIVE
1887 main_window_menu_callback_unblock(mainwin);
1890 void main_window_popup(MainWindow *mainwin)
1892 gtkut_window_popup(mainwin->window);
1894 switch (mainwin->type) {
1895 case SEPARATE_FOLDER:
1896 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1898 case SEPARATE_MESSAGE:
1899 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1902 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1903 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1910 void main_window_show(MainWindow *mainwin)
1912 gtk_widget_show(mainwin->window);
1913 gtk_widget_show(mainwin->vbox_body);
1915 gtk_widget_set_uposition(mainwin->window,
1916 prefs_common.mainwin_x,
1917 prefs_common.mainwin_y);
1919 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1920 prefs_common.folderview_width,
1921 prefs_common.folderview_height);
1922 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1923 prefs_common.summaryview_width,
1924 prefs_common.summaryview_height);
1925 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1926 prefs_common.msgview_width,
1927 prefs_common.msgview_height);
1929 if (mainwin->type & SEPARATE_FOLDER) {
1930 GtkWidget *folderwin;
1932 folderwin = main_window_get_folder_window(mainwin);
1933 gtk_widget_show(folderwin);
1934 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1935 prefs_common.folderwin_y);
1938 if (mainwin->type & SEPARATE_MESSAGE) {
1939 GtkWidget *messagewin;
1941 messagewin = main_window_get_message_window(mainwin);
1942 gtk_widget_show(messagewin);
1943 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1944 prefs_common.main_msgwin_y);
1948 void main_window_hide(MainWindow *mainwin)
1950 main_window_get_size(mainwin);
1951 main_window_get_position(mainwin);
1953 gtk_widget_hide(mainwin->window);
1954 gtk_widget_hide(mainwin->vbox_body);
1956 if (mainwin->type & SEPARATE_FOLDER) {
1957 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1960 if (mainwin->type & SEPARATE_MESSAGE) {
1961 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1965 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1967 GtkWidget *folderwin = NULL;
1968 GtkWidget *messagewin = NULL;
1971 GtkWidget *vbox_body = mainwin->vbox_body;
1972 GtkItemFactory *ifactory = mainwin->menu_factory;
1973 GtkWidget *menuitem;
1974 GtkItemFactory *msgview_ifactory;
1976 debug_print("Setting widgets... ");
1978 /* create separated window(s) if needed */
1979 if (type & SEPARATE_FOLDER) {
1980 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1981 gtk_window_set_title(GTK_WINDOW(folderwin),
1982 _("Sylpheed - Folder View"));
1983 gtk_window_set_resizable(GTK_WINDOW(folderwin), TRUE);
1984 gtk_window_move(GTK_WINDOW(folderwin), prefs_common.folderwin_x,
1985 prefs_common.folderwin_y);
1986 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1988 g_signal_connect(G_OBJECT(folderwin), "delete_event",
1989 G_CALLBACK(folder_window_close_cb),
1991 gtk_container_add(GTK_CONTAINER(folderwin),
1992 GTK_WIDGET_PTR(mainwin->folderview));
1993 gtk_widget_realize(folderwin);
1994 if (prefs_common.folderview_visible)
1995 gtk_widget_show(folderwin);
1997 if (type & SEPARATE_MESSAGE) {
1998 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1999 gtk_window_set_title(GTK_WINDOW(messagewin),
2000 _("Sylpheed - Message View"));
2001 gtk_window_set_resizable(GTK_WINDOW(messagewin), TRUE);
2002 gtk_window_move(GTK_WINDOW(messagewin),
2003 prefs_common.main_msgwin_x,
2004 prefs_common.main_msgwin_y);
2005 gtk_widget_set_size_request(messagewin,
2006 prefs_common.msgwin_width,
2007 prefs_common.msgwin_height);
2008 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2010 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2011 G_CALLBACK(message_window_close_cb),
2013 if (messageview_is_visible(mainwin->messageview))
2014 gtk_widget_show(messagewin);
2017 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2018 prefs_common.folderview_width,
2019 prefs_common.folderview_height);
2020 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2021 prefs_common.summaryview_width,
2022 prefs_common.summaryview_height);
2023 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2024 prefs_common.msgview_width,
2025 prefs_common.msgview_height);
2029 hpaned = gtk_hpaned_new();
2030 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2031 gtk_paned_add1(GTK_PANED(hpaned),
2032 GTK_WIDGET_PTR(mainwin->folderview));
2033 gtk_widget_show(hpaned);
2034 gtk_widget_queue_resize(hpaned);
2036 vpaned = gtk_vpaned_new();
2037 if (messageview_is_visible(mainwin->messageview)) {
2038 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2039 gtk_paned_add1(GTK_PANED(vpaned),
2040 GTK_WIDGET_PTR(mainwin->summaryview));
2042 gtk_paned_add2(GTK_PANED(hpaned),
2043 GTK_WIDGET_PTR(mainwin->summaryview));
2044 gtk_widget_ref(vpaned);
2046 gtk_paned_add2(GTK_PANED(vpaned),
2047 GTK_WIDGET_PTR(mainwin->messageview));
2048 gtk_widget_show(vpaned);
2049 gtk_widget_queue_resize(vpaned);
2051 mainwin->win.sep_none.hpaned = hpaned;
2052 mainwin->win.sep_none.vpaned = vpaned;
2054 /* remove headerview if not in prefs */
2055 headerview_set_visibility(mainwin->messageview->headerview,
2056 prefs_common.display_header_pane);
2058 case SEPARATE_FOLDER:
2059 vpaned = gtk_vpaned_new();
2060 if (messageview_is_visible(mainwin->messageview)) {
2061 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2063 gtk_paned_add1(GTK_PANED(vpaned),
2064 GTK_WIDGET_PTR(mainwin->summaryview));
2066 gtk_box_pack_start(GTK_BOX(vbox_body),
2067 GTK_WIDGET_PTR(mainwin->summaryview),
2069 gtk_widget_ref(vpaned);
2071 gtk_paned_add2(GTK_PANED(vpaned),
2072 GTK_WIDGET_PTR(mainwin->messageview));
2073 gtk_widget_show(vpaned);
2074 gtk_widget_queue_resize(vpaned);
2076 mainwin->win.sep_folder.folderwin = folderwin;
2077 mainwin->win.sep_folder.vpaned = vpaned;
2079 /* remove headerview if not in prefs */
2080 headerview_set_visibility(mainwin->messageview->headerview,
2081 prefs_common.display_header_pane);
2084 case SEPARATE_MESSAGE:
2085 hpaned = gtk_hpaned_new();
2086 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2087 gtk_paned_add1(GTK_PANED(hpaned),
2088 GTK_WIDGET_PTR(mainwin->folderview));
2089 gtk_paned_add2(GTK_PANED(hpaned),
2090 GTK_WIDGET_PTR(mainwin->summaryview));
2091 gtk_widget_show(hpaned);
2092 gtk_widget_queue_resize(hpaned);
2093 messageview_add_toolbar(mainwin->messageview, messagewin);
2094 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2095 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2097 mainwin->win.sep_message.messagewin = messagewin;
2098 mainwin->win.sep_message.hpaned = hpaned;
2100 gtk_widget_realize(messagewin);
2101 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2102 gtk_widget_show_all(messagewin);
2103 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2104 mainwin->messageview->handlebox,
2105 prefs_common.toolbar_style);
2109 messageview_add_toolbar(mainwin->messageview, messagewin);
2110 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2111 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2113 gtk_box_pack_start(GTK_BOX(vbox_body),
2114 GTK_WIDGET_PTR(mainwin->summaryview),
2117 mainwin->win.sep_both.folderwin = folderwin;
2118 mainwin->win.sep_both.messagewin = messagewin;
2120 gtk_widget_realize(messagewin);
2121 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2122 gtk_widget_show_all(messagewin);
2123 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2124 mainwin->messageview->handlebox,
2125 prefs_common.toolbar_style);
2130 gtk_window_move(GTK_WINDOW(mainwin->window),
2131 prefs_common.mainwin_x,
2132 prefs_common.mainwin_y);
2134 gtk_widget_queue_resize(vbox_body);
2135 gtk_widget_queue_resize(mainwin->vbox);
2136 gtk_widget_queue_resize(mainwin->window);
2137 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2138 * and mimeview icon list/ctree lose track of their visibility states */
2139 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2140 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2141 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2142 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2143 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2144 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2146 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2148 mainwin->type = type;
2151 /* toggle menu state */
2152 menuitem = gtk_item_factory_get_item
2153 (ifactory, "/View/Show or hide/Folder tree");
2154 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2155 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2156 prefs_common.folderview_visible);
2157 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2158 menuitem = gtk_item_factory_get_item
2159 (ifactory, "/View/Show or hide/Message view");
2160 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2161 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
2162 prefs_common.msgview_visible);
2164 menuitem = gtk_item_factory_get_item
2165 (ifactory, "/View/Separate folder tree");
2166 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2167 ((type & SEPARATE_FOLDER) != 0));
2168 menuitem = gtk_item_factory_get_item
2169 (ifactory, "/View/Separate message view");
2170 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2171 ((type & SEPARATE_MESSAGE) != 0));
2175 (G_OBJECT(folderwin), "size_allocate",
2176 G_CALLBACK(folder_window_size_allocate_cb),
2181 (G_OBJECT(messagewin), "size_allocate",
2182 G_CALLBACK(message_window_size_allocate_cb),
2186 debug_print("done.\n");
2189 void main_window_destroy_all(void)
2191 while (mainwin_list != NULL) {
2192 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2194 /* free toolbar stuff */
2195 toolbar_clear_list(TOOLBAR_MAIN);
2196 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2197 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2199 g_free(mainwin->toolbar);
2202 mainwin_list = g_list_remove(mainwin_list, mainwin);
2204 g_list_free(mainwin_list);
2208 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2209 GdkEventButton *event,
2212 MainWindow *mainwin = (MainWindow *)data;
2214 if (!event) return FALSE;
2215 if (event->button != 3) return FALSE;
2217 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2218 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2221 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2222 menu_button_position, widget,
2223 event->button, event->time);
2229 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2232 gtk_widget_set_usize(child, 1, -1);
2235 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2238 gtk_widget_set_usize(child, -1, -1);
2241 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2244 MainWindow *mainwin = (MainWindow *)data;
2246 if (!event) return FALSE;
2248 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2249 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2252 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2253 menu_button_position, widget,
2254 event->button, event->time);
2259 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2261 MainWindow *mainwin = (MainWindow *)data;
2264 button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2265 if (!button) return;
2266 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2267 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2268 manage_window_focus_in(mainwin->window, NULL, NULL);
2271 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2274 MainWindow *mainwin = (MainWindow *)data;
2276 if (mainwin->lock_count == 0)
2277 app_exit_cb(data, 0, widget);
2282 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2285 MainWindow *mainwin = (MainWindow *)data;
2286 GtkWidget *menuitem;
2288 menuitem = gtk_item_factory_get_item
2289 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2290 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2295 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2298 MainWindow *mainwin = (MainWindow *)data;
2299 GtkWidget *menuitem;
2301 menuitem = gtk_item_factory_get_item
2302 (mainwin->menu_factory, "/View/Show or hide/Message view");
2303 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2308 static void main_window_size_allocate_cb(GtkWidget *widget,
2309 GtkAllocation *allocation,
2312 MainWindow *mainwin = (MainWindow *)data;
2314 main_window_get_size(mainwin);
2317 static void folder_window_size_allocate_cb(GtkWidget *widget,
2318 GtkAllocation *allocation,
2321 MainWindow *mainwin = (MainWindow *)data;
2323 main_window_get_size(mainwin);
2326 static void message_window_size_allocate_cb(GtkWidget *widget,
2327 GtkAllocation *allocation,
2330 MainWindow *mainwin = (MainWindow *)data;
2332 main_window_get_size(mainwin);
2335 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2338 main_window_add_mailbox(mainwin);
2341 static void update_folderview_cb(MainWindow *mainwin, guint action,
2344 summary_show(mainwin->summaryview, NULL);
2345 folderview_check_new_all();
2348 static void foldersort_cb(MainWindow *mainwin, guint action,
2354 static void import_mbox_cb(MainWindow *mainwin, guint action,
2357 import_mbox(mainwin->summaryview->folder_item);
2360 static void export_mbox_cb(MainWindow *mainwin, guint action,
2363 export_mbox(mainwin->summaryview->folder_item);
2366 static void empty_trash_cb(MainWindow *mainwin, guint action,
2369 main_window_empty_trash(mainwin, TRUE);
2372 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2374 summary_save_as(mainwin->summaryview);
2377 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2379 summary_print(mainwin->summaryview);
2382 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2384 if (prefs_common.confirm_on_exit) {
2385 if (alertpanel(_("Exit"), _("Exit this program?"),
2386 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2388 manage_window_focus_in(mainwin->window, NULL, NULL);
2391 app_will_exit(widget, mainwin);
2394 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2397 summary_search(mainwin->summaryview);
2399 message_search(mainwin->messageview);
2402 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2407 active = GTK_CHECK_MENU_ITEM(widget)->active;
2409 switch (mainwin->type) {
2411 case SEPARATE_MESSAGE:
2414 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2416 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2419 case SEPARATE_FOLDER:
2420 debug_print("separate folder\n");
2422 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2424 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2428 gtk_widget_show(mainwin->win.sep_both.folderwin);
2430 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2434 prefs_common.folderview_visible = active;
2437 static void toggle_message_cb(MainWindow *mainwin, guint action,
2442 active = GTK_CHECK_MENU_ITEM(widget)->active;
2444 if (active != messageview_is_visible(mainwin->messageview))
2445 summary_toggle_view(mainwin->summaryview);
2448 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2451 toolbar_toggle(action, mainwin);
2454 void main_window_reply_cb(MainWindow *mainwin, guint action,
2457 MessageView *msgview = (MessageView*)mainwin->messageview;
2458 GSList *msginfo_list = NULL;
2461 g_return_if_fail(msgview != NULL);
2463 msginfo_list = summary_get_selection(mainwin->summaryview);
2464 g_return_if_fail(msginfo_list != NULL);
2466 body = messageview_get_selection(msgview);
2467 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2469 g_slist_free(msginfo_list);
2473 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2476 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2477 gtk_widget_show(mainwin->hbox_stat);
2478 prefs_common.show_statusbar = TRUE;
2480 gtk_widget_hide(mainwin->hbox_stat);
2481 prefs_common.show_statusbar = FALSE;
2485 static void separate_widget_cb(MainWindow *mainwin, guint action,
2490 if (GTK_CHECK_MENU_ITEM(widget)->active)
2491 type = mainwin->type | action;
2493 type = mainwin->type & ~action;
2495 main_window_separation_change(mainwin, type);
2497 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2498 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2501 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2504 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2506 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2509 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2511 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2514 static void online_switch_clicked (GtkButton *btn, gpointer data)
2516 MainWindow *mainwin;
2517 GtkItemFactory *ifactory;
2518 GtkCheckMenuItem *menuitem;
2520 mainwin = (MainWindow *) data;
2522 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2523 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2525 g_return_if_fail(mainwin != NULL);
2526 g_return_if_fail(menuitem != NULL);
2528 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2530 gtk_widget_hide (mainwin->online_switch);
2531 gtk_widget_show (mainwin->offline_switch);
2532 menuitem->active = TRUE;
2533 prefs_common.work_offline = TRUE;
2534 inc_autocheck_timer_remove();
2537 gtk_widget_hide (mainwin->offline_switch);
2538 gtk_widget_show (mainwin->online_switch);
2539 menuitem->active = FALSE;
2540 prefs_common.work_offline = FALSE;
2541 inc_autocheck_timer_set();
2545 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2548 addressbook_open(NULL);
2551 static void log_window_show_cb(MainWindow *mainwin, guint action,
2554 log_window_show(mainwin->logwin);
2557 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2562 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2564 summary_move_to(mainwin->summaryview);
2567 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2569 summary_copy_to(mainwin->summaryview);
2572 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2574 summary_delete(mainwin->summaryview);
2577 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2579 summary_cancel(mainwin->summaryview);
2582 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2584 summary_open_msg(mainwin->summaryview);
2587 static void view_source_cb(MainWindow *mainwin, guint action,
2590 summary_view_source(mainwin->summaryview);
2593 static void show_all_header_cb(MainWindow *mainwin, guint action,
2596 if (mainwin->menu_lock_count) return;
2597 summary_display_msg_selected(mainwin->summaryview,
2598 GTK_CHECK_MENU_ITEM(widget)->active);
2601 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2603 summary_mark(mainwin->summaryview);
2606 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2608 summary_unmark(mainwin->summaryview);
2611 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2614 summary_mark_as_unread(mainwin->summaryview);
2617 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2620 summary_mark_as_read(mainwin->summaryview);
2623 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2626 summary_mark_all_read(mainwin->summaryview);
2629 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2631 summary_reedit(mainwin->summaryview);
2634 static void add_address_cb(MainWindow *mainwin, guint action,
2637 summary_add_address(mainwin->summaryview);
2640 static void set_charset_cb(MainWindow *mainwin, guint action,
2645 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2646 str = conv_get_charset_str((CharSet)action);
2648 g_free(mainwin->messageview->forced_charset);
2649 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2650 procmime_force_charset(str);
2652 summary_redisplay_msg(mainwin->summaryview);
2654 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2658 static void set_decode_cb(MainWindow *mainwin, guint action,
2661 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2662 mainwin->messageview->forced_encoding = (EncodingType)action;
2664 summary_redisplay_msg(mainwin->summaryview);
2666 debug_print("forced encoding: %d\n", action);
2670 static void hide_read_messages (MainWindow *mainwin, guint action,
2673 if (!mainwin->summaryview->folder_item
2674 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2676 summary_toggle_show_read_messages(mainwin->summaryview);
2679 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2681 if (mainwin->menu_lock_count) return;
2682 if (!mainwin->summaryview->folder_item) return;
2684 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2685 summary_thread_build(mainwin->summaryview);
2686 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2688 summary_unthread(mainwin->summaryview);
2689 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2693 static void expand_threads_cb(MainWindow *mainwin, guint action,
2696 summary_expand_threads(mainwin->summaryview);
2699 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2702 summary_collapse_threads(mainwin->summaryview);
2705 static void set_display_item_cb(MainWindow *mainwin, guint action,
2708 prefs_summary_column_open();
2711 static void sort_summary_cb(MainWindow *mainwin, guint action,
2714 FolderItem *item = mainwin->summaryview->folder_item;
2715 GtkWidget *menuitem;
2717 if (mainwin->menu_lock_count) return;
2719 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2720 menuitem = gtk_item_factory_get_item
2721 (mainwin->menu_factory, "/View/Sort/Ascending");
2722 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2723 GTK_CHECK_MENU_ITEM(menuitem)->active
2724 ? SORT_ASCENDING : SORT_DESCENDING);
2725 item->sort_key = action;
2729 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2732 FolderItem *item = mainwin->summaryview->folder_item;
2734 if (mainwin->menu_lock_count) return;
2736 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2737 summary_sort(mainwin->summaryview,
2738 item->sort_key, (FolderSortType)action);
2741 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2744 summary_attract_by_subject(mainwin->summaryview);
2747 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2752 item = folderview_get_selected(mainwin->folderview);
2754 main_window_cursor_wait(mainwin);
2755 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2757 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2758 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2760 STATUSBAR_POP(mainwin);
2761 main_window_cursor_normal(mainwin);
2771 static void deldup_all(FolderItem *item, gpointer _data)
2773 struct DelDupsData *data = _data;
2776 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2778 data->dups += result;
2783 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2786 struct DelDupsData data = {0, 0};
2788 folder_func_to_all_folders(deldup_all, &data);
2789 alertpanel_notice(_("Deleted %d duplicate message(s) in %d folders.\n"),
2790 data.dups, data.folders);
2793 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2795 summary_filter(mainwin->summaryview, (gboolean)action);
2798 static void execute_summary_cb(MainWindow *mainwin, guint action,
2801 summary_execute(mainwin->summaryview);
2804 static void update_summary_cb(MainWindow *mainwin, guint action,
2808 FolderView *folderview = mainwin->folderview;
2810 if (!mainwin->summaryview->folder_item) return;
2811 if (!folderview->opened) return;
2813 folder_update_op_count();
2815 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2816 folderview->opened);
2819 folder_item_scan(fitem);
2820 summary_show(mainwin->summaryview, fitem);
2823 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2825 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2828 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2830 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2833 static void prev_unread_cb(MainWindow *mainwin, guint action,
2836 summary_select_prev_unread(mainwin->summaryview);
2839 static void next_unread_cb(MainWindow *mainwin, guint action,
2842 summary_select_next_unread(mainwin->summaryview);
2845 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2847 summary_select_prev_new(mainwin->summaryview);
2850 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2852 summary_select_next_new(mainwin->summaryview);
2855 static void prev_marked_cb(MainWindow *mainwin, guint action,
2858 summary_select_prev_marked(mainwin->summaryview);
2861 static void next_marked_cb(MainWindow *mainwin, guint action,
2864 summary_select_next_marked(mainwin->summaryview);
2867 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2870 summary_select_prev_labeled(mainwin->summaryview);
2873 static void next_labeled_cb(MainWindow *mainwin, guint action,
2876 summary_select_next_labeled(mainwin->summaryview);
2879 static void goto_folder_cb(MainWindow *mainwin, guint action,
2882 FolderItem *to_folder;
2884 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2887 folderview_select(mainwin->folderview, to_folder);
2890 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2892 messageview_copy_clipboard(mainwin->messageview);
2895 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2897 MessageView *msgview = mainwin->messageview;
2899 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2900 summary_select_all(mainwin->summaryview);
2901 else if (messageview_is_visible(msgview) &&
2902 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2903 messageview_select_all(mainwin->messageview);
2906 static void select_thread_cb(MainWindow *mainwin, guint action,
2909 summary_select_thread(mainwin->summaryview);
2912 static void create_filter_cb(MainWindow *mainwin, guint action,
2915 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2918 static void create_processing_cb(MainWindow *mainwin, guint action,
2921 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2924 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2927 prefs_common_open();
2930 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2933 prefs_filtering_open(&pre_global_processing,
2934 _("Processing rules to apply before folder rules"),
2938 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2941 prefs_filtering_open(&post_global_processing,
2942 _("Processing rules to apply after folder rules"),
2946 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2949 prefs_filtering_open(&filtering_rules,
2950 _("Filtering configuration"),
2954 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2957 prefs_template_open();
2960 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2963 prefs_actions_open(mainwin);
2966 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2969 ssl_manager_open(mainwin);
2972 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2976 new_account_cb(mainwin, 0, widget);
2978 account_open(cur_account);
2982 static void new_account_cb(MainWindow *mainwin, guint action,
2985 account_edit_open();
2986 if (!compose_get_compose_list()) account_add();
2989 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
2991 cur_account = (PrefsAccount *)data;
2992 main_window_reflect_prefs_all();
2995 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
2997 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
2998 PrefsAccount *account = (PrefsAccount *)data;
3000 inc_account_mail(mainwin, account);
3003 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3008 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3010 pluginwindow_create();
3013 static void manual_open_cb(MainWindow *mainwin, guint action,
3016 manual_open((ManualType)action);
3019 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3021 MainWindow *mainwin = (MainWindow *)data;
3025 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3026 LOCAL_FOLDER(folder)->rootpath,
3030 str = g_strdup_printf(_("Scanning folder %s ..."),
3031 LOCAL_FOLDER(folder)->rootpath);
3033 STATUSBAR_PUSH(mainwin, str);
3034 STATUSBAR_POP(mainwin);
3038 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3041 SummaryView *summary;
3043 g_return_val_if_fail(data, FALSE);
3044 summary = ((MainWindow *)data)->summaryview;
3045 g_return_val_if_fail(summary, FALSE);
3047 if (GTK_CLIST(summary->ctree)->selection &&
3048 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3051 if (summary->selected != summary->displayed)
3052 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3056 #define BREAK_ON_MODIFIER_KEY() \
3057 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3059 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3062 MainWindow *mainwin = (MainWindow*) data;
3064 if (!mainwin || !event)
3067 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3070 switch (event->keyval) {
3071 case GDK_Q: /* Quit */
3072 BREAK_ON_MODIFIER_KEY();
3074 app_exit_cb(mainwin, 0, NULL);
3077 if (mainwin->folderview && mainwin->summaryview
3078 && !mainwin->summaryview->displayed) {
3079 summary_lock(mainwin->summaryview);
3080 folderview_select_next_unread(mainwin->folderview);
3081 summary_unlock(mainwin->summaryview);
3090 #undef BREAK_ON_MODIFIER_KEY
3093 * Harvest addresses for selected folder.
3095 static void addr_harvest_cb( MainWindow *mainwin,
3099 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3103 * Harvest addresses for selected messages in summary view.
3105 static void addr_harvest_msg_cb( MainWindow *mainwin,
3109 summary_harvest_address( mainwin->summaryview );
3113 *\brief get a MainWindow
3115 *\return MainWindow * The first mainwindow in the mainwin_list
3117 MainWindow *mainwindow_get_mainwindow(void)
3119 if (mainwin_list && mainwin_list->data)
3120 return (MainWindow *)(mainwin_list->data);
3125 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3127 ProgressData *data = (ProgressData *) source;
3128 MainWindow *mainwin = (MainWindow *) userdata;
3130 switch (data->cmd) {
3131 case PROGRESS_COMMAND_START:
3132 case PROGRESS_COMMAND_STOP:
3133 gtk_progress_bar_set_fraction
3134 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3136 case PROGRESS_COMMAND_SET_PERCENTAGE:
3137 gtk_progress_bar_set_fraction
3138 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3141 while (gtk_events_pending()) gtk_main_iteration ();