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 hide_read_messages (MainWindow *mainwin,
267 static void thread_cb (MainWindow *mainwin,
270 static void expand_threads_cb (MainWindow *mainwin,
273 static void collapse_threads_cb (MainWindow *mainwin,
277 static void set_display_item_cb (MainWindow *mainwin,
280 static void sort_summary_cb (MainWindow *mainwin,
283 static void sort_summary_type_cb (MainWindow *mainwin,
286 static void attract_by_subject_cb(MainWindow *mainwin,
290 static void delete_duplicated_cb (MainWindow *mainwin,
293 static void delete_duplicated_all_cb (MainWindow *mainwin,
296 static void filter_cb (MainWindow *mainwin,
299 static void execute_summary_cb (MainWindow *mainwin,
302 static void update_summary_cb (MainWindow *mainwin,
306 static void prev_cb (MainWindow *mainwin,
309 static void next_cb (MainWindow *mainwin,
312 static void next_unread_cb (MainWindow *mainwin,
315 static void prev_unread_cb (MainWindow *mainwin,
319 static void prev_new_cb (MainWindow *mainwin,
322 static void next_new_cb (MainWindow *mainwin,
325 static void prev_marked_cb (MainWindow *mainwin,
328 static void next_marked_cb (MainWindow *mainwin,
331 static void prev_labeled_cb (MainWindow *mainwin,
334 static void next_labeled_cb (MainWindow *mainwin,
338 static void goto_folder_cb (MainWindow *mainwin,
342 static void copy_cb (MainWindow *mainwin,
345 static void allsel_cb (MainWindow *mainwin,
348 static void select_thread_cb (MainWindow *mainwin,
352 static void create_filter_cb (MainWindow *mainwin,
355 static void create_processing_cb (MainWindow *mainwin,
359 static void prefs_common_open_cb (MainWindow *mainwin,
362 static void prefs_template_open_cb (MainWindow *mainwin,
365 static void prefs_actions_open_cb (MainWindow *mainwin,
368 static void prefs_account_open_cb (MainWindow *mainwin,
372 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
376 static void prefs_post_processing_open_cb (MainWindow *mainwin,
380 static void prefs_filtering_open_cb (MainWindow *mainwin,
384 static void ssl_manager_open_cb (MainWindow *mainwin,
388 static void new_account_cb (MainWindow *mainwin,
392 static void account_selector_menu_cb (GtkMenuItem *menuitem,
394 static void account_receive_menu_cb (GtkMenuItem *menuitem,
397 static void prefs_open_cb (GtkMenuItem *menuitem,
399 static void plugins_open_cb (GtkMenuItem *menuitem,
402 static void online_switch_clicked(GtkButton *btn,
405 static void manual_open_cb (MainWindow *mainwin,
409 static void scan_tree_func (Folder *folder,
413 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
415 static void addr_harvest_cb ( MainWindow *mainwin,
419 static void addr_harvest_msg_cb ( MainWindow *mainwin,
423 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
424 GdkEventFocus *focus,
426 void main_window_reply_cb (MainWindow *mainwin,
429 gboolean mainwindow_progressindicator_hook (gpointer source,
431 #define SEPARATE_ACTION 500
433 static GtkItemFactoryEntry mainwin_entries[] =
435 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
436 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
437 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
438 {N_("/_File/Change folder order"), NULL, foldersort_cb, 0, NULL},
439 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
440 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
441 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
442 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
443 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
444 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
445 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
446 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
447 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
448 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
449 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
451 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
452 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
453 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
454 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
455 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
456 {N_("/_Edit/_Find in current message..."),
457 "<control>F", search_cb, 0, NULL},
458 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
459 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
460 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
461 {N_("/_View/Show or hi_de/_Folder tree"),
462 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
463 {N_("/_View/Show or hi_de/_Message view"),
464 "V", toggle_message_cb, 0, "<ToggleItem>"},
465 {N_("/_View/Show or hi_de/_Toolbar"),
466 NULL, NULL, 0, "<Branch>"},
467 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
468 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
469 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
470 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
471 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
472 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
473 {N_("/_View/Show or hi_de/_Toolbar/_None"),
474 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
475 {N_("/_View/Show or hi_de/Status _bar"),
476 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
477 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
479 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
480 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
481 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
482 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
483 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
484 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
485 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
486 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
487 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
488 {N_("/_View/_Sort/by _color label"),
489 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
490 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
491 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
492 {N_("/_View/_Sort/by a_ttachment"),
493 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
494 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
495 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
496 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
497 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
498 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
499 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
500 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
501 {N_("/_View/_Sort/_Attract by subject"),
502 NULL, attract_by_subject_cb, 0, NULL},
503 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
504 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
505 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
506 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
507 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
509 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
511 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
512 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
513 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_View/_Go to/P_rev unread message"),
515 "<shift>P", prev_unread_cb, 0, NULL},
516 {N_("/_View/_Go to/N_ext unread message"),
517 "<shift>N", next_unread_cb, 0, NULL},
518 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
520 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
521 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
522 {N_("/_View/_Go to/Prev _marked message"),
523 NULL, prev_marked_cb, 0, NULL},
524 {N_("/_View/_Go to/Next m_arked message"),
525 NULL, next_marked_cb, 0, NULL},
526 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
527 {N_("/_View/_Go to/Prev _labeled message"),
528 NULL, prev_labeled_cb, 0, NULL},
529 {N_("/_View/_Go to/Next la_beled message"),
530 NULL, next_labeled_cb, 0, NULL},
531 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
532 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
533 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
535 #define CODESET_SEPARATOR \
536 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
537 #define CODESET_ACTION(action) \
538 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
540 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
541 {N_("/_View/_Code set/_Auto detect"),
542 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
543 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
545 CODESET_ACTION(C_US_ASCII)},
548 {N_("/_View/_Code set/Unicode (_UTF-8)"),
549 CODESET_ACTION(C_UTF_8)},
552 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
553 CODESET_ACTION(C_ISO_8859_1)},
554 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
555 CODESET_ACTION(C_ISO_8859_15)},
558 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
559 CODESET_ACTION(C_ISO_8859_2)},
561 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
562 CODESET_ACTION(C_ISO_8859_13)},
563 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
564 CODESET_ACTION(C_ISO_8859_4)},
566 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
567 CODESET_ACTION(C_ISO_8859_7)},
569 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
570 CODESET_ACTION(C_ISO_8859_9)},
572 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
573 CODESET_ACTION(C_ISO_8859_5)},
574 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
575 CODESET_ACTION(C_KOI8_R)},
576 {N_("/_View/_Code set/Cyrillic (KOI8-U)"),
577 CODESET_ACTION(C_KOI8_U)},
578 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
579 CODESET_ACTION(C_WINDOWS_1251)},
582 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
583 CODESET_ACTION(C_ISO_2022_JP)},
585 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
586 CODESET_ACTION(C_ISO_2022_JP_2)},
588 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
589 CODESET_ACTION(C_EUC_JP)},
590 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
591 CODESET_ACTION(C_SHIFT_JIS)},
594 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
595 CODESET_ACTION(C_GB2312)},
596 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
597 CODESET_ACTION(C_BIG5)},
598 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
599 CODESET_ACTION(C_EUC_TW)},
600 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
601 CODESET_ACTION(C_ISO_2022_CN)},
603 {N_("/_View/_Code set/Korean (EUC-_KR)"),
604 CODESET_ACTION(C_EUC_KR)},
605 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
606 CODESET_ACTION(C_ISO_2022_KR)},
608 {N_("/_View/_Code set/Thai (TIS-620)"),
609 CODESET_ACTION(C_TIS_620)},
610 {N_("/_View/_Code set/Thai (Windows-874)"),
611 CODESET_ACTION(C_WINDOWS_874)},
614 #undef CODESET_SEPARATOR
615 #undef CODESET_ACTION
617 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
619 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
620 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
621 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
624 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
625 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
626 {N_("/_Message/Recei_ve/Get from _current account"),
627 "<control>I", inc_mail_cb, 0, NULL},
628 {N_("/_Message/Recei_ve/Get from _all accounts"),
629 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
630 {N_("/_Message/Recei_ve/Cancel receivin_g"),
631 NULL, inc_cancel_cb, 0, NULL},
632 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
633 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
634 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
636 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
637 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
638 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
639 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
640 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
641 {N_("/_Message/Repl_y to/mailing _list"),
642 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
643 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
644 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
646 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
647 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
649 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
650 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
651 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
652 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
654 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
655 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
656 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
658 {N_("/_Message/_Mark/Mark as rea_d"),
659 NULL, mark_as_read_cb, 0, NULL},
660 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
661 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
664 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
665 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
666 {N_("/_Tools/Add sender to address boo_k"),
667 NULL, add_address_cb, 0, NULL},
668 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
669 {N_("/_Tools/_Harvest addresses/from _Folder..."),
670 NULL, addr_harvest_cb, 0, NULL},
671 {N_("/_Tools/_Harvest addresses/from _Messages..."),
672 NULL, addr_harvest_msg_cb, 0, NULL},
673 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Tools/_Filter all messages in folder"),
675 NULL, filter_cb, 0, NULL},
676 {N_("/_Tools/Filter _selected messages"),
677 NULL, filter_cb, 1, NULL},
678 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
679 {N_("/_Tools/_Create filter rule/_Automatically"),
680 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
681 {N_("/_Tools/_Create filter rule/by _From"),
682 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
683 {N_("/_Tools/_Create filter rule/by _To"),
684 NULL, create_filter_cb, FILTER_BY_TO, NULL},
685 {N_("/_Tools/_Create filter rule/by _Subject"),
686 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
687 {N_("/_Tools/_Create processing rule"), NULL, NULL, 0, "<Branch>"},
688 {N_("/_Tools/_Create processing rule/_Automatically"),
689 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
690 {N_("/_Tools/_Create processing rule/by _From"),
691 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
692 {N_("/_Tools/_Create processing rule/by _To"),
693 NULL, create_processing_cb, FILTER_BY_TO, NULL},
694 {N_("/_Tools/_Create processing rule/by _Subject"),
695 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
696 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
697 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
698 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Tools/_Check for new messages in all folders"),
700 NULL, update_folderview_cb, 0, NULL},
701 {N_("/_Tools/Delete du_plicated messages"),
702 NULL, NULL, 0, "<Branch>"},
703 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
704 NULL, delete_duplicated_cb, 0, NULL},
705 {N_("/_Tools/Delete du_plicated messages/In all folders"),
706 NULL, delete_duplicated_all_cb, 0, NULL},
707 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
710 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
711 {N_("/_Tools/SSL certi_ficates..."),
712 NULL, ssl_manager_open_cb, 0, NULL},
714 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
715 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
717 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_Configuration/C_hange current account"),
719 NULL, NULL, 0, "<Branch>"},
720 {N_("/_Configuration/_Preferences for current account..."),
721 NULL, prefs_account_open_cb, 0, NULL},
722 {N_("/_Configuration/Create _new account..."),
723 NULL, new_account_cb, 0, NULL},
724 {N_("/_Configuration/_Edit accounts..."),
725 NULL, account_edit_open, 0, NULL},
726 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Configuration/_Common preferences..."),
728 NULL, prefs_common_open_cb, 0, NULL},
729 {N_("/_Configuration/Pre-processing..."),
730 NULL, prefs_pre_processing_open_cb, 0, NULL},
731 {N_("/_Configuration/Post-processing..."),
732 NULL, prefs_post_processing_open_cb, 0, NULL},
733 {N_("/_Configuration/_Filtering..."),
734 NULL, prefs_filtering_open_cb, 0, NULL},
735 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
736 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
737 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
738 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
740 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
741 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
742 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
743 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
744 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
745 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
746 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
747 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
748 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
749 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
750 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
753 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
759 MainWindow *mainwin = (MainWindow *)user_data;
761 if (mainwin->summaryview &&
762 mainwin->summaryview->quicksearch &&
763 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
764 (mod == 0 || mod == GDK_SHIFT_MASK)) {
765 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
771 MainWindow *main_window_create(SeparateType type)
777 GtkWidget *handlebox;
778 GtkWidget *vbox_body;
779 GtkWidget *hbox_stat;
780 GtkWidget *statusbar;
781 GtkWidget *progressbar;
782 GtkWidget *statuslabel;
783 GtkWidget *ac_button;
785 GtkWidget *online_pixmap;
786 GtkWidget *offline_pixmap;
787 GtkWidget *online_switch;
788 GtkWidget *offline_switch;
789 GtkTooltips *offline_tip;
790 GtkTooltips *online_tip;
791 GtkTooltips *sel_ac_tip;
793 FolderView *folderview;
794 SummaryView *summaryview;
795 MessageView *messageview;
796 GdkColormap *colormap;
799 GtkItemFactory *ifactory;
803 guint n_menu_entries;
805 static GdkGeometry geometry;
807 debug_print("Creating main window...\n");
808 mainwin = g_new0(MainWindow, 1);
811 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
812 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
813 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
814 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
816 if (!geometry.min_height) {
817 geometry.min_width = 320;
818 geometry.min_height = 200;
820 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
823 g_signal_connect(G_OBJECT(window), "delete_event",
824 G_CALLBACK(main_window_close_cb), mainwin);
825 MANAGE_WINDOW_SIGNALS_CONNECT(window);
826 g_signal_connect(G_OBJECT(window), "focus_in_event",
827 G_CALLBACK(mainwindow_focus_in_event),
829 g_signal_connect(G_OBJECT(window), "key_press_event",
830 G_CALLBACK(mainwindow_key_pressed), mainwin);
832 gtk_widget_realize(window);
833 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
836 gtkut_widget_set_app_icon(window);
838 vbox = gtk_vbox_new(FALSE, 0);
839 gtk_widget_show(vbox);
840 gtk_container_add(GTK_CONTAINER(window), vbox);
843 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
844 menubar = menubar_create(window, mainwin_entries,
845 n_menu_entries, "<Main>", mainwin);
846 gtk_widget_show(menubar);
847 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
848 ifactory = gtk_item_factory_from_widget(menubar);
850 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
851 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
853 handlebox = gtk_handle_box_new();
854 gtk_widget_show(handlebox);
855 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
856 g_signal_connect(G_OBJECT(handlebox), "child_attached",
857 G_CALLBACK(toolbar_child_attached), mainwin);
858 g_signal_connect(G_OBJECT(handlebox), "child_detached",
859 G_CALLBACK(toolbar_child_detached), mainwin);
861 /* link window to mainwin->window to avoid gdk warnings */
862 mainwin->window = window;
865 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
869 /* vbox that contains body */
870 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
871 gtk_widget_show(vbox_body);
872 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
873 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
875 hbox_stat = gtk_hbox_new(FALSE, 2);
876 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
878 statusbar = statusbar_create();
879 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
881 progressbar = gtk_progress_bar_new();
882 gtk_widget_set_size_request(progressbar, 120, 1);
883 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
885 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
886 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
887 online_tip = gtk_tooltips_new();
888 online_switch = gtk_button_new ();
889 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
890 _("You are online. Click the icon to go offline"), NULL);
891 offline_tip = gtk_tooltips_new();
892 offline_switch = gtk_button_new ();
893 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
894 _("You are offline. Click the icon to go online"),
896 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
897 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
898 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
899 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
900 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
901 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
902 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
903 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
905 statuslabel = gtk_label_new("");
906 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
908 sel_ac_tip = gtk_tooltips_new();
909 ac_button = gtk_button_new();
910 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
911 ac_button, _("Select account"), NULL);
912 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
913 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
914 gtk_widget_set_size_request(ac_button, -1, 0);
915 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
916 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
917 G_CALLBACK(ac_label_button_pressed), mainwin);
919 ac_label = gtk_label_new("");
920 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
922 gtk_widget_show_all(hbox_stat);
924 gtk_widget_hide(offline_switch);
926 mainwin->folderview = folderview = folderview_create();
927 mainwin->summaryview = summaryview = summary_create();
928 mainwin->messageview = messageview = messageview_create(mainwin);
929 mainwin->logwin = log_window_create();
931 folderview->mainwin = mainwin;
932 folderview->summaryview = summaryview;
934 summaryview->mainwin = mainwin;
935 summaryview->folderview = folderview;
936 summaryview->messageview = messageview;
937 summaryview->window = window;
939 messageview->statusbar = statusbar;
940 mainwin->vbox = vbox;
941 mainwin->menubar = menubar;
942 mainwin->menu_factory = ifactory;
943 mainwin->handlebox = handlebox;
944 mainwin->vbox_body = vbox_body;
945 mainwin->hbox_stat = hbox_stat;
946 mainwin->statusbar = statusbar;
947 mainwin->progressbar = progressbar;
948 mainwin->statuslabel = statuslabel;
949 mainwin->online_switch = online_switch;
950 mainwin->online_pixmap = online_pixmap;
951 mainwin->offline_pixmap = offline_pixmap;
952 mainwin->ac_button = ac_button;
953 mainwin->ac_label = ac_label;
954 mainwin->offline_switch = offline_switch;
956 /* set context IDs for status bar */
957 mainwin->mainwin_cid = gtk_statusbar_get_context_id
958 (GTK_STATUSBAR(statusbar), "Main Window");
959 mainwin->folderview_cid = gtk_statusbar_get_context_id
960 (GTK_STATUSBAR(statusbar), "Folder View");
961 mainwin->summaryview_cid = gtk_statusbar_get_context_id
962 (GTK_STATUSBAR(statusbar), "Summary View");
963 mainwin->messageview_cid = gtk_statusbar_get_context_id
964 (GTK_STATUSBAR(statusbar), "Message View");
966 messageview->statusbar_cid = mainwin->messageview_cid;
968 /* allocate colors for summary view and folder view */
969 summaryview->color_marked.red = summaryview->color_marked.green = 0;
970 summaryview->color_marked.blue = (guint16)65535;
972 summaryview->color_dim.red = summaryview->color_dim.green =
973 summaryview->color_dim.blue = COLOR_DIM;
975 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
976 &folderview->color_new);
978 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
979 &folderview->color_op);
981 summaryview->color_important.red = 0;
982 summaryview->color_important.green = 0;
983 summaryview->color_important.blue = (guint16)65535;
985 color[0] = summaryview->color_marked;
986 color[1] = summaryview->color_dim;
987 color[2] = folderview->color_new;
988 color[3] = folderview->color_op;
990 colormap = gdk_window_get_colormap(window->window);
991 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
992 for (i = 0; i < 4; i++) {
993 if (success[i] == FALSE)
994 g_warning("MainWindow: color allocation %d failed\n", i);
997 debug_print("done.\n");
999 messageview->visible = prefs_common.msgview_visible;
1001 main_window_set_widgets(mainwin, type);
1003 g_signal_connect(G_OBJECT(window), "size_allocate",
1004 G_CALLBACK(main_window_size_allocate_cb),
1007 /* set menu items */
1008 menuitem = gtk_item_factory_get_item
1009 (ifactory, "/View/Code set/Auto detect");
1010 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1012 switch (prefs_common.toolbar_style) {
1014 menuitem = gtk_item_factory_get_item
1015 (ifactory, "/View/Show or hide/Toolbar/None");
1018 menuitem = gtk_item_factory_get_item
1019 (ifactory, "/View/Show or hide/Toolbar/Icon");
1022 menuitem = gtk_item_factory_get_item
1023 (ifactory, "/View/Show or hide/Toolbar/Text");
1026 menuitem = gtk_item_factory_get_item
1027 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1029 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1031 gtk_widget_hide(mainwin->hbox_stat);
1032 menuitem = gtk_item_factory_get_item
1033 (ifactory, "/View/Show or hide/Status bar");
1034 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1035 prefs_common.show_statusbar);
1037 /* set account selection menu */
1038 ac_menu = gtk_item_factory_get_widget
1039 (ifactory, "/Configuration/Change current account");
1040 g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1041 G_CALLBACK(ac_menu_popup_closed), mainwin);
1042 mainwin->ac_menu = ac_menu;
1044 toolbar_main_set_sensitive(mainwin);
1046 /* create actions menu */
1047 main_window_update_actions_menu(mainwin);
1049 /* attach accel groups to main window */
1050 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1051 gtk_window_add_accel_group \
1053 gtk_item_factory_from_widget(menu)->accel_group); \
1054 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1056 G_CALLBACK(main_window_accel_activate), mainwin);
1059 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1061 /* connect the accelerators for equivalent
1062 menu items in different menus */
1063 menu_connect_identical_items();
1067 /* show main window */
1068 gtk_widget_show(mainwin->window);
1070 /* initialize views */
1071 folderview_init(folderview);
1072 summary_init(summaryview);
1073 messageview_init(messageview);
1074 log_window_init(mainwin->logwin);
1075 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1076 prefs_common.loglength);
1078 sslcertwindow_register_hook();
1080 mainwin->lock_count = 0;
1081 mainwin->menu_lock_count = 0;
1082 mainwin->cursor_count = 0;
1084 mainwin->progressindicator_hook =
1085 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1088 watch_cursor = gdk_cursor_new(GDK_WATCH);
1090 mainwin_list = g_list_append(mainwin_list, mainwin);
1092 /* init work_offline */
1093 if (prefs_common.work_offline)
1094 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1099 void main_window_destroy(MainWindow *mainwin)
1101 /* TODO : destroy other component */
1102 messageview_destroy(mainwin->messageview);
1105 void main_window_update_actions_menu(MainWindow *mainwin)
1107 GtkItemFactory *ifactory;
1109 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1110 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1113 void main_window_cursor_wait(MainWindow *mainwin)
1116 if (mainwin->cursor_count == 0)
1117 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1119 mainwin->cursor_count++;
1124 void main_window_cursor_normal(MainWindow *mainwin)
1126 if (mainwin->cursor_count)
1127 mainwin->cursor_count--;
1129 if (mainwin->cursor_count == 0)
1130 gdk_window_set_cursor(mainwin->window->window, NULL);
1135 /* lock / unlock the user-interface */
1136 void main_window_lock(MainWindow *mainwin)
1138 if (mainwin->lock_count == 0)
1139 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1141 mainwin->lock_count++;
1143 main_window_set_menu_sensitive(mainwin);
1144 toolbar_main_set_sensitive(mainwin);
1147 void main_window_unlock(MainWindow *mainwin)
1149 if (mainwin->lock_count)
1150 mainwin->lock_count--;
1152 main_window_set_menu_sensitive(mainwin);
1153 toolbar_main_set_sensitive(mainwin);
1155 if (mainwin->lock_count == 0)
1156 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1159 static void main_window_menu_callback_block(MainWindow *mainwin)
1161 mainwin->menu_lock_count++;
1164 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1166 if (mainwin->menu_lock_count)
1167 mainwin->menu_lock_count--;
1170 void main_window_reflect_prefs_all(void)
1172 main_window_reflect_prefs_all_real(FALSE);
1175 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1178 MainWindow *mainwin;
1181 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1182 mainwin = (MainWindow *)cur->data;
1184 main_window_show_cur_account(mainwin);
1185 main_window_set_menu_sensitive(mainwin);
1186 toolbar_main_set_sensitive(mainwin);
1189 if (pixmap_theme_changed) {
1190 toolbar_update(TOOLBAR_MAIN, mainwin);
1191 messageview_reflect_prefs_pixmap_theme();
1192 compose_reflect_prefs_pixmap_theme();
1193 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1194 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1196 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1197 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1198 mainwin->online_pixmap);
1199 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1200 gtk_widget_show(pixmap);
1201 mainwin->online_pixmap = pixmap;
1202 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1203 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1204 mainwin->offline_pixmap);
1205 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1206 gtk_widget_show(pixmap);
1207 mainwin->offline_pixmap = pixmap;
1210 summary_redisplay_msg(mainwin->summaryview);
1211 headerview_set_visibility(mainwin->messageview->headerview,
1212 prefs_common.display_header_pane);
1216 void main_window_set_summary_column(void)
1219 MainWindow *mainwin;
1221 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1222 mainwin = (MainWindow *)cur->data;
1223 summary_set_column_order(mainwin->summaryview);
1227 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1228 GList *account_list)
1230 GList *cur_ac, *cur_item;
1231 GtkWidget *menuitem;
1232 PrefsAccount *ac_prefs;
1234 /* destroy all previous menu item */
1235 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1236 while (cur_item != NULL) {
1237 GList *next = cur_item->next;
1238 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1242 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1243 ac_prefs = (PrefsAccount *)cur_ac->data;
1245 menuitem = gtk_menu_item_new_with_label
1246 (ac_prefs->account_name
1247 ? ac_prefs->account_name : _("Untitled"));
1248 gtk_widget_show(menuitem);
1249 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1250 g_signal_connect(G_OBJECT(menuitem), "activate",
1251 G_CALLBACK(account_selector_menu_cb),
1256 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1257 GList *account_list)
1259 GList *cur_ac, *cur_item;
1261 GtkWidget *menuitem;
1262 PrefsAccount *ac_prefs;
1264 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1265 "/Message/Receive");
1267 /* search for separator */
1268 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1269 cur_item = cur_item->next) {
1270 if (GTK_BIN(cur_item->data)->child == NULL) {
1271 cur_item = cur_item->next;
1276 /* destroy all previous menu item */
1277 while (cur_item != NULL) {
1278 GList *next = cur_item->next;
1279 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1283 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1284 ac_prefs = (PrefsAccount *)cur_ac->data;
1286 menuitem = gtk_menu_item_new_with_label
1287 (ac_prefs->account_name ? ac_prefs->account_name
1289 gtk_widget_show(menuitem);
1290 gtk_menu_append(GTK_MENU(menu), menuitem);
1291 g_signal_connect(G_OBJECT(menuitem), "activate",
1292 G_CALLBACK(account_receive_menu_cb),
1297 void main_window_set_account_menu(GList *account_list)
1300 MainWindow *mainwin;
1302 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1303 mainwin = (MainWindow *)cur->data;
1304 main_window_set_account_selector_menu(mainwin, account_list);
1305 main_window_set_account_receive_menu(mainwin, account_list);
1309 static void main_window_show_cur_account(MainWindow *mainwin)
1314 ac_name = g_strdup(cur_account
1315 ? (cur_account->account_name
1316 ? cur_account->account_name : _("Untitled"))
1320 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1322 buf = g_strdup(PROG_VERSION);
1323 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1326 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1327 gtk_widget_queue_resize(mainwin->ac_button);
1332 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1334 switch (mainwin->type) {
1335 case SEPARATE_FOLDER:
1336 return mainwin->win.sep_folder.folderwin;
1338 return mainwin->win.sep_both.folderwin;
1344 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1346 switch (mainwin->type) {
1347 case SEPARATE_MESSAGE:
1348 return mainwin->win.sep_message.messagewin;
1350 return mainwin->win.sep_both.messagewin;
1356 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1358 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1359 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1360 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1361 GtkWidget *message_wid = mainwin->messageview->vbox;
1363 debug_print("Changing window separation type from %d to %d\n",
1364 mainwin->type, type);
1366 if (mainwin->type == type) return;
1368 /* remove widgets from those containers */
1369 gtk_widget_ref(folder_wid);
1370 gtk_widget_ref(summary_wid);
1371 gtk_widget_ref(message_wid);
1372 gtkut_container_remove
1373 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1374 gtkut_container_remove
1375 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1376 gtkut_container_remove
1377 (GTK_CONTAINER(message_wid->parent), message_wid);
1379 /* clean containers */
1380 switch (mainwin->type) {
1382 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1384 case SEPARATE_FOLDER:
1385 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1386 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1388 case SEPARATE_MESSAGE:
1389 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1390 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1393 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1394 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1398 gtk_widget_hide(mainwin->window);
1399 main_window_set_widgets(mainwin, type);
1400 gtk_widget_show(mainwin->window);
1402 gtk_widget_unref(folder_wid);
1403 gtk_widget_unref(summary_wid);
1404 gtk_widget_unref(message_wid);
1407 void main_window_toggle_message_view(MainWindow *mainwin)
1409 SummaryView *summaryview = mainwin->summaryview;
1410 union CompositeWin *cwin = &mainwin->win;
1411 GtkWidget *vpaned = NULL;
1412 GtkWidget *container = NULL;
1413 GtkWidget *msgwin = NULL;
1415 switch (mainwin->type) {
1417 vpaned = cwin->sep_none.vpaned;
1418 container = cwin->sep_none.hpaned;
1420 case SEPARATE_FOLDER:
1421 vpaned = cwin->sep_folder.vpaned;
1422 container = mainwin->vbox_body;
1424 case SEPARATE_MESSAGE:
1425 msgwin = mainwin->win.sep_message.messagewin;
1428 msgwin = mainwin->win.sep_both.messagewin;
1433 if (GTK_WIDGET_VISIBLE(msgwin)) {
1434 gtk_widget_hide(msgwin);
1435 mainwin->messageview->visible = FALSE;
1436 summaryview->displayed = NULL;
1438 gtk_widget_show(msgwin);
1439 mainwin->messageview->visible = TRUE;
1441 } else if (vpaned->parent != NULL) {
1442 mainwin->messageview->visible = FALSE;
1443 summaryview->displayed = NULL;
1444 gtk_widget_ref(vpaned);
1445 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1446 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1447 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1448 GTK_ARROW_UP, GTK_SHADOW_OUT);
1450 mainwin->messageview->visible = TRUE;
1451 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1452 gtk_container_add(GTK_CONTAINER(container), vpaned);
1453 gtk_widget_unref(vpaned);
1454 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1455 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1458 if (mainwin->messageview->visible == FALSE)
1459 messageview_clear(mainwin->messageview);
1461 main_window_set_menu_sensitive(mainwin);
1463 prefs_common.msgview_visible = mainwin->messageview->visible;
1465 gtk_widget_grab_focus(summaryview->ctree);
1468 void main_window_get_size(MainWindow *mainwin)
1470 GtkAllocation *allocation;
1472 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1474 if (allocation->width > 1 && allocation->height > 1) {
1475 prefs_common.summaryview_width = allocation->width;
1477 if ((mainwin->type == SEPARATE_NONE ||
1478 mainwin->type == SEPARATE_FOLDER) &&
1479 messageview_is_visible(mainwin->messageview))
1480 prefs_common.summaryview_height = allocation->height;
1482 prefs_common.mainview_width = allocation->width;
1485 allocation = &mainwin->window->allocation;
1486 if (allocation->width > 1 && allocation->height > 1) {
1487 prefs_common.mainview_height = allocation->height;
1488 prefs_common.mainwin_width = allocation->width;
1489 prefs_common.mainwin_height = allocation->height;
1492 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1493 if (allocation->width > 1 && allocation->height > 1) {
1494 prefs_common.folderview_width = allocation->width;
1495 prefs_common.folderview_height = allocation->height;
1498 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1499 if (allocation->width > 1 && allocation->height > 1) {
1500 prefs_common.msgview_width = allocation->width;
1501 prefs_common.msgview_height = allocation->height;
1504 /* debug_print("summaryview size: %d x %d\n",
1505 prefs_common.summaryview_width,
1506 prefs_common.summaryview_height);
1507 debug_print("folderview size: %d x %d\n",
1508 prefs_common.folderview_width,
1509 prefs_common.folderview_height);
1510 debug_print("messageview size: %d x %d\n",
1511 prefs_common.msgview_width,
1512 prefs_common.msgview_height); */
1515 void main_window_get_position(MainWindow *mainwin)
1520 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1522 prefs_common.mainview_x = x;
1523 prefs_common.mainview_y = y;
1524 prefs_common.mainwin_x = x;
1525 prefs_common.mainwin_y = y;
1527 debug_print("main window position: %d, %d\n", x, y);
1529 window = main_window_get_folder_window(mainwin);
1531 gtkut_widget_get_uposition(window, &x, &y);
1532 prefs_common.folderwin_x = x;
1533 prefs_common.folderwin_y = y;
1534 debug_print("folder window position: %d, %d\n", x, y);
1536 window = main_window_get_message_window(mainwin);
1538 gtkut_widget_get_uposition(window, &x, &y);
1539 prefs_common.main_msgwin_x = x;
1540 prefs_common.main_msgwin_y = y;
1541 debug_print("message window position: %d, %d\n", x, y);
1545 void main_window_progress_on(MainWindow *mainwin)
1547 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE);
1548 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1551 void main_window_progress_off(MainWindow *mainwin)
1553 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE);
1554 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1555 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1558 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1562 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1563 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf);
1564 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar),
1565 (cur == 0 && total == 0) ? 0 :
1566 (gfloat)cur / (gfloat)total);
1569 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1575 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1576 folder = FOLDER(list->data);
1577 if (folder && folder->trash && folder->trash->total_msgs > 0)
1581 if (!has_trash) return;
1584 if (alertpanel(_("Empty trash"),
1585 _("Empty all messages in trash?"),
1586 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1588 manage_window_focus_in(mainwin->window, NULL, NULL);
1591 procmsg_empty_trash();
1593 if (mainwin->summaryview->folder_item &&
1594 mainwin->summaryview->folder_item->stype == F_TRASH)
1595 gtk_widget_grab_focus(mainwin->folderview->ctree);
1598 void main_window_add_mailbox(MainWindow *mainwin)
1603 path = input_dialog(_("Add mailbox"),
1604 _("Input the location of mailbox.\n"
1605 "If the existing mailbox is specified, it will be\n"
1606 "scanned automatically."),
1609 if (folder_find_from_path(path)) {
1610 alertpanel_error(_("The mailbox `%s' already exists."), path);
1614 folder = folder_new(folder_get_class_from_string("mh"),
1615 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1619 if (folder->klass->create_tree(folder) < 0) {
1620 alertpanel_error(_("Creation of the mailbox failed.\n"
1621 "Maybe some files already exist, or you don't have the permission to write there."));
1622 folder_destroy(folder);
1627 folder_set_ui_func(folder, scan_tree_func, mainwin);
1628 folder_scan_tree(folder);
1629 folder_set_ui_func(folder, NULL, NULL);
1632 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1634 SensitiveCond state = 0;
1635 SummarySelection selection;
1636 FolderItem *item = mainwin->summaryview->folder_item;
1637 GList *account_list = account_get_list();
1639 selection = summary_get_selection_type(mainwin->summaryview);
1641 if (mainwin->lock_count == 0)
1642 state |= M_UNLOCKED;
1643 if (selection != SUMMARY_NONE)
1644 state |= M_MSG_EXIST;
1645 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1647 /* if (item->folder->type != F_NEWS) */
1648 state |= M_ALLOW_DELETE;
1650 if (prefs_common.immediate_exec == 0
1651 && mainwin->lock_count == 0)
1652 state |= M_DELAY_EXEC;
1654 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1655 || selection != SUMMARY_NONE)
1656 state |= M_HIDE_READ_MSG;
1658 if (mainwin->summaryview->threaded)
1659 state |= M_THREADED;
1661 state |= M_UNTHREADED;
1662 if (selection == SUMMARY_SELECTED_SINGLE ||
1663 selection == SUMMARY_SELECTED_MULTIPLE)
1664 state |= M_TARGET_EXIST;
1665 if (selection == SUMMARY_SELECTED_SINGLE)
1666 state |= M_SINGLE_TARGET_EXIST;
1667 if (mainwin->summaryview->folder_item &&
1668 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1671 state |= M_NOT_NEWS;
1672 if (selection == SUMMARY_SELECTED_SINGLE &&
1674 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1675 item->stype == F_QUEUE)))
1676 state |= M_ALLOW_REEDIT;
1678 state |= M_HAVE_ACCOUNT;
1680 for ( ; account_list != NULL; account_list = account_list->next) {
1681 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1682 state |= M_HAVE_NEWS_ACCOUNT;
1687 if (inc_is_active())
1688 state |= M_INC_ACTIVE;
1695 void main_window_set_menu_sensitive(MainWindow *mainwin)
1697 GtkItemFactory *ifactory = mainwin->menu_factory;
1698 SensitiveCond state;
1701 GtkWidget *menuitem;
1702 SummaryView *summaryview;
1707 static const struct {
1711 {"/File/Add mailbox" , M_UNLOCKED},
1713 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1714 {"/File/Change folder order" , M_UNLOCKED},
1715 {"/File/Export to mbox file..." , M_UNLOCKED},
1716 {"/File/Empty trash" , M_UNLOCKED},
1717 {"/File/Work offline" , M_UNLOCKED},
1719 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1720 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1721 /* {"/File/Close" , M_UNLOCKED}, */
1722 {"/File/Exit" , M_UNLOCKED},
1724 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1726 {"/View/Sort" , M_EXEC},
1727 {"/View/Thread view" , M_EXEC},
1728 {"/View/Expand all threads" , M_MSG_EXIST},
1729 {"/View/Collapse all threads" , M_MSG_EXIST},
1730 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1731 {"/View/Go to/Prev message" , M_MSG_EXIST},
1732 {"/View/Go to/Next message" , M_MSG_EXIST},
1733 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1734 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1735 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1736 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1737 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1738 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1739 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1740 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1741 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1743 {"/Message/Receive/Get from current account"
1744 , M_HAVE_ACCOUNT|M_UNLOCKED},
1745 {"/Message/Receive/Get from all accounts"
1746 , M_HAVE_ACCOUNT|M_UNLOCKED},
1747 {"/Message/Receive/Cancel receiving"
1750 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1751 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1752 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1753 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1754 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1755 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1756 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1757 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1758 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1759 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1760 {"/Message/Mark" , M_TARGET_EXIST},
1761 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1763 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1764 {"/Tools/Harvest addresses" , M_UNLOCKED},
1765 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1766 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1767 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1768 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1769 {"/Tools/Execute" , M_DELAY_EXEC},
1770 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1772 {"/Configuration", M_UNLOCKED},
1777 state = main_window_get_current_state(mainwin);
1779 for (i = 0; entry[i].entry != NULL; i++) {
1780 sensitive = ((entry[i].cond & state) == entry[i].cond);
1781 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1784 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1786 /* search for separator */
1787 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1788 cur_item = cur_item->next) {
1789 if (GTK_BIN(cur_item->data)->child == NULL) {
1790 cur_item = cur_item->next;
1795 for (; cur_item != NULL; cur_item = cur_item->next) {
1796 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1797 (M_UNLOCKED & state) != 0);
1800 main_window_menu_callback_block(mainwin);
1802 #define SET_CHECK_MENU_ACTIVE(path, active) \
1804 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1805 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1808 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1809 messageview_is_visible(mainwin->messageview));
1811 summaryview = mainwin->summaryview;
1812 menu_path = "/View/Sort/Don't sort";
1814 switch (summaryview->sort_key) {
1815 case SORT_BY_NUMBER:
1816 menu_path = "/View/Sort/by number"; break;
1818 menu_path = "/View/Sort/by size"; break;
1820 menu_path = "/View/Sort/by date"; break;
1822 menu_path = "/View/Sort/by from"; break;
1824 menu_path = "/View/Sort/by recipient"; break;
1825 case SORT_BY_SUBJECT:
1826 menu_path = "/View/Sort/by subject"; break;
1828 menu_path = "/View/Sort/by color label"; break;
1830 menu_path = "/View/Sort/by mark"; break;
1831 case SORT_BY_STATUS:
1832 menu_path = "/View/Sort/by status"; break;
1834 menu_path = "/View/Sort/by attachment"; break;
1836 menu_path = "/View/Sort/by score"; break;
1837 case SORT_BY_LOCKED:
1838 menu_path = "/View/Sort/by locked"; break;
1841 menu_path = "/View/Sort/Don't sort"; break;
1843 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1845 if (summaryview->sort_type == SORT_ASCENDING) {
1846 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1848 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1851 if (summaryview->sort_key != SORT_BY_NONE) {
1852 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1853 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1855 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1856 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1859 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1860 mainwin->messageview->mimeview->textview->show_all_headers);
1861 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1863 #undef SET_CHECK_MENU_ACTIVE
1865 main_window_menu_callback_unblock(mainwin);
1868 void main_window_popup(MainWindow *mainwin)
1870 gtkut_window_popup(mainwin->window);
1872 switch (mainwin->type) {
1873 case SEPARATE_FOLDER:
1874 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1876 case SEPARATE_MESSAGE:
1877 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1880 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1881 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1888 void main_window_show(MainWindow *mainwin)
1890 gtk_widget_show(mainwin->window);
1891 gtk_widget_show(mainwin->vbox_body);
1893 gtk_widget_set_uposition(mainwin->window,
1894 prefs_common.mainwin_x,
1895 prefs_common.mainwin_y);
1897 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1898 prefs_common.folderview_width,
1899 prefs_common.folderview_height);
1900 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1901 prefs_common.summaryview_width,
1902 prefs_common.summaryview_height);
1903 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1904 prefs_common.msgview_width,
1905 prefs_common.msgview_height);
1907 if (mainwin->type & SEPARATE_FOLDER) {
1908 GtkWidget *folderwin;
1910 folderwin = main_window_get_folder_window(mainwin);
1911 gtk_widget_show(folderwin);
1912 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1913 prefs_common.folderwin_y);
1916 if (mainwin->type & SEPARATE_MESSAGE) {
1917 GtkWidget *messagewin;
1919 messagewin = main_window_get_message_window(mainwin);
1920 gtk_widget_show(messagewin);
1921 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1922 prefs_common.main_msgwin_y);
1926 void main_window_hide(MainWindow *mainwin)
1928 main_window_get_size(mainwin);
1929 main_window_get_position(mainwin);
1931 gtk_widget_hide(mainwin->window);
1932 gtk_widget_hide(mainwin->vbox_body);
1934 if (mainwin->type & SEPARATE_FOLDER) {
1935 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1938 if (mainwin->type & SEPARATE_MESSAGE) {
1939 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1943 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1945 GtkWidget *folderwin = NULL;
1946 GtkWidget *messagewin = NULL;
1949 GtkWidget *vbox_body = mainwin->vbox_body;
1950 GtkItemFactory *ifactory = mainwin->menu_factory;
1951 GtkWidget *menuitem;
1952 GtkItemFactory *msgview_ifactory;
1954 debug_print("Setting widgets... ");
1956 /* create separated window(s) if needed */
1957 if (type & SEPARATE_FOLDER) {
1958 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1959 gtk_window_set_title(GTK_WINDOW(folderwin),
1960 _("Sylpheed - Folder View"));
1961 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1962 "folder_view", "Sylpheed");
1963 gtk_window_set_policy(GTK_WINDOW(folderwin),
1965 gtk_window_move(GTK_WINDOW(folderwin), prefs_common.folderwin_x,
1966 prefs_common.folderwin_y);
1967 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1969 g_signal_connect(G_OBJECT(folderwin), "delete_event",
1970 G_CALLBACK(folder_window_close_cb),
1972 gtk_container_add(GTK_CONTAINER(folderwin),
1973 GTK_WIDGET_PTR(mainwin->folderview));
1974 gtk_widget_realize(folderwin);
1975 if (prefs_common.folderview_visible)
1976 gtk_widget_show(folderwin);
1978 if (type & SEPARATE_MESSAGE) {
1979 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1980 gtk_window_set_title(GTK_WINDOW(messagewin),
1981 _("Sylpheed - Message View"));
1982 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1983 "message_view", "Sylpheed");
1984 gtk_window_set_policy(GTK_WINDOW(messagewin),
1986 gtk_window_move(GTK_WINDOW(messagewin),
1987 prefs_common.main_msgwin_x,
1988 prefs_common.main_msgwin_y);
1989 gtk_widget_set_size_request(messagewin,
1990 prefs_common.msgwin_width,
1991 prefs_common.msgwin_height);
1992 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1994 g_signal_connect(G_OBJECT(messagewin), "delete_event",
1995 G_CALLBACK(message_window_close_cb),
1997 if (messageview_is_visible(mainwin->messageview))
1998 gtk_widget_show(messagewin);
2001 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2002 prefs_common.folderview_width,
2003 prefs_common.folderview_height);
2004 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2005 prefs_common.summaryview_width,
2006 prefs_common.summaryview_height);
2007 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2008 prefs_common.msgview_width,
2009 prefs_common.msgview_height);
2013 hpaned = gtk_hpaned_new();
2014 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2015 gtk_paned_add1(GTK_PANED(hpaned),
2016 GTK_WIDGET_PTR(mainwin->folderview));
2017 gtk_widget_show(hpaned);
2018 gtk_widget_queue_resize(hpaned);
2020 vpaned = gtk_vpaned_new();
2021 if (messageview_is_visible(mainwin->messageview)) {
2022 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2023 gtk_paned_add1(GTK_PANED(vpaned),
2024 GTK_WIDGET_PTR(mainwin->summaryview));
2026 gtk_paned_add2(GTK_PANED(hpaned),
2027 GTK_WIDGET_PTR(mainwin->summaryview));
2028 gtk_widget_ref(vpaned);
2030 gtk_paned_add2(GTK_PANED(vpaned),
2031 GTK_WIDGET_PTR(mainwin->messageview));
2032 gtk_widget_show(vpaned);
2033 gtk_widget_queue_resize(vpaned);
2035 mainwin->win.sep_none.hpaned = hpaned;
2036 mainwin->win.sep_none.vpaned = vpaned;
2038 /* remove headerview if not in prefs */
2039 headerview_set_visibility(mainwin->messageview->headerview,
2040 prefs_common.display_header_pane);
2042 case SEPARATE_FOLDER:
2043 vpaned = gtk_vpaned_new();
2044 if (messageview_is_visible(mainwin->messageview)) {
2045 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2047 gtk_paned_add1(GTK_PANED(vpaned),
2048 GTK_WIDGET_PTR(mainwin->summaryview));
2050 gtk_box_pack_start(GTK_BOX(vbox_body),
2051 GTK_WIDGET_PTR(mainwin->summaryview),
2053 gtk_widget_ref(vpaned);
2055 gtk_paned_add2(GTK_PANED(vpaned),
2056 GTK_WIDGET_PTR(mainwin->messageview));
2057 gtk_widget_show(vpaned);
2058 gtk_widget_queue_resize(vpaned);
2060 mainwin->win.sep_folder.folderwin = folderwin;
2061 mainwin->win.sep_folder.vpaned = vpaned;
2063 /* remove headerview if not in prefs */
2064 headerview_set_visibility(mainwin->messageview->headerview,
2065 prefs_common.display_header_pane);
2068 case SEPARATE_MESSAGE:
2069 hpaned = gtk_hpaned_new();
2070 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2071 gtk_paned_add1(GTK_PANED(hpaned),
2072 GTK_WIDGET_PTR(mainwin->folderview));
2073 gtk_paned_add2(GTK_PANED(hpaned),
2074 GTK_WIDGET_PTR(mainwin->summaryview));
2075 gtk_widget_show(hpaned);
2076 gtk_widget_queue_resize(hpaned);
2077 messageview_add_toolbar(mainwin->messageview, messagewin);
2078 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2079 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2081 mainwin->win.sep_message.messagewin = messagewin;
2082 mainwin->win.sep_message.hpaned = hpaned;
2084 gtk_widget_realize(messagewin);
2085 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2086 gtk_widget_show_all(messagewin);
2087 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2088 mainwin->messageview->handlebox,
2089 prefs_common.toolbar_style);
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 gtk_box_pack_start(GTK_BOX(vbox_body),
2098 GTK_WIDGET_PTR(mainwin->summaryview),
2101 mainwin->win.sep_both.folderwin = folderwin;
2102 mainwin->win.sep_both.messagewin = messagewin;
2104 gtk_widget_realize(messagewin);
2105 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2106 gtk_widget_show_all(messagewin);
2107 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2108 mainwin->messageview->handlebox,
2109 prefs_common.toolbar_style);
2114 gtk_window_move(GTK_WINDOW(mainwin->window),
2115 prefs_common.mainwin_x,
2116 prefs_common.mainwin_y);
2118 gtk_widget_queue_resize(vbox_body);
2119 gtk_widget_queue_resize(mainwin->vbox);
2120 gtk_widget_queue_resize(mainwin->window);
2121 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2122 * and mimeview icon list/ctree lose track of their visibility states */
2123 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2124 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2125 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2126 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2127 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2128 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2130 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2132 mainwin->type = type;
2135 /* toggle menu state */
2136 menuitem = gtk_item_factory_get_item
2137 (ifactory, "/View/Show or hide/Folder tree");
2138 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2139 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2140 prefs_common.folderview_visible);
2141 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2142 menuitem = gtk_item_factory_get_item
2143 (ifactory, "/View/Show or hide/Message view");
2144 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2145 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
2146 prefs_common.msgview_visible);
2148 menuitem = gtk_item_factory_get_item
2149 (ifactory, "/View/Separate folder tree");
2150 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2151 ((type & SEPARATE_FOLDER) != 0));
2152 menuitem = gtk_item_factory_get_item
2153 (ifactory, "/View/Separate message view");
2154 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2155 ((type & SEPARATE_MESSAGE) != 0));
2159 (G_OBJECT(folderwin), "size_allocate",
2160 G_CALLBACK(folder_window_size_allocate_cb),
2165 (G_OBJECT(messagewin), "size_allocate",
2166 G_CALLBACK(message_window_size_allocate_cb),
2170 debug_print("done.\n");
2173 void main_window_destroy_all(void)
2175 while (mainwin_list != NULL) {
2176 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2178 /* free toolbar stuff */
2179 toolbar_clear_list(TOOLBAR_MAIN);
2180 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2181 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2183 g_free(mainwin->toolbar);
2186 mainwin_list = g_list_remove(mainwin_list, mainwin);
2188 g_list_free(mainwin_list);
2192 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2193 GdkEventButton *event,
2196 MainWindow *mainwin = (MainWindow *)data;
2198 if (!event) return FALSE;
2199 if (event->button != 3) return FALSE;
2201 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2202 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2205 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2206 menu_button_position, widget,
2207 event->button, event->time);
2213 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2216 gtk_widget_set_usize(child, 1, -1);
2219 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2222 gtk_widget_set_usize(child, -1, -1);
2225 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2228 MainWindow *mainwin = (MainWindow *)data;
2230 if (!event) return FALSE;
2232 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2233 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2236 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2237 menu_button_position, widget,
2238 event->button, event->time);
2243 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2245 MainWindow *mainwin = (MainWindow *)data;
2248 button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2249 if (!button) return;
2250 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2251 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2252 manage_window_focus_in(mainwin->window, NULL, NULL);
2255 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2258 MainWindow *mainwin = (MainWindow *)data;
2260 if (mainwin->lock_count == 0)
2261 app_exit_cb(data, 0, widget);
2266 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2269 MainWindow *mainwin = (MainWindow *)data;
2270 GtkWidget *menuitem;
2272 menuitem = gtk_item_factory_get_item
2273 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2274 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2279 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2282 MainWindow *mainwin = (MainWindow *)data;
2283 GtkWidget *menuitem;
2285 menuitem = gtk_item_factory_get_item
2286 (mainwin->menu_factory, "/View/Show or hide/Message view");
2287 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2292 static void main_window_size_allocate_cb(GtkWidget *widget,
2293 GtkAllocation *allocation,
2296 MainWindow *mainwin = (MainWindow *)data;
2298 main_window_get_size(mainwin);
2301 static void folder_window_size_allocate_cb(GtkWidget *widget,
2302 GtkAllocation *allocation,
2305 MainWindow *mainwin = (MainWindow *)data;
2307 main_window_get_size(mainwin);
2310 static void message_window_size_allocate_cb(GtkWidget *widget,
2311 GtkAllocation *allocation,
2314 MainWindow *mainwin = (MainWindow *)data;
2316 main_window_get_size(mainwin);
2319 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2322 main_window_add_mailbox(mainwin);
2325 static void update_folderview_cb(MainWindow *mainwin, guint action,
2328 summary_show(mainwin->summaryview, NULL);
2329 folderview_check_new_all();
2332 static void foldersort_cb(MainWindow *mainwin, guint action,
2338 static void import_mbox_cb(MainWindow *mainwin, guint action,
2341 import_mbox(mainwin->summaryview->folder_item);
2344 static void export_mbox_cb(MainWindow *mainwin, guint action,
2347 export_mbox(mainwin->summaryview->folder_item);
2350 static void empty_trash_cb(MainWindow *mainwin, guint action,
2353 main_window_empty_trash(mainwin, TRUE);
2356 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2358 summary_save_as(mainwin->summaryview);
2361 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2363 summary_print(mainwin->summaryview);
2366 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2368 if (prefs_common.confirm_on_exit) {
2369 if (alertpanel(_("Exit"), _("Exit this program?"),
2370 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2372 manage_window_focus_in(mainwin->window, NULL, NULL);
2375 app_will_exit(widget, mainwin);
2378 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2381 summary_search(mainwin->summaryview);
2383 message_search(mainwin->messageview);
2386 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2391 active = GTK_CHECK_MENU_ITEM(widget)->active;
2393 switch (mainwin->type) {
2395 case SEPARATE_MESSAGE:
2398 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2400 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2403 case SEPARATE_FOLDER:
2404 debug_print("separate folder\n");
2406 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2408 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2412 gtk_widget_show(mainwin->win.sep_both.folderwin);
2414 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2418 prefs_common.folderview_visible = active;
2421 static void toggle_message_cb(MainWindow *mainwin, guint action,
2426 active = GTK_CHECK_MENU_ITEM(widget)->active;
2428 if (active != messageview_is_visible(mainwin->messageview))
2429 summary_toggle_view(mainwin->summaryview);
2432 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2435 toolbar_toggle(action, mainwin);
2438 void main_window_reply_cb(MainWindow *mainwin, guint action,
2441 MessageView *msgview = (MessageView*)mainwin->messageview;
2442 GSList *msginfo_list = NULL;
2445 g_return_if_fail(msgview != NULL);
2447 msginfo_list = summary_get_selection(mainwin->summaryview);
2448 g_return_if_fail(msginfo_list != NULL);
2450 body = messageview_get_selection(msgview);
2451 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2453 g_slist_free(msginfo_list);
2457 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2460 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2461 gtk_widget_show(mainwin->hbox_stat);
2462 prefs_common.show_statusbar = TRUE;
2464 gtk_widget_hide(mainwin->hbox_stat);
2465 prefs_common.show_statusbar = FALSE;
2469 static void separate_widget_cb(MainWindow *mainwin, guint action,
2474 if (GTK_CHECK_MENU_ITEM(widget)->active)
2475 type = mainwin->type | action;
2477 type = mainwin->type & ~action;
2479 main_window_separation_change(mainwin, type);
2481 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2482 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2485 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2488 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2490 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2493 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2495 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2498 static void online_switch_clicked (GtkButton *btn, gpointer data)
2500 MainWindow *mainwin;
2501 GtkItemFactory *ifactory;
2502 GtkCheckMenuItem *menuitem;
2504 mainwin = (MainWindow *) data;
2506 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2507 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2509 g_return_if_fail(mainwin != NULL);
2510 g_return_if_fail(menuitem != NULL);
2512 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2514 gtk_widget_hide (mainwin->online_switch);
2515 gtk_widget_show (mainwin->offline_switch);
2516 menuitem->active = TRUE;
2517 prefs_common.work_offline = TRUE;
2518 inc_autocheck_timer_remove();
2521 gtk_widget_hide (mainwin->offline_switch);
2522 gtk_widget_show (mainwin->online_switch);
2523 menuitem->active = FALSE;
2524 prefs_common.work_offline = FALSE;
2525 inc_autocheck_timer_set();
2529 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2532 addressbook_open(NULL);
2535 static void log_window_show_cb(MainWindow *mainwin, guint action,
2538 log_window_show(mainwin->logwin);
2541 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2546 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2548 summary_move_to(mainwin->summaryview);
2551 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2553 summary_copy_to(mainwin->summaryview);
2556 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2558 summary_delete(mainwin->summaryview);
2561 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2563 summary_cancel(mainwin->summaryview);
2566 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2568 summary_open_msg(mainwin->summaryview);
2571 static void view_source_cb(MainWindow *mainwin, guint action,
2574 summary_view_source(mainwin->summaryview);
2577 static void show_all_header_cb(MainWindow *mainwin, guint action,
2580 if (mainwin->menu_lock_count) return;
2581 summary_display_msg_selected(mainwin->summaryview,
2582 GTK_CHECK_MENU_ITEM(widget)->active);
2585 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2587 summary_mark(mainwin->summaryview);
2590 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2592 summary_unmark(mainwin->summaryview);
2595 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2598 summary_mark_as_unread(mainwin->summaryview);
2601 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2604 summary_mark_as_read(mainwin->summaryview);
2607 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2610 summary_mark_all_read(mainwin->summaryview);
2613 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2615 summary_reedit(mainwin->summaryview);
2618 static void add_address_cb(MainWindow *mainwin, guint action,
2621 summary_add_address(mainwin->summaryview);
2624 static void set_charset_cb(MainWindow *mainwin, guint action,
2629 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2630 str = conv_get_charset_str((CharSet)action);
2631 g_free(prefs_common.force_charset);
2632 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2634 summary_redisplay_msg(mainwin->summaryview);
2636 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2640 static void hide_read_messages (MainWindow *mainwin, guint action,
2643 if (!mainwin->summaryview->folder_item
2644 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2646 summary_toggle_show_read_messages(mainwin->summaryview);
2649 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2651 if (mainwin->menu_lock_count) return;
2652 if (!mainwin->summaryview->folder_item) return;
2654 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2655 summary_thread_build(mainwin->summaryview);
2656 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2658 summary_unthread(mainwin->summaryview);
2659 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2663 static void expand_threads_cb(MainWindow *mainwin, guint action,
2666 summary_expand_threads(mainwin->summaryview);
2669 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2672 summary_collapse_threads(mainwin->summaryview);
2675 static void set_display_item_cb(MainWindow *mainwin, guint action,
2678 prefs_summary_column_open();
2681 static void sort_summary_cb(MainWindow *mainwin, guint action,
2684 FolderItem *item = mainwin->summaryview->folder_item;
2685 GtkWidget *menuitem;
2687 if (mainwin->menu_lock_count) return;
2689 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2690 menuitem = gtk_item_factory_get_item
2691 (mainwin->menu_factory, "/View/Sort/Ascending");
2692 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2693 GTK_CHECK_MENU_ITEM(menuitem)->active
2694 ? SORT_ASCENDING : SORT_DESCENDING);
2695 item->sort_key = action;
2699 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2702 FolderItem *item = mainwin->summaryview->folder_item;
2704 if (mainwin->menu_lock_count) return;
2706 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2707 summary_sort(mainwin->summaryview,
2708 item->sort_key, (FolderSortType)action);
2711 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2714 summary_attract_by_subject(mainwin->summaryview);
2717 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2722 item = folderview_get_selected(mainwin->folderview);
2724 main_window_cursor_wait(mainwin);
2725 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2727 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2728 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2730 STATUSBAR_POP(mainwin);
2731 main_window_cursor_normal(mainwin);
2741 static void deldup_all(FolderItem *item, gpointer _data)
2743 struct DelDupsData *data = _data;
2746 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2748 data->dups += result;
2753 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2756 struct DelDupsData data = {0, 0};
2758 folder_func_to_all_folders(deldup_all, &data);
2759 alertpanel_notice(_("Deleted %d duplicate message(s) in %d folders.\n"),
2760 data.dups, data.folders);
2763 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2765 summary_filter(mainwin->summaryview, (gboolean)action);
2768 static void execute_summary_cb(MainWindow *mainwin, guint action,
2771 summary_execute(mainwin->summaryview);
2774 static void update_summary_cb(MainWindow *mainwin, guint action,
2778 FolderView *folderview = mainwin->folderview;
2780 if (!mainwin->summaryview->folder_item) return;
2781 if (!folderview->opened) return;
2783 folder_update_op_count();
2785 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2786 folderview->opened);
2789 folder_item_scan(fitem);
2790 summary_show(mainwin->summaryview, fitem);
2793 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2795 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2798 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2800 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2803 static void prev_unread_cb(MainWindow *mainwin, guint action,
2806 summary_select_prev_unread(mainwin->summaryview);
2809 static void next_unread_cb(MainWindow *mainwin, guint action,
2812 summary_select_next_unread(mainwin->summaryview);
2815 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2817 summary_select_prev_new(mainwin->summaryview);
2820 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2822 summary_select_next_new(mainwin->summaryview);
2825 static void prev_marked_cb(MainWindow *mainwin, guint action,
2828 summary_select_prev_marked(mainwin->summaryview);
2831 static void next_marked_cb(MainWindow *mainwin, guint action,
2834 summary_select_next_marked(mainwin->summaryview);
2837 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2840 summary_select_prev_labeled(mainwin->summaryview);
2843 static void next_labeled_cb(MainWindow *mainwin, guint action,
2846 summary_select_next_labeled(mainwin->summaryview);
2849 static void goto_folder_cb(MainWindow *mainwin, guint action,
2852 FolderItem *to_folder;
2854 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2857 folderview_select(mainwin->folderview, to_folder);
2860 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2862 messageview_copy_clipboard(mainwin->messageview);
2865 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2867 MessageView *msgview = mainwin->messageview;
2869 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2870 summary_select_all(mainwin->summaryview);
2871 else if (messageview_is_visible(msgview) &&
2872 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2873 messageview_select_all(mainwin->messageview);
2876 static void select_thread_cb(MainWindow *mainwin, guint action,
2879 summary_select_thread(mainwin->summaryview);
2882 static void create_filter_cb(MainWindow *mainwin, guint action,
2885 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2888 static void create_processing_cb(MainWindow *mainwin, guint action,
2891 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2894 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2897 prefs_common_open();
2900 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2903 prefs_filtering_open(&pre_global_processing,
2904 _("Processing rules to apply before folder rules"),
2908 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2911 prefs_filtering_open(&post_global_processing,
2912 _("Processing rules to apply after folder rules"),
2916 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2919 prefs_filtering_open(&filtering_rules,
2920 _("Filtering configuration"),
2924 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2927 prefs_template_open();
2930 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2933 prefs_actions_open(mainwin);
2936 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2939 ssl_manager_open(mainwin);
2942 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2946 new_account_cb(mainwin, 0, widget);
2948 account_open(cur_account);
2952 static void new_account_cb(MainWindow *mainwin, guint action,
2955 account_edit_open();
2956 if (!compose_get_compose_list()) account_add();
2959 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
2961 cur_account = (PrefsAccount *)data;
2962 main_window_reflect_prefs_all();
2965 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
2967 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
2968 PrefsAccount *account = (PrefsAccount *)data;
2970 inc_account_mail(mainwin, account);
2973 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2978 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2980 pluginwindow_create();
2983 static void manual_open_cb(MainWindow *mainwin, guint action,
2986 manual_open((ManualType)action);
2989 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2991 MainWindow *mainwin = (MainWindow *)data;
2995 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2996 LOCAL_FOLDER(folder)->rootpath,
3000 str = g_strdup_printf(_("Scanning folder %s ..."),
3001 LOCAL_FOLDER(folder)->rootpath);
3003 STATUSBAR_PUSH(mainwin, str);
3004 STATUSBAR_POP(mainwin);
3008 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3011 SummaryView *summary;
3013 g_return_val_if_fail(data, FALSE);
3014 summary = ((MainWindow *)data)->summaryview;
3015 g_return_val_if_fail(summary, FALSE);
3017 if (GTK_CLIST(summary->ctree)->selection &&
3018 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3021 if (summary->selected != summary->displayed)
3022 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3026 #define BREAK_ON_MODIFIER_KEY() \
3027 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3029 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3032 MainWindow *mainwin = (MainWindow*) data;
3034 if (!mainwin || !event)
3037 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3040 switch (event->keyval) {
3041 case GDK_Q: /* Quit */
3042 BREAK_ON_MODIFIER_KEY();
3044 app_exit_cb(mainwin, 0, NULL);
3047 if (mainwin->folderview && mainwin->summaryview
3048 && !mainwin->summaryview->displayed) {
3049 summary_lock(mainwin->summaryview);
3050 folderview_select_next_unread(mainwin->folderview);
3051 summary_unlock(mainwin->summaryview);
3060 #undef BREAK_ON_MODIFIER_KEY
3063 * Harvest addresses for selected folder.
3065 static void addr_harvest_cb( MainWindow *mainwin,
3069 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3073 * Harvest addresses for selected messages in summary view.
3075 static void addr_harvest_msg_cb( MainWindow *mainwin,
3079 summary_harvest_address( mainwin->summaryview );
3083 *\brief get a MainWindow
3085 *\return MainWindow * The first mainwindow in the mainwin_list
3087 MainWindow *mainwindow_get_mainwindow(void)
3089 if (mainwin_list && mainwin_list->data)
3090 return (MainWindow *)(mainwin_list->data);
3095 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3097 ProgressData *data = (ProgressData *) source;
3098 MainWindow *mainwin = (MainWindow *) userdata;
3100 switch (data->cmd) {
3101 case PROGRESS_COMMAND_START:
3102 case PROGRESS_COMMAND_STOP:
3103 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
3105 case PROGRESS_COMMAND_SET_PERCENTAGE:
3106 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
3109 while (gtk_events_pending()) gtk_main_iteration ();