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"
92 #define AC_LABEL_WIDTH 240
94 /* list of all instantiated MainWindow */
95 static GList *mainwin_list = NULL;
97 static GdkCursor *watch_cursor;
99 static void main_window_menu_callback_block (MainWindow *mainwin);
100 static void main_window_menu_callback_unblock (MainWindow *mainwin);
102 static void main_window_show_cur_account (MainWindow *mainwin);
104 static void main_window_set_widgets (MainWindow *mainwin,
108 static void toolbar_account_button_pressed (GtkWidget *widget,
109 GdkEventButton *event,
113 static void toolbar_child_attached (GtkWidget *widget,
116 static void toolbar_child_detached (GtkWidget *widget,
120 static void ac_label_button_pressed (GtkWidget *widget,
121 GdkEventButton *event,
123 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
126 static gint main_window_close_cb (GtkWidget *widget,
129 static gint folder_window_close_cb (GtkWidget *widget,
132 static gint message_window_close_cb (GtkWidget *widget,
136 static void main_window_size_allocate_cb (GtkWidget *widget,
137 GtkAllocation *allocation,
139 static void folder_window_size_allocate_cb (GtkWidget *widget,
140 GtkAllocation *allocation,
142 static void message_window_size_allocate_cb (GtkWidget *widget,
143 GtkAllocation *allocation,
146 static void new_folder_cb (MainWindow *mainwin,
149 static void rename_folder_cb (MainWindow *mainwin,
152 static void delete_folder_cb (MainWindow *mainwin,
155 static void update_folderview_cb (MainWindow *mainwin,
158 static void add_mailbox_cb (MainWindow *mainwin,
161 static void import_mbox_cb (MainWindow *mainwin,
164 static void export_mbox_cb (MainWindow *mainwin,
167 static void empty_trash_cb (MainWindow *mainwin,
171 static void save_as_cb (MainWindow *mainwin,
174 static void print_cb (MainWindow *mainwin,
177 static void app_exit_cb (MainWindow *mainwin,
181 static void search_cb (MainWindow *mainwin,
185 static void toggle_folder_cb (MainWindow *mainwin,
188 static void toggle_message_cb (MainWindow *mainwin,
191 static void toggle_toolbar_cb (MainWindow *mainwin,
194 static void toggle_statusbar_cb (MainWindow *mainwin,
197 static void separate_widget_cb (MainWindow *mainwin,
201 static void addressbook_open_cb (MainWindow *mainwin,
204 static void log_window_show_cb (MainWindow *mainwin,
208 static void inc_cancel_cb (MainWindow *mainwin,
212 static void open_msg_cb (MainWindow *mainwin,
216 static void view_source_cb (MainWindow *mainwin,
220 static void show_all_header_cb (MainWindow *mainwin,
224 static void reedit_cb (MainWindow *mainwin,
228 static void move_to_cb (MainWindow *mainwin,
231 static void copy_to_cb (MainWindow *mainwin,
234 static void delete_cb (MainWindow *mainwin,
238 static void cancel_cb (MainWindow *mainwin,
242 static void mark_cb (MainWindow *mainwin,
245 static void unmark_cb (MainWindow *mainwin,
249 static void mark_as_unread_cb (MainWindow *mainwin,
252 static void mark_as_read_cb (MainWindow *mainwin,
255 static void mark_all_read_cb (MainWindow *mainwin,
258 static void add_address_cb (MainWindow *mainwin,
262 static void set_charset_cb (MainWindow *mainwin,
266 static void hide_read_messages (MainWindow *mainwin,
270 static void thread_cb (MainWindow *mainwin,
273 static void expand_threads_cb (MainWindow *mainwin,
276 static void collapse_threads_cb (MainWindow *mainwin,
280 static void set_display_item_cb (MainWindow *mainwin,
283 static void sort_summary_cb (MainWindow *mainwin,
286 static void sort_summary_type_cb (MainWindow *mainwin,
289 static void attract_by_subject_cb(MainWindow *mainwin,
293 static void delete_duplicated_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/_Folder"), NULL, NULL, 0, "<Branch>"},
437 {N_("/_File/_Folder/Create _new folder..."),
438 NULL, new_folder_cb, 0, NULL},
439 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
440 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
441 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
442 {N_("/_File/_Folder/_Check for new messages in all folders"),
443 NULL, update_folderview_cb, 0, NULL},
444 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
445 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
446 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
447 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
448 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
449 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
450 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
451 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
452 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
453 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
454 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
455 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
456 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
458 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
459 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
460 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
461 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
462 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
463 {N_("/_Edit/_Find in current message..."),
464 "<control>F", search_cb, 0, NULL},
465 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
466 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
467 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
468 {N_("/_View/Show or hi_de/_Folder tree"),
469 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
470 {N_("/_View/Show or hi_de/_Message view"),
471 "V", toggle_message_cb, 0, "<ToggleItem>"},
472 {N_("/_View/Show or hi_de/_Toolbar"),
473 NULL, NULL, 0, "<Branch>"},
474 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
475 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
476 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
477 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
478 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
479 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
480 {N_("/_View/Show or hi_de/_Toolbar/_None"),
481 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
482 {N_("/_View/Show or hi_de/Status _bar"),
483 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
484 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
486 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
487 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
488 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
489 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
490 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
491 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
492 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
493 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
494 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
495 {N_("/_View/_Sort/by _color label"),
496 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
497 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
498 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
499 {N_("/_View/_Sort/by a_ttachment"),
500 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
501 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
502 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
503 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
504 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
505 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
506 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
507 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_View/_Sort/_Attract by subject"),
509 NULL, attract_by_subject_cb, 0, NULL},
510 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
511 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
512 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
513 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
514 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
516 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
517 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
518 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
519 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
520 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_View/_Go to/P_rev unread message"),
522 "<shift>P", prev_unread_cb, 0, NULL},
523 {N_("/_View/_Go to/N_ext unread message"),
524 "<shift>N", next_unread_cb, 0, NULL},
525 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
527 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
528 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_View/_Go to/Prev _marked message"),
530 NULL, prev_marked_cb, 0, NULL},
531 {N_("/_View/_Go to/Next m_arked message"),
532 NULL, next_marked_cb, 0, NULL},
533 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_View/_Go to/Prev _labeled message"),
535 NULL, prev_labeled_cb, 0, NULL},
536 {N_("/_View/_Go to/Next la_beled message"),
537 NULL, next_labeled_cb, 0, NULL},
538 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
540 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
542 #define CODESET_SEPARATOR \
543 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
544 #define CODESET_ACTION(action) \
545 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
547 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
548 {N_("/_View/_Code set/_Auto detect"),
549 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
550 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
552 CODESET_ACTION(C_US_ASCII)},
555 {N_("/_View/_Code set/Unicode (_UTF-8)"),
556 CODESET_ACTION(C_UTF_8)},
559 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
560 CODESET_ACTION(C_ISO_8859_1)},
561 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
562 CODESET_ACTION(C_ISO_8859_15)},
565 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
566 CODESET_ACTION(C_ISO_8859_2)},
568 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
569 CODESET_ACTION(C_ISO_8859_13)},
570 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
571 CODESET_ACTION(C_ISO_8859_4)},
573 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
574 CODESET_ACTION(C_ISO_8859_7)},
576 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
577 CODESET_ACTION(C_ISO_8859_9)},
579 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
580 CODESET_ACTION(C_ISO_8859_5)},
581 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
582 CODESET_ACTION(C_KOI8_R)},
583 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
584 CODESET_ACTION(C_WINDOWS_1251)},
587 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
588 CODESET_ACTION(C_ISO_2022_JP)},
590 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
591 CODESET_ACTION(C_ISO_2022_JP_2)},
593 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
594 CODESET_ACTION(C_EUC_JP)},
595 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
596 CODESET_ACTION(C_SHIFT_JIS)},
599 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
600 CODESET_ACTION(C_GB2312)},
601 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
602 CODESET_ACTION(C_BIG5)},
603 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
604 CODESET_ACTION(C_EUC_TW)},
605 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
606 CODESET_ACTION(C_ISO_2022_CN)},
608 {N_("/_View/_Code set/Korean (EUC-_KR)"),
609 CODESET_ACTION(C_EUC_KR)},
610 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
611 CODESET_ACTION(C_ISO_2022_KR)},
613 {N_("/_View/_Code set/Thai (TIS-620)"),
614 CODESET_ACTION(C_TIS_620)},
615 {N_("/_View/_Code set/Thai (Windows-874)"),
616 CODESET_ACTION(C_WINDOWS_874)},
619 #undef CODESET_SEPARATOR
620 #undef CODESET_ACTION
622 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
624 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
625 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
626 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
629 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
630 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
631 {N_("/_Message/Recei_ve/Get from _current account"),
632 "<control>I", inc_mail_cb, 0, NULL},
633 {N_("/_Message/Recei_ve/Get from _all accounts"),
634 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
635 {N_("/_Message/Recei_ve/Cancel receivin_g"),
636 NULL, inc_cancel_cb, 0, NULL},
637 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
639 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
641 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
642 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
643 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
644 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
645 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
646 {N_("/_Message/Repl_y to/mailing _list"),
647 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
648 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
649 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
650 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
651 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
652 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
654 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
655 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
656 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
657 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
658 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
659 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
660 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
661 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
662 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
663 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
665 {N_("/_Message/_Mark/Mark as rea_d"),
666 NULL, mark_as_read_cb, 0, NULL},
667 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
669 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
671 {N_("/_Tools/Add sender to address boo_k"),
672 NULL, add_address_cb, 0, NULL},
673 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
674 {N_("/_Tools/_Harvest addresses/from _Folder..."),
675 NULL, addr_harvest_cb, 0, NULL},
676 {N_("/_Tools/_Harvest addresses/from _Messages..."),
677 NULL, addr_harvest_msg_cb, 0, NULL},
678 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
680 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
681 {N_("/_Tools/_Create filter rule/_Automatically"),
682 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
683 {N_("/_Tools/_Create filter rule/by _From"),
684 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
685 {N_("/_Tools/_Create filter rule/by _To"),
686 NULL, create_filter_cb, FILTER_BY_TO, NULL},
687 {N_("/_Tools/_Create filter rule/by _Subject"),
688 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
689 {N_("/_Tools/_Create processing rule"), NULL, NULL, 0, "<Branch>"},
690 {N_("/_Tools/_Create processing rule/_Automatically"),
691 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
692 {N_("/_Tools/_Create processing rule/by _From"),
693 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
694 {N_("/_Tools/_Create processing rule/by _To"),
695 NULL, create_processing_cb, FILTER_BY_TO, NULL},
696 {N_("/_Tools/_Create processing rule/by _Subject"),
697 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
698 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
701 {N_("/_Tools/Delete du_plicated messages"),
702 NULL, delete_duplicated_cb, 0, NULL},
703 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
706 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
707 {N_("/_Tools/SSL certi_ficates..."),
708 NULL, ssl_manager_open_cb, 0, NULL},
710 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
711 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
713 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
714 {N_("/_Configuration/C_hange current account"),
715 NULL, NULL, 0, "<Branch>"},
716 {N_("/_Configuration/_Preferences for current account..."),
717 NULL, prefs_account_open_cb, 0, NULL},
718 {N_("/_Configuration/Create _new account..."),
719 NULL, new_account_cb, 0, NULL},
720 {N_("/_Configuration/_Edit accounts..."),
721 NULL, account_edit_open, 0, NULL},
722 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
723 {N_("/_Configuration/_Common preferences..."),
724 NULL, prefs_common_open_cb, 0, NULL},
725 {N_("/_Configuration/Pre-processing..."),
726 NULL, prefs_pre_processing_open_cb, 0, NULL},
727 {N_("/_Configuration/Post-processing..."),
728 NULL, prefs_post_processing_open_cb, 0, NULL},
729 {N_("/_Configuration/_Filtering..."),
730 NULL, prefs_filtering_open_cb, 0, NULL},
731 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
732 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
733 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
734 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
736 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
737 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
738 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
739 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
740 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
741 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
742 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
743 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
744 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
745 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
746 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
749 MainWindow *main_window_create(SeparateType type)
755 GtkWidget *handlebox;
756 GtkWidget *vbox_body;
757 GtkWidget *hbox_stat;
758 GtkWidget *statusbar;
759 GtkWidget *progressbar;
760 GtkWidget *statuslabel;
761 GtkWidget *ac_button;
763 GtkWidget *online_pixmap;
764 GtkWidget *offline_pixmap;
765 GtkWidget *online_switch;
766 GtkWidget *offline_switch;
767 GtkTooltips *offline_tip;
768 GtkTooltips *online_tip;
769 GtkTooltips *sel_ac_tip;
771 FolderView *folderview;
772 SummaryView *summaryview;
773 MessageView *messageview;
774 GdkColormap *colormap;
777 GtkItemFactory *ifactory;
781 guint n_menu_entries;
783 static GdkGeometry geometry;
785 debug_print("Creating main window...\n");
786 mainwin = g_new0(MainWindow, 1);
789 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
790 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
791 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
792 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
794 if (!geometry.min_height) {
795 geometry.min_width = 320;
796 geometry.min_height = 200;
798 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
801 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
802 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
803 MANAGE_WINDOW_SIGNALS_CONNECT(window);
804 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
805 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
807 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
808 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
810 gtk_widget_realize(window);
811 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
814 gtkut_widget_set_app_icon(window);
816 vbox = gtk_vbox_new(FALSE, 0);
817 gtk_widget_show(vbox);
818 gtk_container_add(GTK_CONTAINER(window), vbox);
821 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
822 menubar = menubar_create(window, mainwin_entries,
823 n_menu_entries, "<Main>", mainwin);
824 gtk_widget_show(menubar);
825 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
826 ifactory = gtk_item_factory_from_widget(menubar);
828 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
829 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
831 handlebox = gtk_handle_box_new();
832 gtk_widget_show(handlebox);
833 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
834 gtk_signal_connect(GTK_OBJECT(handlebox), "child_attached",
835 GTK_SIGNAL_FUNC(toolbar_child_attached), mainwin);
836 gtk_signal_connect(GTK_OBJECT(handlebox), "child_detached",
837 GTK_SIGNAL_FUNC(toolbar_child_detached), mainwin);
839 /* link window to mainwin->window to avoid gdk warnings */
840 mainwin->window = window;
843 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
847 /* vbox that contains body */
848 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
849 gtk_widget_show(vbox_body);
850 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
851 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
853 hbox_stat = gtk_hbox_new(FALSE, 2);
854 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
856 statusbar = statusbar_create();
857 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
859 progressbar = gtk_progress_bar_new();
860 gtk_widget_set_usize(progressbar, 120, 1);
861 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
863 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
864 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
865 online_tip = gtk_tooltips_new();
866 online_switch = gtk_button_new ();
867 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
868 _("You are online. Click the icon to go offline"), NULL);
869 offline_tip = gtk_tooltips_new();
870 offline_switch = gtk_button_new ();
871 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
872 _("You are offline. Click the icon to go online"),
874 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
875 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
876 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
877 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
878 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
879 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
880 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
881 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
883 statuslabel = gtk_label_new("");
884 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
886 sel_ac_tip = gtk_tooltips_new();
887 ac_button = gtk_button_new();
888 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
889 ac_button, _("Select account"), NULL);
890 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
891 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
892 gtk_widget_set_usize(ac_button, -1, 1);
893 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
894 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
895 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
897 ac_label = gtk_label_new("");
898 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
900 gtk_widget_show_all(hbox_stat);
902 gtk_widget_hide(offline_switch);
904 mainwin->folderview = folderview = folderview_create();
905 mainwin->summaryview = summaryview = summary_create();
906 mainwin->messageview = messageview = messageview_create(mainwin);
907 mainwin->logwin = log_window_create();
909 folderview->mainwin = mainwin;
910 folderview->summaryview = summaryview;
912 summaryview->mainwin = mainwin;
913 summaryview->folderview = folderview;
914 summaryview->messageview = messageview;
915 summaryview->window = window;
917 mainwin->vbox = vbox;
918 mainwin->menubar = menubar;
919 mainwin->menu_factory = ifactory;
920 mainwin->handlebox = handlebox;
921 mainwin->vbox_body = vbox_body;
922 mainwin->hbox_stat = hbox_stat;
923 mainwin->statusbar = statusbar;
924 mainwin->progressbar = progressbar;
925 mainwin->statuslabel = statuslabel;
926 mainwin->ac_button = ac_button;
927 mainwin->ac_label = ac_label;
929 mainwin->online_switch = online_switch;
930 mainwin->offline_switch = offline_switch;
931 mainwin->online_pixmap = online_pixmap;
932 mainwin->offline_pixmap = offline_pixmap;
934 /* set context IDs for status bar */
935 mainwin->mainwin_cid = gtk_statusbar_get_context_id
936 (GTK_STATUSBAR(statusbar), "Main Window");
937 mainwin->folderview_cid = gtk_statusbar_get_context_id
938 (GTK_STATUSBAR(statusbar), "Folder View");
939 mainwin->summaryview_cid = gtk_statusbar_get_context_id
940 (GTK_STATUSBAR(statusbar), "Summary View");
941 mainwin->messageview_cid = gtk_statusbar_get_context_id
942 (GTK_STATUSBAR(statusbar), "Message View");
944 /* allocate colors for summary view and folder view */
945 summaryview->color_marked.red = summaryview->color_marked.green = 0;
946 summaryview->color_marked.blue = (guint16)65535;
948 summaryview->color_dim.red = summaryview->color_dim.green =
949 summaryview->color_dim.blue = COLOR_DIM;
951 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
952 &folderview->color_new);
954 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
955 &folderview->color_op);
957 summaryview->color_important.red = 0;
958 summaryview->color_important.green = 0;
959 summaryview->color_important.blue = (guint16)65535;
961 color[0] = summaryview->color_marked;
962 color[1] = summaryview->color_dim;
963 color[2] = folderview->color_new;
964 color[3] = folderview->color_op;
966 colormap = gdk_window_get_colormap(window->window);
967 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
968 for (i = 0; i < 4; i++) {
969 if (success[i] == FALSE)
970 g_warning("MainWindow: color allocation %d failed\n", i);
973 debug_print("done.\n");
975 messageview->visible = prefs_common.msgview_visible;
977 main_window_set_widgets(mainwin, type);
979 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
980 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
984 menuitem = gtk_item_factory_get_item
985 (ifactory, "/View/Code set/Auto detect");
986 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
988 switch (prefs_common.toolbar_style) {
990 menuitem = gtk_item_factory_get_item
991 (ifactory, "/View/Show or hide/Toolbar/None");
994 menuitem = gtk_item_factory_get_item
995 (ifactory, "/View/Show or hide/Toolbar/Icon");
998 menuitem = gtk_item_factory_get_item
999 (ifactory, "/View/Show or hide/Toolbar/Text");
1002 menuitem = gtk_item_factory_get_item
1003 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1005 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1007 gtk_widget_hide(mainwin->hbox_stat);
1008 menuitem = gtk_item_factory_get_item
1009 (ifactory, "/View/Show or hide/Status bar");
1010 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1011 prefs_common.show_statusbar);
1013 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1015 if (prefs_common.show_searchbar) {
1016 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1017 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
1018 gtk_widget_hide(summaryview->search_description);
1021 /* set account selection menu */
1022 ac_menu = gtk_item_factory_get_widget
1023 (ifactory, "/Configuration/Change current account");
1024 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1025 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1026 mainwin->ac_menu = ac_menu;
1028 toolbar_main_set_sensitive(mainwin);
1030 /* create actions menu */
1031 main_window_update_actions_menu(mainwin);
1033 /* attach accel groups to main window */
1034 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1035 gtk_window_add_accel_group \
1037 gtk_item_factory_from_widget(menu)->accel_group)
1039 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
1041 /* connect the accelerators for equivalent
1042 menu items in different menus */
1043 menu_connect_identical_items();
1047 /* show main window */
1048 gtk_widget_show(mainwin->window);
1050 /* initialize views */
1051 folderview_init(folderview);
1052 summary_init(summaryview);
1053 messageview_init(messageview);
1054 log_window_init(mainwin->logwin);
1055 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1056 prefs_common.loglength);
1058 sslcertwindow_register_hook();
1060 mainwin->lock_count = 0;
1061 mainwin->menu_lock_count = 0;
1062 mainwin->cursor_count = 0;
1064 mainwin->progressindicator_hook =
1065 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1068 watch_cursor = gdk_cursor_new(GDK_WATCH);
1070 mainwin_list = g_list_append(mainwin_list, mainwin);
1072 /* init work_offline */
1073 if (prefs_common.work_offline)
1074 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1079 void main_window_destroy(MainWindow *mainwin)
1081 /* TODO : destroy other component */
1082 messageview_destroy(mainwin->messageview);
1085 void main_window_update_actions_menu(MainWindow *mainwin)
1087 GtkItemFactory *ifactory;
1089 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1090 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1093 void main_window_cursor_wait(MainWindow *mainwin)
1096 if (mainwin->cursor_count == 0)
1097 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1099 mainwin->cursor_count++;
1104 void main_window_cursor_normal(MainWindow *mainwin)
1106 if (mainwin->cursor_count)
1107 mainwin->cursor_count--;
1109 if (mainwin->cursor_count == 0)
1110 gdk_window_set_cursor(mainwin->window->window, NULL);
1115 /* lock / unlock the user-interface */
1116 void main_window_lock(MainWindow *mainwin)
1118 if (mainwin->lock_count == 0)
1119 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1121 mainwin->lock_count++;
1123 main_window_set_menu_sensitive(mainwin);
1124 toolbar_main_set_sensitive(mainwin);
1127 void main_window_unlock(MainWindow *mainwin)
1129 if (mainwin->lock_count)
1130 mainwin->lock_count--;
1132 main_window_set_menu_sensitive(mainwin);
1133 toolbar_main_set_sensitive(mainwin);
1135 if (mainwin->lock_count == 0)
1136 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1139 static void main_window_menu_callback_block(MainWindow *mainwin)
1141 mainwin->menu_lock_count++;
1144 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1146 if (mainwin->menu_lock_count)
1147 mainwin->menu_lock_count--;
1150 void main_window_reflect_prefs_all(void)
1152 main_window_reflect_prefs_all_real(FALSE);
1155 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1158 MainWindow *mainwin;
1161 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1162 mainwin = (MainWindow *)cur->data;
1164 main_window_show_cur_account(mainwin);
1165 main_window_set_menu_sensitive(mainwin);
1166 toolbar_main_set_sensitive(mainwin);
1169 if (pixmap_theme_changed) {
1170 toolbar_update(TOOLBAR_MAIN, mainwin);
1171 messageview_reflect_prefs_pixmap_theme();
1172 compose_reflect_prefs_pixmap_theme();
1173 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1174 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1176 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1177 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1178 mainwin->online_pixmap);
1179 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1180 gtk_widget_show(pixmap);
1181 mainwin->online_pixmap = pixmap;
1182 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1183 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1184 mainwin->offline_pixmap);
1185 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1186 gtk_widget_show(pixmap);
1187 mainwin->offline_pixmap = pixmap;
1190 summary_redisplay_msg(mainwin->summaryview);
1191 headerview_set_visibility(mainwin->messageview->headerview,
1192 prefs_common.display_header_pane);
1196 void main_window_set_summary_column(void)
1199 MainWindow *mainwin;
1201 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1202 mainwin = (MainWindow *)cur->data;
1203 summary_set_column_order(mainwin->summaryview);
1207 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1208 GList *account_list)
1210 GList *cur_ac, *cur_item;
1211 GtkWidget *menuitem;
1212 PrefsAccount *ac_prefs;
1214 /* destroy all previous menu item */
1215 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1216 while (cur_item != NULL) {
1217 GList *next = cur_item->next;
1218 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1222 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1223 ac_prefs = (PrefsAccount *)cur_ac->data;
1225 menuitem = gtk_menu_item_new_with_label
1226 (ac_prefs->account_name
1227 ? ac_prefs->account_name : _("Untitled"));
1228 gtk_widget_show(menuitem);
1229 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1230 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1231 GTK_SIGNAL_FUNC(account_selector_menu_cb),
1236 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1237 GList *account_list)
1239 GList *cur_ac, *cur_item;
1241 GtkWidget *menuitem;
1242 PrefsAccount *ac_prefs;
1244 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1245 "/Message/Receive");
1247 /* search for separator */
1248 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1249 cur_item = cur_item->next) {
1250 if (GTK_BIN(cur_item->data)->child == NULL) {
1251 cur_item = cur_item->next;
1256 /* destroy all previous menu item */
1257 while (cur_item != NULL) {
1258 GList *next = cur_item->next;
1259 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1263 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1264 ac_prefs = (PrefsAccount *)cur_ac->data;
1266 menuitem = gtk_menu_item_new_with_label
1267 (ac_prefs->account_name ? ac_prefs->account_name
1269 gtk_widget_show(menuitem);
1270 gtk_menu_append(GTK_MENU(menu), menuitem);
1271 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1272 GTK_SIGNAL_FUNC(account_receive_menu_cb),
1277 void main_window_set_account_menu(GList *account_list)
1280 MainWindow *mainwin;
1282 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1283 mainwin = (MainWindow *)cur->data;
1284 main_window_set_account_selector_menu(mainwin, account_list);
1285 main_window_set_account_receive_menu(mainwin, account_list);
1289 static void main_window_show_cur_account(MainWindow *mainwin)
1294 ac_name = g_strdup(cur_account
1295 ? (cur_account->account_name
1296 ? cur_account->account_name : _("Untitled"))
1300 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1302 buf = g_strdup(PROG_VERSION);
1303 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1306 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1307 gtk_widget_queue_resize(mainwin->ac_button);
1312 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1314 switch (mainwin->type) {
1315 case SEPARATE_FOLDER:
1316 return mainwin->win.sep_folder.folderwin;
1318 return mainwin->win.sep_both.folderwin;
1324 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1326 switch (mainwin->type) {
1327 case SEPARATE_MESSAGE:
1328 return mainwin->win.sep_message.messagewin;
1330 return mainwin->win.sep_both.messagewin;
1336 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1338 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1339 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1340 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1341 GtkWidget *message_wid = mainwin->messageview->vbox;
1343 debug_print("Changing window separation type from %d to %d\n",
1344 mainwin->type, type);
1346 if (mainwin->type == type) return;
1348 /* remove widgets from those containers */
1349 gtk_widget_ref(folder_wid);
1350 gtk_widget_ref(summary_wid);
1351 gtk_widget_ref(message_wid);
1352 gtkut_container_remove
1353 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1354 gtkut_container_remove
1355 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1356 gtkut_container_remove
1357 (GTK_CONTAINER(message_wid->parent), message_wid);
1359 /* clean containers */
1360 switch (mainwin->type) {
1362 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1364 case SEPARATE_FOLDER:
1365 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1366 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1368 case SEPARATE_MESSAGE:
1369 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1370 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1373 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1374 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1378 gtk_widget_hide(mainwin->window);
1379 main_window_set_widgets(mainwin, type);
1380 gtk_widget_show(mainwin->window);
1382 gtk_widget_unref(folder_wid);
1383 gtk_widget_unref(summary_wid);
1384 gtk_widget_unref(message_wid);
1387 void main_window_toggle_message_view(MainWindow *mainwin)
1389 SummaryView *summaryview = mainwin->summaryview;
1390 union CompositeWin *cwin = &mainwin->win;
1391 GtkWidget *vpaned = NULL;
1392 GtkWidget *container = NULL;
1393 GtkWidget *msgwin = NULL;
1395 switch (mainwin->type) {
1397 vpaned = cwin->sep_none.vpaned;
1398 container = cwin->sep_none.hpaned;
1400 case SEPARATE_FOLDER:
1401 vpaned = cwin->sep_folder.vpaned;
1402 container = mainwin->vbox_body;
1404 case SEPARATE_MESSAGE:
1405 msgwin = mainwin->win.sep_message.messagewin;
1408 msgwin = mainwin->win.sep_both.messagewin;
1413 if (GTK_WIDGET_VISIBLE(msgwin)) {
1414 gtk_widget_hide(msgwin);
1415 mainwin->messageview->visible = FALSE;
1416 summaryview->displayed = NULL;
1418 gtk_widget_show(msgwin);
1419 mainwin->messageview->visible = TRUE;
1421 } else if (vpaned->parent != NULL) {
1422 mainwin->messageview->visible = FALSE;
1423 summaryview->displayed = NULL;
1424 gtk_widget_ref(vpaned);
1425 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1426 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1427 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1428 GTK_ARROW_UP, GTK_SHADOW_OUT);
1430 mainwin->messageview->visible = TRUE;
1431 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1432 gtk_container_add(GTK_CONTAINER(container), vpaned);
1433 gtk_widget_unref(vpaned);
1434 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1435 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1438 if (mainwin->messageview->visible == FALSE)
1439 messageview_clear(mainwin->messageview);
1441 main_window_set_menu_sensitive(mainwin);
1443 prefs_common.msgview_visible = mainwin->messageview->visible;
1445 gtk_widget_grab_focus(summaryview->ctree);
1448 void main_window_get_size(MainWindow *mainwin)
1450 GtkAllocation *allocation;
1452 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1454 if (allocation->width > 1 && allocation->height > 1) {
1455 prefs_common.summaryview_width = allocation->width;
1457 if ((mainwin->type == SEPARATE_NONE ||
1458 mainwin->type == SEPARATE_FOLDER) &&
1459 messageview_is_visible(mainwin->messageview))
1460 prefs_common.summaryview_height = allocation->height;
1462 prefs_common.mainview_width = allocation->width;
1465 allocation = &mainwin->window->allocation;
1466 if (allocation->width > 1 && allocation->height > 1) {
1467 prefs_common.mainview_height = allocation->height;
1468 prefs_common.mainwin_width = allocation->width;
1469 prefs_common.mainwin_height = allocation->height;
1472 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1473 if (allocation->width > 1 && allocation->height > 1) {
1474 prefs_common.folderview_width = allocation->width;
1475 prefs_common.folderview_height = allocation->height;
1478 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1479 if (allocation->width > 1 && allocation->height > 1) {
1480 prefs_common.msgview_width = allocation->width;
1481 prefs_common.msgview_height = allocation->height;
1484 debug_print("summaryview size: %d x %d\n",
1485 prefs_common.summaryview_width,
1486 prefs_common.summaryview_height);
1487 debug_print("folderview size: %d x %d\n",
1488 prefs_common.folderview_width,
1489 prefs_common.folderview_height);
1490 debug_print("messageview size: %d x %d\n",
1491 prefs_common.msgview_width,
1492 prefs_common.msgview_height);
1495 void main_window_get_position(MainWindow *mainwin)
1500 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1502 prefs_common.mainview_x = x;
1503 prefs_common.mainview_y = y;
1504 prefs_common.mainwin_x = x;
1505 prefs_common.mainwin_y = y;
1507 debug_print("main window position: %d, %d\n", x, y);
1509 window = main_window_get_folder_window(mainwin);
1511 gtkut_widget_get_uposition(window, &x, &y);
1512 prefs_common.folderwin_x = x;
1513 prefs_common.folderwin_y = y;
1514 debug_print("folder window position: %d, %d\n", x, y);
1516 window = main_window_get_message_window(mainwin);
1518 gtkut_widget_get_uposition(window, &x, &y);
1519 prefs_common.main_msgwin_x = x;
1520 prefs_common.main_msgwin_y = y;
1521 debug_print("message window position: %d, %d\n", x, y);
1525 void main_window_progress_on(MainWindow *mainwin)
1527 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE);
1528 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1531 void main_window_progress_off(MainWindow *mainwin)
1533 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE);
1534 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1535 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1538 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1542 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1543 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf);
1544 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar),
1545 (cur == 0 && total == 0) ? 0 :
1546 (gfloat)cur / (gfloat)total);
1549 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1555 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1556 folder = FOLDER(list->data);
1557 if (folder && folder->trash && folder->trash->total_msgs > 0)
1561 if (!has_trash) return;
1564 if (alertpanel(_("Empty trash"),
1565 _("Empty all messages in trash?"),
1566 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1568 manage_window_focus_in(mainwin->window, NULL, NULL);
1571 procmsg_empty_trash();
1573 if (mainwin->summaryview->folder_item &&
1574 mainwin->summaryview->folder_item->stype == F_TRASH)
1575 gtk_widget_grab_focus(mainwin->folderview->ctree);
1578 void main_window_add_mailbox(MainWindow *mainwin)
1583 path = input_dialog(_("Add mailbox"),
1584 _("Input the location of mailbox.\n"
1585 "If the existing mailbox is specified, it will be\n"
1586 "scanned automatically."),
1589 if (folder_find_from_path(path)) {
1590 alertpanel_error(_("The mailbox `%s' already exists."), path);
1594 folder = folder_new(folder_get_class_from_string("mh"),
1595 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1599 if (folder->klass->create_tree(folder) < 0) {
1600 alertpanel_error(_("Creation of the mailbox failed.\n"
1601 "Maybe some files already exist, or you don't have the permission to write there."));
1602 folder_destroy(folder);
1607 folder_set_ui_func(folder, scan_tree_func, mainwin);
1608 folder_scan_tree(folder);
1609 folder_set_ui_func(folder, NULL, NULL);
1612 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1614 SensitiveCond state = 0;
1615 SummarySelection selection;
1616 FolderItem *item = mainwin->summaryview->folder_item;
1617 GList *account_list = account_get_list();
1619 selection = summary_get_selection_type(mainwin->summaryview);
1621 if (mainwin->lock_count == 0)
1622 state |= M_UNLOCKED;
1623 if (selection != SUMMARY_NONE)
1624 state |= M_MSG_EXIST;
1625 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1627 /* if (item->folder->type != F_NEWS) */
1628 state |= M_ALLOW_DELETE;
1630 if (prefs_common.immediate_exec == 0
1631 && mainwin->lock_count == 0)
1632 state |= M_DELAY_EXEC;
1634 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1635 || selection != SUMMARY_NONE)
1636 state |= M_HIDE_READ_MSG;
1638 if (mainwin->summaryview->threaded)
1639 state |= M_THREADED;
1641 state |= M_UNTHREADED;
1642 if (selection == SUMMARY_SELECTED_SINGLE ||
1643 selection == SUMMARY_SELECTED_MULTIPLE)
1644 state |= M_TARGET_EXIST;
1645 if (selection == SUMMARY_SELECTED_SINGLE)
1646 state |= M_SINGLE_TARGET_EXIST;
1647 if (mainwin->summaryview->folder_item &&
1648 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1651 state |= M_NOT_NEWS;
1652 if (selection == SUMMARY_SELECTED_SINGLE &&
1654 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1655 item->stype == F_QUEUE)))
1656 state |= M_ALLOW_REEDIT;
1658 state |= M_HAVE_ACCOUNT;
1660 for ( ; account_list != NULL; account_list = account_list->next) {
1661 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1662 state |= M_HAVE_NEWS_ACCOUNT;
1667 if (inc_is_active())
1668 state |= M_INC_ACTIVE;
1675 void main_window_set_menu_sensitive(MainWindow *mainwin)
1677 GtkItemFactory *ifactory = mainwin->menu_factory;
1678 SensitiveCond state;
1681 GtkWidget *menuitem;
1682 SummaryView *summaryview;
1687 static const struct {
1691 {"/File/Folder" , M_UNLOCKED},
1692 {"/File/Add mailbox" , M_UNLOCKED},
1694 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1695 {"/File/Export to mbox file..." , M_UNLOCKED},
1696 {"/File/Empty trash" , M_UNLOCKED},
1697 {"/File/Work offline" , M_UNLOCKED},
1699 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1700 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1701 /* {"/File/Close" , M_UNLOCKED}, */
1702 {"/File/Exit" , M_UNLOCKED},
1704 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1706 {"/View/Sort" , M_EXEC},
1707 {"/View/Thread view" , M_EXEC},
1708 {"/View/Expand all threads" , M_MSG_EXIST},
1709 {"/View/Collapse all threads" , M_MSG_EXIST},
1710 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1711 {"/View/Go to/Prev message" , M_MSG_EXIST},
1712 {"/View/Go to/Next message" , M_MSG_EXIST},
1713 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1714 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1715 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1716 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1717 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1718 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1719 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1720 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1721 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1723 {"/Message/Receive/Get from current account"
1724 , M_HAVE_ACCOUNT|M_UNLOCKED},
1725 {"/Message/Receive/Get from all accounts"
1726 , M_HAVE_ACCOUNT|M_UNLOCKED},
1727 {"/Message/Receive/Cancel receiving"
1730 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1731 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1732 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1733 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1734 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1735 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1736 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1737 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1738 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1739 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1740 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1741 {"/Message/Mark" , M_TARGET_EXIST},
1743 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1744 {"/Tools/Harvest addresses" , M_UNLOCKED},
1745 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1746 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1747 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1748 {"/Tools/Execute" , M_DELAY_EXEC},
1749 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1751 {"/Configuration", M_UNLOCKED},
1756 state = main_window_get_current_state(mainwin);
1758 for (i = 0; entry[i].entry != NULL; i++) {
1759 sensitive = ((entry[i].cond & state) == entry[i].cond);
1760 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1763 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1765 /* search for separator */
1766 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1767 cur_item = cur_item->next) {
1768 if (GTK_BIN(cur_item->data)->child == NULL) {
1769 cur_item = cur_item->next;
1774 for (; cur_item != NULL; cur_item = cur_item->next) {
1775 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1776 (M_UNLOCKED & state) != 0);
1779 main_window_menu_callback_block(mainwin);
1781 #define SET_CHECK_MENU_ACTIVE(path, active) \
1783 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1784 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1787 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1788 messageview_is_visible(mainwin->messageview));
1790 summaryview = mainwin->summaryview;
1791 menu_path = "/View/Sort/Don't sort";
1793 switch (summaryview->sort_key) {
1794 case SORT_BY_NUMBER:
1795 menu_path = "/View/Sort/by number"; break;
1797 menu_path = "/View/Sort/by size"; break;
1799 menu_path = "/View/Sort/by date"; break;
1801 menu_path = "/View/Sort/by from"; break;
1803 menu_path = "/View/Sort/by recipient"; break;
1804 case SORT_BY_SUBJECT:
1805 menu_path = "/View/Sort/by subject"; break;
1807 menu_path = "/View/Sort/by color label"; break;
1809 menu_path = "/View/Sort/by mark"; break;
1810 case SORT_BY_STATUS:
1811 menu_path = "/View/Sort/by status"; break;
1813 menu_path = "/View/Sort/by attachment"; break;
1815 menu_path = "/View/Sort/by score"; break;
1816 case SORT_BY_LOCKED:
1817 menu_path = "/View/Sort/by locked"; break;
1820 menu_path = "/View/Sort/Don't sort"; break;
1822 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1824 if (summaryview->sort_type == SORT_ASCENDING) {
1825 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1827 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1830 if (summaryview->sort_key != SORT_BY_NONE) {
1831 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1832 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1834 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1835 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1838 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1839 mainwin->messageview->mimeview->textview->show_all_headers);
1840 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1842 #undef SET_CHECK_MENU_ACTIVE
1844 main_window_menu_callback_unblock(mainwin);
1847 void main_window_popup(MainWindow *mainwin)
1849 gtkut_window_popup(mainwin->window);
1851 switch (mainwin->type) {
1852 case SEPARATE_FOLDER:
1853 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1855 case SEPARATE_MESSAGE:
1856 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1859 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1860 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1867 void main_window_show(MainWindow *mainwin)
1869 gtk_widget_show(mainwin->window);
1870 gtk_widget_show(mainwin->vbox_body);
1872 gtk_widget_set_uposition(mainwin->window,
1873 prefs_common.mainwin_x,
1874 prefs_common.mainwin_y);
1876 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1877 prefs_common.folderview_width,
1878 prefs_common.folderview_height);
1879 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1880 prefs_common.summaryview_width,
1881 prefs_common.summaryview_height);
1882 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1883 prefs_common.msgview_width,
1884 prefs_common.msgview_height);
1886 if (mainwin->type & SEPARATE_FOLDER) {
1887 GtkWidget *folderwin;
1889 folderwin = main_window_get_folder_window(mainwin);
1890 gtk_widget_show(folderwin);
1891 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1892 prefs_common.folderwin_y);
1895 if (mainwin->type & SEPARATE_MESSAGE) {
1896 GtkWidget *messagewin;
1898 messagewin = main_window_get_message_window(mainwin);
1899 gtk_widget_show(messagewin);
1900 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1901 prefs_common.main_msgwin_y);
1905 void main_window_hide(MainWindow *mainwin)
1907 main_window_get_size(mainwin);
1908 main_window_get_position(mainwin);
1910 gtk_widget_hide(mainwin->window);
1911 gtk_widget_hide(mainwin->vbox_body);
1913 if (mainwin->type & SEPARATE_FOLDER) {
1914 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1917 if (mainwin->type & SEPARATE_MESSAGE) {
1918 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1922 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1924 GtkWidget *folderwin = NULL;
1925 GtkWidget *messagewin = NULL;
1928 GtkWidget *vbox_body = mainwin->vbox_body;
1929 GtkItemFactory *ifactory = mainwin->menu_factory;
1930 GtkWidget *menuitem;
1931 GtkItemFactory *msgview_ifactory;
1933 debug_print("Setting widgets... ");
1935 /* create separated window(s) if needed */
1936 if (type & SEPARATE_FOLDER) {
1937 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1938 gtk_window_set_title(GTK_WINDOW(folderwin),
1939 _("Sylpheed - Folder View"));
1940 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1941 "folder_view", "Sylpheed");
1942 gtk_window_set_policy(GTK_WINDOW(folderwin),
1944 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1945 prefs_common.folderwin_y);
1946 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1948 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1949 GTK_SIGNAL_FUNC(folder_window_close_cb),
1951 gtk_container_add(GTK_CONTAINER(folderwin),
1952 GTK_WIDGET_PTR(mainwin->folderview));
1953 gtk_widget_realize(folderwin);
1954 if (prefs_common.folderview_visible)
1955 gtk_widget_show(folderwin);
1957 if (type & SEPARATE_MESSAGE) {
1958 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1959 gtk_window_set_title(GTK_WINDOW(messagewin),
1960 _("Sylpheed - Message View"));
1961 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1962 "message_view", "Sylpheed");
1963 gtk_window_set_policy(GTK_WINDOW(messagewin),
1965 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1966 prefs_common.main_msgwin_y);
1967 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1969 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1970 GTK_SIGNAL_FUNC(message_window_close_cb),
1972 if (messageview_is_visible(mainwin->messageview))
1973 gtk_widget_show(messagewin);
1976 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1977 prefs_common.folderview_width,
1978 prefs_common.folderview_height);
1979 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1980 prefs_common.summaryview_width,
1981 prefs_common.summaryview_height);
1982 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1983 prefs_common.msgview_width,
1984 prefs_common.msgview_height);
1988 hpaned = gtk_hpaned_new();
1989 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1990 gtk_paned_add1(GTK_PANED(hpaned),
1991 GTK_WIDGET_PTR(mainwin->folderview));
1992 gtk_widget_show(hpaned);
1993 gtk_widget_queue_resize(hpaned);
1995 vpaned = gtk_vpaned_new();
1996 if (messageview_is_visible(mainwin->messageview)) {
1997 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1998 gtk_paned_add1(GTK_PANED(vpaned),
1999 GTK_WIDGET_PTR(mainwin->summaryview));
2001 gtk_paned_add2(GTK_PANED(hpaned),
2002 GTK_WIDGET_PTR(mainwin->summaryview));
2003 gtk_widget_ref(vpaned);
2005 gtk_paned_add2(GTK_PANED(vpaned),
2006 GTK_WIDGET_PTR(mainwin->messageview));
2007 gtk_widget_show(vpaned);
2008 gtk_widget_queue_resize(vpaned);
2010 mainwin->win.sep_none.hpaned = hpaned;
2011 mainwin->win.sep_none.vpaned = vpaned;
2013 /* remove headerview if not in prefs */
2014 headerview_set_visibility(mainwin->messageview->headerview,
2015 prefs_common.display_header_pane);
2017 case SEPARATE_FOLDER:
2018 vpaned = gtk_vpaned_new();
2019 if (messageview_is_visible(mainwin->messageview)) {
2020 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2022 gtk_paned_add1(GTK_PANED(vpaned),
2023 GTK_WIDGET_PTR(mainwin->summaryview));
2025 gtk_box_pack_start(GTK_BOX(vbox_body),
2026 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_folder.folderwin = folderwin;
2036 mainwin->win.sep_folder.vpaned = vpaned;
2038 /* remove headerview if not in prefs */
2039 headerview_set_visibility(mainwin->messageview->headerview,
2040 prefs_common.display_header_pane);
2043 case SEPARATE_MESSAGE:
2044 hpaned = gtk_hpaned_new();
2045 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2046 gtk_paned_add1(GTK_PANED(hpaned),
2047 GTK_WIDGET_PTR(mainwin->folderview));
2048 gtk_paned_add2(GTK_PANED(hpaned),
2049 GTK_WIDGET_PTR(mainwin->summaryview));
2050 gtk_widget_show(hpaned);
2051 gtk_widget_queue_resize(hpaned);
2052 messageview_add_toolbar(mainwin->messageview, messagewin);
2053 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2054 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2056 mainwin->win.sep_message.messagewin = messagewin;
2057 mainwin->win.sep_message.hpaned = hpaned;
2059 gtk_widget_realize(messagewin);
2060 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2061 gtk_widget_show_all(messagewin);
2062 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2063 mainwin->messageview->handlebox,
2064 prefs_common.toolbar_style);
2068 messageview_add_toolbar(mainwin->messageview, messagewin);
2069 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2070 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2072 gtk_box_pack_start(GTK_BOX(vbox_body),
2073 GTK_WIDGET_PTR(mainwin->summaryview),
2076 mainwin->win.sep_both.folderwin = folderwin;
2077 mainwin->win.sep_both.messagewin = messagewin;
2079 gtk_widget_realize(messagewin);
2080 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2081 gtk_widget_show_all(messagewin);
2082 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2083 mainwin->messageview->handlebox,
2084 prefs_common.toolbar_style);
2089 gtk_widget_set_uposition(mainwin->window,
2090 prefs_common.mainwin_x,
2091 prefs_common.mainwin_y);
2093 gtk_widget_queue_resize(vbox_body);
2094 gtk_widget_queue_resize(mainwin->vbox);
2095 gtk_widget_queue_resize(mainwin->window);
2096 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2097 * and mimeview icon list/ctree lose track of their visibility states */
2098 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2099 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2100 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2101 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2102 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2103 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2105 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2107 /* rehide quick search if necessary */
2108 if (!prefs_common.show_searchbar)
2109 gtk_widget_hide(mainwin->summaryview->hbox_search);
2111 mainwin->type = type;
2114 /* toggle menu state */
2115 menuitem = gtk_item_factory_get_item
2116 (ifactory, "/View/Show or hide/Folder tree");
2117 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2118 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2119 prefs_common.folderview_visible);
2120 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2121 menuitem = gtk_item_factory_get_item
2122 (ifactory, "/View/Show or hide/Message view");
2123 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2124 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
2125 prefs_common.msgview_visible);
2127 menuitem = gtk_item_factory_get_item
2128 (ifactory, "/View/Separate folder tree");
2129 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2130 ((type & SEPARATE_FOLDER) != 0));
2131 menuitem = gtk_item_factory_get_item
2132 (ifactory, "/View/Separate message view");
2133 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2134 ((type & SEPARATE_MESSAGE) != 0));
2138 (GTK_OBJECT(folderwin), "size_allocate",
2139 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
2144 (GTK_OBJECT(messagewin), "size_allocate",
2145 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
2149 debug_print("done.\n");
2152 void main_window_destroy_all(void)
2154 while (mainwin_list != NULL) {
2155 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2157 /* free toolbar stuff */
2158 toolbar_clear_list(TOOLBAR_MAIN);
2159 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2160 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2162 g_free(mainwin->toolbar);
2165 mainwin_list = g_list_remove(mainwin_list, mainwin);
2167 g_list_free(mainwin_list);
2171 static void toolbar_account_button_pressed(GtkWidget *widget,
2172 GdkEventButton *event,
2175 MainWindow *mainwin = (MainWindow *)data;
2178 if (event->button != 3) return;
2180 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2181 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2184 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2185 menu_button_position, widget,
2186 event->button, event->time);
2190 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2193 gtk_widget_set_usize(child, 1, -1);
2196 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2199 gtk_widget_set_usize(child, -1, -1);
2202 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2205 MainWindow *mainwin = (MainWindow *)data;
2209 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2210 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2213 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2214 menu_button_position, widget,
2215 event->button, event->time);
2218 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2220 MainWindow *mainwin = (MainWindow *)data;
2223 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2224 if (!button) return;
2225 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2226 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2227 manage_window_focus_in(mainwin->window, NULL, NULL);
2230 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2233 MainWindow *mainwin = (MainWindow *)data;
2235 if (mainwin->lock_count == 0)
2236 app_exit_cb(data, 0, widget);
2241 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2244 MainWindow *mainwin = (MainWindow *)data;
2245 GtkWidget *menuitem;
2247 menuitem = gtk_item_factory_get_item
2248 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2249 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2254 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2257 MainWindow *mainwin = (MainWindow *)data;
2258 GtkWidget *menuitem;
2260 menuitem = gtk_item_factory_get_item
2261 (mainwin->menu_factory, "/View/Show or hide/Message view");
2262 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2267 static void main_window_size_allocate_cb(GtkWidget *widget,
2268 GtkAllocation *allocation,
2271 MainWindow *mainwin = (MainWindow *)data;
2273 main_window_get_size(mainwin);
2276 static void folder_window_size_allocate_cb(GtkWidget *widget,
2277 GtkAllocation *allocation,
2280 MainWindow *mainwin = (MainWindow *)data;
2282 main_window_get_size(mainwin);
2285 static void message_window_size_allocate_cb(GtkWidget *widget,
2286 GtkAllocation *allocation,
2289 MainWindow *mainwin = (MainWindow *)data;
2291 main_window_get_size(mainwin);
2294 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2297 main_window_add_mailbox(mainwin);
2300 static void update_folderview_cb(MainWindow *mainwin, guint action,
2303 summary_show(mainwin->summaryview, NULL);
2304 folderview_check_new_all();
2307 static void new_folder_cb(MainWindow *mainwin, guint action,
2310 folderview_new_folder(mainwin->folderview);
2313 static void rename_folder_cb(MainWindow *mainwin, guint action,
2316 folderview_rename_folder(mainwin->folderview);
2319 static void delete_folder_cb(MainWindow *mainwin, guint action,
2322 folderview_delete_folder(mainwin->folderview);
2325 static void import_mbox_cb(MainWindow *mainwin, guint action,
2328 import_mbox(mainwin->summaryview->folder_item);
2331 static void export_mbox_cb(MainWindow *mainwin, guint action,
2334 export_mbox(mainwin->summaryview->folder_item);
2337 static void empty_trash_cb(MainWindow *mainwin, guint action,
2340 main_window_empty_trash(mainwin, TRUE);
2343 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2345 summary_save_as(mainwin->summaryview);
2348 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2350 summary_print(mainwin->summaryview);
2353 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2355 if (prefs_common.confirm_on_exit) {
2356 if (alertpanel(_("Exit"), _("Exit this program?"),
2357 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2359 manage_window_focus_in(mainwin->window, NULL, NULL);
2362 app_will_exit(widget, mainwin);
2365 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2368 summary_search(mainwin->summaryview);
2370 message_search(mainwin->messageview);
2373 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2378 active = GTK_CHECK_MENU_ITEM(widget)->active;
2380 switch (mainwin->type) {
2382 case SEPARATE_MESSAGE:
2385 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2387 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2390 case SEPARATE_FOLDER:
2391 debug_print("separate folder\n");
2393 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2395 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2399 gtk_widget_show(mainwin->win.sep_both.folderwin);
2401 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2405 prefs_common.folderview_visible = active;
2408 static void toggle_message_cb(MainWindow *mainwin, guint action,
2413 active = GTK_CHECK_MENU_ITEM(widget)->active;
2415 if (active != messageview_is_visible(mainwin->messageview))
2416 summary_toggle_view(mainwin->summaryview);
2419 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2422 toolbar_toggle(action, mainwin);
2425 void main_window_reply_cb(MainWindow *mainwin, guint action,
2428 MessageView *msgview = (MessageView*)mainwin->messageview;
2429 GSList *msginfo_list = NULL;
2432 g_return_if_fail(msgview != NULL);
2434 msginfo_list = summary_get_selection(mainwin->summaryview);
2435 g_return_if_fail(msginfo_list != NULL);
2437 body = messageview_get_selection(msgview);
2438 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2440 g_slist_free(msginfo_list);
2444 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2447 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2448 gtk_widget_show(mainwin->hbox_stat);
2449 prefs_common.show_statusbar = TRUE;
2451 gtk_widget_hide(mainwin->hbox_stat);
2452 prefs_common.show_statusbar = FALSE;
2456 static void separate_widget_cb(MainWindow *mainwin, guint action,
2461 if (GTK_CHECK_MENU_ITEM(widget)->active)
2462 type = mainwin->type | action;
2464 type = mainwin->type & ~action;
2466 main_window_separation_change(mainwin, type);
2468 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2469 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2472 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2475 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2477 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2480 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2482 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2485 static void online_switch_clicked (GtkButton *btn, gpointer data)
2487 MainWindow *mainwin;
2488 GtkItemFactory *ifactory;
2489 GtkCheckMenuItem *menuitem;
2491 mainwin = (MainWindow *) data;
2493 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2494 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2496 g_return_if_fail(mainwin != NULL);
2497 g_return_if_fail(menuitem != NULL);
2499 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2501 gtk_widget_hide (mainwin->online_switch);
2502 gtk_widget_show (mainwin->offline_switch);
2503 menuitem->active = TRUE;
2504 prefs_common.work_offline = TRUE;
2505 inc_autocheck_timer_remove();
2508 gtk_widget_hide (mainwin->offline_switch);
2509 gtk_widget_show (mainwin->online_switch);
2510 menuitem->active = FALSE;
2511 prefs_common.work_offline = FALSE;
2512 inc_autocheck_timer_set();
2516 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2519 addressbook_open(NULL);
2522 static void log_window_show_cb(MainWindow *mainwin, guint action,
2525 log_window_show(mainwin->logwin);
2528 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2533 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2535 summary_move_to(mainwin->summaryview);
2538 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2540 summary_copy_to(mainwin->summaryview);
2543 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2545 summary_delete(mainwin->summaryview);
2548 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2550 summary_cancel(mainwin->summaryview);
2553 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2555 summary_open_msg(mainwin->summaryview);
2558 static void view_source_cb(MainWindow *mainwin, guint action,
2561 summary_view_source(mainwin->summaryview);
2564 static void show_all_header_cb(MainWindow *mainwin, guint action,
2567 if (mainwin->menu_lock_count) return;
2568 summary_display_msg_selected(mainwin->summaryview,
2569 GTK_CHECK_MENU_ITEM(widget)->active);
2572 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2574 summary_reedit(mainwin->summaryview);
2577 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2579 summary_mark(mainwin->summaryview);
2582 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2584 summary_unmark(mainwin->summaryview);
2587 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2590 summary_mark_as_unread(mainwin->summaryview);
2593 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2596 summary_mark_as_read(mainwin->summaryview);
2599 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2602 summary_mark_all_read(mainwin->summaryview);
2605 static void add_address_cb(MainWindow *mainwin, guint action,
2608 summary_add_address(mainwin->summaryview);
2611 static void set_charset_cb(MainWindow *mainwin, guint action,
2616 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2617 str = conv_get_charset_str((CharSet)action);
2618 g_free(prefs_common.force_charset);
2619 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2621 summary_redisplay_msg(mainwin->summaryview);
2623 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2627 static void hide_read_messages (MainWindow *mainwin, guint action,
2630 if (!mainwin->summaryview->folder_item
2631 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2633 summary_toggle_show_read_messages(mainwin->summaryview);
2636 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2638 if (mainwin->menu_lock_count) return;
2639 if (!mainwin->summaryview->folder_item) return;
2641 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2642 summary_thread_build(mainwin->summaryview);
2643 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2645 summary_unthread(mainwin->summaryview);
2646 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2650 static void expand_threads_cb(MainWindow *mainwin, guint action,
2653 summary_expand_threads(mainwin->summaryview);
2656 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2659 summary_collapse_threads(mainwin->summaryview);
2662 static void set_display_item_cb(MainWindow *mainwin, guint action,
2665 prefs_summary_column_open();
2668 static void sort_summary_cb(MainWindow *mainwin, guint action,
2671 FolderItem *item = mainwin->summaryview->folder_item;
2672 GtkWidget *menuitem;
2674 if (mainwin->menu_lock_count) return;
2676 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2677 menuitem = gtk_item_factory_get_item
2678 (mainwin->menu_factory, "/View/Sort/Ascending");
2679 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2680 GTK_CHECK_MENU_ITEM(menuitem)->active
2681 ? SORT_ASCENDING : SORT_DESCENDING);
2685 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2688 FolderItem *item = mainwin->summaryview->folder_item;
2690 if (mainwin->menu_lock_count) return;
2692 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2693 summary_sort(mainwin->summaryview,
2694 item->sort_key, (FolderSortType)action);
2697 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2700 summary_attract_by_subject(mainwin->summaryview);
2703 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2706 summary_delete_duplicated(mainwin->summaryview);
2709 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2711 summary_filter(mainwin->summaryview);
2714 static void execute_summary_cb(MainWindow *mainwin, guint action,
2717 summary_execute(mainwin->summaryview);
2720 static void update_summary_cb(MainWindow *mainwin, guint action,
2724 FolderView *folderview = mainwin->folderview;
2726 if (!mainwin->summaryview->folder_item) return;
2727 if (!folderview->opened) return;
2729 folder_update_op_count();
2731 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2732 folderview->opened);
2735 folder_item_scan(fitem);
2736 summary_show(mainwin->summaryview, fitem);
2739 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2741 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2744 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2746 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2749 static void prev_unread_cb(MainWindow *mainwin, guint action,
2752 summary_select_prev_unread(mainwin->summaryview);
2755 static void next_unread_cb(MainWindow *mainwin, guint action,
2758 summary_select_next_unread(mainwin->summaryview);
2761 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2763 summary_select_prev_new(mainwin->summaryview);
2766 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2768 summary_select_next_new(mainwin->summaryview);
2771 static void prev_marked_cb(MainWindow *mainwin, guint action,
2774 summary_select_prev_marked(mainwin->summaryview);
2777 static void next_marked_cb(MainWindow *mainwin, guint action,
2780 summary_select_next_marked(mainwin->summaryview);
2783 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2786 summary_select_prev_labeled(mainwin->summaryview);
2789 static void next_labeled_cb(MainWindow *mainwin, guint action,
2792 summary_select_next_labeled(mainwin->summaryview);
2795 static void goto_folder_cb(MainWindow *mainwin, guint action,
2798 FolderItem *to_folder;
2800 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2803 folderview_select(mainwin->folderview, to_folder);
2806 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2808 messageview_copy_clipboard(mainwin->messageview);
2811 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2813 MessageView *msgview = mainwin->messageview;
2815 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2816 summary_select_all(mainwin->summaryview);
2817 else if (messageview_is_visible(msgview) &&
2818 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2819 messageview_select_all(mainwin->messageview);
2822 static void select_thread_cb(MainWindow *mainwin, guint action,
2825 summary_select_thread(mainwin->summaryview);
2828 static void create_filter_cb(MainWindow *mainwin, guint action,
2831 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2834 static void create_processing_cb(MainWindow *mainwin, guint action,
2837 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2840 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2843 prefs_common_open();
2846 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2849 prefs_filtering_open(&pre_global_processing,
2850 _("Processing rules to apply before folder rules"),
2854 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2857 prefs_filtering_open(&post_global_processing,
2858 _("Processing rules to apply after folder rules"),
2862 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2865 prefs_filtering_open(&filtering_rules,
2866 _("Filtering configuration"),
2870 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2873 prefs_template_open();
2876 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2879 prefs_actions_open(mainwin);
2882 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2885 ssl_manager_open(mainwin);
2888 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2892 new_account_cb(mainwin, 0, widget);
2894 account_open(cur_account);
2898 static void new_account_cb(MainWindow *mainwin, guint action,
2901 account_edit_open();
2902 if (!compose_get_compose_list()) account_add();
2905 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
2907 cur_account = (PrefsAccount *)data;
2908 main_window_reflect_prefs_all();
2911 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
2913 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
2914 PrefsAccount *account = (PrefsAccount *)data;
2916 inc_account_mail(mainwin, account);
2919 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2924 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2926 pluginwindow_create();
2929 static void manual_open_cb(MainWindow *mainwin, guint action,
2932 manual_open((ManualType)action);
2935 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2937 MainWindow *mainwin = (MainWindow *)data;
2941 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2942 LOCAL_FOLDER(folder)->rootpath,
2946 str = g_strdup_printf(_("Scanning folder %s ..."),
2947 LOCAL_FOLDER(folder)->rootpath);
2949 STATUSBAR_PUSH(mainwin, str);
2950 STATUSBAR_POP(mainwin);
2954 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2957 SummaryView *summary;
2959 g_return_val_if_fail(data, FALSE);
2960 summary = ((MainWindow *)data)->summaryview;
2961 g_return_val_if_fail(summary, FALSE);
2963 if (GTK_CLIST(summary->ctree)->selection &&
2964 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2967 if (summary->selected != summary->displayed)
2968 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2972 #define BREAK_ON_MODIFIER_KEY() \
2973 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2975 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2978 MainWindow *mainwin = (MainWindow*) data;
2980 if (!mainwin || !event) return;
2982 switch (event->keyval) {
2983 case GDK_Q: /* Quit */
2984 BREAK_ON_MODIFIER_KEY();
2986 app_exit_cb(mainwin, 0, NULL);
2989 if (mainwin->folderview && mainwin->summaryview
2990 && !mainwin->summaryview->displayed) {
2991 summary_lock(mainwin->summaryview);
2992 folderview_select_next_unread(mainwin->folderview);
2993 summary_unlock(mainwin->summaryview);
3001 #undef BREAK_ON_MODIFIER_KEY
3004 * Harvest addresses for selected folder.
3006 static void addr_harvest_cb( MainWindow *mainwin,
3010 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3014 * Harvest addresses for selected messages in summary view.
3016 static void addr_harvest_msg_cb( MainWindow *mainwin,
3020 summary_harvest_address( mainwin->summaryview );
3024 *\brief get a MainWindow
3026 *\return MainWindow * The first mainwindow in the mainwin_list
3028 MainWindow *mainwindow_get_mainwindow(void)
3030 if (mainwin_list && mainwin_list->data)
3031 return (MainWindow *)(mainwin_list->data);
3036 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3038 ProgressData *data = (ProgressData *) source;
3039 MainWindow *mainwin = (MainWindow *) userdata;
3041 switch (data->cmd) {
3042 case PROGRESS_COMMAND_START:
3043 case PROGRESS_COMMAND_STOP:
3044 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
3046 case PROGRESS_COMMAND_SET_PERCENTAGE:
3047 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
3050 while (gtk_events_pending()) gtk_main_iteration ();