2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 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>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_actions.h"
64 #include "prefs_filtering.h"
65 #include "prefs_account.h"
66 #include "prefs_summary_column.h"
67 #include "prefs_template.h"
70 #include "addressbook.h"
71 #include "logwindow.h"
72 #include "manage_window.h"
73 #include "alertpanel.h"
74 #include "statusbar.h"
75 #include "inputdialog.h"
82 #include "ssl_manager.h"
83 #include "sslcertwindow.h"
84 #include "prefs_gtk.h"
85 #include "pluginwindow.h"
87 #include "progressindicator.h"
88 #include "localfolder.h"
89 #include "filtering.h"
91 #define AC_LABEL_WIDTH 240
93 /* list of all instantiated MainWindow */
94 static GList *mainwin_list = NULL;
96 static GdkCursor *watch_cursor;
98 static void main_window_menu_callback_block (MainWindow *mainwin);
99 static void main_window_menu_callback_unblock (MainWindow *mainwin);
101 static void main_window_show_cur_account (MainWindow *mainwin);
103 static void main_window_set_widgets (MainWindow *mainwin,
107 static void toolbar_account_button_pressed (GtkWidget *widget,
108 GdkEventButton *event,
111 static void ac_label_button_pressed (GtkWidget *widget,
112 GdkEventButton *event,
114 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
117 static gint main_window_close_cb (GtkWidget *widget,
120 static gint folder_window_close_cb (GtkWidget *widget,
123 static gint message_window_close_cb (GtkWidget *widget,
127 static void main_window_size_allocate_cb (GtkWidget *widget,
128 GtkAllocation *allocation,
130 static void folder_window_size_allocate_cb (GtkWidget *widget,
131 GtkAllocation *allocation,
133 static void message_window_size_allocate_cb (GtkWidget *widget,
134 GtkAllocation *allocation,
137 static void new_folder_cb (MainWindow *mainwin,
140 static void rename_folder_cb (MainWindow *mainwin,
143 static void delete_folder_cb (MainWindow *mainwin,
146 static void update_folderview_cb (MainWindow *mainwin,
149 static void add_mailbox_cb (MainWindow *mainwin,
152 static void import_mbox_cb (MainWindow *mainwin,
155 static void export_mbox_cb (MainWindow *mainwin,
158 static void empty_trash_cb (MainWindow *mainwin,
162 static void save_as_cb (MainWindow *mainwin,
165 static void print_cb (MainWindow *mainwin,
168 static void app_exit_cb (MainWindow *mainwin,
172 static void search_cb (MainWindow *mainwin,
176 static void toggle_folder_cb (MainWindow *mainwin,
179 static void toggle_message_cb (MainWindow *mainwin,
182 static void toggle_toolbar_cb (MainWindow *mainwin,
185 static void toggle_statusbar_cb (MainWindow *mainwin,
188 static void separate_widget_cb (MainWindow *mainwin,
192 static void addressbook_open_cb (MainWindow *mainwin,
195 static void log_window_show_cb (MainWindow *mainwin,
199 static void inc_cancel_cb (MainWindow *mainwin,
203 static void open_msg_cb (MainWindow *mainwin,
207 static void view_source_cb (MainWindow *mainwin,
211 static void show_all_header_cb (MainWindow *mainwin,
215 static void reedit_cb (MainWindow *mainwin,
219 static void move_to_cb (MainWindow *mainwin,
222 static void copy_to_cb (MainWindow *mainwin,
225 static void delete_cb (MainWindow *mainwin,
229 static void cancel_cb (MainWindow *mainwin,
233 static void mark_cb (MainWindow *mainwin,
236 static void unmark_cb (MainWindow *mainwin,
240 static void mark_as_unread_cb (MainWindow *mainwin,
243 static void mark_as_read_cb (MainWindow *mainwin,
246 static void mark_all_read_cb (MainWindow *mainwin,
249 static void add_address_cb (MainWindow *mainwin,
253 static void set_charset_cb (MainWindow *mainwin,
257 static void hide_read_messages (MainWindow *mainwin,
261 static void thread_cb (MainWindow *mainwin,
264 static void expand_threads_cb (MainWindow *mainwin,
267 static void collapse_threads_cb (MainWindow *mainwin,
271 static void set_display_item_cb (MainWindow *mainwin,
274 static void sort_summary_cb (MainWindow *mainwin,
277 static void sort_summary_type_cb (MainWindow *mainwin,
280 static void attract_by_subject_cb(MainWindow *mainwin,
284 static void delete_duplicated_cb (MainWindow *mainwin,
287 static void filter_cb (MainWindow *mainwin,
290 static void execute_summary_cb (MainWindow *mainwin,
293 static void update_summary_cb (MainWindow *mainwin,
297 static void prev_cb (MainWindow *mainwin,
300 static void next_cb (MainWindow *mainwin,
303 static void next_unread_cb (MainWindow *mainwin,
306 static void prev_unread_cb (MainWindow *mainwin,
310 static void prev_new_cb (MainWindow *mainwin,
313 static void next_new_cb (MainWindow *mainwin,
316 static void prev_marked_cb (MainWindow *mainwin,
319 static void next_marked_cb (MainWindow *mainwin,
322 static void prev_labeled_cb (MainWindow *mainwin,
325 static void next_labeled_cb (MainWindow *mainwin,
329 static void goto_folder_cb (MainWindow *mainwin,
333 static void copy_cb (MainWindow *mainwin,
336 static void allsel_cb (MainWindow *mainwin,
339 static void select_thread_cb (MainWindow *mainwin,
343 static void create_filter_cb (MainWindow *mainwin,
347 static void prefs_common_open_cb (MainWindow *mainwin,
350 static void prefs_template_open_cb (MainWindow *mainwin,
353 static void prefs_actions_open_cb (MainWindow *mainwin,
356 static void prefs_account_open_cb (MainWindow *mainwin,
360 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
364 static void prefs_post_processing_open_cb (MainWindow *mainwin,
368 static void prefs_filtering_open_cb (MainWindow *mainwin,
372 static void ssl_manager_open_cb (MainWindow *mainwin,
376 static void new_account_cb (MainWindow *mainwin,
380 static void account_menu_cb (GtkMenuItem *menuitem,
383 static void prefs_open_cb (GtkMenuItem *menuitem,
385 static void plugins_open_cb (GtkMenuItem *menuitem,
388 static void online_switch_clicked(GtkButton *btn,
391 static void manual_open_cb (MainWindow *mainwin,
395 static void scan_tree_func (Folder *folder,
399 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
401 static void addr_harvest_cb ( MainWindow *mainwin,
405 static void addr_harvest_msg_cb ( MainWindow *mainwin,
409 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
410 GdkEventFocus *focus,
412 void main_window_reply_cb (MainWindow *mainwin,
415 gboolean mainwindow_progressindicator_hook (gpointer source,
417 #define SEPARATE_ACTION 500
419 static GtkItemFactoryEntry mainwin_entries[] =
421 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
422 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
423 {N_("/_File/_Folder/Create _new folder..."),
424 NULL, new_folder_cb, 0, NULL},
425 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
426 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
427 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
428 {N_("/_File/_Folder/_Check for new messages in all folders"),
429 NULL, update_folderview_cb, 0, NULL},
430 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
431 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
432 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
433 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
434 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
435 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
436 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
437 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
438 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
439 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
440 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
441 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
443 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
444 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
445 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
446 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
447 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
448 {N_("/_Edit/_Find in current message..."),
449 "<control>F", search_cb, 0, NULL},
450 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
451 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
452 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
453 {N_("/_View/Show or hi_de/_Folder tree"),
454 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
455 {N_("/_View/Show or hi_de/_Message view"),
456 "V", toggle_message_cb, 0, "<ToggleItem>"},
457 {N_("/_View/Show or hi_de/_Toolbar"),
458 NULL, NULL, 0, "<Branch>"},
459 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
460 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
461 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
462 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
463 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
464 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
465 {N_("/_View/Show or hi_de/_Toolbar/_None"),
466 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
467 {N_("/_View/Show or hi_de/Status _bar"),
468 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
469 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
470 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
471 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
472 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
473 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
474 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
475 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
476 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
477 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
478 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
479 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
480 {N_("/_View/_Sort/by _color label"),
481 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
482 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
483 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
484 {N_("/_View/_Sort/by a_ttachment"),
485 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
486 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
487 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
488 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
489 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
491 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
492 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_View/_Sort/_Attract by subject"),
494 NULL, attract_by_subject_cb, 0, NULL},
495 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
496 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
497 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
498 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
499 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
501 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
503 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
504 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
505 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
506 {N_("/_View/_Go to/P_rev unread message"),
507 "<shift>P", prev_unread_cb, 0, NULL},
508 {N_("/_View/_Go to/N_ext unread message"),
509 "<shift>N", next_unread_cb, 0, NULL},
510 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
512 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
513 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_View/_Go to/Prev _marked message"),
515 NULL, prev_marked_cb, 0, NULL},
516 {N_("/_View/_Go to/Next m_arked message"),
517 NULL, next_marked_cb, 0, NULL},
518 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_View/_Go to/Prev _labeled message"),
520 NULL, prev_labeled_cb, 0, NULL},
521 {N_("/_View/_Go to/Next la_beled message"),
522 NULL, next_labeled_cb, 0, NULL},
523 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
525 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
527 #define CODESET_SEPARATOR \
528 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
529 #define CODESET_ACTION(action) \
530 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
532 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
533 {N_("/_View/_Code set/_Auto detect"),
534 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
535 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
537 CODESET_ACTION(C_US_ASCII)},
540 {N_("/_View/_Code set/Unicode (_UTF-8)"),
541 CODESET_ACTION(C_UTF_8)},
544 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
545 CODESET_ACTION(C_ISO_8859_1)},
546 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
547 CODESET_ACTION(C_ISO_8859_15)},
550 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
551 CODESET_ACTION(C_ISO_8859_2)},
553 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
554 CODESET_ACTION(C_ISO_8859_13)},
555 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
556 CODESET_ACTION(C_ISO_8859_4)},
558 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
559 CODESET_ACTION(C_ISO_8859_7)},
561 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
562 CODESET_ACTION(C_ISO_8859_9)},
564 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
565 CODESET_ACTION(C_ISO_8859_5)},
566 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
567 CODESET_ACTION(C_KOI8_R)},
568 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
569 CODESET_ACTION(C_WINDOWS_1251)},
572 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
573 CODESET_ACTION(C_ISO_2022_JP)},
575 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
576 CODESET_ACTION(C_ISO_2022_JP_2)},
578 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
579 CODESET_ACTION(C_EUC_JP)},
580 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
581 CODESET_ACTION(C_SHIFT_JIS)},
584 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
585 CODESET_ACTION(C_GB2312)},
586 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
587 CODESET_ACTION(C_BIG5)},
588 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
589 CODESET_ACTION(C_EUC_TW)},
590 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
591 CODESET_ACTION(C_ISO_2022_CN)},
593 {N_("/_View/_Code set/Korean (EUC-_KR)"),
594 CODESET_ACTION(C_EUC_KR)},
595 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
596 CODESET_ACTION(C_ISO_2022_KR)},
598 {N_("/_View/_Code set/Thai (TIS-620)"),
599 CODESET_ACTION(C_TIS_620)},
600 {N_("/_View/_Code set/Thai (Windows-874)"),
601 CODESET_ACTION(C_WINDOWS_874)},
604 #undef CODESET_SEPARATOR
605 #undef CODESET_ACTION
607 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
608 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
609 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
610 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
611 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
612 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
614 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
615 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
616 {N_("/_Message/Get from _all accounts"),
617 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
618 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
619 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
621 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
623 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
624 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
625 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
626 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
627 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
628 {N_("/_Message/Repl_y to/mailing _list"),
629 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
630 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
631 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
632 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
633 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
634 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
636 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
637 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
638 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
639 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
640 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
641 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
642 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
643 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
644 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
645 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
646 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
647 {N_("/_Message/_Mark/Mark as rea_d"),
648 NULL, mark_as_read_cb, 0, NULL},
649 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
651 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
652 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
653 {N_("/_Tools/Add sender to address boo_k"),
654 NULL, add_address_cb, 0, NULL},
655 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
656 {N_("/_Tools/_Harvest addresses/from _Folder..."),
657 NULL, addr_harvest_cb, 0, NULL},
658 {N_("/_Tools/_Harvest addresses/from _Messages..."),
659 NULL, addr_harvest_msg_cb, 0, NULL},
660 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
661 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
662 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
663 {N_("/_Tools/_Create filter rule/_Automatically"),
664 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
665 {N_("/_Tools/_Create filter rule/by _From"),
666 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
667 {N_("/_Tools/_Create filter rule/by _To"),
668 NULL, create_filter_cb, FILTER_BY_TO, NULL},
669 {N_("/_Tools/_Create filter rule/by _Subject"),
670 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
671 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
672 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
673 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Tools/Delete du_plicated messages"),
675 NULL, delete_duplicated_cb, 0, NULL},
676 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
677 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
679 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
680 {N_("/_Tools/SSL certi_ficates..."),
681 NULL, ssl_manager_open_cb, 0, NULL},
683 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
686 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
687 {N_("/_Configuration/C_hange current account"),
688 NULL, NULL, 0, "<Branch>"},
689 {N_("/_Configuration/_Preferences for current account..."),
690 NULL, prefs_account_open_cb, 0, NULL},
691 {N_("/_Configuration/Create _new account..."),
692 NULL, new_account_cb, 0, NULL},
693 {N_("/_Configuration/_Edit accounts..."),
694 NULL, account_edit_open, 0, NULL},
695 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_Configuration/_Common preferences..."),
697 NULL, prefs_common_open_cb, 0, NULL},
698 {N_("/_Configuration/Pre processing..."),
699 NULL, prefs_pre_processing_open_cb, 0, NULL},
700 {N_("/_Configuration/Post processing..."),
701 NULL, prefs_post_processing_open_cb, 0, NULL},
702 {N_("/_Configuration/_Filtering..."),
703 NULL, prefs_filtering_open_cb, 0, NULL},
704 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
705 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
706 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
707 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
709 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
710 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
711 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
712 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
713 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
714 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
715 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
716 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
717 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
718 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
719 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
722 MainWindow *main_window_create(SeparateType type)
728 GtkWidget *handlebox;
729 GtkWidget *vbox_body;
730 GtkWidget *hbox_stat;
731 GtkWidget *statusbar;
732 GtkWidget *progressbar;
733 GtkWidget *statuslabel;
734 GtkWidget *ac_button;
736 GtkWidget *online_pixmap;
737 GtkWidget *offline_pixmap;
738 GtkWidget *online_switch;
739 GtkWidget *offline_switch;
740 GtkTooltips *offline_tip;
741 GtkTooltips *online_tip;
742 GtkTooltips *sel_ac_tip;
744 FolderView *folderview;
745 SummaryView *summaryview;
746 MessageView *messageview;
747 GdkColormap *colormap;
750 GtkItemFactory *ifactory;
754 guint n_menu_entries;
756 static GdkGeometry geometry;
758 debug_print("Creating main window...\n");
759 mainwin = g_new0(MainWindow, 1);
762 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
763 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
764 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
765 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
767 if (!geometry.min_height) {
768 geometry.min_width = 320;
769 geometry.min_height = 200;
771 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
774 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
775 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
776 MANAGE_WINDOW_SIGNALS_CONNECT(window);
777 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
778 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
780 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
781 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
783 gtk_widget_realize(window);
784 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
787 gtkut_widget_set_app_icon(window);
789 vbox = gtk_vbox_new(FALSE, 0);
790 gtk_widget_show(vbox);
791 gtk_container_add(GTK_CONTAINER(window), vbox);
794 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
795 menubar = menubar_create(window, mainwin_entries,
796 n_menu_entries, "<Main>", mainwin);
797 gtk_widget_show(menubar);
798 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
799 ifactory = gtk_item_factory_from_widget(menubar);
801 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
802 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
804 handlebox = gtk_handle_box_new();
805 gtk_widget_show(handlebox);
806 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
808 /* link window to mainwin->window to avoid gdk warnings */
809 mainwin->window = window;
812 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
816 /* vbox that contains body */
817 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
818 gtk_widget_show(vbox_body);
819 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
820 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
822 hbox_stat = gtk_hbox_new(FALSE, 2);
823 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
825 statusbar = statusbar_create();
826 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
828 progressbar = gtk_progress_bar_new();
829 gtk_widget_set_usize(progressbar, 120, 1);
830 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
832 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
833 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
834 online_tip = gtk_tooltips_new();
835 online_switch = gtk_button_new ();
836 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
837 online_switch, _("Go offline"), NULL);
838 offline_tip = gtk_tooltips_new();
839 offline_switch = gtk_button_new ();
840 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
841 offline_switch, _("Go online"), NULL);
842 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
843 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
844 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
845 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
846 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
847 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
848 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
849 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
851 statuslabel = gtk_label_new("");
852 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
854 sel_ac_tip = gtk_tooltips_new();
855 ac_button = gtk_button_new();
856 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
857 ac_button, _("Select account"), NULL);
858 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
859 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
860 gtk_widget_set_usize(ac_button, -1, 1);
861 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
862 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
863 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
865 ac_label = gtk_label_new("");
866 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
868 gtk_widget_show_all(hbox_stat);
870 gtk_widget_hide(offline_switch);
872 mainwin->folderview = folderview = folderview_create();
873 mainwin->summaryview = summaryview = summary_create();
874 mainwin->messageview = messageview = messageview_create(mainwin);
875 mainwin->logwin = log_window_create();
877 folderview->mainwin = mainwin;
878 folderview->summaryview = summaryview;
880 summaryview->mainwin = mainwin;
881 summaryview->folderview = folderview;
882 summaryview->messageview = messageview;
883 summaryview->window = window;
885 mainwin->vbox = vbox;
886 mainwin->menubar = menubar;
887 mainwin->menu_factory = ifactory;
888 mainwin->handlebox = handlebox;
889 mainwin->vbox_body = vbox_body;
890 mainwin->hbox_stat = hbox_stat;
891 mainwin->statusbar = statusbar;
892 mainwin->progressbar = progressbar;
893 mainwin->statuslabel = statuslabel;
894 mainwin->ac_button = ac_button;
895 mainwin->ac_label = ac_label;
897 mainwin->online_switch = online_switch;
898 mainwin->offline_switch = offline_switch;
899 mainwin->online_pixmap = online_pixmap;
900 mainwin->offline_pixmap = offline_pixmap;
902 /* set context IDs for status bar */
903 mainwin->mainwin_cid = gtk_statusbar_get_context_id
904 (GTK_STATUSBAR(statusbar), "Main Window");
905 mainwin->folderview_cid = gtk_statusbar_get_context_id
906 (GTK_STATUSBAR(statusbar), "Folder View");
907 mainwin->summaryview_cid = gtk_statusbar_get_context_id
908 (GTK_STATUSBAR(statusbar), "Summary View");
910 /* allocate colors for summary view and folder view */
911 summaryview->color_marked.red = summaryview->color_marked.green = 0;
912 summaryview->color_marked.blue = (guint16)65535;
914 summaryview->color_dim.red = summaryview->color_dim.green =
915 summaryview->color_dim.blue = COLOR_DIM;
917 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
918 &folderview->color_new);
920 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
921 &folderview->color_op);
923 summaryview->color_important.red = 0;
924 summaryview->color_important.green = 0;
925 summaryview->color_important.blue = (guint16)65535;
927 color[0] = summaryview->color_marked;
928 color[1] = summaryview->color_dim;
929 color[2] = folderview->color_new;
930 color[3] = folderview->color_op;
932 colormap = gdk_window_get_colormap(window->window);
933 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
934 for (i = 0; i < 4; i++) {
935 if (success[i] == FALSE)
936 g_warning("MainWindow: color allocation %d failed\n", i);
939 debug_print("done.\n");
941 messageview->visible = prefs_common.msgview_visible;
943 main_window_set_widgets(mainwin, type);
945 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
946 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
950 menuitem = gtk_item_factory_get_item
951 (ifactory, "/View/Code set/Auto detect");
952 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
954 switch (prefs_common.toolbar_style) {
956 menuitem = gtk_item_factory_get_item
957 (ifactory, "/View/Show or hide/Toolbar/None");
960 menuitem = gtk_item_factory_get_item
961 (ifactory, "/View/Show or hide/Toolbar/Icon");
964 menuitem = gtk_item_factory_get_item
965 (ifactory, "/View/Show or hide/Toolbar/Text");
968 menuitem = gtk_item_factory_get_item
969 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
971 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
973 gtk_widget_hide(mainwin->hbox_stat);
974 menuitem = gtk_item_factory_get_item
975 (ifactory, "/View/Show or hide/Status bar");
976 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
977 prefs_common.show_statusbar);
979 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
981 if (prefs_common.show_searchbar) {
982 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
983 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
984 gtk_widget_hide(summaryview->search_description);
987 /* set account selection menu */
988 ac_menu = gtk_item_factory_get_widget
989 (ifactory, "/Configuration/Change current account");
990 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
991 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
992 mainwin->ac_menu = ac_menu;
994 toolbar_main_set_sensitive(mainwin);
996 /* create actions menu */
997 action_update_mainwin_menu(ifactory, mainwin);
999 /* attach accel groups to main window */
1000 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1001 gtk_window_add_accel_group \
1003 gtk_item_factory_from_widget(menu)->accel_group)
1005 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
1007 /* connect the accelerators for equivalent
1008 menu items in different menus */
1009 menu_connect_identical_items();
1013 /* show main window */
1014 gtk_widget_show(mainwin->window);
1016 /* initialize views */
1017 folderview_init(folderview);
1018 summary_init(summaryview);
1019 messageview_init(messageview);
1020 log_window_init(mainwin->logwin);
1021 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1022 prefs_common.loglength);
1024 sslcertwindow_register_hook();
1026 mainwin->lock_count = 0;
1027 mainwin->menu_lock_count = 0;
1028 mainwin->cursor_count = 0;
1030 mainwin->progressindicator_hook =
1031 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1034 watch_cursor = gdk_cursor_new(GDK_WATCH);
1036 mainwin_list = g_list_append(mainwin_list, mainwin);
1038 /* init work_offline */
1039 if (prefs_common.work_offline)
1040 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1045 void main_window_destroy(MainWindow *mainwin)
1047 /* TODO : destroy other component */
1048 messageview_destroy(mainwin->messageview);
1051 void main_window_cursor_wait(MainWindow *mainwin)
1054 if (mainwin->cursor_count == 0)
1055 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1057 mainwin->cursor_count++;
1062 void main_window_cursor_normal(MainWindow *mainwin)
1064 if (mainwin->cursor_count)
1065 mainwin->cursor_count--;
1067 if (mainwin->cursor_count == 0)
1068 gdk_window_set_cursor(mainwin->window->window, NULL);
1073 /* lock / unlock the user-interface */
1074 void main_window_lock(MainWindow *mainwin)
1076 if (mainwin->lock_count == 0)
1077 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1079 mainwin->lock_count++;
1081 main_window_set_menu_sensitive(mainwin);
1082 toolbar_main_set_sensitive(mainwin);
1085 void main_window_unlock(MainWindow *mainwin)
1087 if (mainwin->lock_count)
1088 mainwin->lock_count--;
1090 main_window_set_menu_sensitive(mainwin);
1091 toolbar_main_set_sensitive(mainwin);
1093 if (mainwin->lock_count == 0)
1094 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1097 static void main_window_menu_callback_block(MainWindow *mainwin)
1099 mainwin->menu_lock_count++;
1102 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1104 if (mainwin->menu_lock_count)
1105 mainwin->menu_lock_count--;
1108 void main_window_reflect_prefs_all(void)
1110 main_window_reflect_prefs_all_real(FALSE);
1113 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1116 MainWindow *mainwin;
1119 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1120 mainwin = (MainWindow *)cur->data;
1122 main_window_show_cur_account(mainwin);
1123 main_window_set_menu_sensitive(mainwin);
1124 toolbar_main_set_sensitive(mainwin);
1127 if (pixmap_theme_changed) {
1128 toolbar_update(TOOLBAR_MAIN, mainwin);
1129 messageview_reflect_prefs_pixmap_theme();
1130 compose_reflect_prefs_pixmap_theme();
1131 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1132 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1134 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1135 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1136 mainwin->online_pixmap);
1137 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1138 gtk_widget_show(pixmap);
1139 mainwin->online_pixmap = pixmap;
1140 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1141 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1142 mainwin->offline_pixmap);
1143 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1144 gtk_widget_show(pixmap);
1145 mainwin->offline_pixmap = pixmap;
1148 summary_redisplay_msg(mainwin->summaryview);
1149 headerview_set_visibility(mainwin->messageview->headerview,
1150 prefs_common.display_header_pane);
1154 void main_window_set_summary_column(void)
1157 MainWindow *mainwin;
1159 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1160 mainwin = (MainWindow *)cur->data;
1161 summary_set_column_order(mainwin->summaryview);
1165 void main_window_set_account_menu(GList *account_list)
1167 GList *cur, *cur_ac, *cur_item;
1168 GtkWidget *menuitem;
1169 MainWindow *mainwin;
1170 PrefsAccount *ac_prefs;
1172 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1173 mainwin = (MainWindow *)cur->data;
1175 /* destroy all previous menu item */
1176 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1177 while (cur_item != NULL) {
1178 GList *next = cur_item->next;
1179 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1183 for (cur_ac = account_list; cur_ac != NULL;
1184 cur_ac = cur_ac->next) {
1185 ac_prefs = (PrefsAccount *)cur_ac->data;
1187 menuitem = gtk_menu_item_new_with_label
1188 (ac_prefs->account_name
1189 ? ac_prefs->account_name : _("Untitled"));
1190 gtk_widget_show(menuitem);
1191 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1192 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1193 GTK_SIGNAL_FUNC(account_menu_cb),
1199 static void main_window_show_cur_account(MainWindow *mainwin)
1204 ac_name = g_strdup(cur_account
1205 ? (cur_account->account_name
1206 ? cur_account->account_name : _("Untitled"))
1210 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1212 buf = g_strdup(PROG_VERSION);
1213 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1216 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1217 gtk_widget_queue_resize(mainwin->ac_button);
1222 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1224 switch (mainwin->type) {
1225 case SEPARATE_FOLDER:
1226 return mainwin->win.sep_folder.folderwin;
1228 return mainwin->win.sep_both.folderwin;
1234 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1236 switch (mainwin->type) {
1237 case SEPARATE_MESSAGE:
1238 return mainwin->win.sep_message.messagewin;
1240 return mainwin->win.sep_both.messagewin;
1246 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1248 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1249 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1250 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1251 GtkWidget *message_wid = mainwin->messageview->vbox;
1253 debug_print("Changing window separation type from %d to %d\n",
1254 mainwin->type, type);
1256 if (mainwin->type == type) return;
1258 /* remove widgets from those containers */
1259 gtk_widget_ref(folder_wid);
1260 gtk_widget_ref(summary_wid);
1261 gtk_widget_ref(message_wid);
1262 gtkut_container_remove
1263 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1264 gtkut_container_remove
1265 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1266 gtkut_container_remove
1267 (GTK_CONTAINER(message_wid->parent), message_wid);
1269 /* clean containers */
1270 switch (mainwin->type) {
1272 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1274 case SEPARATE_FOLDER:
1275 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1276 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1278 case SEPARATE_MESSAGE:
1279 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1280 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1283 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1284 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1288 gtk_widget_hide(mainwin->window);
1289 main_window_set_widgets(mainwin, type);
1290 gtk_widget_show(mainwin->window);
1292 gtk_widget_unref(folder_wid);
1293 gtk_widget_unref(summary_wid);
1294 gtk_widget_unref(message_wid);
1297 void main_window_toggle_message_view(MainWindow *mainwin)
1299 SummaryView *summaryview = mainwin->summaryview;
1300 union CompositeWin *cwin = &mainwin->win;
1301 GtkWidget *vpaned = NULL;
1302 GtkWidget *container = NULL;
1303 GtkWidget *msgwin = NULL;
1305 switch (mainwin->type) {
1307 vpaned = cwin->sep_none.vpaned;
1308 container = cwin->sep_none.hpaned;
1310 case SEPARATE_FOLDER:
1311 vpaned = cwin->sep_folder.vpaned;
1312 container = mainwin->vbox_body;
1314 case SEPARATE_MESSAGE:
1315 msgwin = mainwin->win.sep_message.messagewin;
1318 msgwin = mainwin->win.sep_both.messagewin;
1323 if (GTK_WIDGET_VISIBLE(msgwin)) {
1324 gtk_widget_hide(msgwin);
1325 mainwin->messageview->visible = FALSE;
1326 summaryview->displayed = NULL;
1328 gtk_widget_show(msgwin);
1329 mainwin->messageview->visible = TRUE;
1331 } else if (vpaned->parent != NULL) {
1332 mainwin->messageview->visible = FALSE;
1333 summaryview->displayed = NULL;
1334 gtk_widget_ref(vpaned);
1335 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1336 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1337 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1338 GTK_ARROW_UP, GTK_SHADOW_OUT);
1340 mainwin->messageview->visible = TRUE;
1341 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1342 gtk_container_add(GTK_CONTAINER(container), vpaned);
1343 gtk_widget_unref(vpaned);
1344 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1345 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1348 main_window_set_menu_sensitive(mainwin);
1350 prefs_common.msgview_visible = mainwin->messageview->visible;
1352 gtk_widget_grab_focus(summaryview->ctree);
1355 void main_window_get_size(MainWindow *mainwin)
1357 GtkAllocation *allocation;
1359 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1361 if (allocation->width > 1 && allocation->height > 1) {
1362 prefs_common.summaryview_width = allocation->width;
1364 if ((mainwin->type == SEPARATE_NONE ||
1365 mainwin->type == SEPARATE_FOLDER) &&
1366 messageview_is_visible(mainwin->messageview))
1367 prefs_common.summaryview_height = allocation->height;
1369 prefs_common.mainview_width = allocation->width;
1372 allocation = &mainwin->window->allocation;
1373 if (allocation->width > 1 && allocation->height > 1) {
1374 prefs_common.mainview_height = allocation->height;
1375 prefs_common.mainwin_width = allocation->width;
1376 prefs_common.mainwin_height = allocation->height;
1379 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1380 if (allocation->width > 1 && allocation->height > 1) {
1381 prefs_common.folderview_width = allocation->width;
1382 prefs_common.folderview_height = allocation->height;
1385 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1386 if (allocation->width > 1 && allocation->height > 1) {
1387 prefs_common.msgview_width = allocation->width;
1388 prefs_common.msgview_height = allocation->height;
1391 debug_print("summaryview size: %d x %d\n",
1392 prefs_common.summaryview_width,
1393 prefs_common.summaryview_height);
1394 debug_print("folderview size: %d x %d\n",
1395 prefs_common.folderview_width,
1396 prefs_common.folderview_height);
1397 debug_print("messageview size: %d x %d\n",
1398 prefs_common.msgview_width,
1399 prefs_common.msgview_height);
1402 void main_window_get_position(MainWindow *mainwin)
1407 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1409 prefs_common.mainview_x = x;
1410 prefs_common.mainview_y = y;
1411 prefs_common.mainwin_x = x;
1412 prefs_common.mainwin_y = y;
1414 debug_print("main window position: %d, %d\n", x, y);
1416 window = main_window_get_folder_window(mainwin);
1418 gtkut_widget_get_uposition(window, &x, &y);
1419 prefs_common.folderwin_x = x;
1420 prefs_common.folderwin_y = y;
1421 debug_print("folder window position: %d, %d\n", x, y);
1423 window = main_window_get_message_window(mainwin);
1425 gtkut_widget_get_uposition(window, &x, &y);
1426 prefs_common.main_msgwin_x = x;
1427 prefs_common.main_msgwin_y = y;
1428 debug_print("message window position: %d, %d\n", x, y);
1432 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1438 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1439 folder = FOLDER(list->data);
1440 if (folder && folder->trash && folder->trash->total_msgs > 0)
1444 if (!has_trash) return;
1447 if (alertpanel(_("Empty trash"),
1448 _("Empty all messages in trash?"),
1449 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1451 manage_window_focus_in(mainwin->window, NULL, NULL);
1454 procmsg_empty_trash();
1456 if (mainwin->summaryview->folder_item &&
1457 mainwin->summaryview->folder_item->stype == F_TRASH)
1458 gtk_widget_grab_focus(mainwin->folderview->ctree);
1461 void main_window_add_mailbox(MainWindow *mainwin)
1466 path = input_dialog(_("Add mailbox"),
1467 _("Input the location of mailbox.\n"
1468 "If the existing mailbox is specified, it will be\n"
1469 "scanned automatically."),
1472 if (folder_find_from_path(path)) {
1473 alertpanel_error(_("The mailbox `%s' already exists."), path);
1477 folder = folder_new(folder_get_class_from_string("mh"),
1478 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1482 if (folder->klass->create_tree(folder) < 0) {
1483 alertpanel_error(_("Creation of the mailbox failed.\n"
1484 "Maybe some files already exist, or you don't have the permission to write there."));
1485 folder_destroy(folder);
1490 folder_set_ui_func(folder, scan_tree_func, mainwin);
1491 folder_scan_tree(folder);
1492 folder_set_ui_func(folder, NULL, NULL);
1494 folderview_set(mainwin->folderview);
1497 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1499 SensitiveCond state = 0;
1500 SummarySelection selection;
1501 FolderItem *item = mainwin->summaryview->folder_item;
1502 GList *account_list = account_get_list();
1504 selection = summary_get_selection_type(mainwin->summaryview);
1506 if (mainwin->lock_count == 0)
1507 state |= M_UNLOCKED;
1508 if (selection != SUMMARY_NONE)
1509 state |= M_MSG_EXIST;
1510 if (item && item->path && item->parent && !item->no_select) {
1512 /* if (item->folder->type != F_NEWS) */
1513 state |= M_ALLOW_DELETE;
1515 if (prefs_common.immediate_exec == 0
1516 && mainwin->lock_count == 0)
1517 state |= M_DELAY_EXEC;
1519 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1520 || selection != SUMMARY_NONE)
1521 state |= M_HIDE_READ_MSG;
1523 if (mainwin->summaryview->threaded)
1524 state |= M_THREADED;
1526 state |= M_UNTHREADED;
1527 if (selection == SUMMARY_SELECTED_SINGLE ||
1528 selection == SUMMARY_SELECTED_MULTIPLE)
1529 state |= M_TARGET_EXIST;
1530 if (selection == SUMMARY_SELECTED_SINGLE)
1531 state |= M_SINGLE_TARGET_EXIST;
1532 if (mainwin->summaryview->folder_item &&
1533 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1536 state |= M_NOT_NEWS;
1537 if (selection == SUMMARY_SELECTED_SINGLE &&
1539 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1540 item->stype == F_QUEUE)))
1541 state |= M_ALLOW_REEDIT;
1543 state |= M_HAVE_ACCOUNT;
1545 for ( ; account_list != NULL; account_list = account_list->next) {
1546 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1547 state |= M_HAVE_NEWS_ACCOUNT;
1552 if (inc_is_active())
1553 state |= M_INC_ACTIVE;
1560 void main_window_set_menu_sensitive(MainWindow *mainwin)
1562 GtkItemFactory *ifactory = mainwin->menu_factory;
1563 SensitiveCond state;
1565 GtkWidget *menuitem;
1566 SummaryView *summaryview;
1570 static const struct {
1574 {"/File/Folder" , M_UNLOCKED},
1575 {"/File/Add mailbox" , M_UNLOCKED},
1577 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1578 {"/File/Export to mbox file..." , M_UNLOCKED},
1579 {"/File/Empty trash" , M_UNLOCKED},
1580 {"/File/Work offline" , M_UNLOCKED},
1582 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1583 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1584 /* {"/File/Close" , M_UNLOCKED}, */
1585 {"/File/Exit" , M_UNLOCKED},
1587 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1589 {"/View/Sort" , M_EXEC},
1590 {"/View/Thread view" , M_EXEC},
1591 {"/View/Expand all threads" , M_MSG_EXIST},
1592 {"/View/Collapse all threads" , M_MSG_EXIST},
1593 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1594 {"/View/Go to/Prev message" , M_MSG_EXIST},
1595 {"/View/Go to/Next message" , M_MSG_EXIST},
1596 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1597 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1598 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1599 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1600 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1601 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1602 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1603 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1604 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1606 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1607 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1608 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1609 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1610 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1611 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1612 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1613 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1614 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1615 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1616 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1617 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1618 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1619 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1620 {"/Message/Mark" , M_TARGET_EXIST},
1622 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1623 {"/Tools/Harvest addresses" , M_UNLOCKED},
1624 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1625 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1626 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1627 {"/Tools/Execute" , M_DELAY_EXEC},
1628 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1630 {"/Configuration", M_UNLOCKED},
1635 state = main_window_get_current_state(mainwin);
1637 for (i = 0; entry[i].entry != NULL; i++) {
1638 sensitive = ((entry[i].cond & state) == entry[i].cond);
1639 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1642 main_window_menu_callback_block(mainwin);
1644 #define SET_CHECK_MENU_ACTIVE(path, active) \
1646 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1647 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1650 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1651 messageview_is_visible(mainwin->messageview));
1653 summaryview = mainwin->summaryview;
1654 menu_path = "/View/Sort/Don't sort";
1656 switch (summaryview->sort_key) {
1657 case SORT_BY_NUMBER:
1658 menu_path = "/View/Sort/by number"; break;
1660 menu_path = "/View/Sort/by size"; break;
1662 menu_path = "/View/Sort/by date"; break;
1664 menu_path = "/View/Sort/by from"; break;
1666 menu_path = "/View/Sort/by recipient"; break;
1667 case SORT_BY_SUBJECT:
1668 menu_path = "/View/Sort/by subject"; break;
1670 menu_path = "/View/Sort/by color label"; break;
1672 menu_path = "/View/Sort/by mark"; break;
1673 case SORT_BY_STATUS:
1674 menu_path = "/View/Sort/by status"; break;
1676 menu_path = "/View/Sort/by attachment"; break;
1678 menu_path = "/View/Sort/by score"; break;
1679 case SORT_BY_LOCKED:
1680 menu_path = "/View/Sort/by locked"; break;
1683 menu_path = "/View/Sort/Don't sort"; break;
1685 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1687 if (summaryview->sort_type == SORT_ASCENDING) {
1688 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1690 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1693 if (summaryview->sort_key != SORT_BY_NONE) {
1694 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1695 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1697 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1698 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1701 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1702 mainwin->messageview->mimeview->textview->show_all_headers);
1703 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1705 #undef SET_CHECK_MENU_ACTIVE
1707 main_window_menu_callback_unblock(mainwin);
1710 void main_window_popup(MainWindow *mainwin)
1712 gtkut_window_popup(mainwin->window);
1714 switch (mainwin->type) {
1715 case SEPARATE_FOLDER:
1716 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1718 case SEPARATE_MESSAGE:
1719 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1722 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1723 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1730 void main_window_show(MainWindow *mainwin)
1732 gtk_widget_show(mainwin->window);
1733 gtk_widget_show(mainwin->vbox_body);
1735 gtk_widget_set_uposition(mainwin->window,
1736 prefs_common.mainwin_x,
1737 prefs_common.mainwin_y);
1739 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1740 prefs_common.folderview_width,
1741 prefs_common.folderview_height);
1742 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1743 prefs_common.summaryview_width,
1744 prefs_common.summaryview_height);
1745 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1746 prefs_common.msgview_width,
1747 prefs_common.msgview_height);
1749 if (mainwin->type & SEPARATE_FOLDER) {
1750 GtkWidget *folderwin;
1752 folderwin = main_window_get_folder_window(mainwin);
1753 gtk_widget_show(folderwin);
1754 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1755 prefs_common.folderwin_y);
1758 if (mainwin->type & SEPARATE_MESSAGE) {
1759 GtkWidget *messagewin;
1761 messagewin = main_window_get_message_window(mainwin);
1762 gtk_widget_show(messagewin);
1763 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1764 prefs_common.main_msgwin_y);
1768 void main_window_hide(MainWindow *mainwin)
1770 main_window_get_size(mainwin);
1771 main_window_get_position(mainwin);
1773 gtk_widget_hide(mainwin->window);
1774 gtk_widget_hide(mainwin->vbox_body);
1776 if (mainwin->type & SEPARATE_FOLDER) {
1777 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1780 if (mainwin->type & SEPARATE_MESSAGE) {
1781 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1785 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1787 GtkWidget *folderwin = NULL;
1788 GtkWidget *messagewin = NULL;
1791 GtkWidget *vbox_body = mainwin->vbox_body;
1792 GtkItemFactory *ifactory = mainwin->menu_factory;
1793 GtkWidget *menuitem;
1794 GtkItemFactory *msgview_ifactory;
1796 debug_print("Setting widgets... ");
1798 /* create separated window(s) if needed */
1799 if (type & SEPARATE_FOLDER) {
1800 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1801 gtk_window_set_title(GTK_WINDOW(folderwin),
1802 _("Sylpheed - Folder View"));
1803 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1804 "folder_view", "Sylpheed");
1805 gtk_window_set_policy(GTK_WINDOW(folderwin),
1807 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1808 prefs_common.folderwin_y);
1809 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1811 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1812 GTK_SIGNAL_FUNC(folder_window_close_cb),
1814 gtk_container_add(GTK_CONTAINER(folderwin),
1815 GTK_WIDGET_PTR(mainwin->folderview));
1816 gtk_widget_realize(folderwin);
1817 if (prefs_common.folderview_visible)
1818 gtk_widget_show(folderwin);
1820 if (type & SEPARATE_MESSAGE) {
1821 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1822 gtk_window_set_title(GTK_WINDOW(messagewin),
1823 _("Sylpheed - Message View"));
1824 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1825 "message_view", "Sylpheed");
1826 gtk_window_set_policy(GTK_WINDOW(messagewin),
1828 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1829 prefs_common.main_msgwin_y);
1830 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1832 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1833 GTK_SIGNAL_FUNC(message_window_close_cb),
1835 if (messageview_is_visible(mainwin->messageview))
1836 gtk_widget_show(messagewin);
1839 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1840 prefs_common.folderview_width,
1841 prefs_common.folderview_height);
1842 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1843 prefs_common.summaryview_width,
1844 prefs_common.summaryview_height);
1845 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1846 prefs_common.msgview_width,
1847 prefs_common.msgview_height);
1851 hpaned = gtk_hpaned_new();
1852 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1853 gtk_paned_add1(GTK_PANED(hpaned),
1854 GTK_WIDGET_PTR(mainwin->folderview));
1855 gtk_widget_show(hpaned);
1856 gtk_widget_queue_resize(hpaned);
1858 vpaned = gtk_vpaned_new();
1859 if (messageview_is_visible(mainwin->messageview)) {
1860 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1861 gtk_paned_add1(GTK_PANED(vpaned),
1862 GTK_WIDGET_PTR(mainwin->summaryview));
1864 gtk_paned_add2(GTK_PANED(hpaned),
1865 GTK_WIDGET_PTR(mainwin->summaryview));
1866 gtk_widget_ref(vpaned);
1868 gtk_paned_add2(GTK_PANED(vpaned),
1869 GTK_WIDGET_PTR(mainwin->messageview));
1870 gtk_widget_show(vpaned);
1871 gtk_widget_queue_resize(vpaned);
1873 mainwin->win.sep_none.hpaned = hpaned;
1874 mainwin->win.sep_none.vpaned = vpaned;
1876 /* remove headerview if not in prefs */
1877 headerview_set_visibility(mainwin->messageview->headerview,
1878 prefs_common.display_header_pane);
1880 case SEPARATE_FOLDER:
1881 vpaned = gtk_vpaned_new();
1882 if (messageview_is_visible(mainwin->messageview)) {
1883 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1885 gtk_paned_add1(GTK_PANED(vpaned),
1886 GTK_WIDGET_PTR(mainwin->summaryview));
1888 gtk_box_pack_start(GTK_BOX(vbox_body),
1889 GTK_WIDGET_PTR(mainwin->summaryview),
1891 gtk_widget_ref(vpaned);
1893 gtk_paned_add2(GTK_PANED(vpaned),
1894 GTK_WIDGET_PTR(mainwin->messageview));
1895 gtk_widget_show(vpaned);
1896 gtk_widget_queue_resize(vpaned);
1898 mainwin->win.sep_folder.folderwin = folderwin;
1899 mainwin->win.sep_folder.vpaned = vpaned;
1901 /* remove headerview if not in prefs */
1902 headerview_set_visibility(mainwin->messageview->headerview,
1903 prefs_common.display_header_pane);
1906 case SEPARATE_MESSAGE:
1907 hpaned = gtk_hpaned_new();
1908 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1909 gtk_paned_add1(GTK_PANED(hpaned),
1910 GTK_WIDGET_PTR(mainwin->folderview));
1911 gtk_paned_add2(GTK_PANED(hpaned),
1912 GTK_WIDGET_PTR(mainwin->summaryview));
1913 gtk_widget_show(hpaned);
1914 gtk_widget_queue_resize(hpaned);
1915 messageview_add_toolbar(mainwin->messageview, messagewin);
1916 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1917 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1919 mainwin->win.sep_message.messagewin = messagewin;
1920 mainwin->win.sep_message.hpaned = hpaned;
1922 gtk_widget_realize(messagewin);
1923 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1924 gtk_widget_show_all(messagewin);
1925 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1926 mainwin->messageview->handlebox,
1927 prefs_common.toolbar_style);
1931 messageview_add_toolbar(mainwin->messageview, messagewin);
1932 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1933 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1935 gtk_box_pack_start(GTK_BOX(vbox_body),
1936 GTK_WIDGET_PTR(mainwin->summaryview),
1939 mainwin->win.sep_both.folderwin = folderwin;
1940 mainwin->win.sep_both.messagewin = messagewin;
1942 gtk_widget_realize(messagewin);
1943 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1944 gtk_widget_show_all(messagewin);
1945 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1946 mainwin->messageview->handlebox,
1947 prefs_common.toolbar_style);
1952 gtk_widget_set_uposition(mainwin->window,
1953 prefs_common.mainwin_x,
1954 prefs_common.mainwin_y);
1956 gtk_widget_queue_resize(vbox_body);
1957 gtk_widget_queue_resize(mainwin->vbox);
1958 gtk_widget_queue_resize(mainwin->window);
1959 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1960 * and mimeview icon list/ctree lose track of their visibility states */
1961 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1962 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1963 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
1964 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
1965 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
1966 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
1968 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
1970 /* rehide quick search if necessary */
1971 if (!prefs_common.show_searchbar)
1972 gtk_widget_hide(mainwin->summaryview->hbox_search);
1974 mainwin->type = type;
1977 /* toggle menu state */
1978 menuitem = gtk_item_factory_get_item
1979 (ifactory, "/View/Show or hide/Folder tree");
1980 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1981 (type & SEPARATE_FOLDER) == 0 ? TRUE :
1982 prefs_common.folderview_visible);
1983 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
1984 menuitem = gtk_item_factory_get_item
1985 (ifactory, "/View/Show or hide/Message view");
1986 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1987 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
1988 prefs_common.msgview_visible);
1990 menuitem = gtk_item_factory_get_item
1991 (ifactory, "/View/Separate folder tree");
1992 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1993 ((type & SEPARATE_FOLDER) != 0));
1994 menuitem = gtk_item_factory_get_item
1995 (ifactory, "/View/Separate message view");
1996 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1997 ((type & SEPARATE_MESSAGE) != 0));
2001 (GTK_OBJECT(folderwin), "size_allocate",
2002 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
2007 (GTK_OBJECT(messagewin), "size_allocate",
2008 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
2012 debug_print("done.\n");
2015 void main_window_destroy_all(void)
2017 while (mainwin_list != NULL) {
2018 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2020 /* free toolbar stuff */
2021 toolbar_clear_list(TOOLBAR_MAIN);
2022 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2023 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2025 g_free(mainwin->toolbar);
2028 mainwin_list = g_list_remove(mainwin_list, mainwin);
2030 g_list_free(mainwin_list);
2034 static void toolbar_account_button_pressed(GtkWidget *widget,
2035 GdkEventButton *event,
2038 MainWindow *mainwin = (MainWindow *)data;
2041 if (event->button != 3) return;
2043 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2044 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2047 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2048 menu_button_position, widget,
2049 event->button, event->time);
2053 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2056 MainWindow *mainwin = (MainWindow *)data;
2060 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2061 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2064 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2065 menu_button_position, widget,
2066 event->button, event->time);
2069 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2071 MainWindow *mainwin = (MainWindow *)data;
2074 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2075 if (!button) return;
2076 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2077 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2078 manage_window_focus_in(mainwin->window, NULL, NULL);
2081 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2084 MainWindow *mainwin = (MainWindow *)data;
2086 if (mainwin->lock_count == 0)
2087 app_exit_cb(data, 0, widget);
2092 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2095 MainWindow *mainwin = (MainWindow *)data;
2096 GtkWidget *menuitem;
2098 menuitem = gtk_item_factory_get_item
2099 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2100 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2105 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2108 MainWindow *mainwin = (MainWindow *)data;
2109 GtkWidget *menuitem;
2111 menuitem = gtk_item_factory_get_item
2112 (mainwin->menu_factory, "/View/Show or hide/Message view");
2113 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2118 static void main_window_size_allocate_cb(GtkWidget *widget,
2119 GtkAllocation *allocation,
2122 MainWindow *mainwin = (MainWindow *)data;
2124 main_window_get_size(mainwin);
2127 static void folder_window_size_allocate_cb(GtkWidget *widget,
2128 GtkAllocation *allocation,
2131 MainWindow *mainwin = (MainWindow *)data;
2133 main_window_get_size(mainwin);
2136 static void message_window_size_allocate_cb(GtkWidget *widget,
2137 GtkAllocation *allocation,
2140 MainWindow *mainwin = (MainWindow *)data;
2142 main_window_get_size(mainwin);
2145 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2148 main_window_add_mailbox(mainwin);
2151 static void update_folderview_cb(MainWindow *mainwin, guint action,
2154 summary_show(mainwin->summaryview, NULL);
2155 folderview_check_new_all();
2158 static void new_folder_cb(MainWindow *mainwin, guint action,
2161 folderview_new_folder(mainwin->folderview);
2164 static void rename_folder_cb(MainWindow *mainwin, guint action,
2167 folderview_rename_folder(mainwin->folderview);
2170 static void delete_folder_cb(MainWindow *mainwin, guint action,
2173 folderview_delete_folder(mainwin->folderview);
2176 static void import_mbox_cb(MainWindow *mainwin, guint action,
2179 import_mbox(mainwin->summaryview->folder_item);
2182 static void export_mbox_cb(MainWindow *mainwin, guint action,
2185 export_mbox(mainwin->summaryview->folder_item);
2188 static void empty_trash_cb(MainWindow *mainwin, guint action,
2191 main_window_empty_trash(mainwin, TRUE);
2194 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2196 summary_save_as(mainwin->summaryview);
2199 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2201 summary_print(mainwin->summaryview);
2204 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2206 if (prefs_common.confirm_on_exit) {
2207 if (alertpanel(_("Exit"), _("Exit this program?"),
2208 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2210 manage_window_focus_in(mainwin->window, NULL, NULL);
2213 app_will_exit(widget, mainwin);
2216 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2219 summary_search(mainwin->summaryview);
2221 message_search(mainwin->messageview);
2224 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2229 active = GTK_CHECK_MENU_ITEM(widget)->active;
2231 switch (mainwin->type) {
2233 case SEPARATE_MESSAGE:
2236 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2238 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2241 case SEPARATE_FOLDER:
2242 debug_print("separate folder\n");
2244 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2246 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2250 gtk_widget_show(mainwin->win.sep_both.folderwin);
2252 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2256 prefs_common.folderview_visible = active;
2259 static void toggle_message_cb(MainWindow *mainwin, guint action,
2264 active = GTK_CHECK_MENU_ITEM(widget)->active;
2266 if (active != messageview_is_visible(mainwin->messageview))
2267 summary_toggle_view(mainwin->summaryview);
2270 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2273 toolbar_toggle(action, mainwin);
2276 void main_window_reply_cb(MainWindow *mainwin, guint action,
2279 MessageView *msgview = (MessageView*)mainwin->messageview;
2280 GSList *msginfo_list = NULL;
2283 g_return_if_fail(msgview != NULL);
2285 msginfo_list = summary_get_selection(mainwin->summaryview);
2286 g_return_if_fail(msginfo_list != NULL);
2288 body = messageview_get_selection(msgview);
2289 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2291 g_slist_free(msginfo_list);
2295 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2298 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2299 gtk_widget_show(mainwin->hbox_stat);
2300 prefs_common.show_statusbar = TRUE;
2302 gtk_widget_hide(mainwin->hbox_stat);
2303 prefs_common.show_statusbar = FALSE;
2307 static void separate_widget_cb(MainWindow *mainwin, guint action,
2312 if (GTK_CHECK_MENU_ITEM(widget)->active)
2313 type = mainwin->type | action;
2315 type = mainwin->type & ~action;
2317 main_window_separation_change(mainwin, type);
2319 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2320 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2323 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2326 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2328 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2331 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2333 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2336 static void online_switch_clicked (GtkButton *btn, gpointer data)
2338 MainWindow *mainwin;
2339 GtkItemFactory *ifactory;
2340 GtkCheckMenuItem *menuitem;
2342 mainwin = (MainWindow *) data;
2344 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2345 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2347 g_return_if_fail(mainwin != NULL);
2348 g_return_if_fail(menuitem != NULL);
2350 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2352 gtk_widget_hide (mainwin->online_switch);
2353 gtk_widget_show (mainwin->offline_switch);
2354 menuitem->active = TRUE;
2355 prefs_common.work_offline = TRUE;
2356 inc_autocheck_timer_remove();
2359 gtk_widget_hide (mainwin->offline_switch);
2360 gtk_widget_show (mainwin->online_switch);
2361 menuitem->active = FALSE;
2362 prefs_common.work_offline = FALSE;
2363 inc_autocheck_timer_set();
2367 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2370 addressbook_open(NULL);
2373 static void log_window_show_cb(MainWindow *mainwin, guint action,
2376 log_window_show(mainwin->logwin);
2379 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2384 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2386 summary_move_to(mainwin->summaryview);
2389 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2391 summary_copy_to(mainwin->summaryview);
2394 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2396 summary_delete(mainwin->summaryview);
2399 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2401 summary_cancel(mainwin->summaryview);
2404 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 summary_open_msg(mainwin->summaryview);
2409 static void view_source_cb(MainWindow *mainwin, guint action,
2412 summary_view_source(mainwin->summaryview);
2415 static void show_all_header_cb(MainWindow *mainwin, guint action,
2418 if (mainwin->menu_lock_count) return;
2419 summary_display_msg_selected(mainwin->summaryview,
2420 GTK_CHECK_MENU_ITEM(widget)->active);
2423 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2425 summary_reedit(mainwin->summaryview);
2428 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2430 summary_mark(mainwin->summaryview);
2433 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2435 summary_unmark(mainwin->summaryview);
2438 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2441 summary_mark_as_unread(mainwin->summaryview);
2444 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2447 summary_mark_as_read(mainwin->summaryview);
2450 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2453 summary_mark_all_read(mainwin->summaryview);
2456 static void add_address_cb(MainWindow *mainwin, guint action,
2459 summary_add_address(mainwin->summaryview);
2462 static void set_charset_cb(MainWindow *mainwin, guint action,
2467 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2468 str = conv_get_charset_str((CharSet)action);
2469 g_free(prefs_common.force_charset);
2470 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2472 summary_redisplay_msg(mainwin->summaryview);
2474 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2478 static void hide_read_messages (MainWindow *mainwin, guint action,
2481 if (!mainwin->summaryview->folder_item
2482 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2484 summary_toggle_show_read_messages(mainwin->summaryview);
2487 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2489 if (mainwin->menu_lock_count) return;
2490 if (!mainwin->summaryview->folder_item) return;
2492 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2493 summary_thread_build(mainwin->summaryview);
2494 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2496 summary_unthread(mainwin->summaryview);
2497 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2501 static void expand_threads_cb(MainWindow *mainwin, guint action,
2504 summary_expand_threads(mainwin->summaryview);
2507 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2510 summary_collapse_threads(mainwin->summaryview);
2513 static void set_display_item_cb(MainWindow *mainwin, guint action,
2516 prefs_summary_column_open();
2519 static void sort_summary_cb(MainWindow *mainwin, guint action,
2522 FolderItem *item = mainwin->summaryview->folder_item;
2523 GtkWidget *menuitem;
2525 if (mainwin->menu_lock_count) return;
2527 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2528 menuitem = gtk_item_factory_get_item
2529 (mainwin->menu_factory, "/View/Sort/Ascending");
2530 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2531 GTK_CHECK_MENU_ITEM(menuitem)->active
2532 ? SORT_ASCENDING : SORT_DESCENDING);
2536 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2539 FolderItem *item = mainwin->summaryview->folder_item;
2541 if (mainwin->menu_lock_count) return;
2543 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2544 summary_sort(mainwin->summaryview,
2545 item->sort_key, (FolderSortType)action);
2548 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2551 summary_attract_by_subject(mainwin->summaryview);
2554 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2557 summary_delete_duplicated(mainwin->summaryview);
2560 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2562 summary_filter(mainwin->summaryview);
2565 static void execute_summary_cb(MainWindow *mainwin, guint action,
2568 summary_execute(mainwin->summaryview);
2571 static void update_summary_cb(MainWindow *mainwin, guint action,
2575 FolderView *folderview = mainwin->folderview;
2577 if (!mainwin->summaryview->folder_item) return;
2578 if (!folderview->opened) return;
2580 folder_update_op_count();
2582 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2583 folderview->opened);
2586 folder_item_scan(fitem);
2587 summary_show(mainwin->summaryview, fitem);
2590 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2592 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2595 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2597 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2600 static void prev_unread_cb(MainWindow *mainwin, guint action,
2603 summary_select_prev_unread(mainwin->summaryview);
2606 static void next_unread_cb(MainWindow *mainwin, guint action,
2609 summary_select_next_unread(mainwin->summaryview);
2612 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2614 summary_select_prev_new(mainwin->summaryview);
2617 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2619 summary_select_next_new(mainwin->summaryview);
2622 static void prev_marked_cb(MainWindow *mainwin, guint action,
2625 summary_select_prev_marked(mainwin->summaryview);
2628 static void next_marked_cb(MainWindow *mainwin, guint action,
2631 summary_select_next_marked(mainwin->summaryview);
2634 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2637 summary_select_prev_labeled(mainwin->summaryview);
2640 static void next_labeled_cb(MainWindow *mainwin, guint action,
2643 summary_select_next_labeled(mainwin->summaryview);
2646 static void goto_folder_cb(MainWindow *mainwin, guint action,
2649 FolderItem *to_folder;
2651 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2654 folderview_select(mainwin->folderview, to_folder);
2657 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2659 messageview_copy_clipboard(mainwin->messageview);
2662 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2664 MessageView *msgview = mainwin->messageview;
2666 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2667 summary_select_all(mainwin->summaryview);
2668 else if (messageview_is_visible(msgview) &&
2669 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2670 messageview_select_all(mainwin->messageview);
2673 static void select_thread_cb(MainWindow *mainwin, guint action,
2676 summary_select_thread(mainwin->summaryview);
2679 static void create_filter_cb(MainWindow *mainwin, guint action,
2682 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2685 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2688 prefs_common_open();
2691 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2694 prefs_filtering_open(&pre_global_processing,
2695 _("Processing rules to apply before folder rules"),
2699 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2702 prefs_filtering_open(&post_global_processing,
2703 _("Processing rules to apply after folder rules"),
2707 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2710 prefs_filtering_open(&filtering_rules,
2711 _("Filtering configuration"),
2715 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2718 prefs_template_open();
2721 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2724 prefs_actions_open(mainwin);
2727 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2730 ssl_manager_open(mainwin);
2733 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2737 new_account_cb(mainwin, 0, widget);
2739 account_open(cur_account);
2743 static void new_account_cb(MainWindow *mainwin, guint action,
2746 account_edit_open();
2747 if (!compose_get_compose_list()) account_add();
2750 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2752 cur_account = (PrefsAccount *)data;
2753 main_window_reflect_prefs_all();
2756 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2761 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2763 pluginwindow_create();
2766 static void manual_open_cb(MainWindow *mainwin, guint action,
2769 manual_open((ManualType)action);
2772 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2774 MainWindow *mainwin = (MainWindow *)data;
2778 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2779 LOCAL_FOLDER(folder)->rootpath,
2783 str = g_strdup_printf(_("Scanning folder %s ..."),
2784 LOCAL_FOLDER(folder)->rootpath);
2786 STATUSBAR_PUSH(mainwin, str);
2787 STATUSBAR_POP(mainwin);
2791 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2794 SummaryView *summary;
2796 g_return_val_if_fail(data, FALSE);
2797 summary = ((MainWindow *)data)->summaryview;
2798 g_return_val_if_fail(summary, FALSE);
2800 if (GTK_CLIST(summary->ctree)->selection &&
2801 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2804 if (summary->selected != summary->displayed)
2805 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2809 #define BREAK_ON_MODIFIER_KEY() \
2810 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2812 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2815 MainWindow *mainwin = (MainWindow*) data;
2817 if (!mainwin || !event) return;
2819 switch (event->keyval) {
2820 case GDK_Q: /* Quit */
2821 BREAK_ON_MODIFIER_KEY();
2823 app_exit_cb(mainwin, 0, NULL);
2826 if (mainwin->folderview && mainwin->summaryview
2827 && !mainwin->summaryview->displayed) {
2828 summary_lock(mainwin->summaryview);
2829 folderview_select_next_unread(mainwin->folderview);
2830 summary_unlock(mainwin->summaryview);
2838 #undef BREAK_ON_MODIFIER_KEY
2841 * Harvest addresses for selected folder.
2843 static void addr_harvest_cb( MainWindow *mainwin,
2847 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2851 * Harvest addresses for selected messages in summary view.
2853 static void addr_harvest_msg_cb( MainWindow *mainwin,
2857 summary_harvest_address( mainwin->summaryview );
2861 *\brief get a MainWindow
2863 *\return MainWindow * The first mainwindow in the mainwin_list
2865 MainWindow *mainwindow_get_mainwindow(void)
2867 if (mainwin_list && mainwin_list->data)
2868 return (MainWindow *)(mainwin_list->data);
2873 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2875 ProgressData *data = (ProgressData *) source;
2876 MainWindow *mainwin = (MainWindow *) userdata;
2878 switch (data->cmd) {
2879 case PROGRESS_COMMAND_START:
2880 case PROGRESS_COMMAND_STOP:
2881 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2883 case PROGRESS_COMMAND_SET_PERCENTAGE:
2884 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2887 while (gtk_events_pending()) gtk_main_iteration ();