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_processing_open_cb (MainWindow *mainwin,
364 static void prefs_filtering_open_cb (MainWindow *mainwin,
368 static void ssl_manager_open_cb (MainWindow *mainwin,
372 static void new_account_cb (MainWindow *mainwin,
376 static void account_menu_cb (GtkMenuItem *menuitem,
379 static void prefs_open_cb (GtkMenuItem *menuitem,
381 static void plugins_open_cb (GtkMenuItem *menuitem,
384 static void online_switch_clicked(GtkButton *btn,
387 static void manual_open_cb (MainWindow *mainwin,
391 static void scan_tree_func (Folder *folder,
395 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
397 static void addr_harvest_cb ( MainWindow *mainwin,
401 static void addr_harvest_msg_cb ( MainWindow *mainwin,
405 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
406 GdkEventFocus *focus,
408 void main_window_reply_cb (MainWindow *mainwin,
411 gboolean mainwindow_progressindicator_hook (gpointer source,
413 #define SEPARATE_ACTION 500
415 static GtkItemFactoryEntry mainwin_entries[] =
417 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
418 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
419 {N_("/_File/_Folder/Create _new folder..."),
420 NULL, new_folder_cb, 0, NULL},
421 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
422 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
423 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
424 {N_("/_File/_Folder/_Check for new messages in all folders"),
425 NULL, update_folderview_cb, 0, NULL},
426 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
427 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
428 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
429 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
430 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
431 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
432 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
433 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
434 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
435 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
436 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
437 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
439 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
440 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
441 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
442 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
443 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
444 {N_("/_Edit/_Find in current message..."),
445 "<control>F", search_cb, 0, NULL},
446 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
447 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
448 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
449 {N_("/_View/Show or hi_de/_Folder tree"),
450 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
451 {N_("/_View/Show or hi_de/_Message view"),
452 "V", toggle_message_cb, 0, "<ToggleItem>"},
453 {N_("/_View/Show or hi_de/_Toolbar"),
454 NULL, NULL, 0, "<Branch>"},
455 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
456 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
457 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
458 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
459 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
460 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
461 {N_("/_View/Show or hi_de/_Toolbar/_None"),
462 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
463 {N_("/_View/Show or hi_de/Status _bar"),
464 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
465 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
466 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
467 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
468 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
469 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
470 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
471 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
472 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
473 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
474 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
475 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
476 {N_("/_View/_Sort/by _color label"),
477 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
478 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
479 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
480 {N_("/_View/_Sort/by a_ttachment"),
481 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
482 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
483 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
484 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
485 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
486 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
487 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
488 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_View/_Sort/_Attract by subject"),
490 NULL, attract_by_subject_cb, 0, NULL},
491 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
492 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
493 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
494 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
495 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
497 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
498 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
499 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
500 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
501 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_View/_Go to/P_rev unread message"),
503 "<shift>P", prev_unread_cb, 0, NULL},
504 {N_("/_View/_Go to/N_ext unread message"),
505 "<shift>N", next_unread_cb, 0, NULL},
506 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
508 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
509 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_View/_Go to/Prev _marked message"),
511 NULL, prev_marked_cb, 0, NULL},
512 {N_("/_View/_Go to/Next m_arked message"),
513 NULL, next_marked_cb, 0, NULL},
514 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
515 {N_("/_View/_Go to/Prev _labeled message"),
516 NULL, prev_labeled_cb, 0, NULL},
517 {N_("/_View/_Go to/Next la_beled message"),
518 NULL, next_labeled_cb, 0, NULL},
519 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
520 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
521 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
523 #define CODESET_SEPARATOR \
524 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
525 #define CODESET_ACTION(action) \
526 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
528 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
529 {N_("/_View/_Code set/_Auto detect"),
530 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
531 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
532 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
533 CODESET_ACTION(C_US_ASCII)},
536 {N_("/_View/_Code set/Unicode (_UTF-8)"),
537 CODESET_ACTION(C_UTF_8)},
540 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
541 CODESET_ACTION(C_ISO_8859_1)},
542 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
543 CODESET_ACTION(C_ISO_8859_15)},
546 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
547 CODESET_ACTION(C_ISO_8859_2)},
549 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
550 CODESET_ACTION(C_ISO_8859_13)},
551 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
552 CODESET_ACTION(C_ISO_8859_4)},
554 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
555 CODESET_ACTION(C_ISO_8859_7)},
557 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
558 CODESET_ACTION(C_ISO_8859_9)},
560 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
561 CODESET_ACTION(C_ISO_8859_5)},
562 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
563 CODESET_ACTION(C_KOI8_R)},
564 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
565 CODESET_ACTION(C_WINDOWS_1251)},
568 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
569 CODESET_ACTION(C_ISO_2022_JP)},
571 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
572 CODESET_ACTION(C_ISO_2022_JP_2)},
574 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
575 CODESET_ACTION(C_EUC_JP)},
576 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
577 CODESET_ACTION(C_SHIFT_JIS)},
580 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
581 CODESET_ACTION(C_GB2312)},
582 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
583 CODESET_ACTION(C_BIG5)},
584 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
585 CODESET_ACTION(C_EUC_TW)},
586 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
587 CODESET_ACTION(C_ISO_2022_CN)},
589 {N_("/_View/_Code set/Korean (EUC-_KR)"),
590 CODESET_ACTION(C_EUC_KR)},
591 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
592 CODESET_ACTION(C_ISO_2022_KR)},
594 {N_("/_View/_Code set/Thai (TIS-620)"),
595 CODESET_ACTION(C_TIS_620)},
596 {N_("/_View/_Code set/Thai (Windows-874)"),
597 CODESET_ACTION(C_WINDOWS_874)},
600 #undef CODESET_SEPARATOR
601 #undef CODESET_ACTION
603 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
605 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
606 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
607 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
608 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
610 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
611 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
612 {N_("/_Message/Get from _all accounts"),
613 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
614 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
615 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
616 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
617 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
619 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
620 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
621 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
622 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
623 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
624 {N_("/_Message/Repl_y to/mailing _list"),
625 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
626 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
627 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
629 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
630 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
632 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
633 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
634 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
635 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
636 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
637 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
639 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
640 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
641 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
642 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
643 {N_("/_Message/_Mark/Mark as rea_d"),
644 NULL, mark_as_read_cb, 0, NULL},
645 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
647 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
648 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
649 {N_("/_Tools/Add sender to address boo_k"),
650 NULL, add_address_cb, 0, NULL},
651 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
652 {N_("/_Tools/_Harvest addresses/from _Folder..."),
653 NULL, addr_harvest_cb, 0, NULL},
654 {N_("/_Tools/_Harvest addresses/from _Messages..."),
655 NULL, addr_harvest_msg_cb, 0, NULL},
656 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
658 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
659 {N_("/_Tools/_Create filter rule/_Automatically"),
660 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
661 {N_("/_Tools/_Create filter rule/by _From"),
662 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
663 {N_("/_Tools/_Create filter rule/by _To"),
664 NULL, create_filter_cb, FILTER_BY_TO, NULL},
665 {N_("/_Tools/_Create filter rule/by _Subject"),
666 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
667 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
669 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
670 {N_("/_Tools/Delete du_plicated messages"),
671 NULL, delete_duplicated_cb, 0, NULL},
672 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
675 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
676 {N_("/_Tools/SSL certi_ficates..."),
677 NULL, ssl_manager_open_cb, 0, NULL},
679 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
680 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
682 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
683 {N_("/_Configuration/C_hange current account"),
684 NULL, NULL, 0, "<Branch>"},
685 {N_("/_Configuration/_Preferences for current account..."),
686 NULL, prefs_account_open_cb, 0, NULL},
687 {N_("/_Configuration/Create _new account..."),
688 NULL, new_account_cb, 0, NULL},
689 {N_("/_Configuration/_Edit accounts..."),
690 NULL, account_edit_open, 0, NULL},
691 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
692 {N_("/_Configuration/_Common preferences..."),
693 NULL, prefs_common_open_cb, 0, NULL},
694 {N_("/_Configuration/Processing..."),
695 NULL, prefs_processing_open_cb, 0, NULL},
696 {N_("/_Configuration/_Filtering..."),
697 NULL, prefs_filtering_open_cb, 0, NULL},
698 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
699 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
700 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
701 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
703 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
704 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
705 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
706 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
707 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
708 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
709 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
710 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
711 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
712 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
713 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
716 MainWindow *main_window_create(SeparateType type)
722 GtkWidget *handlebox;
723 GtkWidget *vbox_body;
724 GtkWidget *hbox_stat;
725 GtkWidget *statusbar;
726 GtkWidget *progressbar;
727 GtkWidget *statuslabel;
728 GtkWidget *ac_button;
730 GtkWidget *online_pixmap;
731 GtkWidget *offline_pixmap;
732 GtkWidget *online_switch;
733 GtkWidget *offline_switch;
734 GtkTooltips *offline_tip;
735 GtkTooltips *online_tip;
736 GtkTooltips *sel_ac_tip;
738 FolderView *folderview;
739 SummaryView *summaryview;
740 MessageView *messageview;
741 GdkColormap *colormap;
744 GtkItemFactory *ifactory;
748 guint n_menu_entries;
750 static GdkGeometry geometry;
752 debug_print("Creating main window...\n");
753 mainwin = g_new0(MainWindow, 1);
756 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
757 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
758 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
759 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
761 if (!geometry.min_height) {
762 geometry.min_width = 320;
763 geometry.min_height = 200;
765 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
768 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
769 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
770 MANAGE_WINDOW_SIGNALS_CONNECT(window);
771 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
772 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
774 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
775 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
777 gtk_widget_realize(window);
778 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
781 gtkut_widget_set_app_icon(window);
783 vbox = gtk_vbox_new(FALSE, 0);
784 gtk_widget_show(vbox);
785 gtk_container_add(GTK_CONTAINER(window), vbox);
788 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
789 menubar = menubar_create(window, mainwin_entries,
790 n_menu_entries, "<Main>", mainwin);
791 gtk_widget_show(menubar);
792 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
793 ifactory = gtk_item_factory_from_widget(menubar);
795 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
796 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
798 handlebox = gtk_handle_box_new();
799 gtk_widget_show(handlebox);
800 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
802 /* link window to mainwin->window to avoid gdk warnings */
803 mainwin->window = window;
806 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
810 /* vbox that contains body */
811 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
812 gtk_widget_show(vbox_body);
813 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
814 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
816 hbox_stat = gtk_hbox_new(FALSE, 2);
817 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
819 statusbar = statusbar_create();
820 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
822 progressbar = gtk_progress_bar_new();
823 gtk_widget_set_usize(progressbar, 120, 1);
824 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
826 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
827 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
828 online_tip = gtk_tooltips_new();
829 online_switch = gtk_button_new ();
830 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
831 online_switch, _("Go offline"), NULL);
832 offline_tip = gtk_tooltips_new();
833 offline_switch = gtk_button_new ();
834 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
835 offline_switch, _("Go online"), NULL);
836 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
837 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
838 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
839 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
840 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
841 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
842 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
843 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
845 statuslabel = gtk_label_new("");
846 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
848 sel_ac_tip = gtk_tooltips_new();
849 ac_button = gtk_button_new();
850 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
851 ac_button, _("Select account"), NULL);
852 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
853 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
854 gtk_widget_set_usize(ac_button, -1, 1);
855 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
856 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
857 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
859 ac_label = gtk_label_new("");
860 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
862 gtk_widget_show_all(hbox_stat);
864 gtk_widget_hide(offline_switch);
866 mainwin->folderview = folderview = folderview_create();
867 mainwin->summaryview = summaryview = summary_create();
868 mainwin->messageview = messageview = messageview_create(mainwin);
869 mainwin->logwin = log_window_create();
871 folderview->mainwin = mainwin;
872 folderview->summaryview = summaryview;
874 summaryview->mainwin = mainwin;
875 summaryview->folderview = folderview;
876 summaryview->messageview = messageview;
877 summaryview->window = window;
879 mainwin->vbox = vbox;
880 mainwin->menubar = menubar;
881 mainwin->menu_factory = ifactory;
882 mainwin->handlebox = handlebox;
883 mainwin->vbox_body = vbox_body;
884 mainwin->hbox_stat = hbox_stat;
885 mainwin->statusbar = statusbar;
886 mainwin->progressbar = progressbar;
887 mainwin->statuslabel = statuslabel;
888 mainwin->ac_button = ac_button;
889 mainwin->ac_label = ac_label;
891 mainwin->online_switch = online_switch;
892 mainwin->offline_switch = offline_switch;
893 mainwin->online_pixmap = online_pixmap;
894 mainwin->offline_pixmap = offline_pixmap;
896 /* set context IDs for status bar */
897 mainwin->mainwin_cid = gtk_statusbar_get_context_id
898 (GTK_STATUSBAR(statusbar), "Main Window");
899 mainwin->folderview_cid = gtk_statusbar_get_context_id
900 (GTK_STATUSBAR(statusbar), "Folder View");
901 mainwin->summaryview_cid = gtk_statusbar_get_context_id
902 (GTK_STATUSBAR(statusbar), "Summary View");
904 /* allocate colors for summary view and folder view */
905 summaryview->color_marked.red = summaryview->color_marked.green = 0;
906 summaryview->color_marked.blue = (guint16)65535;
908 summaryview->color_dim.red = summaryview->color_dim.green =
909 summaryview->color_dim.blue = COLOR_DIM;
911 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
912 &folderview->color_new);
914 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
915 &folderview->color_op);
917 summaryview->color_important.red = 0;
918 summaryview->color_important.green = 0;
919 summaryview->color_important.blue = (guint16)65535;
921 color[0] = summaryview->color_marked;
922 color[1] = summaryview->color_dim;
923 color[2] = folderview->color_new;
924 color[3] = folderview->color_op;
926 colormap = gdk_window_get_colormap(window->window);
927 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
928 for (i = 0; i < 4; i++) {
929 if (success[i] == FALSE)
930 g_warning("MainWindow: color allocation %d failed\n", i);
933 debug_print("done.\n");
935 messageview->visible = prefs_common.msgview_visible;
937 main_window_set_widgets(mainwin, type);
939 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
940 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
944 menuitem = gtk_item_factory_get_item
945 (ifactory, "/View/Code set/Auto detect");
946 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
948 switch (prefs_common.toolbar_style) {
950 menuitem = gtk_item_factory_get_item
951 (ifactory, "/View/Show or hide/Toolbar/None");
954 menuitem = gtk_item_factory_get_item
955 (ifactory, "/View/Show or hide/Toolbar/Icon");
958 menuitem = gtk_item_factory_get_item
959 (ifactory, "/View/Show or hide/Toolbar/Text");
962 menuitem = gtk_item_factory_get_item
963 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
965 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
967 gtk_widget_hide(mainwin->hbox_stat);
968 menuitem = gtk_item_factory_get_item
969 (ifactory, "/View/Show or hide/Status bar");
970 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
971 prefs_common.show_statusbar);
973 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
975 if (prefs_common.show_searchbar) {
976 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
977 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
978 gtk_widget_hide(summaryview->search_description);
981 /* set account selection menu */
982 ac_menu = gtk_item_factory_get_widget
983 (ifactory, "/Configuration/Change current account");
984 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
985 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
986 mainwin->ac_menu = ac_menu;
988 toolbar_main_set_sensitive(mainwin);
990 /* create actions menu */
991 action_update_mainwin_menu(ifactory, mainwin);
993 /* attach accel groups to main window */
994 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
995 gtk_window_add_accel_group \
997 gtk_item_factory_from_widget(menu)->accel_group)
999 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
1001 /* connect the accelerators for equivalent
1002 menu items in different menus */
1003 menu_connect_identical_items();
1007 /* show main window */
1008 gtk_widget_show(mainwin->window);
1010 /* initialize views */
1011 folderview_init(folderview);
1012 summary_init(summaryview);
1013 messageview_init(messageview);
1014 log_window_init(mainwin->logwin);
1015 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1016 prefs_common.loglength);
1018 sslcertwindow_register_hook();
1020 mainwin->lock_count = 0;
1021 mainwin->menu_lock_count = 0;
1022 mainwin->cursor_count = 0;
1024 mainwin->progressindicator_hook =
1025 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1028 watch_cursor = gdk_cursor_new(GDK_WATCH);
1030 mainwin_list = g_list_append(mainwin_list, mainwin);
1032 /* init work_offline */
1033 if (prefs_common.work_offline)
1034 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1039 void main_window_cursor_wait(MainWindow *mainwin)
1042 if (mainwin->cursor_count == 0)
1043 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1045 mainwin->cursor_count++;
1050 void main_window_cursor_normal(MainWindow *mainwin)
1052 if (mainwin->cursor_count)
1053 mainwin->cursor_count--;
1055 if (mainwin->cursor_count == 0)
1056 gdk_window_set_cursor(mainwin->window->window, NULL);
1061 /* lock / unlock the user-interface */
1062 void main_window_lock(MainWindow *mainwin)
1064 if (mainwin->lock_count == 0)
1065 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1067 mainwin->lock_count++;
1069 main_window_set_menu_sensitive(mainwin);
1070 toolbar_main_set_sensitive(mainwin);
1073 void main_window_unlock(MainWindow *mainwin)
1075 if (mainwin->lock_count)
1076 mainwin->lock_count--;
1078 main_window_set_menu_sensitive(mainwin);
1079 toolbar_main_set_sensitive(mainwin);
1081 if (mainwin->lock_count == 0)
1082 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1085 static void main_window_menu_callback_block(MainWindow *mainwin)
1087 mainwin->menu_lock_count++;
1090 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1092 if (mainwin->menu_lock_count)
1093 mainwin->menu_lock_count--;
1096 void main_window_reflect_prefs_all(void)
1098 main_window_reflect_prefs_all_real(FALSE);
1101 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1104 MainWindow *mainwin;
1107 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1108 mainwin = (MainWindow *)cur->data;
1110 main_window_show_cur_account(mainwin);
1111 main_window_set_menu_sensitive(mainwin);
1112 toolbar_main_set_sensitive(mainwin);
1115 if (pixmap_theme_changed) {
1116 toolbar_update(TOOLBAR_MAIN, mainwin);
1117 messageview_reflect_prefs_pixmap_theme();
1118 compose_reflect_prefs_pixmap_theme();
1119 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1120 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1122 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1123 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1124 mainwin->online_pixmap);
1125 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1126 gtk_widget_show(pixmap);
1127 mainwin->online_pixmap = pixmap;
1128 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1129 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1130 mainwin->offline_pixmap);
1131 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1132 gtk_widget_show(pixmap);
1133 mainwin->offline_pixmap = pixmap;
1136 summary_redisplay_msg(mainwin->summaryview);
1137 headerview_set_visibility(mainwin->messageview->headerview,
1138 prefs_common.display_header_pane);
1142 void main_window_set_summary_column(void)
1145 MainWindow *mainwin;
1147 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1148 mainwin = (MainWindow *)cur->data;
1149 summary_set_column_order(mainwin->summaryview);
1153 void main_window_set_account_menu(GList *account_list)
1155 GList *cur, *cur_ac, *cur_item;
1156 GtkWidget *menuitem;
1157 MainWindow *mainwin;
1158 PrefsAccount *ac_prefs;
1160 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1161 mainwin = (MainWindow *)cur->data;
1163 /* destroy all previous menu item */
1164 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1165 while (cur_item != NULL) {
1166 GList *next = cur_item->next;
1167 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1171 for (cur_ac = account_list; cur_ac != NULL;
1172 cur_ac = cur_ac->next) {
1173 ac_prefs = (PrefsAccount *)cur_ac->data;
1175 menuitem = gtk_menu_item_new_with_label
1176 (ac_prefs->account_name
1177 ? ac_prefs->account_name : _("Untitled"));
1178 gtk_widget_show(menuitem);
1179 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1180 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1181 GTK_SIGNAL_FUNC(account_menu_cb),
1187 static void main_window_show_cur_account(MainWindow *mainwin)
1192 ac_name = g_strdup(cur_account
1193 ? (cur_account->account_name
1194 ? cur_account->account_name : _("Untitled"))
1198 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1200 buf = g_strdup(PROG_VERSION);
1201 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1204 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1205 gtk_widget_queue_resize(mainwin->ac_button);
1210 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1212 switch (mainwin->type) {
1213 case SEPARATE_FOLDER:
1214 return mainwin->win.sep_folder.folderwin;
1216 return mainwin->win.sep_both.folderwin;
1222 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1224 switch (mainwin->type) {
1225 case SEPARATE_MESSAGE:
1226 return mainwin->win.sep_message.messagewin;
1228 return mainwin->win.sep_both.messagewin;
1234 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1236 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1237 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1238 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1239 GtkWidget *message_wid = mainwin->messageview->vbox;
1241 debug_print("Changing window separation type from %d to %d\n",
1242 mainwin->type, type);
1244 if (mainwin->type == type) return;
1246 /* remove widgets from those containers */
1247 gtk_widget_ref(folder_wid);
1248 gtk_widget_ref(summary_wid);
1249 gtk_widget_ref(message_wid);
1250 gtkut_container_remove
1251 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1252 gtkut_container_remove
1253 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1254 gtkut_container_remove
1255 (GTK_CONTAINER(message_wid->parent), message_wid);
1257 /* clean containers */
1258 switch (mainwin->type) {
1260 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1262 case SEPARATE_FOLDER:
1263 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1264 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1266 case SEPARATE_MESSAGE:
1267 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1268 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1271 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1272 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1276 gtk_widget_hide(mainwin->window);
1277 main_window_set_widgets(mainwin, type);
1278 gtk_widget_show(mainwin->window);
1280 gtk_widget_unref(folder_wid);
1281 gtk_widget_unref(summary_wid);
1282 gtk_widget_unref(message_wid);
1285 void main_window_toggle_message_view(MainWindow *mainwin)
1287 SummaryView *summaryview = mainwin->summaryview;
1288 union CompositeWin *cwin = &mainwin->win;
1289 GtkWidget *vpaned = NULL;
1290 GtkWidget *container = NULL;
1291 GtkWidget *msgwin = NULL;
1293 switch (mainwin->type) {
1295 vpaned = cwin->sep_none.vpaned;
1296 container = cwin->sep_none.hpaned;
1298 case SEPARATE_FOLDER:
1299 vpaned = cwin->sep_folder.vpaned;
1300 container = mainwin->vbox_body;
1302 case SEPARATE_MESSAGE:
1303 msgwin = mainwin->win.sep_message.messagewin;
1306 msgwin = mainwin->win.sep_both.messagewin;
1311 if (GTK_WIDGET_VISIBLE(msgwin)) {
1312 gtk_widget_hide(msgwin);
1313 mainwin->messageview->visible = FALSE;
1314 summaryview->displayed = NULL;
1316 gtk_widget_show(msgwin);
1317 mainwin->messageview->visible = TRUE;
1319 } else if (vpaned->parent != NULL) {
1320 mainwin->messageview->visible = FALSE;
1321 summaryview->displayed = NULL;
1322 gtk_widget_ref(vpaned);
1323 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1324 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1325 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1326 GTK_ARROW_UP, GTK_SHADOW_OUT);
1328 mainwin->messageview->visible = TRUE;
1329 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1330 gtk_container_add(GTK_CONTAINER(container), vpaned);
1331 gtk_widget_unref(vpaned);
1332 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1333 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1336 main_window_set_menu_sensitive(mainwin);
1338 prefs_common.msgview_visible = mainwin->messageview->visible;
1340 gtk_widget_grab_focus(summaryview->ctree);
1343 void main_window_get_size(MainWindow *mainwin)
1345 GtkAllocation *allocation;
1347 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1349 if (allocation->width > 1 && allocation->height > 1) {
1350 prefs_common.summaryview_width = allocation->width;
1352 if ((mainwin->type == SEPARATE_NONE ||
1353 mainwin->type == SEPARATE_FOLDER) &&
1354 messageview_is_visible(mainwin->messageview))
1355 prefs_common.summaryview_height = allocation->height;
1357 prefs_common.mainview_width = allocation->width;
1360 allocation = &mainwin->window->allocation;
1361 if (allocation->width > 1 && allocation->height > 1) {
1362 prefs_common.mainview_height = allocation->height;
1363 prefs_common.mainwin_width = allocation->width;
1364 prefs_common.mainwin_height = allocation->height;
1367 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1368 if (allocation->width > 1 && allocation->height > 1) {
1369 prefs_common.folderview_width = allocation->width;
1370 prefs_common.folderview_height = allocation->height;
1373 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1374 if (allocation->width > 1 && allocation->height > 1) {
1375 prefs_common.msgview_width = allocation->width;
1376 prefs_common.msgview_height = allocation->height;
1379 debug_print("summaryview size: %d x %d\n",
1380 prefs_common.summaryview_width,
1381 prefs_common.summaryview_height);
1382 debug_print("folderview size: %d x %d\n",
1383 prefs_common.folderview_width,
1384 prefs_common.folderview_height);
1385 debug_print("messageview size: %d x %d\n",
1386 prefs_common.msgview_width,
1387 prefs_common.msgview_height);
1390 void main_window_get_position(MainWindow *mainwin)
1395 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1397 prefs_common.mainview_x = x;
1398 prefs_common.mainview_y = y;
1399 prefs_common.mainwin_x = x;
1400 prefs_common.mainwin_y = y;
1402 debug_print("main window position: %d, %d\n", x, y);
1404 window = main_window_get_folder_window(mainwin);
1406 gtkut_widget_get_uposition(window, &x, &y);
1407 prefs_common.folderwin_x = x;
1408 prefs_common.folderwin_y = y;
1409 debug_print("folder window position: %d, %d\n", x, y);
1411 window = main_window_get_message_window(mainwin);
1413 gtkut_widget_get_uposition(window, &x, &y);
1414 prefs_common.main_msgwin_x = x;
1415 prefs_common.main_msgwin_y = y;
1416 debug_print("message window position: %d, %d\n", x, y);
1420 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1426 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1427 folder = FOLDER(list->data);
1428 if (folder && folder->trash && folder->trash->total_msgs > 0)
1432 if (!has_trash) return;
1435 if (alertpanel(_("Empty trash"),
1436 _("Empty all messages in trash?"),
1437 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1439 manage_window_focus_in(mainwin->window, NULL, NULL);
1442 procmsg_empty_trash();
1444 if (mainwin->summaryview->folder_item &&
1445 mainwin->summaryview->folder_item->stype == F_TRASH)
1446 gtk_widget_grab_focus(mainwin->folderview->ctree);
1449 void main_window_add_mailbox(MainWindow *mainwin)
1454 path = input_dialog(_("Add mailbox"),
1455 _("Input the location of mailbox.\n"
1456 "If the existing mailbox is specified, it will be\n"
1457 "scanned automatically."),
1460 if (folder_find_from_path(path)) {
1461 alertpanel_error(_("The mailbox `%s' already exists."), path);
1465 folder = folder_new(folder_get_class_from_string("mh"),
1466 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1470 if (folder->klass->create_tree(folder) < 0) {
1471 alertpanel_error(_("Creation of the mailbox failed.\n"
1472 "Maybe some files already exist, or you don't have the permission to write there."));
1473 folder_destroy(folder);
1478 folder_set_ui_func(folder, scan_tree_func, mainwin);
1479 folder_scan_tree(folder);
1480 folder_set_ui_func(folder, NULL, NULL);
1482 folderview_set(mainwin->folderview);
1485 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1487 SensitiveCond state = 0;
1488 SummarySelection selection;
1489 FolderItem *item = mainwin->summaryview->folder_item;
1490 GList *account_list = account_get_list();
1492 selection = summary_get_selection_type(mainwin->summaryview);
1494 if (mainwin->lock_count == 0)
1495 state |= M_UNLOCKED;
1496 if (selection != SUMMARY_NONE)
1497 state |= M_MSG_EXIST;
1498 if (item && item->path && item->parent && !item->no_select) {
1500 /* if (item->folder->type != F_NEWS) */
1501 state |= M_ALLOW_DELETE;
1503 if (prefs_common.immediate_exec == 0
1504 && mainwin->lock_count == 0)
1505 state |= M_DELAY_EXEC;
1507 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1508 || selection != SUMMARY_NONE)
1509 state |= M_HIDE_READ_MSG;
1511 if (mainwin->summaryview->threaded)
1512 state |= M_THREADED;
1514 state |= M_UNTHREADED;
1515 if (selection == SUMMARY_SELECTED_SINGLE ||
1516 selection == SUMMARY_SELECTED_MULTIPLE)
1517 state |= M_TARGET_EXIST;
1518 if (selection == SUMMARY_SELECTED_SINGLE)
1519 state |= M_SINGLE_TARGET_EXIST;
1520 if (mainwin->summaryview->folder_item &&
1521 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1524 state |= M_NOT_NEWS;
1525 if (selection == SUMMARY_SELECTED_SINGLE &&
1527 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1528 item->stype == F_QUEUE)))
1529 state |= M_ALLOW_REEDIT;
1531 state |= M_HAVE_ACCOUNT;
1533 for ( ; account_list != NULL; account_list = account_list->next) {
1534 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1535 state |= M_HAVE_NEWS_ACCOUNT;
1540 if (inc_is_active())
1541 state |= M_INC_ACTIVE;
1548 void main_window_set_menu_sensitive(MainWindow *mainwin)
1550 GtkItemFactory *ifactory = mainwin->menu_factory;
1551 SensitiveCond state;
1553 GtkWidget *menuitem;
1554 SummaryView *summaryview;
1558 static const struct {
1562 {"/File/Folder" , M_UNLOCKED},
1563 {"/File/Add mailbox" , M_UNLOCKED},
1565 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1566 {"/File/Export to mbox file..." , M_UNLOCKED},
1567 {"/File/Empty trash" , M_UNLOCKED},
1568 {"/File/Work offline" , M_UNLOCKED},
1570 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1571 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1572 /* {"/File/Close" , M_UNLOCKED}, */
1573 {"/File/Exit" , M_UNLOCKED},
1575 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1577 {"/View/Sort" , M_EXEC},
1578 {"/View/Thread view" , M_EXEC},
1579 {"/View/Expand all threads" , M_MSG_EXIST},
1580 {"/View/Collapse all threads" , M_MSG_EXIST},
1581 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1582 {"/View/Go to/Prev message" , M_MSG_EXIST},
1583 {"/View/Go to/Next message" , M_MSG_EXIST},
1584 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1585 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1586 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1587 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1588 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1589 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1590 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1591 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1592 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1594 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1595 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1596 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1597 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1598 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1599 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1600 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1601 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1602 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1603 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1604 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1605 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1606 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1607 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1608 {"/Message/Mark" , M_TARGET_EXIST},
1610 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1611 {"/Tools/Harvest addresses" , M_UNLOCKED},
1612 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1613 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1614 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1615 {"/Tools/Execute" , M_DELAY_EXEC},
1616 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1618 {"/Configuration", M_UNLOCKED},
1623 state = main_window_get_current_state(mainwin);
1625 for (i = 0; entry[i].entry != NULL; i++) {
1626 sensitive = ((entry[i].cond & state) == entry[i].cond);
1627 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1630 main_window_menu_callback_block(mainwin);
1632 #define SET_CHECK_MENU_ACTIVE(path, active) \
1634 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1635 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1638 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1639 messageview_is_visible(mainwin->messageview));
1641 summaryview = mainwin->summaryview;
1642 menu_path = "/View/Sort/Don't sort";
1644 switch (summaryview->sort_key) {
1645 case SORT_BY_NUMBER:
1646 menu_path = "/View/Sort/by number"; break;
1648 menu_path = "/View/Sort/by size"; break;
1650 menu_path = "/View/Sort/by date"; break;
1652 menu_path = "/View/Sort/by from"; break;
1654 menu_path = "/View/Sort/by recipient"; break;
1655 case SORT_BY_SUBJECT:
1656 menu_path = "/View/Sort/by subject"; break;
1658 menu_path = "/View/Sort/by color label"; break;
1660 menu_path = "/View/Sort/by mark"; break;
1661 case SORT_BY_STATUS:
1662 menu_path = "/View/Sort/by status"; break;
1664 menu_path = "/View/Sort/by attachment"; break;
1666 menu_path = "/View/Sort/by score"; break;
1667 case SORT_BY_LOCKED:
1668 menu_path = "/View/Sort/by locked"; break;
1671 menu_path = "/View/Sort/Don't sort"; break;
1673 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1675 if (summaryview->sort_type == SORT_ASCENDING) {
1676 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1678 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1681 if (summaryview->sort_key != SORT_BY_NONE) {
1682 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1683 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1685 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1686 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1689 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1690 mainwin->messageview->mimeview->textview->show_all_headers);
1691 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1693 #undef SET_CHECK_MENU_ACTIVE
1695 main_window_menu_callback_unblock(mainwin);
1698 void main_window_popup(MainWindow *mainwin)
1700 gtkut_window_popup(mainwin->window);
1702 switch (mainwin->type) {
1703 case SEPARATE_FOLDER:
1704 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1706 case SEPARATE_MESSAGE:
1707 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1710 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1711 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1718 void main_window_show(MainWindow *mainwin)
1720 gtk_widget_show(mainwin->window);
1721 gtk_widget_show(mainwin->vbox_body);
1723 gtk_widget_set_uposition(mainwin->window,
1724 prefs_common.mainwin_x,
1725 prefs_common.mainwin_y);
1727 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1728 prefs_common.folderview_width,
1729 prefs_common.folderview_height);
1730 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1731 prefs_common.summaryview_width,
1732 prefs_common.summaryview_height);
1733 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1734 prefs_common.msgview_width,
1735 prefs_common.msgview_height);
1737 if (mainwin->type & SEPARATE_FOLDER) {
1738 GtkWidget *folderwin;
1740 folderwin = main_window_get_folder_window(mainwin);
1741 gtk_widget_show(folderwin);
1742 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1743 prefs_common.folderwin_y);
1746 if (mainwin->type & SEPARATE_MESSAGE) {
1747 GtkWidget *messagewin;
1749 messagewin = main_window_get_message_window(mainwin);
1750 gtk_widget_show(messagewin);
1751 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1752 prefs_common.main_msgwin_y);
1756 void main_window_hide(MainWindow *mainwin)
1758 main_window_get_size(mainwin);
1759 main_window_get_position(mainwin);
1761 gtk_widget_hide(mainwin->window);
1762 gtk_widget_hide(mainwin->vbox_body);
1764 if (mainwin->type & SEPARATE_FOLDER) {
1765 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1768 if (mainwin->type & SEPARATE_MESSAGE) {
1769 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1773 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1775 GtkWidget *folderwin = NULL;
1776 GtkWidget *messagewin = NULL;
1779 GtkWidget *vbox_body = mainwin->vbox_body;
1780 GtkItemFactory *ifactory = mainwin->menu_factory;
1781 GtkWidget *menuitem;
1782 GtkItemFactory *msgview_ifactory;
1784 debug_print("Setting widgets... ");
1786 /* create separated window(s) if needed */
1787 if (type & SEPARATE_FOLDER) {
1788 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1789 gtk_window_set_title(GTK_WINDOW(folderwin),
1790 _("Sylpheed - Folder View"));
1791 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1792 "folder_view", "Sylpheed");
1793 gtk_window_set_policy(GTK_WINDOW(folderwin),
1795 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1796 prefs_common.folderwin_y);
1797 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1799 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1800 GTK_SIGNAL_FUNC(folder_window_close_cb),
1802 gtk_container_add(GTK_CONTAINER(folderwin),
1803 GTK_WIDGET_PTR(mainwin->folderview));
1804 gtk_widget_realize(folderwin);
1805 if (prefs_common.folderview_visible)
1806 gtk_widget_show(folderwin);
1808 if (type & SEPARATE_MESSAGE) {
1809 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1810 gtk_window_set_title(GTK_WINDOW(messagewin),
1811 _("Sylpheed - Message View"));
1812 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1813 "message_view", "Sylpheed");
1814 gtk_window_set_policy(GTK_WINDOW(messagewin),
1816 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1817 prefs_common.main_msgwin_y);
1818 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1820 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1821 GTK_SIGNAL_FUNC(message_window_close_cb),
1823 if (messageview_is_visible(mainwin->messageview))
1824 gtk_widget_show(messagewin);
1827 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1828 prefs_common.folderview_width,
1829 prefs_common.folderview_height);
1830 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1831 prefs_common.summaryview_width,
1832 prefs_common.summaryview_height);
1833 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1834 prefs_common.msgview_width,
1835 prefs_common.msgview_height);
1839 hpaned = gtk_hpaned_new();
1840 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1841 gtk_paned_add1(GTK_PANED(hpaned),
1842 GTK_WIDGET_PTR(mainwin->folderview));
1843 gtk_widget_show(hpaned);
1844 gtk_widget_queue_resize(hpaned);
1846 vpaned = gtk_vpaned_new();
1847 if (messageview_is_visible(mainwin->messageview)) {
1848 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1849 gtk_paned_add1(GTK_PANED(vpaned),
1850 GTK_WIDGET_PTR(mainwin->summaryview));
1852 gtk_paned_add2(GTK_PANED(hpaned),
1853 GTK_WIDGET_PTR(mainwin->summaryview));
1854 gtk_widget_ref(vpaned);
1856 gtk_paned_add2(GTK_PANED(vpaned),
1857 GTK_WIDGET_PTR(mainwin->messageview));
1858 gtk_widget_show(vpaned);
1859 gtk_widget_queue_resize(vpaned);
1861 mainwin->win.sep_none.hpaned = hpaned;
1862 mainwin->win.sep_none.vpaned = vpaned;
1864 /* remove headerview if not in prefs */
1865 headerview_set_visibility(mainwin->messageview->headerview,
1866 prefs_common.display_header_pane);
1868 case SEPARATE_FOLDER:
1869 vpaned = gtk_vpaned_new();
1870 if (messageview_is_visible(mainwin->messageview)) {
1871 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1873 gtk_paned_add1(GTK_PANED(vpaned),
1874 GTK_WIDGET_PTR(mainwin->summaryview));
1876 gtk_box_pack_start(GTK_BOX(vbox_body),
1877 GTK_WIDGET_PTR(mainwin->summaryview),
1879 gtk_widget_ref(vpaned);
1881 gtk_paned_add2(GTK_PANED(vpaned),
1882 GTK_WIDGET_PTR(mainwin->messageview));
1883 gtk_widget_show(vpaned);
1884 gtk_widget_queue_resize(vpaned);
1886 mainwin->win.sep_folder.folderwin = folderwin;
1887 mainwin->win.sep_folder.vpaned = vpaned;
1889 /* remove headerview if not in prefs */
1890 headerview_set_visibility(mainwin->messageview->headerview,
1891 prefs_common.display_header_pane);
1894 case SEPARATE_MESSAGE:
1895 hpaned = gtk_hpaned_new();
1896 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1897 gtk_paned_add1(GTK_PANED(hpaned),
1898 GTK_WIDGET_PTR(mainwin->folderview));
1899 gtk_paned_add2(GTK_PANED(hpaned),
1900 GTK_WIDGET_PTR(mainwin->summaryview));
1901 gtk_widget_show(hpaned);
1902 gtk_widget_queue_resize(hpaned);
1903 messageview_add_toolbar(mainwin->messageview, messagewin);
1904 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1905 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1907 mainwin->win.sep_message.messagewin = messagewin;
1908 mainwin->win.sep_message.hpaned = hpaned;
1910 gtk_widget_realize(messagewin);
1911 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1912 gtk_widget_show_all(messagewin);
1913 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1914 mainwin->messageview->handlebox,
1915 prefs_common.toolbar_style);
1919 messageview_add_toolbar(mainwin->messageview, messagewin);
1920 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1921 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1923 gtk_box_pack_start(GTK_BOX(vbox_body),
1924 GTK_WIDGET_PTR(mainwin->summaryview),
1927 mainwin->win.sep_both.folderwin = folderwin;
1928 mainwin->win.sep_both.messagewin = messagewin;
1930 gtk_widget_realize(messagewin);
1931 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1932 gtk_widget_show_all(messagewin);
1933 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1934 mainwin->messageview->handlebox,
1935 prefs_common.toolbar_style);
1940 gtk_widget_set_uposition(mainwin->window,
1941 prefs_common.mainwin_x,
1942 prefs_common.mainwin_y);
1944 gtk_widget_queue_resize(vbox_body);
1945 gtk_widget_queue_resize(mainwin->vbox);
1946 gtk_widget_queue_resize(mainwin->window);
1947 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1948 * and mimeview icon list/ctree lose track of their visibility states */
1949 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1950 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1951 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
1952 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
1953 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
1954 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
1956 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
1958 /* rehide quick search if necessary */
1959 if (!prefs_common.show_searchbar)
1960 gtk_widget_hide(mainwin->summaryview->hbox_search);
1962 mainwin->type = type;
1965 /* toggle menu state */
1966 menuitem = gtk_item_factory_get_item
1967 (ifactory, "/View/Show or hide/Folder tree");
1968 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1969 (type & SEPARATE_FOLDER) == 0 ? TRUE :
1970 prefs_common.folderview_visible);
1971 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
1972 menuitem = gtk_item_factory_get_item
1973 (ifactory, "/View/Show or hide/Message view");
1974 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1975 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
1976 prefs_common.msgview_visible);
1978 menuitem = gtk_item_factory_get_item
1979 (ifactory, "/View/Separate folder tree");
1980 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1981 ((type & SEPARATE_FOLDER) != 0));
1982 menuitem = gtk_item_factory_get_item
1983 (ifactory, "/View/Separate message view");
1984 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1985 ((type & SEPARATE_MESSAGE) != 0));
1989 (GTK_OBJECT(folderwin), "size_allocate",
1990 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
1995 (GTK_OBJECT(messagewin), "size_allocate",
1996 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
2000 debug_print("done.\n");
2003 void main_window_destroy_all(void)
2005 while (mainwin_list != NULL) {
2006 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2008 /* free toolbar stuff */
2009 toolbar_clear_list(TOOLBAR_MAIN);
2010 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2011 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2013 g_free(mainwin->toolbar);
2016 mainwin_list = g_list_remove(mainwin_list, mainwin);
2018 g_list_free(mainwin_list);
2022 static void toolbar_account_button_pressed(GtkWidget *widget,
2023 GdkEventButton *event,
2026 MainWindow *mainwin = (MainWindow *)data;
2029 if (event->button != 3) return;
2031 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2032 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2035 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2036 menu_button_position, widget,
2037 event->button, event->time);
2041 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2044 MainWindow *mainwin = (MainWindow *)data;
2048 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2049 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2052 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2053 menu_button_position, widget,
2054 event->button, event->time);
2057 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2059 MainWindow *mainwin = (MainWindow *)data;
2062 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2063 if (!button) return;
2064 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2065 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2066 manage_window_focus_in(mainwin->window, NULL, NULL);
2069 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2072 MainWindow *mainwin = (MainWindow *)data;
2074 if (mainwin->lock_count == 0)
2075 app_exit_cb(data, 0, widget);
2080 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2083 MainWindow *mainwin = (MainWindow *)data;
2084 GtkWidget *menuitem;
2086 menuitem = gtk_item_factory_get_item
2087 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2088 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2093 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2096 MainWindow *mainwin = (MainWindow *)data;
2097 GtkWidget *menuitem;
2099 menuitem = gtk_item_factory_get_item
2100 (mainwin->menu_factory, "/View/Show or hide/Message view");
2101 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2106 static void main_window_size_allocate_cb(GtkWidget *widget,
2107 GtkAllocation *allocation,
2110 MainWindow *mainwin = (MainWindow *)data;
2112 main_window_get_size(mainwin);
2115 static void folder_window_size_allocate_cb(GtkWidget *widget,
2116 GtkAllocation *allocation,
2119 MainWindow *mainwin = (MainWindow *)data;
2121 main_window_get_size(mainwin);
2124 static void message_window_size_allocate_cb(GtkWidget *widget,
2125 GtkAllocation *allocation,
2128 MainWindow *mainwin = (MainWindow *)data;
2130 main_window_get_size(mainwin);
2133 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2136 main_window_add_mailbox(mainwin);
2139 static void update_folderview_cb(MainWindow *mainwin, guint action,
2142 summary_show(mainwin->summaryview, NULL);
2143 folderview_check_new_all();
2146 static void new_folder_cb(MainWindow *mainwin, guint action,
2149 folderview_new_folder(mainwin->folderview);
2152 static void rename_folder_cb(MainWindow *mainwin, guint action,
2155 folderview_rename_folder(mainwin->folderview);
2158 static void delete_folder_cb(MainWindow *mainwin, guint action,
2161 folderview_delete_folder(mainwin->folderview);
2164 static void import_mbox_cb(MainWindow *mainwin, guint action,
2167 import_mbox(mainwin->summaryview->folder_item);
2170 static void export_mbox_cb(MainWindow *mainwin, guint action,
2173 export_mbox(mainwin->summaryview->folder_item);
2176 static void empty_trash_cb(MainWindow *mainwin, guint action,
2179 main_window_empty_trash(mainwin, TRUE);
2182 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2184 summary_save_as(mainwin->summaryview);
2187 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2189 summary_print(mainwin->summaryview);
2192 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2194 if (prefs_common.confirm_on_exit) {
2195 if (alertpanel(_("Exit"), _("Exit this program?"),
2196 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2198 manage_window_focus_in(mainwin->window, NULL, NULL);
2201 app_will_exit(widget, mainwin);
2204 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2207 summary_search(mainwin->summaryview);
2209 message_search(mainwin->messageview);
2212 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2217 active = GTK_CHECK_MENU_ITEM(widget)->active;
2219 switch (mainwin->type) {
2221 case SEPARATE_MESSAGE:
2224 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2226 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2229 case SEPARATE_FOLDER:
2230 debug_print("separate folder\n");
2232 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2234 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2238 gtk_widget_show(mainwin->win.sep_both.folderwin);
2240 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2244 prefs_common.folderview_visible = active;
2247 static void toggle_message_cb(MainWindow *mainwin, guint action,
2252 active = GTK_CHECK_MENU_ITEM(widget)->active;
2254 if (active != messageview_is_visible(mainwin->messageview))
2255 summary_toggle_view(mainwin->summaryview);
2258 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2261 toolbar_toggle(action, mainwin);
2264 void main_window_reply_cb(MainWindow *mainwin, guint action,
2267 MessageView *msgview = (MessageView*)mainwin->messageview;
2268 GSList *msginfo_list = NULL;
2271 g_return_if_fail(msgview != NULL);
2273 msginfo_list = summary_get_selection(mainwin->summaryview);
2274 g_return_if_fail(msginfo_list != NULL);
2276 body = messageview_get_selection(msgview);
2277 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2279 g_slist_free(msginfo_list);
2283 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2286 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2287 gtk_widget_show(mainwin->hbox_stat);
2288 prefs_common.show_statusbar = TRUE;
2290 gtk_widget_hide(mainwin->hbox_stat);
2291 prefs_common.show_statusbar = FALSE;
2295 static void separate_widget_cb(MainWindow *mainwin, guint action,
2300 if (GTK_CHECK_MENU_ITEM(widget)->active)
2301 type = mainwin->type | action;
2303 type = mainwin->type & ~action;
2305 main_window_separation_change(mainwin, type);
2307 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2308 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2311 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2314 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2316 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2319 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2321 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2324 static void online_switch_clicked (GtkButton *btn, gpointer data)
2326 MainWindow *mainwin;
2327 GtkItemFactory *ifactory;
2328 GtkCheckMenuItem *menuitem;
2330 mainwin = (MainWindow *) data;
2332 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2333 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2335 g_return_if_fail(mainwin != NULL);
2336 g_return_if_fail(menuitem != NULL);
2338 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2340 gtk_widget_hide (mainwin->online_switch);
2341 gtk_widget_show (mainwin->offline_switch);
2342 menuitem->active = TRUE;
2343 prefs_common.work_offline = TRUE;
2344 inc_autocheck_timer_remove();
2347 gtk_widget_hide (mainwin->offline_switch);
2348 gtk_widget_show (mainwin->online_switch);
2349 menuitem->active = FALSE;
2350 prefs_common.work_offline = FALSE;
2351 inc_autocheck_timer_set();
2355 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2358 addressbook_open(NULL);
2361 static void log_window_show_cb(MainWindow *mainwin, guint action,
2364 log_window_show(mainwin->logwin);
2367 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2372 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2374 summary_move_to(mainwin->summaryview);
2377 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2379 summary_copy_to(mainwin->summaryview);
2382 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2384 summary_delete(mainwin->summaryview);
2387 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2389 summary_cancel(mainwin->summaryview);
2392 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2394 summary_open_msg(mainwin->summaryview);
2397 static void view_source_cb(MainWindow *mainwin, guint action,
2400 summary_view_source(mainwin->summaryview);
2403 static void show_all_header_cb(MainWindow *mainwin, guint action,
2406 if (mainwin->menu_lock_count) return;
2407 summary_display_msg_selected(mainwin->summaryview,
2408 GTK_CHECK_MENU_ITEM(widget)->active);
2411 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2413 summary_reedit(mainwin->summaryview);
2416 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2418 summary_mark(mainwin->summaryview);
2421 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2423 summary_unmark(mainwin->summaryview);
2426 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2429 summary_mark_as_unread(mainwin->summaryview);
2432 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2435 summary_mark_as_read(mainwin->summaryview);
2438 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2441 summary_mark_all_read(mainwin->summaryview);
2444 static void add_address_cb(MainWindow *mainwin, guint action,
2447 summary_add_address(mainwin->summaryview);
2450 static void set_charset_cb(MainWindow *mainwin, guint action,
2455 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2456 str = conv_get_charset_str((CharSet)action);
2457 g_free(prefs_common.force_charset);
2458 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2460 summary_redisplay_msg(mainwin->summaryview);
2462 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2466 static void hide_read_messages (MainWindow *mainwin, guint action,
2469 if (!mainwin->summaryview->folder_item
2470 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2472 summary_toggle_show_read_messages(mainwin->summaryview);
2475 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2477 if (mainwin->menu_lock_count) return;
2478 if (!mainwin->summaryview->folder_item) return;
2480 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2481 summary_thread_build(mainwin->summaryview);
2482 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2484 summary_unthread(mainwin->summaryview);
2485 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2489 static void expand_threads_cb(MainWindow *mainwin, guint action,
2492 summary_expand_threads(mainwin->summaryview);
2495 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2498 summary_collapse_threads(mainwin->summaryview);
2501 static void set_display_item_cb(MainWindow *mainwin, guint action,
2504 prefs_summary_column_open();
2507 static void sort_summary_cb(MainWindow *mainwin, guint action,
2510 FolderItem *item = mainwin->summaryview->folder_item;
2511 GtkWidget *menuitem;
2513 if (mainwin->menu_lock_count) return;
2515 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2516 menuitem = gtk_item_factory_get_item
2517 (mainwin->menu_factory, "/View/Sort/Ascending");
2518 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2519 GTK_CHECK_MENU_ITEM(menuitem)->active
2520 ? SORT_ASCENDING : SORT_DESCENDING);
2524 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2527 FolderItem *item = mainwin->summaryview->folder_item;
2529 if (mainwin->menu_lock_count) return;
2531 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2532 summary_sort(mainwin->summaryview,
2533 item->sort_key, (FolderSortType)action);
2536 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2539 summary_attract_by_subject(mainwin->summaryview);
2542 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2545 summary_delete_duplicated(mainwin->summaryview);
2548 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2550 summary_filter(mainwin->summaryview);
2553 static void execute_summary_cb(MainWindow *mainwin, guint action,
2556 summary_execute(mainwin->summaryview);
2559 static void update_summary_cb(MainWindow *mainwin, guint action,
2563 FolderView *folderview = mainwin->folderview;
2565 if (!mainwin->summaryview->folder_item) return;
2566 if (!folderview->opened) return;
2568 folder_update_op_count();
2570 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2571 folderview->opened);
2574 folder_item_scan(fitem);
2575 summary_show(mainwin->summaryview, fitem);
2578 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2580 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2583 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2585 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2588 static void prev_unread_cb(MainWindow *mainwin, guint action,
2591 summary_select_prev_unread(mainwin->summaryview);
2594 static void next_unread_cb(MainWindow *mainwin, guint action,
2597 summary_select_next_unread(mainwin->summaryview);
2600 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2602 summary_select_prev_new(mainwin->summaryview);
2605 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2607 summary_select_next_new(mainwin->summaryview);
2610 static void prev_marked_cb(MainWindow *mainwin, guint action,
2613 summary_select_prev_marked(mainwin->summaryview);
2616 static void next_marked_cb(MainWindow *mainwin, guint action,
2619 summary_select_next_marked(mainwin->summaryview);
2622 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2625 summary_select_prev_labeled(mainwin->summaryview);
2628 static void next_labeled_cb(MainWindow *mainwin, guint action,
2631 summary_select_next_labeled(mainwin->summaryview);
2634 static void goto_folder_cb(MainWindow *mainwin, guint action,
2637 FolderItem *to_folder;
2639 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2642 folderview_select(mainwin->folderview, to_folder);
2645 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2647 messageview_copy_clipboard(mainwin->messageview);
2650 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2652 MessageView *msgview = mainwin->messageview;
2654 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2655 summary_select_all(mainwin->summaryview);
2656 else if (messageview_is_visible(msgview) &&
2657 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2658 messageview_select_all(mainwin->messageview);
2661 static void select_thread_cb(MainWindow *mainwin, guint action,
2664 summary_select_thread(mainwin->summaryview);
2667 static void create_filter_cb(MainWindow *mainwin, guint action,
2670 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2673 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2676 prefs_common_open();
2679 static void prefs_processing_open_cb(MainWindow *mainwin, guint action,
2682 prefs_filtering_open(&global_processing, NULL, NULL);
2685 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2688 prefs_filtering_open(&filtering_rules, NULL, NULL);
2691 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2694 prefs_template_open();
2697 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2700 prefs_actions_open(mainwin);
2703 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2706 ssl_manager_open(mainwin);
2709 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2713 new_account_cb(mainwin, 0, widget);
2715 account_open(cur_account);
2719 static void new_account_cb(MainWindow *mainwin, guint action,
2722 account_edit_open();
2723 if (!compose_get_compose_list()) account_add();
2726 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2728 cur_account = (PrefsAccount *)data;
2729 main_window_reflect_prefs_all();
2732 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2737 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2739 pluginwindow_create();
2742 static void manual_open_cb(MainWindow *mainwin, guint action,
2745 manual_open((ManualType)action);
2748 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2750 MainWindow *mainwin = (MainWindow *)data;
2754 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2755 LOCAL_FOLDER(folder)->rootpath,
2759 str = g_strdup_printf(_("Scanning folder %s ..."),
2760 LOCAL_FOLDER(folder)->rootpath);
2762 STATUSBAR_PUSH(mainwin, str);
2763 STATUSBAR_POP(mainwin);
2767 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2770 SummaryView *summary;
2772 g_return_val_if_fail(data, FALSE);
2773 summary = ((MainWindow *)data)->summaryview;
2774 g_return_val_if_fail(summary, FALSE);
2776 if (GTK_CLIST(summary->ctree)->selection &&
2777 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2780 if (summary->selected != summary->displayed)
2781 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2785 #define BREAK_ON_MODIFIER_KEY() \
2786 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2788 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2791 MainWindow *mainwin = (MainWindow*) data;
2793 if (!mainwin || !event) return;
2795 switch (event->keyval) {
2796 case GDK_Q: /* Quit */
2797 BREAK_ON_MODIFIER_KEY();
2799 app_exit_cb(mainwin, 0, NULL);
2802 if (mainwin->folderview && mainwin->summaryview
2803 && !mainwin->summaryview->displayed) {
2804 summary_lock(mainwin->summaryview);
2805 folderview_select_next_unread(mainwin->folderview);
2806 summary_unlock(mainwin->summaryview);
2814 #undef BREAK_ON_MODIFIER_KEY
2817 * Harvest addresses for selected folder.
2819 static void addr_harvest_cb( MainWindow *mainwin,
2823 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2827 * Harvest addresses for selected messages in summary view.
2829 static void addr_harvest_msg_cb( MainWindow *mainwin,
2833 summary_harvest_address( mainwin->summaryview );
2837 *\brief get a MainWindow
2839 *\return MainWindow * The first mainwindow in the mainwin_list
2841 MainWindow *mainwindow_get_mainwindow(void)
2843 if (mainwin_list && mainwin_list->data)
2844 return (MainWindow *)(mainwin_list->data);
2849 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2851 ProgressData *data = (ProgressData *) source;
2852 MainWindow *mainwin = (MainWindow *) userdata;
2854 switch (data->cmd) {
2855 case PROGRESS_COMMAND_START:
2856 case PROGRESS_COMMAND_STOP:
2857 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2859 case PROGRESS_COMMAND_SET_PERCENTAGE:
2860 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2863 while (gtk_events_pending()) gtk_main_iteration ();