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>
42 #include <gtk/gtktooltips.h>
47 #include "mainwindow.h"
48 #include "folderview.h"
49 #include "foldersel.h"
50 #include "summaryview.h"
51 #include "summary_search.h"
52 #include "messageview.h"
53 #include "message_search.h"
54 #include "headerview.h"
56 #include "stock_pixmap.h"
63 #include "prefs_common.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "ssl_manager.h"
84 #include "sslcertwindow.h"
85 #include "prefs_gtk.h"
86 #include "pluginwindow.h"
88 #include "progressindicator.h"
89 #include "localfolder.h"
90 #include "filtering.h"
92 #define AC_LABEL_WIDTH 240
94 /* list of all instantiated MainWindow */
95 static GList *mainwin_list = NULL;
97 static GdkCursor *watch_cursor;
99 static void main_window_menu_callback_block (MainWindow *mainwin);
100 static void main_window_menu_callback_unblock (MainWindow *mainwin);
102 static void main_window_show_cur_account (MainWindow *mainwin);
104 static void main_window_set_widgets (MainWindow *mainwin,
108 static void toolbar_account_button_pressed (GtkWidget *widget,
109 GdkEventButton *event,
112 static void ac_label_button_pressed (GtkWidget *widget,
113 GdkEventButton *event,
115 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
118 static gint main_window_close_cb (GtkWidget *widget,
121 static gint folder_window_close_cb (GtkWidget *widget,
124 static gint message_window_close_cb (GtkWidget *widget,
128 static void main_window_size_allocate_cb (GtkWidget *widget,
129 GtkAllocation *allocation,
131 static void folder_window_size_allocate_cb (GtkWidget *widget,
132 GtkAllocation *allocation,
134 static void message_window_size_allocate_cb (GtkWidget *widget,
135 GtkAllocation *allocation,
138 static void new_folder_cb (MainWindow *mainwin,
141 static void rename_folder_cb (MainWindow *mainwin,
144 static void delete_folder_cb (MainWindow *mainwin,
147 static void update_folderview_cb (MainWindow *mainwin,
150 static void add_mailbox_cb (MainWindow *mainwin,
153 static void import_mbox_cb (MainWindow *mainwin,
156 static void export_mbox_cb (MainWindow *mainwin,
159 static void empty_trash_cb (MainWindow *mainwin,
163 static void save_as_cb (MainWindow *mainwin,
166 static void print_cb (MainWindow *mainwin,
169 static void app_exit_cb (MainWindow *mainwin,
173 static void search_cb (MainWindow *mainwin,
177 static void toggle_folder_cb (MainWindow *mainwin,
180 static void toggle_message_cb (MainWindow *mainwin,
183 static void toggle_toolbar_cb (MainWindow *mainwin,
186 static void toggle_statusbar_cb (MainWindow *mainwin,
189 static void separate_widget_cb (MainWindow *mainwin,
193 static void addressbook_open_cb (MainWindow *mainwin,
196 static void log_window_show_cb (MainWindow *mainwin,
200 static void inc_cancel_cb (MainWindow *mainwin,
204 static void open_msg_cb (MainWindow *mainwin,
208 static void view_source_cb (MainWindow *mainwin,
212 static void show_all_header_cb (MainWindow *mainwin,
216 static void reedit_cb (MainWindow *mainwin,
220 static void move_to_cb (MainWindow *mainwin,
223 static void copy_to_cb (MainWindow *mainwin,
226 static void delete_cb (MainWindow *mainwin,
230 static void cancel_cb (MainWindow *mainwin,
234 static void mark_cb (MainWindow *mainwin,
237 static void unmark_cb (MainWindow *mainwin,
241 static void mark_as_unread_cb (MainWindow *mainwin,
244 static void mark_as_read_cb (MainWindow *mainwin,
247 static void mark_all_read_cb (MainWindow *mainwin,
250 static void add_address_cb (MainWindow *mainwin,
254 static void set_charset_cb (MainWindow *mainwin,
258 static void hide_read_messages (MainWindow *mainwin,
262 static void thread_cb (MainWindow *mainwin,
265 static void expand_threads_cb (MainWindow *mainwin,
268 static void collapse_threads_cb (MainWindow *mainwin,
272 static void set_display_item_cb (MainWindow *mainwin,
275 static void sort_summary_cb (MainWindow *mainwin,
278 static void sort_summary_type_cb (MainWindow *mainwin,
281 static void attract_by_subject_cb(MainWindow *mainwin,
285 static void delete_duplicated_cb (MainWindow *mainwin,
288 static void filter_cb (MainWindow *mainwin,
291 static void execute_summary_cb (MainWindow *mainwin,
294 static void update_summary_cb (MainWindow *mainwin,
298 static void prev_cb (MainWindow *mainwin,
301 static void next_cb (MainWindow *mainwin,
304 static void next_unread_cb (MainWindow *mainwin,
307 static void prev_unread_cb (MainWindow *mainwin,
311 static void prev_new_cb (MainWindow *mainwin,
314 static void next_new_cb (MainWindow *mainwin,
317 static void prev_marked_cb (MainWindow *mainwin,
320 static void next_marked_cb (MainWindow *mainwin,
323 static void prev_labeled_cb (MainWindow *mainwin,
326 static void next_labeled_cb (MainWindow *mainwin,
330 static void goto_folder_cb (MainWindow *mainwin,
334 static void copy_cb (MainWindow *mainwin,
337 static void allsel_cb (MainWindow *mainwin,
340 static void select_thread_cb (MainWindow *mainwin,
344 static void create_filter_cb (MainWindow *mainwin,
347 static void create_processing_cb (MainWindow *mainwin,
351 static void prefs_common_open_cb (MainWindow *mainwin,
354 static void prefs_template_open_cb (MainWindow *mainwin,
357 static void prefs_actions_open_cb (MainWindow *mainwin,
360 static void prefs_account_open_cb (MainWindow *mainwin,
364 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
368 static void prefs_post_processing_open_cb (MainWindow *mainwin,
372 static void prefs_filtering_open_cb (MainWindow *mainwin,
376 static void ssl_manager_open_cb (MainWindow *mainwin,
380 static void new_account_cb (MainWindow *mainwin,
384 static void account_menu_cb (GtkMenuItem *menuitem,
387 static void prefs_open_cb (GtkMenuItem *menuitem,
389 static void plugins_open_cb (GtkMenuItem *menuitem,
392 static void online_switch_clicked(GtkButton *btn,
395 static void manual_open_cb (MainWindow *mainwin,
399 static void scan_tree_func (Folder *folder,
403 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
405 static void addr_harvest_cb ( MainWindow *mainwin,
409 static void addr_harvest_msg_cb ( MainWindow *mainwin,
413 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
414 GdkEventFocus *focus,
416 void main_window_reply_cb (MainWindow *mainwin,
419 gboolean mainwindow_progressindicator_hook (gpointer source,
421 #define SEPARATE_ACTION 500
423 static GtkItemFactoryEntry mainwin_entries[] =
425 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
426 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
427 {N_("/_File/_Folder/Create _new folder..."),
428 NULL, new_folder_cb, 0, NULL},
429 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
430 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
431 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
432 {N_("/_File/_Folder/_Check for new messages in all folders"),
433 NULL, update_folderview_cb, 0, NULL},
434 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
435 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
436 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
437 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
438 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
439 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
440 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
441 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
442 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
443 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
444 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
445 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
446 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
448 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
449 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
450 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
451 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
452 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
453 {N_("/_Edit/_Find in current message..."),
454 "<control>F", search_cb, 0, NULL},
455 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
456 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
457 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
458 {N_("/_View/Show or hi_de/_Folder tree"),
459 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
460 {N_("/_View/Show or hi_de/_Message view"),
461 "V", toggle_message_cb, 0, "<ToggleItem>"},
462 {N_("/_View/Show or hi_de/_Toolbar"),
463 NULL, NULL, 0, "<Branch>"},
464 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
465 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
466 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
467 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
468 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
469 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
470 {N_("/_View/Show or hi_de/_Toolbar/_None"),
471 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
472 {N_("/_View/Show or hi_de/Status _bar"),
473 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
474 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
475 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
476 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
477 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
479 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
480 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
481 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
482 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
483 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
484 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
485 {N_("/_View/_Sort/by _color label"),
486 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
487 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
488 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
489 {N_("/_View/_Sort/by a_ttachment"),
490 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
491 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
492 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
493 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
494 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
495 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
496 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
497 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
498 {N_("/_View/_Sort/_Attract by subject"),
499 NULL, attract_by_subject_cb, 0, NULL},
500 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
501 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
502 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
503 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
504 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
506 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
508 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
509 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
510 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_View/_Go to/P_rev unread message"),
512 "<shift>P", prev_unread_cb, 0, NULL},
513 {N_("/_View/_Go to/N_ext unread message"),
514 "<shift>N", next_unread_cb, 0, NULL},
515 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
517 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
518 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_View/_Go to/Prev _marked message"),
520 NULL, prev_marked_cb, 0, NULL},
521 {N_("/_View/_Go to/Next m_arked message"),
522 NULL, next_marked_cb, 0, NULL},
523 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_View/_Go to/Prev _labeled message"),
525 NULL, prev_labeled_cb, 0, NULL},
526 {N_("/_View/_Go to/Next la_beled message"),
527 NULL, next_labeled_cb, 0, NULL},
528 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
530 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
532 #define CODESET_SEPARATOR \
533 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
534 #define CODESET_ACTION(action) \
535 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
537 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
538 {N_("/_View/_Code set/_Auto detect"),
539 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
540 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
542 CODESET_ACTION(C_US_ASCII)},
545 {N_("/_View/_Code set/Unicode (_UTF-8)"),
546 CODESET_ACTION(C_UTF_8)},
549 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
550 CODESET_ACTION(C_ISO_8859_1)},
551 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
552 CODESET_ACTION(C_ISO_8859_15)},
555 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
556 CODESET_ACTION(C_ISO_8859_2)},
558 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
559 CODESET_ACTION(C_ISO_8859_13)},
560 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
561 CODESET_ACTION(C_ISO_8859_4)},
563 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
564 CODESET_ACTION(C_ISO_8859_7)},
566 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
567 CODESET_ACTION(C_ISO_8859_9)},
569 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
570 CODESET_ACTION(C_ISO_8859_5)},
571 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
572 CODESET_ACTION(C_KOI8_R)},
573 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
574 CODESET_ACTION(C_WINDOWS_1251)},
577 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
578 CODESET_ACTION(C_ISO_2022_JP)},
580 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
581 CODESET_ACTION(C_ISO_2022_JP_2)},
583 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
584 CODESET_ACTION(C_EUC_JP)},
585 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
586 CODESET_ACTION(C_SHIFT_JIS)},
589 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
590 CODESET_ACTION(C_GB2312)},
591 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
592 CODESET_ACTION(C_BIG5)},
593 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
594 CODESET_ACTION(C_EUC_TW)},
595 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
596 CODESET_ACTION(C_ISO_2022_CN)},
598 {N_("/_View/_Code set/Korean (EUC-_KR)"),
599 CODESET_ACTION(C_EUC_KR)},
600 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
601 CODESET_ACTION(C_ISO_2022_KR)},
603 {N_("/_View/_Code set/Thai (TIS-620)"),
604 CODESET_ACTION(C_TIS_620)},
605 {N_("/_View/_Code set/Thai (Windows-874)"),
606 CODESET_ACTION(C_WINDOWS_874)},
609 #undef CODESET_SEPARATOR
610 #undef CODESET_ACTION
612 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
614 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
615 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
616 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
617 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
619 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
620 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
621 {N_("/_Message/Get from _all accounts"),
622 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
623 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
624 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
626 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
628 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
629 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
630 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
631 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
632 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
633 {N_("/_Message/Repl_y to/mailing _list"),
634 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
635 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
636 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
637 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
638 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
639 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
641 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
642 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
643 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
644 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
645 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
646 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
647 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
648 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
649 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
650 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
651 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
652 {N_("/_Message/_Mark/Mark as rea_d"),
653 NULL, mark_as_read_cb, 0, NULL},
654 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
656 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
657 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
658 {N_("/_Tools/Add sender to address boo_k"),
659 NULL, add_address_cb, 0, NULL},
660 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
661 {N_("/_Tools/_Harvest addresses/from _Folder..."),
662 NULL, addr_harvest_cb, 0, NULL},
663 {N_("/_Tools/_Harvest addresses/from _Messages..."),
664 NULL, addr_harvest_msg_cb, 0, NULL},
665 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
666 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
667 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
668 {N_("/_Tools/_Create filter rule/_Automatically"),
669 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
670 {N_("/_Tools/_Create filter rule/by _From"),
671 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
672 {N_("/_Tools/_Create filter rule/by _To"),
673 NULL, create_filter_cb, FILTER_BY_TO, NULL},
674 {N_("/_Tools/_Create filter rule/by _Subject"),
675 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
676 {N_("/_Tools/_Create processing rule"), NULL, NULL, 0, "<Branch>"},
677 {N_("/_Tools/_Create processing rule/_Automatically"),
678 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
679 {N_("/_Tools/_Create processing rule/by _From"),
680 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
681 {N_("/_Tools/_Create processing rule/by _To"),
682 NULL, create_processing_cb, FILTER_BY_TO, NULL},
683 {N_("/_Tools/_Create processing rule/by _Subject"),
684 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
685 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
686 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
687 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
688 {N_("/_Tools/Delete du_plicated messages"),
689 NULL, delete_duplicated_cb, 0, NULL},
690 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
691 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
693 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
694 {N_("/_Tools/SSL certi_ficates..."),
695 NULL, ssl_manager_open_cb, 0, NULL},
697 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
698 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
700 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
701 {N_("/_Configuration/C_hange current account"),
702 NULL, NULL, 0, "<Branch>"},
703 {N_("/_Configuration/_Preferences for current account..."),
704 NULL, prefs_account_open_cb, 0, NULL},
705 {N_("/_Configuration/Create _new account..."),
706 NULL, new_account_cb, 0, NULL},
707 {N_("/_Configuration/_Edit accounts..."),
708 NULL, account_edit_open, 0, NULL},
709 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
710 {N_("/_Configuration/_Common preferences..."),
711 NULL, prefs_common_open_cb, 0, NULL},
712 {N_("/_Configuration/Pre-processing..."),
713 NULL, prefs_pre_processing_open_cb, 0, NULL},
714 {N_("/_Configuration/Post-processing..."),
715 NULL, prefs_post_processing_open_cb, 0, NULL},
716 {N_("/_Configuration/_Filtering..."),
717 NULL, prefs_filtering_open_cb, 0, NULL},
718 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
719 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
720 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
721 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
723 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
724 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
725 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
726 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
727 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
728 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
729 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
730 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
731 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
732 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
733 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
736 MainWindow *main_window_create(SeparateType type)
742 GtkWidget *handlebox;
743 GtkWidget *vbox_body;
744 GtkWidget *hbox_stat;
745 GtkWidget *statusbar;
746 GtkWidget *progressbar;
747 GtkWidget *statuslabel;
748 GtkWidget *ac_button;
750 GtkWidget *online_pixmap;
751 GtkWidget *offline_pixmap;
752 GtkWidget *online_switch;
753 GtkWidget *offline_switch;
754 GtkTooltips *offline_tip;
755 GtkTooltips *online_tip;
756 GtkTooltips *sel_ac_tip;
758 FolderView *folderview;
759 SummaryView *summaryview;
760 MessageView *messageview;
761 GdkColormap *colormap;
764 GtkItemFactory *ifactory;
768 guint n_menu_entries;
770 static GdkGeometry geometry;
772 debug_print("Creating main window...\n");
773 mainwin = g_new0(MainWindow, 1);
776 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
777 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
778 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
779 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
781 if (!geometry.min_height) {
782 geometry.min_width = 320;
783 geometry.min_height = 200;
785 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
788 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
789 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
790 MANAGE_WINDOW_SIGNALS_CONNECT(window);
791 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
792 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
794 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
795 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
797 gtk_widget_realize(window);
798 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
801 gtkut_widget_set_app_icon(window);
803 vbox = gtk_vbox_new(FALSE, 0);
804 gtk_widget_show(vbox);
805 gtk_container_add(GTK_CONTAINER(window), vbox);
808 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
809 menubar = menubar_create(window, mainwin_entries,
810 n_menu_entries, "<Main>", mainwin);
811 gtk_widget_show(menubar);
812 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
813 ifactory = gtk_item_factory_from_widget(menubar);
815 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
816 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
818 handlebox = gtk_handle_box_new();
819 gtk_widget_show(handlebox);
820 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
822 /* link window to mainwin->window to avoid gdk warnings */
823 mainwin->window = window;
826 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
830 /* vbox that contains body */
831 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
832 gtk_widget_show(vbox_body);
833 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
834 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
836 hbox_stat = gtk_hbox_new(FALSE, 2);
837 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
839 statusbar = statusbar_create();
840 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
842 progressbar = gtk_progress_bar_new();
843 gtk_widget_set_usize(progressbar, 120, 1);
844 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
846 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
847 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
848 online_tip = gtk_tooltips_new();
849 online_switch = gtk_button_new ();
850 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
851 _("You are online. Click the icon to go offline"), NULL);
852 offline_tip = gtk_tooltips_new();
853 offline_switch = gtk_button_new ();
854 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
855 _("You are offline. Click the icon to go online"),
857 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
858 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
859 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
860 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
861 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
862 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
863 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
864 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
866 statuslabel = gtk_label_new("");
867 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
869 sel_ac_tip = gtk_tooltips_new();
870 ac_button = gtk_button_new();
871 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
872 ac_button, _("Select account"), NULL);
873 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
874 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
875 gtk_widget_set_usize(ac_button, -1, 1);
876 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
877 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
878 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
880 ac_label = gtk_label_new("");
881 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
883 gtk_widget_show_all(hbox_stat);
885 gtk_widget_hide(offline_switch);
887 mainwin->folderview = folderview = folderview_create();
888 mainwin->summaryview = summaryview = summary_create();
889 mainwin->messageview = messageview = messageview_create(mainwin);
890 mainwin->logwin = log_window_create();
892 folderview->mainwin = mainwin;
893 folderview->summaryview = summaryview;
895 summaryview->mainwin = mainwin;
896 summaryview->folderview = folderview;
897 summaryview->messageview = messageview;
898 summaryview->window = window;
900 mainwin->vbox = vbox;
901 mainwin->menubar = menubar;
902 mainwin->menu_factory = ifactory;
903 mainwin->handlebox = handlebox;
904 mainwin->vbox_body = vbox_body;
905 mainwin->hbox_stat = hbox_stat;
906 mainwin->statusbar = statusbar;
907 mainwin->progressbar = progressbar;
908 mainwin->statuslabel = statuslabel;
909 mainwin->ac_button = ac_button;
910 mainwin->ac_label = ac_label;
912 mainwin->online_switch = online_switch;
913 mainwin->offline_switch = offline_switch;
914 mainwin->online_pixmap = online_pixmap;
915 mainwin->offline_pixmap = offline_pixmap;
917 /* set context IDs for status bar */
918 mainwin->mainwin_cid = gtk_statusbar_get_context_id
919 (GTK_STATUSBAR(statusbar), "Main Window");
920 mainwin->folderview_cid = gtk_statusbar_get_context_id
921 (GTK_STATUSBAR(statusbar), "Folder View");
922 mainwin->summaryview_cid = gtk_statusbar_get_context_id
923 (GTK_STATUSBAR(statusbar), "Summary View");
925 /* allocate colors for summary view and folder view */
926 summaryview->color_marked.red = summaryview->color_marked.green = 0;
927 summaryview->color_marked.blue = (guint16)65535;
929 summaryview->color_dim.red = summaryview->color_dim.green =
930 summaryview->color_dim.blue = COLOR_DIM;
932 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
933 &folderview->color_new);
935 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
936 &folderview->color_op);
938 summaryview->color_important.red = 0;
939 summaryview->color_important.green = 0;
940 summaryview->color_important.blue = (guint16)65535;
942 color[0] = summaryview->color_marked;
943 color[1] = summaryview->color_dim;
944 color[2] = folderview->color_new;
945 color[3] = folderview->color_op;
947 colormap = gdk_window_get_colormap(window->window);
948 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
949 for (i = 0; i < 4; i++) {
950 if (success[i] == FALSE)
951 g_warning("MainWindow: color allocation %d failed\n", i);
954 debug_print("done.\n");
956 messageview->visible = prefs_common.msgview_visible;
958 main_window_set_widgets(mainwin, type);
960 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
961 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
965 menuitem = gtk_item_factory_get_item
966 (ifactory, "/View/Code set/Auto detect");
967 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
969 switch (prefs_common.toolbar_style) {
971 menuitem = gtk_item_factory_get_item
972 (ifactory, "/View/Show or hide/Toolbar/None");
975 menuitem = gtk_item_factory_get_item
976 (ifactory, "/View/Show or hide/Toolbar/Icon");
979 menuitem = gtk_item_factory_get_item
980 (ifactory, "/View/Show or hide/Toolbar/Text");
983 menuitem = gtk_item_factory_get_item
984 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
986 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
988 gtk_widget_hide(mainwin->hbox_stat);
989 menuitem = gtk_item_factory_get_item
990 (ifactory, "/View/Show or hide/Status bar");
991 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
992 prefs_common.show_statusbar);
994 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
996 if (prefs_common.show_searchbar) {
997 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
998 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
999 gtk_widget_hide(summaryview->search_description);
1002 /* set account selection menu */
1003 ac_menu = gtk_item_factory_get_widget
1004 (ifactory, "/Configuration/Change current account");
1005 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1006 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1007 mainwin->ac_menu = ac_menu;
1009 toolbar_main_set_sensitive(mainwin);
1011 /* create actions menu */
1012 action_update_mainwin_menu(ifactory, mainwin);
1014 /* attach accel groups to main window */
1015 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1016 gtk_window_add_accel_group \
1018 gtk_item_factory_from_widget(menu)->accel_group)
1020 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
1022 /* connect the accelerators for equivalent
1023 menu items in different menus */
1024 menu_connect_identical_items();
1028 /* show main window */
1029 gtk_widget_show(mainwin->window);
1031 /* initialize views */
1032 folderview_init(folderview);
1033 summary_init(summaryview);
1034 messageview_init(messageview);
1035 log_window_init(mainwin->logwin);
1036 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1037 prefs_common.loglength);
1039 sslcertwindow_register_hook();
1041 mainwin->lock_count = 0;
1042 mainwin->menu_lock_count = 0;
1043 mainwin->cursor_count = 0;
1045 mainwin->progressindicator_hook =
1046 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1049 watch_cursor = gdk_cursor_new(GDK_WATCH);
1051 mainwin_list = g_list_append(mainwin_list, mainwin);
1053 /* init work_offline */
1054 if (prefs_common.work_offline)
1055 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1060 void main_window_destroy(MainWindow *mainwin)
1062 /* TODO : destroy other component */
1063 messageview_destroy(mainwin->messageview);
1066 void main_window_cursor_wait(MainWindow *mainwin)
1069 if (mainwin->cursor_count == 0)
1070 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1072 mainwin->cursor_count++;
1077 void main_window_cursor_normal(MainWindow *mainwin)
1079 if (mainwin->cursor_count)
1080 mainwin->cursor_count--;
1082 if (mainwin->cursor_count == 0)
1083 gdk_window_set_cursor(mainwin->window->window, NULL);
1088 /* lock / unlock the user-interface */
1089 void main_window_lock(MainWindow *mainwin)
1091 if (mainwin->lock_count == 0)
1092 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1094 mainwin->lock_count++;
1096 main_window_set_menu_sensitive(mainwin);
1097 toolbar_main_set_sensitive(mainwin);
1100 void main_window_unlock(MainWindow *mainwin)
1102 if (mainwin->lock_count)
1103 mainwin->lock_count--;
1105 main_window_set_menu_sensitive(mainwin);
1106 toolbar_main_set_sensitive(mainwin);
1108 if (mainwin->lock_count == 0)
1109 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1112 static void main_window_menu_callback_block(MainWindow *mainwin)
1114 mainwin->menu_lock_count++;
1117 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1119 if (mainwin->menu_lock_count)
1120 mainwin->menu_lock_count--;
1123 void main_window_reflect_prefs_all(void)
1125 main_window_reflect_prefs_all_real(FALSE);
1128 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1131 MainWindow *mainwin;
1134 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1135 mainwin = (MainWindow *)cur->data;
1137 main_window_show_cur_account(mainwin);
1138 main_window_set_menu_sensitive(mainwin);
1139 toolbar_main_set_sensitive(mainwin);
1142 if (pixmap_theme_changed) {
1143 toolbar_update(TOOLBAR_MAIN, mainwin);
1144 messageview_reflect_prefs_pixmap_theme();
1145 compose_reflect_prefs_pixmap_theme();
1146 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1147 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1149 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1150 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1151 mainwin->online_pixmap);
1152 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1153 gtk_widget_show(pixmap);
1154 mainwin->online_pixmap = pixmap;
1155 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1156 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1157 mainwin->offline_pixmap);
1158 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1159 gtk_widget_show(pixmap);
1160 mainwin->offline_pixmap = pixmap;
1163 summary_redisplay_msg(mainwin->summaryview);
1164 headerview_set_visibility(mainwin->messageview->headerview,
1165 prefs_common.display_header_pane);
1169 void main_window_set_summary_column(void)
1172 MainWindow *mainwin;
1174 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1175 mainwin = (MainWindow *)cur->data;
1176 summary_set_column_order(mainwin->summaryview);
1180 void main_window_set_account_menu(GList *account_list)
1182 GList *cur, *cur_ac, *cur_item;
1183 GtkWidget *menuitem;
1184 MainWindow *mainwin;
1185 PrefsAccount *ac_prefs;
1187 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1188 mainwin = (MainWindow *)cur->data;
1190 /* destroy all previous menu item */
1191 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1192 while (cur_item != NULL) {
1193 GList *next = cur_item->next;
1194 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1198 for (cur_ac = account_list; cur_ac != NULL;
1199 cur_ac = cur_ac->next) {
1200 ac_prefs = (PrefsAccount *)cur_ac->data;
1202 menuitem = gtk_menu_item_new_with_label
1203 (ac_prefs->account_name
1204 ? ac_prefs->account_name : _("Untitled"));
1205 gtk_widget_show(menuitem);
1206 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1207 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1208 GTK_SIGNAL_FUNC(account_menu_cb),
1214 static void main_window_show_cur_account(MainWindow *mainwin)
1219 ac_name = g_strdup(cur_account
1220 ? (cur_account->account_name
1221 ? cur_account->account_name : _("Untitled"))
1225 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1227 buf = g_strdup(PROG_VERSION);
1228 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1231 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1232 gtk_widget_queue_resize(mainwin->ac_button);
1237 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1239 switch (mainwin->type) {
1240 case SEPARATE_FOLDER:
1241 return mainwin->win.sep_folder.folderwin;
1243 return mainwin->win.sep_both.folderwin;
1249 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1251 switch (mainwin->type) {
1252 case SEPARATE_MESSAGE:
1253 return mainwin->win.sep_message.messagewin;
1255 return mainwin->win.sep_both.messagewin;
1261 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1263 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1264 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1265 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1266 GtkWidget *message_wid = mainwin->messageview->vbox;
1268 debug_print("Changing window separation type from %d to %d\n",
1269 mainwin->type, type);
1271 if (mainwin->type == type) return;
1273 /* remove widgets from those containers */
1274 gtk_widget_ref(folder_wid);
1275 gtk_widget_ref(summary_wid);
1276 gtk_widget_ref(message_wid);
1277 gtkut_container_remove
1278 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1279 gtkut_container_remove
1280 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1281 gtkut_container_remove
1282 (GTK_CONTAINER(message_wid->parent), message_wid);
1284 /* clean containers */
1285 switch (mainwin->type) {
1287 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1289 case SEPARATE_FOLDER:
1290 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1291 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1293 case SEPARATE_MESSAGE:
1294 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1295 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1298 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1299 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1303 gtk_widget_hide(mainwin->window);
1304 main_window_set_widgets(mainwin, type);
1305 gtk_widget_show(mainwin->window);
1307 gtk_widget_unref(folder_wid);
1308 gtk_widget_unref(summary_wid);
1309 gtk_widget_unref(message_wid);
1312 void main_window_toggle_message_view(MainWindow *mainwin)
1314 SummaryView *summaryview = mainwin->summaryview;
1315 union CompositeWin *cwin = &mainwin->win;
1316 GtkWidget *vpaned = NULL;
1317 GtkWidget *container = NULL;
1318 GtkWidget *msgwin = NULL;
1320 switch (mainwin->type) {
1322 vpaned = cwin->sep_none.vpaned;
1323 container = cwin->sep_none.hpaned;
1325 case SEPARATE_FOLDER:
1326 vpaned = cwin->sep_folder.vpaned;
1327 container = mainwin->vbox_body;
1329 case SEPARATE_MESSAGE:
1330 msgwin = mainwin->win.sep_message.messagewin;
1333 msgwin = mainwin->win.sep_both.messagewin;
1338 if (GTK_WIDGET_VISIBLE(msgwin)) {
1339 gtk_widget_hide(msgwin);
1340 mainwin->messageview->visible = FALSE;
1341 summaryview->displayed = NULL;
1343 gtk_widget_show(msgwin);
1344 mainwin->messageview->visible = TRUE;
1346 } else if (vpaned->parent != NULL) {
1347 mainwin->messageview->visible = FALSE;
1348 summaryview->displayed = NULL;
1349 gtk_widget_ref(vpaned);
1350 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1351 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1352 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1353 GTK_ARROW_UP, GTK_SHADOW_OUT);
1355 mainwin->messageview->visible = TRUE;
1356 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1357 gtk_container_add(GTK_CONTAINER(container), vpaned);
1358 gtk_widget_unref(vpaned);
1359 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1360 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1363 main_window_set_menu_sensitive(mainwin);
1365 prefs_common.msgview_visible = mainwin->messageview->visible;
1367 gtk_widget_grab_focus(summaryview->ctree);
1370 void main_window_get_size(MainWindow *mainwin)
1372 GtkAllocation *allocation;
1374 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1376 if (allocation->width > 1 && allocation->height > 1) {
1377 prefs_common.summaryview_width = allocation->width;
1379 if ((mainwin->type == SEPARATE_NONE ||
1380 mainwin->type == SEPARATE_FOLDER) &&
1381 messageview_is_visible(mainwin->messageview))
1382 prefs_common.summaryview_height = allocation->height;
1384 prefs_common.mainview_width = allocation->width;
1387 allocation = &mainwin->window->allocation;
1388 if (allocation->width > 1 && allocation->height > 1) {
1389 prefs_common.mainview_height = allocation->height;
1390 prefs_common.mainwin_width = allocation->width;
1391 prefs_common.mainwin_height = allocation->height;
1394 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1395 if (allocation->width > 1 && allocation->height > 1) {
1396 prefs_common.folderview_width = allocation->width;
1397 prefs_common.folderview_height = allocation->height;
1400 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1401 if (allocation->width > 1 && allocation->height > 1) {
1402 prefs_common.msgview_width = allocation->width;
1403 prefs_common.msgview_height = allocation->height;
1406 debug_print("summaryview size: %d x %d\n",
1407 prefs_common.summaryview_width,
1408 prefs_common.summaryview_height);
1409 debug_print("folderview size: %d x %d\n",
1410 prefs_common.folderview_width,
1411 prefs_common.folderview_height);
1412 debug_print("messageview size: %d x %d\n",
1413 prefs_common.msgview_width,
1414 prefs_common.msgview_height);
1417 void main_window_get_position(MainWindow *mainwin)
1422 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1424 prefs_common.mainview_x = x;
1425 prefs_common.mainview_y = y;
1426 prefs_common.mainwin_x = x;
1427 prefs_common.mainwin_y = y;
1429 debug_print("main window position: %d, %d\n", x, y);
1431 window = main_window_get_folder_window(mainwin);
1433 gtkut_widget_get_uposition(window, &x, &y);
1434 prefs_common.folderwin_x = x;
1435 prefs_common.folderwin_y = y;
1436 debug_print("folder window position: %d, %d\n", x, y);
1438 window = main_window_get_message_window(mainwin);
1440 gtkut_widget_get_uposition(window, &x, &y);
1441 prefs_common.main_msgwin_x = x;
1442 prefs_common.main_msgwin_y = y;
1443 debug_print("message window position: %d, %d\n", x, y);
1447 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1453 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1454 folder = FOLDER(list->data);
1455 if (folder && folder->trash && folder->trash->total_msgs > 0)
1459 if (!has_trash) return;
1462 if (alertpanel(_("Empty trash"),
1463 _("Empty all messages in trash?"),
1464 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1466 manage_window_focus_in(mainwin->window, NULL, NULL);
1469 procmsg_empty_trash();
1471 if (mainwin->summaryview->folder_item &&
1472 mainwin->summaryview->folder_item->stype == F_TRASH)
1473 gtk_widget_grab_focus(mainwin->folderview->ctree);
1476 void main_window_add_mailbox(MainWindow *mainwin)
1481 path = input_dialog(_("Add mailbox"),
1482 _("Input the location of mailbox.\n"
1483 "If the existing mailbox is specified, it will be\n"
1484 "scanned automatically."),
1487 if (folder_find_from_path(path)) {
1488 alertpanel_error(_("The mailbox `%s' already exists."), path);
1492 folder = folder_new(folder_get_class_from_string("mh"),
1493 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1497 if (folder->klass->create_tree(folder) < 0) {
1498 alertpanel_error(_("Creation of the mailbox failed.\n"
1499 "Maybe some files already exist, or you don't have the permission to write there."));
1500 folder_destroy(folder);
1505 folder_set_ui_func(folder, scan_tree_func, mainwin);
1506 folder_scan_tree(folder);
1507 folder_set_ui_func(folder, NULL, NULL);
1509 folderview_set(mainwin->folderview);
1512 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1514 SensitiveCond state = 0;
1515 SummarySelection selection;
1516 FolderItem *item = mainwin->summaryview->folder_item;
1517 GList *account_list = account_get_list();
1519 selection = summary_get_selection_type(mainwin->summaryview);
1521 if (mainwin->lock_count == 0)
1522 state |= M_UNLOCKED;
1523 if (selection != SUMMARY_NONE)
1524 state |= M_MSG_EXIST;
1525 if (item && item->path && item->parent && !item->no_select) {
1527 /* if (item->folder->type != F_NEWS) */
1528 state |= M_ALLOW_DELETE;
1530 if (prefs_common.immediate_exec == 0
1531 && mainwin->lock_count == 0)
1532 state |= M_DELAY_EXEC;
1534 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1535 || selection != SUMMARY_NONE)
1536 state |= M_HIDE_READ_MSG;
1538 if (mainwin->summaryview->threaded)
1539 state |= M_THREADED;
1541 state |= M_UNTHREADED;
1542 if (selection == SUMMARY_SELECTED_SINGLE ||
1543 selection == SUMMARY_SELECTED_MULTIPLE)
1544 state |= M_TARGET_EXIST;
1545 if (selection == SUMMARY_SELECTED_SINGLE)
1546 state |= M_SINGLE_TARGET_EXIST;
1547 if (mainwin->summaryview->folder_item &&
1548 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1551 state |= M_NOT_NEWS;
1552 if (selection == SUMMARY_SELECTED_SINGLE &&
1554 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1555 item->stype == F_QUEUE)))
1556 state |= M_ALLOW_REEDIT;
1558 state |= M_HAVE_ACCOUNT;
1560 for ( ; account_list != NULL; account_list = account_list->next) {
1561 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1562 state |= M_HAVE_NEWS_ACCOUNT;
1567 if (inc_is_active())
1568 state |= M_INC_ACTIVE;
1575 void main_window_set_menu_sensitive(MainWindow *mainwin)
1577 GtkItemFactory *ifactory = mainwin->menu_factory;
1578 SensitiveCond state;
1580 GtkWidget *menuitem;
1581 SummaryView *summaryview;
1585 static const struct {
1589 {"/File/Folder" , M_UNLOCKED},
1590 {"/File/Add mailbox" , M_UNLOCKED},
1592 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1593 {"/File/Export to mbox file..." , M_UNLOCKED},
1594 {"/File/Empty trash" , M_UNLOCKED},
1595 {"/File/Work offline" , M_UNLOCKED},
1597 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1598 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1599 /* {"/File/Close" , M_UNLOCKED}, */
1600 {"/File/Exit" , M_UNLOCKED},
1602 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1604 {"/View/Sort" , M_EXEC},
1605 {"/View/Thread view" , M_EXEC},
1606 {"/View/Expand all threads" , M_MSG_EXIST},
1607 {"/View/Collapse all threads" , M_MSG_EXIST},
1608 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1609 {"/View/Go to/Prev message" , M_MSG_EXIST},
1610 {"/View/Go to/Next message" , M_MSG_EXIST},
1611 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1612 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1613 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1614 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1615 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1616 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1617 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1618 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1619 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1621 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1622 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1623 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1624 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1625 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1626 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1627 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1628 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1629 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1630 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1631 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1632 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1633 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1634 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1635 {"/Message/Mark" , M_TARGET_EXIST},
1637 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1638 {"/Tools/Harvest addresses" , M_UNLOCKED},
1639 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1640 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1641 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1642 {"/Tools/Execute" , M_DELAY_EXEC},
1643 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1645 {"/Configuration", M_UNLOCKED},
1650 state = main_window_get_current_state(mainwin);
1652 for (i = 0; entry[i].entry != NULL; i++) {
1653 sensitive = ((entry[i].cond & state) == entry[i].cond);
1654 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1657 main_window_menu_callback_block(mainwin);
1659 #define SET_CHECK_MENU_ACTIVE(path, active) \
1661 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1662 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1665 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1666 messageview_is_visible(mainwin->messageview));
1668 summaryview = mainwin->summaryview;
1669 menu_path = "/View/Sort/Don't sort";
1671 switch (summaryview->sort_key) {
1672 case SORT_BY_NUMBER:
1673 menu_path = "/View/Sort/by number"; break;
1675 menu_path = "/View/Sort/by size"; break;
1677 menu_path = "/View/Sort/by date"; break;
1679 menu_path = "/View/Sort/by from"; break;
1681 menu_path = "/View/Sort/by recipient"; break;
1682 case SORT_BY_SUBJECT:
1683 menu_path = "/View/Sort/by subject"; break;
1685 menu_path = "/View/Sort/by color label"; break;
1687 menu_path = "/View/Sort/by mark"; break;
1688 case SORT_BY_STATUS:
1689 menu_path = "/View/Sort/by status"; break;
1691 menu_path = "/View/Sort/by attachment"; break;
1693 menu_path = "/View/Sort/by score"; break;
1694 case SORT_BY_LOCKED:
1695 menu_path = "/View/Sort/by locked"; break;
1698 menu_path = "/View/Sort/Don't sort"; break;
1700 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1702 if (summaryview->sort_type == SORT_ASCENDING) {
1703 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1705 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1708 if (summaryview->sort_key != SORT_BY_NONE) {
1709 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1710 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1712 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1713 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1716 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1717 mainwin->messageview->mimeview->textview->show_all_headers);
1718 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1720 #undef SET_CHECK_MENU_ACTIVE
1722 main_window_menu_callback_unblock(mainwin);
1725 void main_window_popup(MainWindow *mainwin)
1727 gtkut_window_popup(mainwin->window);
1729 switch (mainwin->type) {
1730 case SEPARATE_FOLDER:
1731 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1733 case SEPARATE_MESSAGE:
1734 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1737 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1738 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1745 void main_window_show(MainWindow *mainwin)
1747 gtk_widget_show(mainwin->window);
1748 gtk_widget_show(mainwin->vbox_body);
1750 gtk_widget_set_uposition(mainwin->window,
1751 prefs_common.mainwin_x,
1752 prefs_common.mainwin_y);
1754 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1755 prefs_common.folderview_width,
1756 prefs_common.folderview_height);
1757 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1758 prefs_common.summaryview_width,
1759 prefs_common.summaryview_height);
1760 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1761 prefs_common.msgview_width,
1762 prefs_common.msgview_height);
1764 if (mainwin->type & SEPARATE_FOLDER) {
1765 GtkWidget *folderwin;
1767 folderwin = main_window_get_folder_window(mainwin);
1768 gtk_widget_show(folderwin);
1769 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1770 prefs_common.folderwin_y);
1773 if (mainwin->type & SEPARATE_MESSAGE) {
1774 GtkWidget *messagewin;
1776 messagewin = main_window_get_message_window(mainwin);
1777 gtk_widget_show(messagewin);
1778 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1779 prefs_common.main_msgwin_y);
1783 void main_window_hide(MainWindow *mainwin)
1785 main_window_get_size(mainwin);
1786 main_window_get_position(mainwin);
1788 gtk_widget_hide(mainwin->window);
1789 gtk_widget_hide(mainwin->vbox_body);
1791 if (mainwin->type & SEPARATE_FOLDER) {
1792 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1795 if (mainwin->type & SEPARATE_MESSAGE) {
1796 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1800 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1802 GtkWidget *folderwin = NULL;
1803 GtkWidget *messagewin = NULL;
1806 GtkWidget *vbox_body = mainwin->vbox_body;
1807 GtkItemFactory *ifactory = mainwin->menu_factory;
1808 GtkWidget *menuitem;
1809 GtkItemFactory *msgview_ifactory;
1811 debug_print("Setting widgets... ");
1813 /* create separated window(s) if needed */
1814 if (type & SEPARATE_FOLDER) {
1815 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1816 gtk_window_set_title(GTK_WINDOW(folderwin),
1817 _("Sylpheed - Folder View"));
1818 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1819 "folder_view", "Sylpheed");
1820 gtk_window_set_policy(GTK_WINDOW(folderwin),
1822 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1823 prefs_common.folderwin_y);
1824 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1826 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1827 GTK_SIGNAL_FUNC(folder_window_close_cb),
1829 gtk_container_add(GTK_CONTAINER(folderwin),
1830 GTK_WIDGET_PTR(mainwin->folderview));
1831 gtk_widget_realize(folderwin);
1832 if (prefs_common.folderview_visible)
1833 gtk_widget_show(folderwin);
1835 if (type & SEPARATE_MESSAGE) {
1836 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1837 gtk_window_set_title(GTK_WINDOW(messagewin),
1838 _("Sylpheed - Message View"));
1839 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1840 "message_view", "Sylpheed");
1841 gtk_window_set_policy(GTK_WINDOW(messagewin),
1843 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1844 prefs_common.main_msgwin_y);
1845 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1847 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1848 GTK_SIGNAL_FUNC(message_window_close_cb),
1850 if (messageview_is_visible(mainwin->messageview))
1851 gtk_widget_show(messagewin);
1854 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1855 prefs_common.folderview_width,
1856 prefs_common.folderview_height);
1857 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1858 prefs_common.summaryview_width,
1859 prefs_common.summaryview_height);
1860 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1861 prefs_common.msgview_width,
1862 prefs_common.msgview_height);
1866 hpaned = gtk_hpaned_new();
1867 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1868 gtk_paned_add1(GTK_PANED(hpaned),
1869 GTK_WIDGET_PTR(mainwin->folderview));
1870 gtk_widget_show(hpaned);
1871 gtk_widget_queue_resize(hpaned);
1873 vpaned = gtk_vpaned_new();
1874 if (messageview_is_visible(mainwin->messageview)) {
1875 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1876 gtk_paned_add1(GTK_PANED(vpaned),
1877 GTK_WIDGET_PTR(mainwin->summaryview));
1879 gtk_paned_add2(GTK_PANED(hpaned),
1880 GTK_WIDGET_PTR(mainwin->summaryview));
1881 gtk_widget_ref(vpaned);
1883 gtk_paned_add2(GTK_PANED(vpaned),
1884 GTK_WIDGET_PTR(mainwin->messageview));
1885 gtk_widget_show(vpaned);
1886 gtk_widget_queue_resize(vpaned);
1888 mainwin->win.sep_none.hpaned = hpaned;
1889 mainwin->win.sep_none.vpaned = vpaned;
1891 /* remove headerview if not in prefs */
1892 headerview_set_visibility(mainwin->messageview->headerview,
1893 prefs_common.display_header_pane);
1895 case SEPARATE_FOLDER:
1896 vpaned = gtk_vpaned_new();
1897 if (messageview_is_visible(mainwin->messageview)) {
1898 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1900 gtk_paned_add1(GTK_PANED(vpaned),
1901 GTK_WIDGET_PTR(mainwin->summaryview));
1903 gtk_box_pack_start(GTK_BOX(vbox_body),
1904 GTK_WIDGET_PTR(mainwin->summaryview),
1906 gtk_widget_ref(vpaned);
1908 gtk_paned_add2(GTK_PANED(vpaned),
1909 GTK_WIDGET_PTR(mainwin->messageview));
1910 gtk_widget_show(vpaned);
1911 gtk_widget_queue_resize(vpaned);
1913 mainwin->win.sep_folder.folderwin = folderwin;
1914 mainwin->win.sep_folder.vpaned = vpaned;
1916 /* remove headerview if not in prefs */
1917 headerview_set_visibility(mainwin->messageview->headerview,
1918 prefs_common.display_header_pane);
1921 case SEPARATE_MESSAGE:
1922 hpaned = gtk_hpaned_new();
1923 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1924 gtk_paned_add1(GTK_PANED(hpaned),
1925 GTK_WIDGET_PTR(mainwin->folderview));
1926 gtk_paned_add2(GTK_PANED(hpaned),
1927 GTK_WIDGET_PTR(mainwin->summaryview));
1928 gtk_widget_show(hpaned);
1929 gtk_widget_queue_resize(hpaned);
1930 messageview_add_toolbar(mainwin->messageview, messagewin);
1931 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1932 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1934 mainwin->win.sep_message.messagewin = messagewin;
1935 mainwin->win.sep_message.hpaned = hpaned;
1937 gtk_widget_realize(messagewin);
1938 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1939 gtk_widget_show_all(messagewin);
1940 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1941 mainwin->messageview->handlebox,
1942 prefs_common.toolbar_style);
1946 messageview_add_toolbar(mainwin->messageview, messagewin);
1947 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1948 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1950 gtk_box_pack_start(GTK_BOX(vbox_body),
1951 GTK_WIDGET_PTR(mainwin->summaryview),
1954 mainwin->win.sep_both.folderwin = folderwin;
1955 mainwin->win.sep_both.messagewin = messagewin;
1957 gtk_widget_realize(messagewin);
1958 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1959 gtk_widget_show_all(messagewin);
1960 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1961 mainwin->messageview->handlebox,
1962 prefs_common.toolbar_style);
1967 gtk_widget_set_uposition(mainwin->window,
1968 prefs_common.mainwin_x,
1969 prefs_common.mainwin_y);
1971 gtk_widget_queue_resize(vbox_body);
1972 gtk_widget_queue_resize(mainwin->vbox);
1973 gtk_widget_queue_resize(mainwin->window);
1974 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1975 * and mimeview icon list/ctree lose track of their visibility states */
1976 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1977 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1978 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
1979 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
1980 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
1981 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
1983 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
1985 /* rehide quick search if necessary */
1986 if (!prefs_common.show_searchbar)
1987 gtk_widget_hide(mainwin->summaryview->hbox_search);
1989 mainwin->type = type;
1992 /* toggle menu state */
1993 menuitem = gtk_item_factory_get_item
1994 (ifactory, "/View/Show or hide/Folder tree");
1995 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1996 (type & SEPARATE_FOLDER) == 0 ? TRUE :
1997 prefs_common.folderview_visible);
1998 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
1999 menuitem = gtk_item_factory_get_item
2000 (ifactory, "/View/Show or hide/Message view");
2001 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2002 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
2003 prefs_common.msgview_visible);
2005 menuitem = gtk_item_factory_get_item
2006 (ifactory, "/View/Separate folder tree");
2007 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2008 ((type & SEPARATE_FOLDER) != 0));
2009 menuitem = gtk_item_factory_get_item
2010 (ifactory, "/View/Separate message view");
2011 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2012 ((type & SEPARATE_MESSAGE) != 0));
2016 (GTK_OBJECT(folderwin), "size_allocate",
2017 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
2022 (GTK_OBJECT(messagewin), "size_allocate",
2023 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
2027 debug_print("done.\n");
2030 void main_window_destroy_all(void)
2032 while (mainwin_list != NULL) {
2033 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2035 /* free toolbar stuff */
2036 toolbar_clear_list(TOOLBAR_MAIN);
2037 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2038 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2040 g_free(mainwin->toolbar);
2043 mainwin_list = g_list_remove(mainwin_list, mainwin);
2045 g_list_free(mainwin_list);
2049 static void toolbar_account_button_pressed(GtkWidget *widget,
2050 GdkEventButton *event,
2053 MainWindow *mainwin = (MainWindow *)data;
2056 if (event->button != 3) return;
2058 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2059 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2062 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2063 menu_button_position, widget,
2064 event->button, event->time);
2068 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2071 MainWindow *mainwin = (MainWindow *)data;
2075 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2076 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2079 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2080 menu_button_position, widget,
2081 event->button, event->time);
2084 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2086 MainWindow *mainwin = (MainWindow *)data;
2089 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2090 if (!button) return;
2091 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2092 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2093 manage_window_focus_in(mainwin->window, NULL, NULL);
2096 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2099 MainWindow *mainwin = (MainWindow *)data;
2101 if (mainwin->lock_count == 0)
2102 app_exit_cb(data, 0, widget);
2107 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2110 MainWindow *mainwin = (MainWindow *)data;
2111 GtkWidget *menuitem;
2113 menuitem = gtk_item_factory_get_item
2114 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2115 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2120 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2123 MainWindow *mainwin = (MainWindow *)data;
2124 GtkWidget *menuitem;
2126 menuitem = gtk_item_factory_get_item
2127 (mainwin->menu_factory, "/View/Show or hide/Message view");
2128 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2133 static void main_window_size_allocate_cb(GtkWidget *widget,
2134 GtkAllocation *allocation,
2137 MainWindow *mainwin = (MainWindow *)data;
2139 main_window_get_size(mainwin);
2142 static void folder_window_size_allocate_cb(GtkWidget *widget,
2143 GtkAllocation *allocation,
2146 MainWindow *mainwin = (MainWindow *)data;
2148 main_window_get_size(mainwin);
2151 static void message_window_size_allocate_cb(GtkWidget *widget,
2152 GtkAllocation *allocation,
2155 MainWindow *mainwin = (MainWindow *)data;
2157 main_window_get_size(mainwin);
2160 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2163 main_window_add_mailbox(mainwin);
2166 static void update_folderview_cb(MainWindow *mainwin, guint action,
2169 summary_show(mainwin->summaryview, NULL);
2170 folderview_check_new_all();
2173 static void new_folder_cb(MainWindow *mainwin, guint action,
2176 folderview_new_folder(mainwin->folderview);
2179 static void rename_folder_cb(MainWindow *mainwin, guint action,
2182 folderview_rename_folder(mainwin->folderview);
2185 static void delete_folder_cb(MainWindow *mainwin, guint action,
2188 folderview_delete_folder(mainwin->folderview);
2191 static void import_mbox_cb(MainWindow *mainwin, guint action,
2194 import_mbox(mainwin->summaryview->folder_item);
2197 static void export_mbox_cb(MainWindow *mainwin, guint action,
2200 export_mbox(mainwin->summaryview->folder_item);
2203 static void empty_trash_cb(MainWindow *mainwin, guint action,
2206 main_window_empty_trash(mainwin, TRUE);
2209 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2211 summary_save_as(mainwin->summaryview);
2214 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2216 summary_print(mainwin->summaryview);
2219 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2221 if (prefs_common.confirm_on_exit) {
2222 if (alertpanel(_("Exit"), _("Exit this program?"),
2223 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2225 manage_window_focus_in(mainwin->window, NULL, NULL);
2228 app_will_exit(widget, mainwin);
2231 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2234 summary_search(mainwin->summaryview);
2236 message_search(mainwin->messageview);
2239 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2244 active = GTK_CHECK_MENU_ITEM(widget)->active;
2246 switch (mainwin->type) {
2248 case SEPARATE_MESSAGE:
2251 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2253 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2256 case SEPARATE_FOLDER:
2257 debug_print("separate folder\n");
2259 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2261 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2265 gtk_widget_show(mainwin->win.sep_both.folderwin);
2267 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2271 prefs_common.folderview_visible = active;
2274 static void toggle_message_cb(MainWindow *mainwin, guint action,
2279 active = GTK_CHECK_MENU_ITEM(widget)->active;
2281 if (active != messageview_is_visible(mainwin->messageview))
2282 summary_toggle_view(mainwin->summaryview);
2285 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2288 toolbar_toggle(action, mainwin);
2291 void main_window_reply_cb(MainWindow *mainwin, guint action,
2294 MessageView *msgview = (MessageView*)mainwin->messageview;
2295 GSList *msginfo_list = NULL;
2298 g_return_if_fail(msgview != NULL);
2300 msginfo_list = summary_get_selection(mainwin->summaryview);
2301 g_return_if_fail(msginfo_list != NULL);
2303 body = messageview_get_selection(msgview);
2304 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2306 g_slist_free(msginfo_list);
2310 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2313 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2314 gtk_widget_show(mainwin->hbox_stat);
2315 prefs_common.show_statusbar = TRUE;
2317 gtk_widget_hide(mainwin->hbox_stat);
2318 prefs_common.show_statusbar = FALSE;
2322 static void separate_widget_cb(MainWindow *mainwin, guint action,
2327 if (GTK_CHECK_MENU_ITEM(widget)->active)
2328 type = mainwin->type | action;
2330 type = mainwin->type & ~action;
2332 main_window_separation_change(mainwin, type);
2334 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2335 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2338 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2341 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2343 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2346 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2348 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2351 static void online_switch_clicked (GtkButton *btn, gpointer data)
2353 MainWindow *mainwin;
2354 GtkItemFactory *ifactory;
2355 GtkCheckMenuItem *menuitem;
2357 mainwin = (MainWindow *) data;
2359 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2360 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2362 g_return_if_fail(mainwin != NULL);
2363 g_return_if_fail(menuitem != NULL);
2365 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2367 gtk_widget_hide (mainwin->online_switch);
2368 gtk_widget_show (mainwin->offline_switch);
2369 menuitem->active = TRUE;
2370 prefs_common.work_offline = TRUE;
2371 inc_autocheck_timer_remove();
2374 gtk_widget_hide (mainwin->offline_switch);
2375 gtk_widget_show (mainwin->online_switch);
2376 menuitem->active = FALSE;
2377 prefs_common.work_offline = FALSE;
2378 inc_autocheck_timer_set();
2382 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2385 addressbook_open(NULL);
2388 static void log_window_show_cb(MainWindow *mainwin, guint action,
2391 log_window_show(mainwin->logwin);
2394 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2399 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2401 summary_move_to(mainwin->summaryview);
2404 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 summary_copy_to(mainwin->summaryview);
2409 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2411 summary_delete(mainwin->summaryview);
2414 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2416 summary_cancel(mainwin->summaryview);
2419 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2421 summary_open_msg(mainwin->summaryview);
2424 static void view_source_cb(MainWindow *mainwin, guint action,
2427 summary_view_source(mainwin->summaryview);
2430 static void show_all_header_cb(MainWindow *mainwin, guint action,
2433 if (mainwin->menu_lock_count) return;
2434 summary_display_msg_selected(mainwin->summaryview,
2435 GTK_CHECK_MENU_ITEM(widget)->active);
2438 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2440 summary_reedit(mainwin->summaryview);
2443 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2445 summary_mark(mainwin->summaryview);
2448 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2450 summary_unmark(mainwin->summaryview);
2453 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2456 summary_mark_as_unread(mainwin->summaryview);
2459 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2462 summary_mark_as_read(mainwin->summaryview);
2465 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2468 summary_mark_all_read(mainwin->summaryview);
2471 static void add_address_cb(MainWindow *mainwin, guint action,
2474 summary_add_address(mainwin->summaryview);
2477 static void set_charset_cb(MainWindow *mainwin, guint action,
2482 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2483 str = conv_get_charset_str((CharSet)action);
2484 g_free(prefs_common.force_charset);
2485 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2487 summary_redisplay_msg(mainwin->summaryview);
2489 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2493 static void hide_read_messages (MainWindow *mainwin, guint action,
2496 if (!mainwin->summaryview->folder_item
2497 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2499 summary_toggle_show_read_messages(mainwin->summaryview);
2502 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2504 if (mainwin->menu_lock_count) return;
2505 if (!mainwin->summaryview->folder_item) return;
2507 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2508 summary_thread_build(mainwin->summaryview);
2509 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2511 summary_unthread(mainwin->summaryview);
2512 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2516 static void expand_threads_cb(MainWindow *mainwin, guint action,
2519 summary_expand_threads(mainwin->summaryview);
2522 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2525 summary_collapse_threads(mainwin->summaryview);
2528 static void set_display_item_cb(MainWindow *mainwin, guint action,
2531 prefs_summary_column_open();
2534 static void sort_summary_cb(MainWindow *mainwin, guint action,
2537 FolderItem *item = mainwin->summaryview->folder_item;
2538 GtkWidget *menuitem;
2540 if (mainwin->menu_lock_count) return;
2542 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2543 menuitem = gtk_item_factory_get_item
2544 (mainwin->menu_factory, "/View/Sort/Ascending");
2545 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2546 GTK_CHECK_MENU_ITEM(menuitem)->active
2547 ? SORT_ASCENDING : SORT_DESCENDING);
2551 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2554 FolderItem *item = mainwin->summaryview->folder_item;
2556 if (mainwin->menu_lock_count) return;
2558 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2559 summary_sort(mainwin->summaryview,
2560 item->sort_key, (FolderSortType)action);
2563 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2566 summary_attract_by_subject(mainwin->summaryview);
2569 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2572 summary_delete_duplicated(mainwin->summaryview);
2575 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2577 summary_filter(mainwin->summaryview);
2580 static void execute_summary_cb(MainWindow *mainwin, guint action,
2583 summary_execute(mainwin->summaryview);
2586 static void update_summary_cb(MainWindow *mainwin, guint action,
2590 FolderView *folderview = mainwin->folderview;
2592 if (!mainwin->summaryview->folder_item) return;
2593 if (!folderview->opened) return;
2595 folder_update_op_count();
2597 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2598 folderview->opened);
2601 folder_item_scan(fitem);
2602 summary_show(mainwin->summaryview, fitem);
2605 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2607 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2610 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2615 static void prev_unread_cb(MainWindow *mainwin, guint action,
2618 summary_select_prev_unread(mainwin->summaryview);
2621 static void next_unread_cb(MainWindow *mainwin, guint action,
2624 summary_select_next_unread(mainwin->summaryview);
2627 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2629 summary_select_prev_new(mainwin->summaryview);
2632 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2634 summary_select_next_new(mainwin->summaryview);
2637 static void prev_marked_cb(MainWindow *mainwin, guint action,
2640 summary_select_prev_marked(mainwin->summaryview);
2643 static void next_marked_cb(MainWindow *mainwin, guint action,
2646 summary_select_next_marked(mainwin->summaryview);
2649 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2652 summary_select_prev_labeled(mainwin->summaryview);
2655 static void next_labeled_cb(MainWindow *mainwin, guint action,
2658 summary_select_next_labeled(mainwin->summaryview);
2661 static void goto_folder_cb(MainWindow *mainwin, guint action,
2664 FolderItem *to_folder;
2666 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2669 folderview_select(mainwin->folderview, to_folder);
2672 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2674 messageview_copy_clipboard(mainwin->messageview);
2677 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2679 MessageView *msgview = mainwin->messageview;
2681 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2682 summary_select_all(mainwin->summaryview);
2683 else if (messageview_is_visible(msgview) &&
2684 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2685 messageview_select_all(mainwin->messageview);
2688 static void select_thread_cb(MainWindow *mainwin, guint action,
2691 summary_select_thread(mainwin->summaryview);
2694 static void create_filter_cb(MainWindow *mainwin, guint action,
2697 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2700 static void create_processing_cb(MainWindow *mainwin, guint action,
2703 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2706 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2709 prefs_common_open();
2712 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2715 prefs_filtering_open(&pre_global_processing,
2716 _("Processing rules to apply before folder rules"),
2720 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2723 prefs_filtering_open(&post_global_processing,
2724 _("Processing rules to apply after folder rules"),
2728 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2731 prefs_filtering_open(&filtering_rules,
2732 _("Filtering configuration"),
2736 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2739 prefs_template_open();
2742 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2745 prefs_actions_open(mainwin);
2748 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2751 ssl_manager_open(mainwin);
2754 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2758 new_account_cb(mainwin, 0, widget);
2760 account_open(cur_account);
2764 static void new_account_cb(MainWindow *mainwin, guint action,
2767 account_edit_open();
2768 if (!compose_get_compose_list()) account_add();
2771 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2773 cur_account = (PrefsAccount *)data;
2774 main_window_reflect_prefs_all();
2777 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2782 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2784 pluginwindow_create();
2787 static void manual_open_cb(MainWindow *mainwin, guint action,
2790 manual_open((ManualType)action);
2793 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2795 MainWindow *mainwin = (MainWindow *)data;
2799 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2800 LOCAL_FOLDER(folder)->rootpath,
2804 str = g_strdup_printf(_("Scanning folder %s ..."),
2805 LOCAL_FOLDER(folder)->rootpath);
2807 STATUSBAR_PUSH(mainwin, str);
2808 STATUSBAR_POP(mainwin);
2812 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2815 SummaryView *summary;
2817 g_return_val_if_fail(data, FALSE);
2818 summary = ((MainWindow *)data)->summaryview;
2819 g_return_val_if_fail(summary, FALSE);
2821 if (GTK_CLIST(summary->ctree)->selection &&
2822 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2825 if (summary->selected != summary->displayed)
2826 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2830 #define BREAK_ON_MODIFIER_KEY() \
2831 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2833 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2836 MainWindow *mainwin = (MainWindow*) data;
2838 if (!mainwin || !event) return;
2840 switch (event->keyval) {
2841 case GDK_Q: /* Quit */
2842 BREAK_ON_MODIFIER_KEY();
2844 app_exit_cb(mainwin, 0, NULL);
2847 if (mainwin->folderview && mainwin->summaryview
2848 && !mainwin->summaryview->displayed) {
2849 summary_lock(mainwin->summaryview);
2850 folderview_select_next_unread(mainwin->folderview);
2851 summary_unlock(mainwin->summaryview);
2859 #undef BREAK_ON_MODIFIER_KEY
2862 * Harvest addresses for selected folder.
2864 static void addr_harvest_cb( MainWindow *mainwin,
2868 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2872 * Harvest addresses for selected messages in summary view.
2874 static void addr_harvest_msg_cb( MainWindow *mainwin,
2878 summary_harvest_address( mainwin->summaryview );
2882 *\brief get a MainWindow
2884 *\return MainWindow * The first mainwindow in the mainwin_list
2886 MainWindow *mainwindow_get_mainwindow(void)
2888 if (mainwin_list && mainwin_list->data)
2889 return (MainWindow *)(mainwin_list->data);
2894 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2896 ProgressData *data = (ProgressData *) source;
2897 MainWindow *mainwin = (MainWindow *) userdata;
2899 switch (data->cmd) {
2900 case PROGRESS_COMMAND_START:
2901 case PROGRESS_COMMAND_STOP:
2902 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2904 case PROGRESS_COMMAND_SET_PERCENTAGE:
2905 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2908 while (gtk_events_pending()) gtk_main_iteration ();