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 void 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 MainWindow *main_window_create(SeparateType type)
759 GtkWidget *handlebox;
760 GtkWidget *vbox_body;
761 GtkWidget *hbox_stat;
762 GtkWidget *statusbar;
763 GtkWidget *progressbar;
764 GtkWidget *statuslabel;
765 GtkWidget *ac_button;
767 GtkWidget *online_pixmap;
768 GtkWidget *offline_pixmap;
769 GtkWidget *online_switch;
770 GtkWidget *offline_switch;
771 GtkTooltips *offline_tip;
772 GtkTooltips *online_tip;
773 GtkTooltips *sel_ac_tip;
775 FolderView *folderview;
776 SummaryView *summaryview;
777 MessageView *messageview;
778 GdkColormap *colormap;
781 GtkItemFactory *ifactory;
785 guint n_menu_entries;
787 static GdkGeometry geometry;
789 debug_print("Creating main window...\n");
790 mainwin = g_new0(MainWindow, 1);
793 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
794 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
795 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
796 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
798 if (!geometry.min_height) {
799 geometry.min_width = 320;
800 geometry.min_height = 200;
802 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
805 g_signal_connect(G_OBJECT(window), "delete_event",
806 G_CALLBACK(main_window_close_cb), mainwin);
807 MANAGE_WINDOW_SIGNALS_CONNECT(window);
808 g_signal_connect(G_OBJECT(window), "focus_in_event",
809 G_CALLBACK(mainwindow_focus_in_event),
811 g_signal_connect(G_OBJECT(window), "key_press_event",
812 G_CALLBACK(mainwindow_key_pressed), mainwin);
814 gtk_widget_realize(window);
815 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
818 gtkut_widget_set_app_icon(window);
820 vbox = gtk_vbox_new(FALSE, 0);
821 gtk_widget_show(vbox);
822 gtk_container_add(GTK_CONTAINER(window), vbox);
825 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
826 menubar = menubar_create(window, mainwin_entries,
827 n_menu_entries, "<Main>", mainwin);
828 gtk_widget_show(menubar);
829 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
830 ifactory = gtk_item_factory_from_widget(menubar);
832 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
833 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
835 handlebox = gtk_handle_box_new();
836 gtk_widget_show(handlebox);
837 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
838 g_signal_connect(G_OBJECT(handlebox), "child_attached",
839 G_CALLBACK(toolbar_child_attached), mainwin);
840 g_signal_connect(G_OBJECT(handlebox), "child_detached",
841 G_CALLBACK(toolbar_child_detached), mainwin);
843 /* link window to mainwin->window to avoid gdk warnings */
844 mainwin->window = window;
847 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
851 /* vbox that contains body */
852 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
853 gtk_widget_show(vbox_body);
854 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
855 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
857 hbox_stat = gtk_hbox_new(FALSE, 2);
858 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
860 statusbar = statusbar_create();
861 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
863 progressbar = gtk_progress_bar_new();
864 gtk_widget_set_size_request(progressbar, 120, 1);
865 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
867 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
868 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
869 online_tip = gtk_tooltips_new();
870 online_switch = gtk_button_new ();
871 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
872 _("You are online. Click the icon to go offline"), NULL);
873 offline_tip = gtk_tooltips_new();
874 offline_switch = gtk_button_new ();
875 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
876 _("You are offline. Click the icon to go online"),
878 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
879 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
880 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
881 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
882 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
883 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
884 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
885 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
887 statuslabel = gtk_label_new("");
888 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
890 sel_ac_tip = gtk_tooltips_new();
891 ac_button = gtk_button_new();
892 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
893 ac_button, _("Select account"), NULL);
894 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
895 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
896 gtk_widget_set_size_request(ac_button, -1, 1);
897 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
898 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
899 G_CALLBACK(ac_label_button_pressed), mainwin);
901 ac_label = gtk_label_new("");
902 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
904 gtk_widget_show_all(hbox_stat);
906 gtk_widget_hide(offline_switch);
908 mainwin->folderview = folderview = folderview_create();
909 mainwin->summaryview = summaryview = summary_create();
910 mainwin->messageview = messageview = messageview_create(mainwin);
911 mainwin->logwin = log_window_create();
913 folderview->mainwin = mainwin;
914 folderview->summaryview = summaryview;
916 summaryview->mainwin = mainwin;
917 summaryview->folderview = folderview;
918 summaryview->messageview = messageview;
919 summaryview->window = window;
921 messageview->statusbar = statusbar;
922 mainwin->vbox = vbox;
923 mainwin->menubar = menubar;
924 mainwin->menu_factory = ifactory;
925 mainwin->handlebox = handlebox;
926 mainwin->vbox_body = vbox_body;
927 mainwin->hbox_stat = hbox_stat;
928 mainwin->statusbar = statusbar;
929 mainwin->progressbar = progressbar;
930 mainwin->statuslabel = statuslabel;
931 mainwin->online_switch = online_switch;
932 mainwin->online_pixmap = online_pixmap;
933 mainwin->offline_pixmap = offline_pixmap;
934 mainwin->ac_button = ac_button;
935 mainwin->ac_label = ac_label;
936 mainwin->offline_switch = offline_switch;
938 /* set context IDs for status bar */
939 mainwin->mainwin_cid = gtk_statusbar_get_context_id
940 (GTK_STATUSBAR(statusbar), "Main Window");
941 mainwin->folderview_cid = gtk_statusbar_get_context_id
942 (GTK_STATUSBAR(statusbar), "Folder View");
943 mainwin->summaryview_cid = gtk_statusbar_get_context_id
944 (GTK_STATUSBAR(statusbar), "Summary View");
945 mainwin->messageview_cid = gtk_statusbar_get_context_id
946 (GTK_STATUSBAR(statusbar), "Message View");
948 messageview->statusbar_cid = mainwin->messageview_cid;
950 /* allocate colors for summary view and folder view */
951 summaryview->color_marked.red = summaryview->color_marked.green = 0;
952 summaryview->color_marked.blue = (guint16)65535;
954 summaryview->color_dim.red = summaryview->color_dim.green =
955 summaryview->color_dim.blue = COLOR_DIM;
957 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
958 &folderview->color_new);
960 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
961 &folderview->color_op);
963 summaryview->color_important.red = 0;
964 summaryview->color_important.green = 0;
965 summaryview->color_important.blue = (guint16)65535;
967 color[0] = summaryview->color_marked;
968 color[1] = summaryview->color_dim;
969 color[2] = folderview->color_new;
970 color[3] = folderview->color_op;
972 colormap = gdk_window_get_colormap(window->window);
973 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
974 for (i = 0; i < 4; i++) {
975 if (success[i] == FALSE)
976 g_warning("MainWindow: color allocation %d failed\n", i);
979 debug_print("done.\n");
981 messageview->visible = prefs_common.msgview_visible;
983 main_window_set_widgets(mainwin, type);
985 g_signal_connect(G_OBJECT(window), "size_allocate",
986 G_CALLBACK(main_window_size_allocate_cb),
990 menuitem = gtk_item_factory_get_item
991 (ifactory, "/View/Code set/Auto detect");
992 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
994 switch (prefs_common.toolbar_style) {
996 menuitem = gtk_item_factory_get_item
997 (ifactory, "/View/Show or hide/Toolbar/None");
1000 menuitem = gtk_item_factory_get_item
1001 (ifactory, "/View/Show or hide/Toolbar/Icon");
1004 menuitem = gtk_item_factory_get_item
1005 (ifactory, "/View/Show or hide/Toolbar/Text");
1008 menuitem = gtk_item_factory_get_item
1009 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1011 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1013 gtk_widget_hide(mainwin->hbox_stat);
1014 menuitem = gtk_item_factory_get_item
1015 (ifactory, "/View/Show or hide/Status bar");
1016 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1017 prefs_common.show_statusbar);
1019 /* set account selection menu */
1020 ac_menu = gtk_item_factory_get_widget
1021 (ifactory, "/Configuration/Change current account");
1022 g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1023 G_CALLBACK(ac_menu_popup_closed), mainwin);
1024 mainwin->ac_menu = ac_menu;
1026 toolbar_main_set_sensitive(mainwin);
1028 /* create actions menu */
1029 main_window_update_actions_menu(mainwin);
1031 /* attach accel groups to main window */
1032 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1033 gtk_window_add_accel_group \
1035 gtk_item_factory_from_widget(menu)->accel_group)
1037 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1039 /* connect the accelerators for equivalent
1040 menu items in different menus */
1041 menu_connect_identical_items();
1045 /* show main window */
1046 gtk_widget_show(mainwin->window);
1048 /* initialize views */
1049 folderview_init(folderview);
1050 summary_init(summaryview);
1051 messageview_init(messageview);
1052 log_window_init(mainwin->logwin);
1053 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1054 prefs_common.loglength);
1056 sslcertwindow_register_hook();
1058 mainwin->lock_count = 0;
1059 mainwin->menu_lock_count = 0;
1060 mainwin->cursor_count = 0;
1062 mainwin->progressindicator_hook =
1063 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1066 watch_cursor = gdk_cursor_new(GDK_WATCH);
1068 mainwin_list = g_list_append(mainwin_list, mainwin);
1070 /* init work_offline */
1071 if (prefs_common.work_offline)
1072 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1077 void main_window_destroy(MainWindow *mainwin)
1079 /* TODO : destroy other component */
1080 messageview_destroy(mainwin->messageview);
1083 void main_window_update_actions_menu(MainWindow *mainwin)
1085 GtkItemFactory *ifactory;
1087 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1088 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1091 void main_window_cursor_wait(MainWindow *mainwin)
1094 if (mainwin->cursor_count == 0)
1095 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1097 mainwin->cursor_count++;
1102 void main_window_cursor_normal(MainWindow *mainwin)
1104 if (mainwin->cursor_count)
1105 mainwin->cursor_count--;
1107 if (mainwin->cursor_count == 0)
1108 gdk_window_set_cursor(mainwin->window->window, NULL);
1113 /* lock / unlock the user-interface */
1114 void main_window_lock(MainWindow *mainwin)
1116 if (mainwin->lock_count == 0)
1117 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1119 mainwin->lock_count++;
1121 main_window_set_menu_sensitive(mainwin);
1122 toolbar_main_set_sensitive(mainwin);
1125 void main_window_unlock(MainWindow *mainwin)
1127 if (mainwin->lock_count)
1128 mainwin->lock_count--;
1130 main_window_set_menu_sensitive(mainwin);
1131 toolbar_main_set_sensitive(mainwin);
1133 if (mainwin->lock_count == 0)
1134 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1137 static void main_window_menu_callback_block(MainWindow *mainwin)
1139 mainwin->menu_lock_count++;
1142 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1144 if (mainwin->menu_lock_count)
1145 mainwin->menu_lock_count--;
1148 void main_window_reflect_prefs_all(void)
1150 main_window_reflect_prefs_all_real(FALSE);
1153 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1156 MainWindow *mainwin;
1159 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1160 mainwin = (MainWindow *)cur->data;
1162 main_window_show_cur_account(mainwin);
1163 main_window_set_menu_sensitive(mainwin);
1164 toolbar_main_set_sensitive(mainwin);
1167 if (pixmap_theme_changed) {
1168 toolbar_update(TOOLBAR_MAIN, mainwin);
1169 messageview_reflect_prefs_pixmap_theme();
1170 compose_reflect_prefs_pixmap_theme();
1171 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1172 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1174 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1175 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1176 mainwin->online_pixmap);
1177 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1178 gtk_widget_show(pixmap);
1179 mainwin->online_pixmap = pixmap;
1180 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1181 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1182 mainwin->offline_pixmap);
1183 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1184 gtk_widget_show(pixmap);
1185 mainwin->offline_pixmap = pixmap;
1188 summary_redisplay_msg(mainwin->summaryview);
1189 headerview_set_visibility(mainwin->messageview->headerview,
1190 prefs_common.display_header_pane);
1194 void main_window_set_summary_column(void)
1197 MainWindow *mainwin;
1199 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1200 mainwin = (MainWindow *)cur->data;
1201 summary_set_column_order(mainwin->summaryview);
1205 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1206 GList *account_list)
1208 GList *cur_ac, *cur_item;
1209 GtkWidget *menuitem;
1210 PrefsAccount *ac_prefs;
1212 /* destroy all previous menu item */
1213 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1214 while (cur_item != NULL) {
1215 GList *next = cur_item->next;
1216 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1220 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1221 ac_prefs = (PrefsAccount *)cur_ac->data;
1223 menuitem = gtk_menu_item_new_with_label
1224 (ac_prefs->account_name
1225 ? ac_prefs->account_name : _("Untitled"));
1226 gtk_widget_show(menuitem);
1227 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1228 g_signal_connect(G_OBJECT(menuitem), "activate",
1229 G_CALLBACK(account_selector_menu_cb),
1234 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1235 GList *account_list)
1237 GList *cur_ac, *cur_item;
1239 GtkWidget *menuitem;
1240 PrefsAccount *ac_prefs;
1242 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1243 "/Message/Receive");
1245 /* search for separator */
1246 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1247 cur_item = cur_item->next) {
1248 if (GTK_BIN(cur_item->data)->child == NULL) {
1249 cur_item = cur_item->next;
1254 /* destroy all previous menu item */
1255 while (cur_item != NULL) {
1256 GList *next = cur_item->next;
1257 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1261 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1262 ac_prefs = (PrefsAccount *)cur_ac->data;
1264 menuitem = gtk_menu_item_new_with_label
1265 (ac_prefs->account_name ? ac_prefs->account_name
1267 gtk_widget_show(menuitem);
1268 gtk_menu_append(GTK_MENU(menu), menuitem);
1269 g_signal_connect(G_OBJECT(menuitem), "activate",
1270 G_CALLBACK(account_receive_menu_cb),
1275 void main_window_set_account_menu(GList *account_list)
1278 MainWindow *mainwin;
1280 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1281 mainwin = (MainWindow *)cur->data;
1282 main_window_set_account_selector_menu(mainwin, account_list);
1283 main_window_set_account_receive_menu(mainwin, account_list);
1287 static void main_window_show_cur_account(MainWindow *mainwin)
1292 ac_name = g_strdup(cur_account
1293 ? (cur_account->account_name
1294 ? cur_account->account_name : _("Untitled"))
1298 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1300 buf = g_strdup(PROG_VERSION);
1301 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1304 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1305 gtk_widget_queue_resize(mainwin->ac_button);
1310 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1312 switch (mainwin->type) {
1313 case SEPARATE_FOLDER:
1314 return mainwin->win.sep_folder.folderwin;
1316 return mainwin->win.sep_both.folderwin;
1322 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1324 switch (mainwin->type) {
1325 case SEPARATE_MESSAGE:
1326 return mainwin->win.sep_message.messagewin;
1328 return mainwin->win.sep_both.messagewin;
1334 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1336 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1337 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1338 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1339 GtkWidget *message_wid = mainwin->messageview->vbox;
1341 debug_print("Changing window separation type from %d to %d\n",
1342 mainwin->type, type);
1344 if (mainwin->type == type) return;
1346 /* remove widgets from those containers */
1347 gtk_widget_ref(folder_wid);
1348 gtk_widget_ref(summary_wid);
1349 gtk_widget_ref(message_wid);
1350 gtkut_container_remove
1351 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1352 gtkut_container_remove
1353 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1354 gtkut_container_remove
1355 (GTK_CONTAINER(message_wid->parent), message_wid);
1357 /* clean containers */
1358 switch (mainwin->type) {
1360 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1362 case SEPARATE_FOLDER:
1363 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1364 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1366 case SEPARATE_MESSAGE:
1367 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1368 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1371 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1372 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1376 gtk_widget_hide(mainwin->window);
1377 main_window_set_widgets(mainwin, type);
1378 gtk_widget_show(mainwin->window);
1380 gtk_widget_unref(folder_wid);
1381 gtk_widget_unref(summary_wid);
1382 gtk_widget_unref(message_wid);
1385 void main_window_toggle_message_view(MainWindow *mainwin)
1387 SummaryView *summaryview = mainwin->summaryview;
1388 union CompositeWin *cwin = &mainwin->win;
1389 GtkWidget *vpaned = NULL;
1390 GtkWidget *container = NULL;
1391 GtkWidget *msgwin = NULL;
1393 switch (mainwin->type) {
1395 vpaned = cwin->sep_none.vpaned;
1396 container = cwin->sep_none.hpaned;
1398 case SEPARATE_FOLDER:
1399 vpaned = cwin->sep_folder.vpaned;
1400 container = mainwin->vbox_body;
1402 case SEPARATE_MESSAGE:
1403 msgwin = mainwin->win.sep_message.messagewin;
1406 msgwin = mainwin->win.sep_both.messagewin;
1411 if (GTK_WIDGET_VISIBLE(msgwin)) {
1412 gtk_widget_hide(msgwin);
1413 mainwin->messageview->visible = FALSE;
1414 summaryview->displayed = NULL;
1416 gtk_widget_show(msgwin);
1417 mainwin->messageview->visible = TRUE;
1419 } else if (vpaned->parent != NULL) {
1420 mainwin->messageview->visible = FALSE;
1421 summaryview->displayed = NULL;
1422 gtk_widget_ref(vpaned);
1423 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1424 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1425 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1426 GTK_ARROW_UP, GTK_SHADOW_OUT);
1428 mainwin->messageview->visible = TRUE;
1429 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1430 gtk_container_add(GTK_CONTAINER(container), vpaned);
1431 gtk_widget_unref(vpaned);
1432 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1433 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1436 if (mainwin->messageview->visible == FALSE)
1437 messageview_clear(mainwin->messageview);
1439 main_window_set_menu_sensitive(mainwin);
1441 prefs_common.msgview_visible = mainwin->messageview->visible;
1443 gtk_widget_grab_focus(summaryview->ctree);
1446 void main_window_get_size(MainWindow *mainwin)
1448 GtkAllocation *allocation;
1450 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1452 if (allocation->width > 1 && allocation->height > 1) {
1453 prefs_common.summaryview_width = allocation->width;
1455 if ((mainwin->type == SEPARATE_NONE ||
1456 mainwin->type == SEPARATE_FOLDER) &&
1457 messageview_is_visible(mainwin->messageview))
1458 prefs_common.summaryview_height = allocation->height;
1460 prefs_common.mainview_width = allocation->width;
1463 allocation = &mainwin->window->allocation;
1464 if (allocation->width > 1 && allocation->height > 1) {
1465 prefs_common.mainview_height = allocation->height;
1466 prefs_common.mainwin_width = allocation->width;
1467 prefs_common.mainwin_height = allocation->height;
1470 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1471 if (allocation->width > 1 && allocation->height > 1) {
1472 prefs_common.folderview_width = allocation->width;
1473 prefs_common.folderview_height = allocation->height;
1476 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1477 if (allocation->width > 1 && allocation->height > 1) {
1478 prefs_common.msgview_width = allocation->width;
1479 prefs_common.msgview_height = allocation->height;
1482 debug_print("summaryview size: %d x %d\n",
1483 prefs_common.summaryview_width,
1484 prefs_common.summaryview_height);
1485 debug_print("folderview size: %d x %d\n",
1486 prefs_common.folderview_width,
1487 prefs_common.folderview_height);
1488 debug_print("messageview size: %d x %d\n",
1489 prefs_common.msgview_width,
1490 prefs_common.msgview_height);
1493 void main_window_get_position(MainWindow *mainwin)
1498 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1500 prefs_common.mainview_x = x;
1501 prefs_common.mainview_y = y;
1502 prefs_common.mainwin_x = x;
1503 prefs_common.mainwin_y = y;
1505 debug_print("main window position: %d, %d\n", x, y);
1507 window = main_window_get_folder_window(mainwin);
1509 gtkut_widget_get_uposition(window, &x, &y);
1510 prefs_common.folderwin_x = x;
1511 prefs_common.folderwin_y = y;
1512 debug_print("folder window position: %d, %d\n", x, y);
1514 window = main_window_get_message_window(mainwin);
1516 gtkut_widget_get_uposition(window, &x, &y);
1517 prefs_common.main_msgwin_x = x;
1518 prefs_common.main_msgwin_y = y;
1519 debug_print("message window position: %d, %d\n", x, y);
1523 void main_window_progress_on(MainWindow *mainwin)
1525 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE);
1526 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1529 void main_window_progress_off(MainWindow *mainwin)
1531 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE);
1532 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1533 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1536 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1540 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1541 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf);
1542 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar),
1543 (cur == 0 && total == 0) ? 0 :
1544 (gfloat)cur / (gfloat)total);
1547 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1553 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1554 folder = FOLDER(list->data);
1555 if (folder && folder->trash && folder->trash->total_msgs > 0)
1559 if (!has_trash) return;
1562 if (alertpanel(_("Empty trash"),
1563 _("Empty all messages in trash?"),
1564 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1566 manage_window_focus_in(mainwin->window, NULL, NULL);
1569 procmsg_empty_trash();
1571 if (mainwin->summaryview->folder_item &&
1572 mainwin->summaryview->folder_item->stype == F_TRASH)
1573 gtk_widget_grab_focus(mainwin->folderview->ctree);
1576 void main_window_add_mailbox(MainWindow *mainwin)
1581 path = input_dialog(_("Add mailbox"),
1582 _("Input the location of mailbox.\n"
1583 "If the existing mailbox is specified, it will be\n"
1584 "scanned automatically."),
1587 if (folder_find_from_path(path)) {
1588 alertpanel_error(_("The mailbox `%s' already exists."), path);
1592 folder = folder_new(folder_get_class_from_string("mh"),
1593 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1597 if (folder->klass->create_tree(folder) < 0) {
1598 alertpanel_error(_("Creation of the mailbox failed.\n"
1599 "Maybe some files already exist, or you don't have the permission to write there."));
1600 folder_destroy(folder);
1605 folder_set_ui_func(folder, scan_tree_func, mainwin);
1606 folder_scan_tree(folder);
1607 folder_set_ui_func(folder, NULL, NULL);
1610 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1612 SensitiveCond state = 0;
1613 SummarySelection selection;
1614 FolderItem *item = mainwin->summaryview->folder_item;
1615 GList *account_list = account_get_list();
1617 selection = summary_get_selection_type(mainwin->summaryview);
1619 if (mainwin->lock_count == 0)
1620 state |= M_UNLOCKED;
1621 if (selection != SUMMARY_NONE)
1622 state |= M_MSG_EXIST;
1623 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1625 /* if (item->folder->type != F_NEWS) */
1626 state |= M_ALLOW_DELETE;
1628 if (prefs_common.immediate_exec == 0
1629 && mainwin->lock_count == 0)
1630 state |= M_DELAY_EXEC;
1632 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1633 || selection != SUMMARY_NONE)
1634 state |= M_HIDE_READ_MSG;
1636 if (mainwin->summaryview->threaded)
1637 state |= M_THREADED;
1639 state |= M_UNTHREADED;
1640 if (selection == SUMMARY_SELECTED_SINGLE ||
1641 selection == SUMMARY_SELECTED_MULTIPLE)
1642 state |= M_TARGET_EXIST;
1643 if (selection == SUMMARY_SELECTED_SINGLE)
1644 state |= M_SINGLE_TARGET_EXIST;
1645 if (mainwin->summaryview->folder_item &&
1646 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1649 state |= M_NOT_NEWS;
1650 if (selection == SUMMARY_SELECTED_SINGLE &&
1652 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1653 item->stype == F_QUEUE)))
1654 state |= M_ALLOW_REEDIT;
1656 state |= M_HAVE_ACCOUNT;
1658 for ( ; account_list != NULL; account_list = account_list->next) {
1659 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1660 state |= M_HAVE_NEWS_ACCOUNT;
1665 if (inc_is_active())
1666 state |= M_INC_ACTIVE;
1673 void main_window_set_menu_sensitive(MainWindow *mainwin)
1675 GtkItemFactory *ifactory = mainwin->menu_factory;
1676 SensitiveCond state;
1679 GtkWidget *menuitem;
1680 SummaryView *summaryview;
1685 static const struct {
1689 {"/File/Add mailbox" , M_UNLOCKED},
1691 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1692 {"/File/Change folder order" , M_UNLOCKED},
1693 {"/File/Export to mbox file..." , M_UNLOCKED},
1694 {"/File/Empty trash" , M_UNLOCKED},
1695 {"/File/Work offline" , M_UNLOCKED},
1697 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1698 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1699 /* {"/File/Close" , M_UNLOCKED}, */
1700 {"/File/Exit" , M_UNLOCKED},
1702 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1704 {"/View/Sort" , M_EXEC},
1705 {"/View/Thread view" , M_EXEC},
1706 {"/View/Expand all threads" , M_MSG_EXIST},
1707 {"/View/Collapse all threads" , M_MSG_EXIST},
1708 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1709 {"/View/Go to/Prev message" , M_MSG_EXIST},
1710 {"/View/Go to/Next message" , M_MSG_EXIST},
1711 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1712 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1713 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1714 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1715 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1716 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1717 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1718 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1719 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1721 {"/Message/Receive/Get from current account"
1722 , M_HAVE_ACCOUNT|M_UNLOCKED},
1723 {"/Message/Receive/Get from all accounts"
1724 , M_HAVE_ACCOUNT|M_UNLOCKED},
1725 {"/Message/Receive/Cancel receiving"
1728 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1729 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1730 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1731 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1732 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1733 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1734 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1735 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1736 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1737 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1738 {"/Message/Mark" , M_TARGET_EXIST},
1739 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1741 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1742 {"/Tools/Harvest addresses" , M_UNLOCKED},
1743 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1744 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1745 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1746 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1747 {"/Tools/Execute" , M_DELAY_EXEC},
1748 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1750 {"/Configuration", M_UNLOCKED},
1755 state = main_window_get_current_state(mainwin);
1757 for (i = 0; entry[i].entry != NULL; i++) {
1758 sensitive = ((entry[i].cond & state) == entry[i].cond);
1759 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1762 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1764 /* search for separator */
1765 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1766 cur_item = cur_item->next) {
1767 if (GTK_BIN(cur_item->data)->child == NULL) {
1768 cur_item = cur_item->next;
1773 for (; cur_item != NULL; cur_item = cur_item->next) {
1774 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1775 (M_UNLOCKED & state) != 0);
1778 main_window_menu_callback_block(mainwin);
1780 #define SET_CHECK_MENU_ACTIVE(path, active) \
1782 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1783 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1786 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1787 messageview_is_visible(mainwin->messageview));
1789 summaryview = mainwin->summaryview;
1790 menu_path = "/View/Sort/Don't sort";
1792 switch (summaryview->sort_key) {
1793 case SORT_BY_NUMBER:
1794 menu_path = "/View/Sort/by number"; break;
1796 menu_path = "/View/Sort/by size"; break;
1798 menu_path = "/View/Sort/by date"; break;
1800 menu_path = "/View/Sort/by from"; break;
1802 menu_path = "/View/Sort/by recipient"; break;
1803 case SORT_BY_SUBJECT:
1804 menu_path = "/View/Sort/by subject"; break;
1806 menu_path = "/View/Sort/by color label"; break;
1808 menu_path = "/View/Sort/by mark"; break;
1809 case SORT_BY_STATUS:
1810 menu_path = "/View/Sort/by status"; break;
1812 menu_path = "/View/Sort/by attachment"; break;
1814 menu_path = "/View/Sort/by score"; break;
1815 case SORT_BY_LOCKED:
1816 menu_path = "/View/Sort/by locked"; break;
1819 menu_path = "/View/Sort/Don't sort"; break;
1821 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1823 if (summaryview->sort_type == SORT_ASCENDING) {
1824 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1826 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1829 if (summaryview->sort_key != SORT_BY_NONE) {
1830 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1831 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1833 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1834 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1837 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1838 mainwin->messageview->mimeview->textview->show_all_headers);
1839 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1841 #undef SET_CHECK_MENU_ACTIVE
1843 main_window_menu_callback_unblock(mainwin);
1846 void main_window_popup(MainWindow *mainwin)
1848 gtkut_window_popup(mainwin->window);
1850 switch (mainwin->type) {
1851 case SEPARATE_FOLDER:
1852 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1854 case SEPARATE_MESSAGE:
1855 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1858 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1859 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1866 void main_window_show(MainWindow *mainwin)
1868 gtk_widget_show(mainwin->window);
1869 gtk_widget_show(mainwin->vbox_body);
1871 gtk_widget_set_uposition(mainwin->window,
1872 prefs_common.mainwin_x,
1873 prefs_common.mainwin_y);
1875 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1876 prefs_common.folderview_width,
1877 prefs_common.folderview_height);
1878 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1879 prefs_common.summaryview_width,
1880 prefs_common.summaryview_height);
1881 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1882 prefs_common.msgview_width,
1883 prefs_common.msgview_height);
1885 if (mainwin->type & SEPARATE_FOLDER) {
1886 GtkWidget *folderwin;
1888 folderwin = main_window_get_folder_window(mainwin);
1889 gtk_widget_show(folderwin);
1890 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1891 prefs_common.folderwin_y);
1894 if (mainwin->type & SEPARATE_MESSAGE) {
1895 GtkWidget *messagewin;
1897 messagewin = main_window_get_message_window(mainwin);
1898 gtk_widget_show(messagewin);
1899 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1900 prefs_common.main_msgwin_y);
1904 void main_window_hide(MainWindow *mainwin)
1906 main_window_get_size(mainwin);
1907 main_window_get_position(mainwin);
1909 gtk_widget_hide(mainwin->window);
1910 gtk_widget_hide(mainwin->vbox_body);
1912 if (mainwin->type & SEPARATE_FOLDER) {
1913 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1916 if (mainwin->type & SEPARATE_MESSAGE) {
1917 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1921 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1923 GtkWidget *folderwin = NULL;
1924 GtkWidget *messagewin = NULL;
1927 GtkWidget *vbox_body = mainwin->vbox_body;
1928 GtkItemFactory *ifactory = mainwin->menu_factory;
1929 GtkWidget *menuitem;
1930 GtkItemFactory *msgview_ifactory;
1932 debug_print("Setting widgets... ");
1934 /* create separated window(s) if needed */
1935 if (type & SEPARATE_FOLDER) {
1936 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1937 gtk_window_set_title(GTK_WINDOW(folderwin),
1938 _("Sylpheed - Folder View"));
1939 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1940 "folder_view", "Sylpheed");
1941 gtk_window_set_policy(GTK_WINDOW(folderwin),
1943 gtk_window_move(GTK_WINDOW(folderwin), prefs_common.folderwin_x,
1944 prefs_common.folderwin_y);
1945 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1947 g_signal_connect(G_OBJECT(folderwin), "delete_event",
1948 G_CALLBACK(folder_window_close_cb),
1950 gtk_container_add(GTK_CONTAINER(folderwin),
1951 GTK_WIDGET_PTR(mainwin->folderview));
1952 gtk_widget_realize(folderwin);
1953 if (prefs_common.folderview_visible)
1954 gtk_widget_show(folderwin);
1956 if (type & SEPARATE_MESSAGE) {
1957 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1958 gtk_window_set_title(GTK_WINDOW(messagewin),
1959 _("Sylpheed - Message View"));
1960 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1961 "message_view", "Sylpheed");
1962 gtk_window_set_policy(GTK_WINDOW(messagewin),
1964 gtk_window_move(GTK_WINDOW(messagewin), prefs_common.main_msgwin_x,
1965 prefs_common.main_msgwin_y);
1966 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1968 g_signal_connect(G_OBJECT(messagewin), "delete_event",
1969 G_CALLBACK(message_window_close_cb),
1971 if (messageview_is_visible(mainwin->messageview))
1972 gtk_widget_show(messagewin);
1975 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1976 prefs_common.folderview_width,
1977 prefs_common.folderview_height);
1978 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1979 prefs_common.summaryview_width,
1980 prefs_common.summaryview_height);
1981 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1982 prefs_common.msgview_width,
1983 prefs_common.msgview_height);
1987 hpaned = gtk_hpaned_new();
1988 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1989 gtk_paned_add1(GTK_PANED(hpaned),
1990 GTK_WIDGET_PTR(mainwin->folderview));
1991 gtk_widget_show(hpaned);
1992 gtk_widget_queue_resize(hpaned);
1994 vpaned = gtk_vpaned_new();
1995 if (messageview_is_visible(mainwin->messageview)) {
1996 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1997 gtk_paned_add1(GTK_PANED(vpaned),
1998 GTK_WIDGET_PTR(mainwin->summaryview));
2000 gtk_paned_add2(GTK_PANED(hpaned),
2001 GTK_WIDGET_PTR(mainwin->summaryview));
2002 gtk_widget_ref(vpaned);
2004 gtk_paned_add2(GTK_PANED(vpaned),
2005 GTK_WIDGET_PTR(mainwin->messageview));
2006 gtk_widget_show(vpaned);
2007 gtk_widget_queue_resize(vpaned);
2009 mainwin->win.sep_none.hpaned = hpaned;
2010 mainwin->win.sep_none.vpaned = vpaned;
2012 /* remove headerview if not in prefs */
2013 headerview_set_visibility(mainwin->messageview->headerview,
2014 prefs_common.display_header_pane);
2016 case SEPARATE_FOLDER:
2017 vpaned = gtk_vpaned_new();
2018 if (messageview_is_visible(mainwin->messageview)) {
2019 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2021 gtk_paned_add1(GTK_PANED(vpaned),
2022 GTK_WIDGET_PTR(mainwin->summaryview));
2024 gtk_box_pack_start(GTK_BOX(vbox_body),
2025 GTK_WIDGET_PTR(mainwin->summaryview),
2027 gtk_widget_ref(vpaned);
2029 gtk_paned_add2(GTK_PANED(vpaned),
2030 GTK_WIDGET_PTR(mainwin->messageview));
2031 gtk_widget_show(vpaned);
2032 gtk_widget_queue_resize(vpaned);
2034 mainwin->win.sep_folder.folderwin = folderwin;
2035 mainwin->win.sep_folder.vpaned = vpaned;
2037 /* remove headerview if not in prefs */
2038 headerview_set_visibility(mainwin->messageview->headerview,
2039 prefs_common.display_header_pane);
2042 case SEPARATE_MESSAGE:
2043 hpaned = gtk_hpaned_new();
2044 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2045 gtk_paned_add1(GTK_PANED(hpaned),
2046 GTK_WIDGET_PTR(mainwin->folderview));
2047 gtk_paned_add2(GTK_PANED(hpaned),
2048 GTK_WIDGET_PTR(mainwin->summaryview));
2049 gtk_widget_show(hpaned);
2050 gtk_widget_queue_resize(hpaned);
2051 messageview_add_toolbar(mainwin->messageview, messagewin);
2052 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2053 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2055 mainwin->win.sep_message.messagewin = messagewin;
2056 mainwin->win.sep_message.hpaned = hpaned;
2058 gtk_widget_realize(messagewin);
2059 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2060 gtk_widget_show_all(messagewin);
2061 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2062 mainwin->messageview->handlebox,
2063 prefs_common.toolbar_style);
2067 messageview_add_toolbar(mainwin->messageview, messagewin);
2068 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2069 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2071 gtk_box_pack_start(GTK_BOX(vbox_body),
2072 GTK_WIDGET_PTR(mainwin->summaryview),
2075 mainwin->win.sep_both.folderwin = folderwin;
2076 mainwin->win.sep_both.messagewin = messagewin;
2078 gtk_widget_realize(messagewin);
2079 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2080 gtk_widget_show_all(messagewin);
2081 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2082 mainwin->messageview->handlebox,
2083 prefs_common.toolbar_style);
2088 gtk_window_move(GTK_WINDOW(mainwin->window),
2089 prefs_common.mainwin_x,
2090 prefs_common.mainwin_y);
2092 gtk_widget_queue_resize(vbox_body);
2093 gtk_widget_queue_resize(mainwin->vbox);
2094 gtk_widget_queue_resize(mainwin->window);
2095 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2096 * and mimeview icon list/ctree lose track of their visibility states */
2097 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2098 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2099 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2100 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2101 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2102 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2104 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2106 mainwin->type = type;
2109 /* toggle menu state */
2110 menuitem = gtk_item_factory_get_item
2111 (ifactory, "/View/Show or hide/Folder tree");
2112 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2113 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2114 prefs_common.folderview_visible);
2115 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2116 menuitem = gtk_item_factory_get_item
2117 (ifactory, "/View/Show or hide/Message view");
2118 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2119 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
2120 prefs_common.msgview_visible);
2122 menuitem = gtk_item_factory_get_item
2123 (ifactory, "/View/Separate folder tree");
2124 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2125 ((type & SEPARATE_FOLDER) != 0));
2126 menuitem = gtk_item_factory_get_item
2127 (ifactory, "/View/Separate message view");
2128 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2129 ((type & SEPARATE_MESSAGE) != 0));
2133 (G_OBJECT(folderwin), "size_allocate",
2134 G_CALLBACK(folder_window_size_allocate_cb),
2139 (G_OBJECT(messagewin), "size_allocate",
2140 G_CALLBACK(message_window_size_allocate_cb),
2144 debug_print("done.\n");
2147 void main_window_destroy_all(void)
2149 while (mainwin_list != NULL) {
2150 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2152 /* free toolbar stuff */
2153 toolbar_clear_list(TOOLBAR_MAIN);
2154 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2155 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2157 g_free(mainwin->toolbar);
2160 mainwin_list = g_list_remove(mainwin_list, mainwin);
2162 g_list_free(mainwin_list);
2166 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2167 GdkEventButton *event,
2170 MainWindow *mainwin = (MainWindow *)data;
2172 if (!event) return FALSE;
2173 if (event->button != 3) return FALSE;
2175 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2176 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2179 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2180 menu_button_position, widget,
2181 event->button, event->time);
2187 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2190 gtk_widget_set_usize(child, 1, -1);
2193 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2196 gtk_widget_set_usize(child, -1, -1);
2199 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2202 MainWindow *mainwin = (MainWindow *)data;
2204 if (!event) return FALSE;
2206 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2207 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2210 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2211 menu_button_position, widget,
2212 event->button, event->time);
2217 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2219 MainWindow *mainwin = (MainWindow *)data;
2222 button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2223 if (!button) return;
2224 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2225 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2226 manage_window_focus_in(mainwin->window, NULL, NULL);
2229 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2232 MainWindow *mainwin = (MainWindow *)data;
2234 if (mainwin->lock_count == 0)
2235 app_exit_cb(data, 0, widget);
2240 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2243 MainWindow *mainwin = (MainWindow *)data;
2244 GtkWidget *menuitem;
2246 menuitem = gtk_item_factory_get_item
2247 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2248 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2253 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2256 MainWindow *mainwin = (MainWindow *)data;
2257 GtkWidget *menuitem;
2259 menuitem = gtk_item_factory_get_item
2260 (mainwin->menu_factory, "/View/Show or hide/Message view");
2261 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2266 static void main_window_size_allocate_cb(GtkWidget *widget,
2267 GtkAllocation *allocation,
2270 MainWindow *mainwin = (MainWindow *)data;
2272 main_window_get_size(mainwin);
2275 static void folder_window_size_allocate_cb(GtkWidget *widget,
2276 GtkAllocation *allocation,
2279 MainWindow *mainwin = (MainWindow *)data;
2281 main_window_get_size(mainwin);
2284 static void message_window_size_allocate_cb(GtkWidget *widget,
2285 GtkAllocation *allocation,
2288 MainWindow *mainwin = (MainWindow *)data;
2290 main_window_get_size(mainwin);
2293 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2296 main_window_add_mailbox(mainwin);
2299 static void update_folderview_cb(MainWindow *mainwin, guint action,
2302 summary_show(mainwin->summaryview, NULL);
2303 folderview_check_new_all();
2306 static void foldersort_cb(MainWindow *mainwin, guint action,
2312 static void import_mbox_cb(MainWindow *mainwin, guint action,
2315 import_mbox(mainwin->summaryview->folder_item);
2318 static void export_mbox_cb(MainWindow *mainwin, guint action,
2321 export_mbox(mainwin->summaryview->folder_item);
2324 static void empty_trash_cb(MainWindow *mainwin, guint action,
2327 main_window_empty_trash(mainwin, TRUE);
2330 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2332 summary_save_as(mainwin->summaryview);
2335 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2337 summary_print(mainwin->summaryview);
2340 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2342 if (prefs_common.confirm_on_exit) {
2343 if (alertpanel(_("Exit"), _("Exit this program?"),
2344 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2346 manage_window_focus_in(mainwin->window, NULL, NULL);
2349 app_will_exit(widget, mainwin);
2352 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2355 summary_search(mainwin->summaryview);
2357 message_search(mainwin->messageview);
2360 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2365 active = GTK_CHECK_MENU_ITEM(widget)->active;
2367 switch (mainwin->type) {
2369 case SEPARATE_MESSAGE:
2372 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2374 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2377 case SEPARATE_FOLDER:
2378 debug_print("separate folder\n");
2380 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2382 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2386 gtk_widget_show(mainwin->win.sep_both.folderwin);
2388 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2392 prefs_common.folderview_visible = active;
2395 static void toggle_message_cb(MainWindow *mainwin, guint action,
2400 active = GTK_CHECK_MENU_ITEM(widget)->active;
2402 if (active != messageview_is_visible(mainwin->messageview))
2403 summary_toggle_view(mainwin->summaryview);
2406 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2409 toolbar_toggle(action, mainwin);
2412 void main_window_reply_cb(MainWindow *mainwin, guint action,
2415 MessageView *msgview = (MessageView*)mainwin->messageview;
2416 GSList *msginfo_list = NULL;
2419 g_return_if_fail(msgview != NULL);
2421 msginfo_list = summary_get_selection(mainwin->summaryview);
2422 g_return_if_fail(msginfo_list != NULL);
2424 body = messageview_get_selection(msgview);
2425 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2427 g_slist_free(msginfo_list);
2431 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2434 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2435 gtk_widget_show(mainwin->hbox_stat);
2436 prefs_common.show_statusbar = TRUE;
2438 gtk_widget_hide(mainwin->hbox_stat);
2439 prefs_common.show_statusbar = FALSE;
2443 static void separate_widget_cb(MainWindow *mainwin, guint action,
2448 if (GTK_CHECK_MENU_ITEM(widget)->active)
2449 type = mainwin->type | action;
2451 type = mainwin->type & ~action;
2453 main_window_separation_change(mainwin, type);
2455 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2456 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2459 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2462 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2464 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2467 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2469 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2472 static void online_switch_clicked (GtkButton *btn, gpointer data)
2474 MainWindow *mainwin;
2475 GtkItemFactory *ifactory;
2476 GtkCheckMenuItem *menuitem;
2478 mainwin = (MainWindow *) data;
2480 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2481 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2483 g_return_if_fail(mainwin != NULL);
2484 g_return_if_fail(menuitem != NULL);
2486 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2488 gtk_widget_hide (mainwin->online_switch);
2489 gtk_widget_show (mainwin->offline_switch);
2490 menuitem->active = TRUE;
2491 prefs_common.work_offline = TRUE;
2492 inc_autocheck_timer_remove();
2495 gtk_widget_hide (mainwin->offline_switch);
2496 gtk_widget_show (mainwin->online_switch);
2497 menuitem->active = FALSE;
2498 prefs_common.work_offline = FALSE;
2499 inc_autocheck_timer_set();
2503 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2506 addressbook_open(NULL);
2509 static void log_window_show_cb(MainWindow *mainwin, guint action,
2512 log_window_show(mainwin->logwin);
2515 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2520 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2522 summary_move_to(mainwin->summaryview);
2525 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2527 summary_copy_to(mainwin->summaryview);
2530 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2532 summary_delete(mainwin->summaryview);
2535 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2537 summary_cancel(mainwin->summaryview);
2540 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2542 summary_open_msg(mainwin->summaryview);
2545 static void view_source_cb(MainWindow *mainwin, guint action,
2548 summary_view_source(mainwin->summaryview);
2551 static void show_all_header_cb(MainWindow *mainwin, guint action,
2554 if (mainwin->menu_lock_count) return;
2555 summary_display_msg_selected(mainwin->summaryview,
2556 GTK_CHECK_MENU_ITEM(widget)->active);
2559 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2561 summary_mark(mainwin->summaryview);
2564 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2566 summary_unmark(mainwin->summaryview);
2569 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2572 summary_mark_as_unread(mainwin->summaryview);
2575 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2578 summary_mark_as_read(mainwin->summaryview);
2581 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2584 summary_mark_all_read(mainwin->summaryview);
2587 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2589 summary_reedit(mainwin->summaryview);
2592 static void add_address_cb(MainWindow *mainwin, guint action,
2595 summary_add_address(mainwin->summaryview);
2598 static void set_charset_cb(MainWindow *mainwin, guint action,
2603 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2604 str = conv_get_charset_str((CharSet)action);
2605 g_free(prefs_common.force_charset);
2606 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2608 summary_redisplay_msg(mainwin->summaryview);
2610 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2614 static void hide_read_messages (MainWindow *mainwin, guint action,
2617 if (!mainwin->summaryview->folder_item
2618 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2620 summary_toggle_show_read_messages(mainwin->summaryview);
2623 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2625 if (mainwin->menu_lock_count) return;
2626 if (!mainwin->summaryview->folder_item) return;
2628 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2629 summary_thread_build(mainwin->summaryview);
2630 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2632 summary_unthread(mainwin->summaryview);
2633 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2637 static void expand_threads_cb(MainWindow *mainwin, guint action,
2640 summary_expand_threads(mainwin->summaryview);
2643 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2646 summary_collapse_threads(mainwin->summaryview);
2649 static void set_display_item_cb(MainWindow *mainwin, guint action,
2652 prefs_summary_column_open();
2655 static void sort_summary_cb(MainWindow *mainwin, guint action,
2658 FolderItem *item = mainwin->summaryview->folder_item;
2659 GtkWidget *menuitem;
2661 if (mainwin->menu_lock_count) return;
2663 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2664 menuitem = gtk_item_factory_get_item
2665 (mainwin->menu_factory, "/View/Sort/Ascending");
2666 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2667 GTK_CHECK_MENU_ITEM(menuitem)->active
2668 ? SORT_ASCENDING : SORT_DESCENDING);
2672 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2675 FolderItem *item = mainwin->summaryview->folder_item;
2677 if (mainwin->menu_lock_count) return;
2679 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2680 summary_sort(mainwin->summaryview,
2681 item->sort_key, (FolderSortType)action);
2684 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2687 summary_attract_by_subject(mainwin->summaryview);
2690 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2695 item = folderview_get_selected(mainwin->folderview);
2697 main_window_cursor_wait(mainwin);
2698 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2700 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2701 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2703 STATUSBAR_POP(mainwin);
2704 main_window_cursor_normal(mainwin);
2714 static void deldup_all(FolderItem *item, gpointer _data)
2716 struct DelDupsData *data = _data;
2719 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2721 data->dups += result;
2726 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2729 struct DelDupsData data = {0, 0};
2731 folder_func_to_all_folders(deldup_all, &data);
2732 alertpanel_notice(_("Deleted %d duplicate message(s) in %d folders.\n"),
2733 data.dups, data.folders);
2736 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2738 summary_filter(mainwin->summaryview, (gboolean)action);
2741 static void execute_summary_cb(MainWindow *mainwin, guint action,
2744 summary_execute(mainwin->summaryview);
2747 static void update_summary_cb(MainWindow *mainwin, guint action,
2751 FolderView *folderview = mainwin->folderview;
2753 if (!mainwin->summaryview->folder_item) return;
2754 if (!folderview->opened) return;
2756 folder_update_op_count();
2758 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2759 folderview->opened);
2762 folder_item_scan(fitem);
2763 summary_show(mainwin->summaryview, fitem);
2766 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2768 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2771 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2773 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2776 static void prev_unread_cb(MainWindow *mainwin, guint action,
2779 summary_select_prev_unread(mainwin->summaryview);
2782 static void next_unread_cb(MainWindow *mainwin, guint action,
2785 summary_select_next_unread(mainwin->summaryview);
2788 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2790 summary_select_prev_new(mainwin->summaryview);
2793 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2795 summary_select_next_new(mainwin->summaryview);
2798 static void prev_marked_cb(MainWindow *mainwin, guint action,
2801 summary_select_prev_marked(mainwin->summaryview);
2804 static void next_marked_cb(MainWindow *mainwin, guint action,
2807 summary_select_next_marked(mainwin->summaryview);
2810 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2813 summary_select_prev_labeled(mainwin->summaryview);
2816 static void next_labeled_cb(MainWindow *mainwin, guint action,
2819 summary_select_next_labeled(mainwin->summaryview);
2822 static void goto_folder_cb(MainWindow *mainwin, guint action,
2825 FolderItem *to_folder;
2827 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2830 folderview_select(mainwin->folderview, to_folder);
2833 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2835 messageview_copy_clipboard(mainwin->messageview);
2838 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2840 MessageView *msgview = mainwin->messageview;
2842 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2843 summary_select_all(mainwin->summaryview);
2844 else if (messageview_is_visible(msgview) &&
2845 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2846 messageview_select_all(mainwin->messageview);
2849 static void select_thread_cb(MainWindow *mainwin, guint action,
2852 summary_select_thread(mainwin->summaryview);
2855 static void create_filter_cb(MainWindow *mainwin, guint action,
2858 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2861 static void create_processing_cb(MainWindow *mainwin, guint action,
2864 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2867 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2870 prefs_common_open();
2873 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2876 prefs_filtering_open(&pre_global_processing,
2877 _("Processing rules to apply before folder rules"),
2881 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2884 prefs_filtering_open(&post_global_processing,
2885 _("Processing rules to apply after folder rules"),
2889 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2892 prefs_filtering_open(&filtering_rules,
2893 _("Filtering configuration"),
2897 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2900 prefs_template_open();
2903 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2906 prefs_actions_open(mainwin);
2909 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2912 ssl_manager_open(mainwin);
2915 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2919 new_account_cb(mainwin, 0, widget);
2921 account_open(cur_account);
2925 static void new_account_cb(MainWindow *mainwin, guint action,
2928 account_edit_open();
2929 if (!compose_get_compose_list()) account_add();
2932 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
2934 cur_account = (PrefsAccount *)data;
2935 main_window_reflect_prefs_all();
2938 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
2940 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
2941 PrefsAccount *account = (PrefsAccount *)data;
2943 inc_account_mail(mainwin, account);
2946 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2951 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2953 pluginwindow_create();
2956 static void manual_open_cb(MainWindow *mainwin, guint action,
2959 manual_open((ManualType)action);
2962 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2964 MainWindow *mainwin = (MainWindow *)data;
2968 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2969 LOCAL_FOLDER(folder)->rootpath,
2973 str = g_strdup_printf(_("Scanning folder %s ..."),
2974 LOCAL_FOLDER(folder)->rootpath);
2976 STATUSBAR_PUSH(mainwin, str);
2977 STATUSBAR_POP(mainwin);
2981 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2984 SummaryView *summary;
2986 g_return_val_if_fail(data, FALSE);
2987 summary = ((MainWindow *)data)->summaryview;
2988 g_return_val_if_fail(summary, FALSE);
2990 if (GTK_CLIST(summary->ctree)->selection &&
2991 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2994 if (summary->selected != summary->displayed)
2995 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2999 #define BREAK_ON_MODIFIER_KEY() \
3000 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3002 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3005 MainWindow *mainwin = (MainWindow*) data;
3007 if (!mainwin || !event) return;
3009 switch (event->keyval) {
3010 case GDK_Q: /* Quit */
3011 BREAK_ON_MODIFIER_KEY();
3013 app_exit_cb(mainwin, 0, NULL);
3016 if (mainwin->folderview && mainwin->summaryview
3017 && !mainwin->summaryview->displayed) {
3018 summary_lock(mainwin->summaryview);
3019 folderview_select_next_unread(mainwin->folderview);
3020 summary_unlock(mainwin->summaryview);
3029 #undef BREAK_ON_MODIFIER_KEY
3032 * Harvest addresses for selected folder.
3034 static void addr_harvest_cb( MainWindow *mainwin,
3038 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3042 * Harvest addresses for selected messages in summary view.
3044 static void addr_harvest_msg_cb( MainWindow *mainwin,
3048 summary_harvest_address( mainwin->summaryview );
3052 *\brief get a MainWindow
3054 *\return MainWindow * The first mainwindow in the mainwin_list
3056 MainWindow *mainwindow_get_mainwindow(void)
3058 if (mainwin_list && mainwin_list->data)
3059 return (MainWindow *)(mainwin_list->data);
3064 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3066 ProgressData *data = (ProgressData *) source;
3067 MainWindow *mainwin = (MainWindow *) userdata;
3069 switch (data->cmd) {
3070 case PROGRESS_COMMAND_START:
3071 case PROGRESS_COMMAND_STOP:
3072 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
3074 case PROGRESS_COMMAND_SET_PERCENTAGE:
3075 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
3078 while (gtk_events_pending()) gtk_main_iteration ();