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_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_folder_item.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "ssl_manager.h"
85 #include "sslcertwindow.h"
86 #include "prefs_gtk.h"
87 #include "pluginwindow.h"
89 #include "progressindicator.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 new_folder_cb (MainWindow *mainwin,
130 static void add_mbox_cb (MainWindow *mainwin,
133 static void rename_folder_cb (MainWindow *mainwin,
136 static void delete_folder_cb (MainWindow *mainwin,
139 static void update_folderview_cb (MainWindow *mainwin,
142 static void add_mailbox_cb (MainWindow *mainwin,
145 static void import_mbox_cb (MainWindow *mainwin,
148 static void export_mbox_cb (MainWindow *mainwin,
151 static void empty_trash_cb (MainWindow *mainwin,
155 static void save_as_cb (MainWindow *mainwin,
158 static void print_cb (MainWindow *mainwin,
161 static void app_exit_cb (MainWindow *mainwin,
165 static void search_cb (MainWindow *mainwin,
169 static void toggle_folder_cb (MainWindow *mainwin,
172 static void toggle_message_cb (MainWindow *mainwin,
175 static void toggle_toolbar_cb (MainWindow *mainwin,
178 static void toggle_statusbar_cb (MainWindow *mainwin,
181 static void separate_widget_cb (MainWindow *mainwin,
185 static void addressbook_open_cb (MainWindow *mainwin,
188 static void log_window_show_cb (MainWindow *mainwin,
192 static void inc_cancel_cb (MainWindow *mainwin,
196 static void open_msg_cb (MainWindow *mainwin,
200 static void view_source_cb (MainWindow *mainwin,
204 static void show_all_header_cb (MainWindow *mainwin,
208 static void reedit_cb (MainWindow *mainwin,
212 static void move_to_cb (MainWindow *mainwin,
215 static void copy_to_cb (MainWindow *mainwin,
218 static void delete_cb (MainWindow *mainwin,
222 static void cancel_cb (MainWindow *mainwin,
226 static void mark_cb (MainWindow *mainwin,
229 static void unmark_cb (MainWindow *mainwin,
233 static void mark_as_unread_cb (MainWindow *mainwin,
236 static void mark_as_read_cb (MainWindow *mainwin,
239 static void mark_all_read_cb (MainWindow *mainwin,
242 static void add_address_cb (MainWindow *mainwin,
246 static void set_charset_cb (MainWindow *mainwin,
250 static void hide_read_messages (MainWindow *mainwin,
254 static void thread_cb (MainWindow *mainwin,
257 static void expand_threads_cb (MainWindow *mainwin,
260 static void collapse_threads_cb (MainWindow *mainwin,
264 static void set_display_item_cb (MainWindow *mainwin,
267 static void sort_summary_cb (MainWindow *mainwin,
270 static void sort_summary_type_cb (MainWindow *mainwin,
273 static void attract_by_subject_cb(MainWindow *mainwin,
277 static void delete_duplicated_cb (MainWindow *mainwin,
280 static void filter_cb (MainWindow *mainwin,
283 static void execute_summary_cb (MainWindow *mainwin,
286 static void update_summary_cb (MainWindow *mainwin,
290 static void prev_cb (MainWindow *mainwin,
293 static void next_cb (MainWindow *mainwin,
296 static void next_unread_cb (MainWindow *mainwin,
299 static void prev_unread_cb (MainWindow *mainwin,
303 static void prev_new_cb (MainWindow *mainwin,
306 static void next_new_cb (MainWindow *mainwin,
309 static void prev_marked_cb (MainWindow *mainwin,
312 static void next_marked_cb (MainWindow *mainwin,
315 static void prev_labeled_cb (MainWindow *mainwin,
318 static void next_labeled_cb (MainWindow *mainwin,
322 static void goto_folder_cb (MainWindow *mainwin,
326 static void copy_cb (MainWindow *mainwin,
329 static void allsel_cb (MainWindow *mainwin,
332 static void select_thread_cb (MainWindow *mainwin,
336 static void create_filter_cb (MainWindow *mainwin,
340 static void prefs_common_open_cb (MainWindow *mainwin,
343 static void prefs_template_open_cb (MainWindow *mainwin,
346 static void prefs_actions_open_cb (MainWindow *mainwin,
349 static void prefs_account_open_cb (MainWindow *mainwin,
352 static void prefs_scoring_open_cb (MainWindow *mainwin,
355 static void prefs_filtering_open_cb (MainWindow *mainwin,
359 static void ssl_manager_open_cb (MainWindow *mainwin,
363 static void new_account_cb (MainWindow *mainwin,
367 static void account_menu_cb (GtkMenuItem *menuitem,
370 static void prefs_open_cb (GtkMenuItem *menuitem,
372 static void plugins_open_cb (GtkMenuItem *menuitem,
375 static void online_switch_clicked(GtkButton *btn,
378 static void manual_open_cb (MainWindow *mainwin,
382 static void scan_tree_func (Folder *folder,
386 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
388 static void addr_harvest_cb ( MainWindow *mainwin,
392 static void addr_harvest_msg_cb ( MainWindow *mainwin,
396 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
397 GdkEventFocus *focus,
399 void main_window_reply_cb (MainWindow *mainwin,
402 gboolean mainwindow_progressindicator_hook (gpointer source,
404 #define SEPARATE_ACTION 500
406 static GtkItemFactoryEntry mainwin_entries[] =
408 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
409 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
410 {N_("/_File/_Folder/Create _new folder..."),
411 NULL, new_folder_cb, 0, NULL},
412 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
413 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
414 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
415 {N_("/_File/_Folder/_Check for new messages in all folders"),
416 NULL, update_folderview_cb, 0, NULL},
417 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
418 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
419 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
420 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
421 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
422 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
423 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
424 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
425 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
426 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
427 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
428 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
430 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
431 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
432 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
433 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
434 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
435 {N_("/_Edit/_Find in current message..."),
436 "<control>F", search_cb, 0, NULL},
437 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
438 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
439 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
440 {N_("/_View/Show or hi_de/_Folder tree"),
441 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
442 {N_("/_View/Show or hi_de/_Message view"),
443 "V", toggle_message_cb, 0, "<ToggleItem>"},
444 {N_("/_View/Show or hi_de/_Toolbar"),
445 NULL, NULL, 0, "<Branch>"},
446 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
447 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
448 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
449 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
450 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
451 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
452 {N_("/_View/Show or hi_de/_Toolbar/_None"),
453 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
454 {N_("/_View/Show or hi_de/Status _bar"),
455 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
456 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
457 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
458 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
459 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
460 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
461 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
462 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
463 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
464 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
465 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
466 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
467 {N_("/_View/_Sort/by _color label"),
468 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
469 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
470 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
471 {N_("/_View/_Sort/by a_ttachment"),
472 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
473 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
474 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
475 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
476 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
477 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
478 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
479 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
480 {N_("/_View/_Sort/_Attract by subject"),
481 NULL, attract_by_subject_cb, 0, NULL},
482 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
483 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
484 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
485 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
486 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
488 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
490 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
491 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
492 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_View/_Go to/P_rev unread message"),
494 "<shift>P", prev_unread_cb, 0, NULL},
495 {N_("/_View/_Go to/N_ext unread message"),
496 "<shift>N", next_unread_cb, 0, NULL},
497 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
498 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
499 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
500 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
501 {N_("/_View/_Go to/Prev _marked message"),
502 NULL, prev_marked_cb, 0, NULL},
503 {N_("/_View/_Go to/Next m_arked message"),
504 NULL, next_marked_cb, 0, NULL},
505 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
506 {N_("/_View/_Go to/Prev _labeled message"),
507 NULL, prev_labeled_cb, 0, NULL},
508 {N_("/_View/_Go to/Next la_beled message"),
509 NULL, next_labeled_cb, 0, NULL},
510 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
512 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
514 #define CODESET_SEPARATOR \
515 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
516 #define CODESET_ACTION(action) \
517 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
519 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
520 {N_("/_View/_Code set/_Auto detect"),
521 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
522 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
524 CODESET_ACTION(C_US_ASCII)},
527 {N_("/_View/_Code set/Unicode (_UTF-8)"),
528 CODESET_ACTION(C_UTF_8)},
531 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
532 CODESET_ACTION(C_ISO_8859_1)},
533 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
534 CODESET_ACTION(C_ISO_8859_15)},
537 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
538 CODESET_ACTION(C_ISO_8859_2)},
540 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
541 CODESET_ACTION(C_ISO_8859_13)},
542 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
543 CODESET_ACTION(C_ISO_8859_4)},
545 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
546 CODESET_ACTION(C_ISO_8859_7)},
548 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
549 CODESET_ACTION(C_ISO_8859_9)},
551 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
552 CODESET_ACTION(C_ISO_8859_5)},
553 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
554 CODESET_ACTION(C_KOI8_R)},
555 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
556 CODESET_ACTION(C_WINDOWS_1251)},
559 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
560 CODESET_ACTION(C_ISO_2022_JP)},
562 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
563 CODESET_ACTION(C_ISO_2022_JP_2)},
565 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
566 CODESET_ACTION(C_EUC_JP)},
567 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
568 CODESET_ACTION(C_SHIFT_JIS)},
571 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
572 CODESET_ACTION(C_GB2312)},
573 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
574 CODESET_ACTION(C_BIG5)},
575 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
576 CODESET_ACTION(C_EUC_TW)},
577 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
578 CODESET_ACTION(C_ISO_2022_CN)},
580 {N_("/_View/_Code set/Korean (EUC-_KR)"),
581 CODESET_ACTION(C_EUC_KR)},
582 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
583 CODESET_ACTION(C_ISO_2022_KR)},
585 {N_("/_View/_Code set/Thai (TIS-620)"),
586 CODESET_ACTION(C_TIS_620)},
587 {N_("/_View/_Code set/Thai (Windows-874)"),
588 CODESET_ACTION(C_WINDOWS_874)},
591 #undef CODESET_SEPARATOR
592 #undef CODESET_ACTION
594 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
596 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
597 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
598 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
601 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
602 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
603 {N_("/_Message/Get from _all accounts"),
604 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
605 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
606 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
608 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
610 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
611 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
612 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
613 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
614 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
615 {N_("/_Message/Repl_y to/mailing _list"),
616 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
617 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
618 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
620 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
621 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
623 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
625 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
626 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
627 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
628 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
629 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
630 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
631 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
632 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
633 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
634 {N_("/_Message/_Mark/Mark as rea_d"),
635 NULL, mark_as_read_cb, 0, NULL},
636 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
638 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
639 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
640 {N_("/_Tools/Add sender to address boo_k"),
641 NULL, add_address_cb, 0, NULL},
642 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
643 {N_("/_Tools/_Harvest addresses/from _Folder..."),
644 NULL, addr_harvest_cb, 0, NULL},
645 {N_("/_Tools/_Harvest addresses/from _Messages..."),
646 NULL, addr_harvest_msg_cb, 0, NULL},
647 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
649 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
650 {N_("/_Tools/_Create filter rule/_Automatically"),
651 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
652 {N_("/_Tools/_Create filter rule/by _From"),
653 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
654 {N_("/_Tools/_Create filter rule/by _To"),
655 NULL, create_filter_cb, FILTER_BY_TO, NULL},
656 {N_("/_Tools/_Create filter rule/by _Subject"),
657 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
658 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
660 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
661 {N_("/_Tools/Delete du_plicated messages"),
662 NULL, delete_duplicated_cb, 0, NULL},
663 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
666 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_Tools/SSL certi_ficates..."),
668 NULL, ssl_manager_open_cb, 0, NULL},
670 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
673 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
674 {N_("/_Configuration/C_hange current account"),
675 NULL, NULL, 0, "<Branch>"},
676 {N_("/_Configuration/_Preferences for current account..."),
677 NULL, prefs_account_open_cb, 0, NULL},
678 {N_("/_Configuration/Create _new account..."),
679 NULL, new_account_cb, 0, NULL},
680 {N_("/_Configuration/_Edit accounts..."),
681 NULL, account_edit_open, 0, NULL},
682 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
683 {N_("/_Configuration/_Common preferences..."),
684 NULL, prefs_common_open_cb, 0, NULL},
685 {N_("/_Configuration/_Scoring..."),
686 NULL, prefs_scoring_open_cb, 0, NULL},
687 {N_("/_Configuration/_Filtering..."),
688 NULL, prefs_filtering_open_cb, 0, NULL},
689 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
690 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
691 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
692 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
694 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
695 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
696 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
697 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
698 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
699 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
700 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
701 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
705 MainWindow *main_window_create(SeparateType type)
711 GtkWidget *handlebox;
712 GtkWidget *vbox_body;
713 GtkWidget *hbox_stat;
714 GtkWidget *statusbar;
715 GtkWidget *progressbar;
716 GtkWidget *statuslabel;
717 GtkWidget *ac_button;
719 GtkWidget *online_pixmap;
720 GtkWidget *offline_pixmap;
721 GtkWidget *online_switch;
722 GtkWidget *offline_switch;
723 GtkTooltips *offline_tip;
724 GtkTooltips *online_tip;
725 GtkTooltips *sel_ac_tip;
727 FolderView *folderview;
728 SummaryView *summaryview;
729 MessageView *messageview;
730 GdkColormap *colormap;
733 GtkItemFactory *ifactory;
737 guint n_menu_entries;
739 static GdkGeometry geometry;
741 debug_print("Creating main window...\n");
742 mainwin = g_new0(MainWindow, 1);
745 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
746 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
747 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
748 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
750 if (!geometry.min_height) {
751 geometry.min_width = 320;
752 geometry.min_height = 200;
754 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
757 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
758 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
759 MANAGE_WINDOW_SIGNALS_CONNECT(window);
760 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
761 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
763 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
764 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
766 gtk_widget_realize(window);
767 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
770 gtkut_widget_set_app_icon(window);
772 vbox = gtk_vbox_new(FALSE, 0);
773 gtk_widget_show(vbox);
774 gtk_container_add(GTK_CONTAINER(window), vbox);
777 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
778 menubar = menubar_create(window, mainwin_entries,
779 n_menu_entries, "<Main>", mainwin);
780 gtk_widget_show(menubar);
781 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
782 ifactory = gtk_item_factory_from_widget(menubar);
784 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
785 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
787 handlebox = gtk_handle_box_new();
788 gtk_widget_show(handlebox);
789 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
791 /* link window to mainwin->window to avoid gdk warnings */
792 mainwin->window = window;
795 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
799 /* vbox that contains body */
800 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
801 gtk_widget_show(vbox_body);
802 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
803 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
805 hbox_stat = gtk_hbox_new(FALSE, 2);
806 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
808 statusbar = statusbar_create();
809 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
811 progressbar = gtk_progress_bar_new();
812 gtk_widget_set_usize(progressbar, 120, 1);
813 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
815 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
816 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
817 online_tip = gtk_tooltips_new();
818 online_switch = gtk_button_new ();
819 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
820 online_switch, _("Go offline"), NULL);
821 offline_tip = gtk_tooltips_new();
822 offline_switch = gtk_button_new ();
823 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
824 offline_switch, _("Go online"), NULL);
825 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
826 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
827 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
828 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
829 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
830 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
831 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
832 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
834 statuslabel = gtk_label_new("");
835 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
837 sel_ac_tip = gtk_tooltips_new();
838 ac_button = gtk_button_new();
839 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
840 ac_button, _("Select account"), NULL);
841 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
842 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
843 gtk_widget_set_usize(ac_button, -1, 1);
844 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
845 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
846 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
848 ac_label = gtk_label_new("");
849 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
851 gtk_widget_show_all(hbox_stat);
853 gtk_widget_hide(offline_switch);
855 mainwin->folderview = folderview = folderview_create();
856 mainwin->summaryview = summaryview = summary_create();
857 mainwin->messageview = messageview = messageview_create(mainwin);
858 mainwin->logwin = log_window_create();
860 folderview->mainwin = mainwin;
861 folderview->summaryview = summaryview;
863 summaryview->mainwin = mainwin;
864 summaryview->folderview = folderview;
865 summaryview->messageview = messageview;
866 summaryview->window = window;
868 mainwin->vbox = vbox;
869 mainwin->menubar = menubar;
870 mainwin->menu_factory = ifactory;
871 mainwin->handlebox = handlebox;
872 mainwin->vbox_body = vbox_body;
873 mainwin->hbox_stat = hbox_stat;
874 mainwin->statusbar = statusbar;
875 mainwin->progressbar = progressbar;
876 mainwin->statuslabel = statuslabel;
877 mainwin->ac_button = ac_button;
878 mainwin->ac_label = ac_label;
880 mainwin->online_switch = online_switch;
881 mainwin->offline_switch = offline_switch;
882 mainwin->online_pixmap = online_pixmap;
883 mainwin->offline_pixmap = offline_pixmap;
885 /* set context IDs for status bar */
886 mainwin->mainwin_cid = gtk_statusbar_get_context_id
887 (GTK_STATUSBAR(statusbar), "Main Window");
888 mainwin->folderview_cid = gtk_statusbar_get_context_id
889 (GTK_STATUSBAR(statusbar), "Folder View");
890 mainwin->summaryview_cid = gtk_statusbar_get_context_id
891 (GTK_STATUSBAR(statusbar), "Summary View");
893 /* allocate colors for summary view and folder view */
894 summaryview->color_marked.red = summaryview->color_marked.green = 0;
895 summaryview->color_marked.blue = (guint16)65535;
897 summaryview->color_dim.red = summaryview->color_dim.green =
898 summaryview->color_dim.blue = COLOR_DIM;
900 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
901 &folderview->color_new);
903 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
904 &folderview->color_op);
906 summaryview->color_important.red = 0;
907 summaryview->color_important.green = 0;
908 summaryview->color_important.blue = (guint16)65535;
910 color[0] = summaryview->color_marked;
911 color[1] = summaryview->color_dim;
912 color[2] = folderview->color_new;
913 color[3] = folderview->color_op;
915 colormap = gdk_window_get_colormap(window->window);
916 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
917 for (i = 0; i < 4; i++) {
918 if (success[i] == FALSE)
919 g_warning("MainWindow: color allocation %d failed\n", i);
922 debug_print("done.\n");
924 messageview->visible = TRUE;
926 main_window_set_widgets(mainwin, type);
929 menuitem = gtk_item_factory_get_item
930 (ifactory, "/View/Code set/Auto detect");
931 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
933 switch (prefs_common.toolbar_style) {
935 menuitem = gtk_item_factory_get_item
936 (ifactory, "/View/Show or hide/Toolbar/None");
939 menuitem = gtk_item_factory_get_item
940 (ifactory, "/View/Show or hide/Toolbar/Icon");
943 menuitem = gtk_item_factory_get_item
944 (ifactory, "/View/Show or hide/Toolbar/Text");
947 menuitem = gtk_item_factory_get_item
948 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
950 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
952 gtk_widget_hide(mainwin->hbox_stat);
953 menuitem = gtk_item_factory_get_item
954 (ifactory, "/View/Show or hide/Status bar");
955 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
956 prefs_common.show_statusbar);
958 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
960 if (prefs_common.show_searchbar) {
961 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
962 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
963 gtk_widget_hide(summaryview->search_description);
966 /* set account selection menu */
967 ac_menu = gtk_item_factory_get_widget
968 (ifactory, "/Configuration/Change current account");
969 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
970 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
971 mainwin->ac_menu = ac_menu;
973 toolbar_main_set_sensitive(mainwin);
975 /* create actions menu */
976 action_update_mainwin_menu(ifactory, mainwin);
978 /* attach accel groups to main window */
979 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
980 gtk_window_add_accel_group \
982 gtk_item_factory_from_widget(menu)->accel_group)
984 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
986 /* connect the accelerators for equivalent
987 menu items in different menus */
988 menu_connect_identical_items();
992 /* show main window */
993 gtk_widget_set_uposition(mainwin->window,
994 prefs_common.mainwin_x,
995 prefs_common.mainwin_y);
996 gtk_widget_set_usize(window, prefs_common.mainwin_width,
997 prefs_common.mainwin_height);
998 gtk_widget_show(mainwin->window);
1000 /* initialize views */
1001 folderview_init(folderview);
1002 summary_init(summaryview);
1003 messageview_init(messageview);
1004 log_window_init(mainwin->logwin);
1006 sslcertwindow_register_hook();
1008 mainwin->lock_count = 0;
1009 mainwin->menu_lock_count = 0;
1010 mainwin->cursor_count = 0;
1012 mainwin->progressindicator_hook =
1013 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1016 watch_cursor = gdk_cursor_new(GDK_WATCH);
1018 mainwin_list = g_list_append(mainwin_list, mainwin);
1020 /* init work_offline */
1021 if (prefs_common.work_offline)
1022 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1027 void main_window_cursor_wait(MainWindow *mainwin)
1030 if (mainwin->cursor_count == 0)
1031 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1033 mainwin->cursor_count++;
1038 void main_window_cursor_normal(MainWindow *mainwin)
1040 if (mainwin->cursor_count)
1041 mainwin->cursor_count--;
1043 if (mainwin->cursor_count == 0)
1044 gdk_window_set_cursor(mainwin->window->window, NULL);
1049 /* lock / unlock the user-interface */
1050 void main_window_lock(MainWindow *mainwin)
1052 if (mainwin->lock_count == 0)
1053 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1055 mainwin->lock_count++;
1057 main_window_set_menu_sensitive(mainwin);
1058 toolbar_main_set_sensitive(mainwin);
1061 void main_window_unlock(MainWindow *mainwin)
1063 if (mainwin->lock_count)
1064 mainwin->lock_count--;
1066 main_window_set_menu_sensitive(mainwin);
1067 toolbar_main_set_sensitive(mainwin);
1069 if (mainwin->lock_count == 0)
1070 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1073 static void main_window_menu_callback_block(MainWindow *mainwin)
1075 mainwin->menu_lock_count++;
1078 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1080 if (mainwin->menu_lock_count)
1081 mainwin->menu_lock_count--;
1084 void main_window_reflect_prefs_all(void)
1086 main_window_reflect_prefs_all_real(FALSE);
1089 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1092 MainWindow *mainwin;
1095 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1096 mainwin = (MainWindow *)cur->data;
1098 main_window_show_cur_account(mainwin);
1099 main_window_set_menu_sensitive(mainwin);
1100 toolbar_main_set_sensitive(mainwin);
1103 if (pixmap_theme_changed) {
1104 toolbar_update(TOOLBAR_MAIN, mainwin);
1105 messageview_reflect_prefs_pixmap_theme();
1106 compose_reflect_prefs_pixmap_theme();
1107 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1108 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1110 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1111 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1112 mainwin->online_pixmap);
1113 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1114 gtk_widget_show(pixmap);
1115 mainwin->online_pixmap = pixmap;
1116 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1117 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1118 mainwin->offline_pixmap);
1119 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1120 gtk_widget_show(pixmap);
1121 mainwin->offline_pixmap = pixmap;
1124 summary_redisplay_msg(mainwin->summaryview);
1125 headerview_set_visibility(mainwin->messageview->headerview,
1126 prefs_common.display_header_pane);
1130 void main_window_set_summary_column(void)
1133 MainWindow *mainwin;
1135 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1136 mainwin = (MainWindow *)cur->data;
1137 summary_set_column_order(mainwin->summaryview);
1141 void main_window_set_account_menu(GList *account_list)
1143 GList *cur, *cur_ac, *cur_item;
1144 GtkWidget *menuitem;
1145 MainWindow *mainwin;
1146 PrefsAccount *ac_prefs;
1148 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1149 mainwin = (MainWindow *)cur->data;
1151 /* destroy all previous menu item */
1152 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1153 while (cur_item != NULL) {
1154 GList *next = cur_item->next;
1155 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1159 for (cur_ac = account_list; cur_ac != NULL;
1160 cur_ac = cur_ac->next) {
1161 ac_prefs = (PrefsAccount *)cur_ac->data;
1163 menuitem = gtk_menu_item_new_with_label
1164 (ac_prefs->account_name
1165 ? ac_prefs->account_name : _("Untitled"));
1166 gtk_widget_show(menuitem);
1167 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1168 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1169 GTK_SIGNAL_FUNC(account_menu_cb),
1175 static void main_window_show_cur_account(MainWindow *mainwin)
1180 ac_name = g_strdup(cur_account
1181 ? (cur_account->account_name
1182 ? cur_account->account_name : _("Untitled"))
1186 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1188 buf = g_strdup(PROG_VERSION);
1189 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1192 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1193 gtk_widget_queue_resize(mainwin->ac_button);
1198 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1200 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1201 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1202 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1203 GtkWidget *message_wid = mainwin->messageview->vbox;
1205 debug_print("Changing window separation type from %d to %d\n",
1206 mainwin->type, type);
1208 if (mainwin->type == type) return;
1210 /* remove widgets from those containers */
1211 gtk_widget_ref(folder_wid);
1212 gtk_widget_ref(summary_wid);
1213 gtk_widget_ref(message_wid);
1214 gtkut_container_remove
1215 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1216 gtkut_container_remove
1217 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1218 gtkut_container_remove
1219 (GTK_CONTAINER(message_wid->parent), message_wid);
1221 /* clean containers */
1222 switch (mainwin->type) {
1224 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1226 case SEPARATE_FOLDER:
1227 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1228 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1230 case SEPARATE_MESSAGE:
1231 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1232 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1235 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1236 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1240 gtk_widget_hide(mainwin->window);
1241 main_window_set_widgets(mainwin, type);
1242 gtk_widget_show(mainwin->window);
1244 gtk_widget_unref(folder_wid);
1245 gtk_widget_unref(summary_wid);
1246 gtk_widget_unref(message_wid);
1249 void main_window_toggle_message_view(MainWindow *mainwin)
1251 SummaryView *summaryview = mainwin->summaryview;
1252 union CompositeWin *cwin = &mainwin->win;
1253 GtkWidget *vpaned = NULL;
1254 GtkWidget *container = NULL;
1255 GtkWidget *msgwin = NULL;
1257 switch (mainwin->type) {
1259 vpaned = cwin->sep_none.vpaned;
1260 container = cwin->sep_none.hpaned;
1262 case SEPARATE_FOLDER:
1263 vpaned = cwin->sep_folder.vpaned;
1264 container = mainwin->vbox_body;
1266 case SEPARATE_MESSAGE:
1267 msgwin = mainwin->win.sep_message.messagewin;
1270 msgwin = mainwin->win.sep_both.messagewin;
1275 if (GTK_WIDGET_VISIBLE(msgwin)) {
1276 gtk_widget_hide(msgwin);
1277 mainwin->messageview->visible = FALSE;
1278 summaryview->displayed = NULL;
1280 gtk_widget_show(msgwin);
1281 mainwin->messageview->visible = TRUE;
1283 } else if (vpaned->parent != NULL) {
1284 mainwin->messageview->visible = FALSE;
1285 summaryview->displayed = NULL;
1286 gtk_widget_ref(vpaned);
1287 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1288 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1289 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1290 GTK_ARROW_UP, GTK_SHADOW_OUT);
1292 mainwin->messageview->visible = TRUE;
1293 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1294 gtk_container_add(GTK_CONTAINER(container), vpaned);
1295 gtk_widget_unref(vpaned);
1296 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1297 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1300 main_window_set_menu_sensitive(mainwin);
1302 gtk_widget_grab_focus(summaryview->ctree);
1305 void main_window_get_size(MainWindow *mainwin)
1307 GtkAllocation *allocation;
1309 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1311 prefs_common.summaryview_width = allocation->width;
1313 if ((mainwin->type == SEPARATE_NONE ||
1314 mainwin->type == SEPARATE_FOLDER) &&
1315 messageview_is_visible(mainwin->messageview))
1316 prefs_common.summaryview_height = allocation->height;
1318 prefs_common.mainview_width = allocation->width;
1320 allocation = &mainwin->window->allocation;
1322 prefs_common.mainview_height = allocation->height;
1323 prefs_common.mainwin_width = allocation->width;
1324 prefs_common.mainwin_height = allocation->height;
1326 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1328 prefs_common.folderview_width = allocation->width;
1329 prefs_common.folderview_height = allocation->height;
1332 void main_window_get_position(MainWindow *mainwin)
1336 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1338 prefs_common.mainview_x = x;
1339 prefs_common.mainview_y = y;
1340 prefs_common.mainwin_x = x;
1341 prefs_common.mainwin_y = y;
1343 debug_print("window position: x = %d, y = %d\n", x, y);
1346 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1352 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1353 folder = FOLDER(list->data);
1354 if (folder && folder->trash && folder->trash->total_msgs > 0)
1358 if (!has_trash) return;
1361 if (alertpanel(_("Empty trash"),
1362 _("Empty all messages in trash?"),
1363 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1365 manage_window_focus_in(mainwin->window, NULL, NULL);
1368 procmsg_empty_trash();
1370 if (mainwin->summaryview->folder_item &&
1371 mainwin->summaryview->folder_item->stype == F_TRASH)
1372 gtk_widget_grab_focus(mainwin->folderview->ctree);
1375 void main_window_add_mailbox(MainWindow *mainwin)
1380 path = input_dialog(_("Add mailbox"),
1381 _("Input the location of mailbox.\n"
1382 "If the existing mailbox is specified, it will be\n"
1383 "scanned automatically."),
1386 if (folder_find_from_path(path)) {
1387 alertpanel_error(_("The mailbox `%s' already exists."), path);
1391 folder = folder_new(folder_get_class_from_string("mh"),
1392 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1396 if (folder->klass->create_tree(folder) < 0) {
1397 alertpanel_error(_("Creation of the mailbox failed.\n"
1398 "Maybe some files already exist, or you don't have the permission to write there."));
1399 folder_destroy(folder);
1404 folder_set_ui_func(folder, scan_tree_func, mainwin);
1405 folder_scan_tree(folder);
1406 folder_set_ui_func(folder, NULL, NULL);
1408 folderview_set(mainwin->folderview);
1411 void main_window_add_mbox(MainWindow *mainwin)
1417 path = input_dialog(_("Add mbox mailbox"),
1418 _("Input the location of mailbox."),
1423 if (folder_find_from_path(path)) {
1424 alertpanel_error(_("The mailbox `%s' already exists."), path);
1429 folder = folder_new(folder_get_class_from_string("mbox"),
1430 g_basename(path), path);
1433 if (folder->klass->create_tree(folder) < 0) {
1434 alertpanel_error(_("Creation of the mailbox failed."));
1435 folder_destroy(folder);
1441 item = folder_item_new(folder, folder->name, NULL);
1442 item->folder = folder;
1443 folder->node = g_node_new(item);
1445 folder_create_folder(item, "inbox");
1446 folder_create_folder(item, "outbox");
1447 folder_create_folder(item, "queue");
1448 folder_create_folder(item, "draft");
1449 folder_create_folder(item, "trash");
1451 folderview_set(mainwin->folderview);
1454 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1456 SensitiveCond state = 0;
1457 SummarySelection selection;
1458 FolderItem *item = mainwin->summaryview->folder_item;
1459 GList *account_list = account_get_list();
1461 selection = summary_get_selection_type(mainwin->summaryview);
1463 if (mainwin->lock_count == 0)
1464 state |= M_UNLOCKED;
1465 if (selection != SUMMARY_NONE)
1466 state |= M_MSG_EXIST;
1467 if (item && item->path && item->parent && !item->no_select) {
1469 /* if (item->folder->type != F_NEWS) */
1470 state |= M_ALLOW_DELETE;
1472 if (prefs_common.immediate_exec == 0
1473 && mainwin->lock_count == 0)
1474 state |= M_DELAY_EXEC;
1476 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1477 || selection != SUMMARY_NONE)
1478 state |= M_HIDE_READ_MSG;
1480 if (mainwin->summaryview->threaded)
1481 state |= M_THREADED;
1483 state |= M_UNTHREADED;
1484 if (selection == SUMMARY_SELECTED_SINGLE ||
1485 selection == SUMMARY_SELECTED_MULTIPLE)
1486 state |= M_TARGET_EXIST;
1487 if (selection == SUMMARY_SELECTED_SINGLE)
1488 state |= M_SINGLE_TARGET_EXIST;
1489 if (mainwin->summaryview->folder_item &&
1490 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1493 state |= M_NOT_NEWS;
1494 if (selection == SUMMARY_SELECTED_SINGLE &&
1496 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1497 item->stype == F_QUEUE)))
1498 state |= M_ALLOW_REEDIT;
1500 state |= M_HAVE_ACCOUNT;
1502 for ( ; account_list != NULL; account_list = account_list->next) {
1503 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1504 state |= M_HAVE_NEWS_ACCOUNT;
1509 if (inc_is_active())
1510 state |= M_INC_ACTIVE;
1517 void main_window_set_menu_sensitive(MainWindow *mainwin)
1519 GtkItemFactory *ifactory = mainwin->menu_factory;
1520 SensitiveCond state;
1522 GtkWidget *menuitem;
1523 SummaryView *summaryview;
1527 static const struct {
1531 {"/File/Folder" , M_UNLOCKED},
1532 {"/File/Add mailbox..." , M_UNLOCKED},
1533 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1534 {"/File/Import mbox file..." , M_UNLOCKED},
1535 {"/File/Export to mbox file..." , M_UNLOCKED},
1536 {"/File/Empty trash" , M_UNLOCKED},
1537 {"/File/Work offline" , M_UNLOCKED},
1539 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1540 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1541 /* {"/File/Close" , M_UNLOCKED}, */
1542 {"/File/Exit" , M_UNLOCKED},
1544 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1546 {"/View/Sort" , M_EXEC},
1547 {"/View/Thread view" , M_EXEC},
1548 {"/View/Expand all threads" , M_MSG_EXIST},
1549 {"/View/Collapse all threads" , M_MSG_EXIST},
1550 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1551 {"/View/Go to/Prev message" , M_MSG_EXIST},
1552 {"/View/Go to/Next message" , M_MSG_EXIST},
1553 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1554 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1555 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1556 {"/View/Go to/Next new message" , M_MSG_EXIST},
1557 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1558 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1559 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1560 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1561 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1562 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1563 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1565 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1566 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1567 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1568 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1569 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1570 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1571 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1572 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1573 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1574 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1575 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1576 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1577 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1578 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1579 {"/Message/Mark" , M_TARGET_EXIST},
1581 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1582 {"/Tools/Harvest addresses" , M_UNLOCKED},
1583 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1584 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1585 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1586 {"/Tools/Execute" , M_DELAY_EXEC},
1587 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1589 {"/Configuration", M_UNLOCKED},
1594 state = main_window_get_current_state(mainwin);
1596 for (i = 0; entry[i].entry != NULL; i++) {
1597 sensitive = ((entry[i].cond & state) == entry[i].cond);
1598 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1601 main_window_menu_callback_block(mainwin);
1603 #define SET_CHECK_MENU_ACTIVE(path, active) \
1605 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1606 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1609 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1610 messageview_is_visible(mainwin->messageview));
1612 summaryview = mainwin->summaryview;
1613 menu_path = "/View/Sort/Don't sort";
1615 switch (summaryview->sort_key) {
1616 case SORT_BY_NUMBER:
1617 menu_path = "/View/Sort/by number"; break;
1619 menu_path = "/View/Sort/by size"; break;
1621 menu_path = "/View/Sort/by date"; break;
1623 menu_path = "/View/Sort/by from"; break;
1625 menu_path = "/View/Sort/by recipient"; break;
1626 case SORT_BY_SUBJECT:
1627 menu_path = "/View/Sort/by subject"; break;
1629 menu_path = "/View/Sort/by color label"; break;
1631 menu_path = "/View/Sort/by mark"; break;
1632 case SORT_BY_STATUS:
1633 menu_path = "/View/Sort/by status"; break;
1635 menu_path = "/View/Sort/by attachment"; break;
1637 menu_path = "/View/Sort/by score"; break;
1638 case SORT_BY_LOCKED:
1639 menu_path = "/View/Sort/by locked"; break;
1642 menu_path = "/View/Sort/Don't sort"; break;
1644 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1646 if (summaryview->sort_type == SORT_ASCENDING) {
1647 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1649 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1652 if (summaryview->sort_key != SORT_BY_NONE) {
1653 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1654 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1656 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1657 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1660 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1661 mainwin->messageview->textview->show_all_headers);
1662 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1664 #undef SET_CHECK_MENU_ACTIVE
1666 main_window_menu_callback_unblock(mainwin);
1669 void main_window_popup(MainWindow *mainwin)
1671 gtkut_window_popup(mainwin->window);
1673 switch (mainwin->type) {
1674 case SEPARATE_FOLDER:
1675 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1677 case SEPARATE_MESSAGE:
1678 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1681 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1682 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1689 void main_window_show(MainWindow *mainwin)
1691 gtk_widget_show(mainwin->window);
1692 gtk_widget_show(mainwin->vbox_body);
1694 switch (mainwin->type) {
1695 case SEPARATE_FOLDER:
1696 gtk_widget_show(mainwin->win.sep_folder.folderwin);
1698 case SEPARATE_MESSAGE:
1699 gtk_widget_show(mainwin->win.sep_message.messagewin);
1702 gtk_widget_show(mainwin->win.sep_both.folderwin);
1703 gtk_widget_show(mainwin->win.sep_both.messagewin);
1710 void main_window_hide(MainWindow *mainwin)
1712 gtk_widget_hide(mainwin->window);
1713 gtk_widget_hide(mainwin->vbox_body);
1715 switch (mainwin->type) {
1716 case SEPARATE_FOLDER:
1717 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1719 case SEPARATE_MESSAGE:
1720 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1723 gtk_widget_hide(mainwin->win.sep_both.folderwin);
1724 gtk_widget_hide(mainwin->win.sep_both.messagewin);
1731 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1733 GtkWidget *folderwin = NULL;
1734 GtkWidget *messagewin = NULL;
1737 GtkWidget *vbox_body = mainwin->vbox_body;
1738 GtkItemFactory *ifactory = mainwin->menu_factory;
1739 GtkWidget *menuitem;
1740 GtkItemFactory *msgview_ifactory;
1742 debug_print("Setting widgets...");
1744 /* create separated window(s) if needed */
1745 if (type & SEPARATE_FOLDER) {
1746 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1747 gtk_window_set_title(GTK_WINDOW(folderwin),
1748 _("Sylpheed - Folder View"));
1749 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1750 "folder_view", "Sylpheed");
1751 gtk_window_set_policy(GTK_WINDOW(folderwin),
1753 gtk_widget_set_usize(folderwin, -1,
1754 prefs_common.mainview_height);
1755 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1757 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1758 GTK_SIGNAL_FUNC(folder_window_close_cb),
1761 if (type & SEPARATE_MESSAGE) {
1762 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1763 gtk_window_set_title(GTK_WINDOW(messagewin),
1764 _("Sylpheed - Message View"));
1765 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1766 "message_view", "Sylpheed");
1767 gtk_window_set_policy(GTK_WINDOW(messagewin),
1769 gtk_widget_set_usize
1770 (messagewin, prefs_common.mainview_width,
1771 prefs_common.mainview_height
1772 - prefs_common.summaryview_height
1773 + DEFAULT_HEADERVIEW_HEIGHT);
1774 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1776 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1777 GTK_SIGNAL_FUNC(message_window_close_cb),
1783 hpaned = gtk_hpaned_new();
1784 gtk_widget_show(hpaned);
1785 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1786 gtk_paned_add1(GTK_PANED(hpaned),
1787 GTK_WIDGET_PTR(mainwin->folderview));
1789 vpaned = gtk_vpaned_new();
1790 if (messageview_is_visible(mainwin->messageview)) {
1791 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1792 gtk_paned_add1(GTK_PANED(vpaned),
1793 GTK_WIDGET_PTR(mainwin->summaryview));
1795 gtk_paned_add2(GTK_PANED(hpaned),
1796 GTK_WIDGET_PTR(mainwin->summaryview));
1797 gtk_widget_ref(vpaned);
1799 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1800 prefs_common.summaryview_width,
1801 prefs_common.summaryview_height);
1802 gtk_paned_add2(GTK_PANED(vpaned),
1803 GTK_WIDGET_PTR(mainwin->messageview));
1804 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1805 prefs_common.mainview_width, -1);
1806 gtk_widget_set_usize(mainwin->window,
1807 prefs_common.folderview_width +
1808 prefs_common.mainview_width,
1809 prefs_common.mainwin_height);
1810 gtk_widget_show_all(vpaned);
1812 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1813 * lose track of its visibility state */
1814 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1815 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1817 mainwin->win.sep_none.hpaned = hpaned;
1818 mainwin->win.sep_none.vpaned = vpaned;
1820 /* remove headerview if not in prefs */
1821 headerview_set_visibility(mainwin->messageview->headerview,
1822 prefs_common.display_header_pane);
1824 case SEPARATE_FOLDER:
1825 vpaned = gtk_vpaned_new();
1826 if (messageview_is_visible(mainwin->messageview)) {
1827 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1829 gtk_paned_add1(GTK_PANED(vpaned),
1830 GTK_WIDGET_PTR(mainwin->summaryview));
1832 gtk_box_pack_start(GTK_BOX(vbox_body),
1833 GTK_WIDGET_PTR(mainwin->summaryview),
1835 gtk_widget_ref(vpaned);
1837 gtk_paned_add2(GTK_PANED(vpaned),
1838 GTK_WIDGET_PTR(mainwin->messageview));
1839 gtk_widget_show_all(vpaned);
1840 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1841 prefs_common.summaryview_width,
1842 prefs_common.summaryview_height);
1843 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1844 prefs_common.mainview_width, -1);
1845 gtk_widget_set_usize(mainwin->window,
1846 prefs_common.mainview_width,
1847 prefs_common.mainview_height);
1849 gtk_container_add(GTK_CONTAINER(folderwin),
1850 GTK_WIDGET_PTR(mainwin->folderview));
1852 mainwin->win.sep_folder.folderwin = folderwin;
1853 mainwin->win.sep_folder.vpaned = vpaned;
1855 gtk_widget_show_all(folderwin);
1857 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1858 * lose track of its visibility state */
1859 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1860 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1862 /* remove headerview if not in prefs */
1863 headerview_set_visibility(mainwin->messageview->headerview,
1864 prefs_common.display_header_pane);
1867 case SEPARATE_MESSAGE:
1868 hpaned = gtk_hpaned_new();
1869 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1871 gtk_paned_add1(GTK_PANED(hpaned),
1872 GTK_WIDGET_PTR(mainwin->folderview));
1873 gtk_paned_add2(GTK_PANED(hpaned),
1874 GTK_WIDGET_PTR(mainwin->summaryview));
1875 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1876 prefs_common.summaryview_width,
1877 prefs_common.summaryview_height);
1878 gtk_widget_set_usize(mainwin->window,
1879 prefs_common.folderview_width +
1880 prefs_common.mainview_width,
1881 prefs_common.mainwin_height);
1882 gtk_widget_show_all(hpaned);
1884 messageview_add_toolbar(mainwin->messageview, messagewin);
1885 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1886 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1888 mainwin->win.sep_message.messagewin = messagewin;
1889 mainwin->win.sep_message.hpaned = hpaned;
1891 gtk_widget_show_all(messagewin);
1893 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1894 * lose track of its visibility state */
1895 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1896 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1899 gtk_box_pack_start(GTK_BOX(vbox_body),
1900 GTK_WIDGET_PTR(mainwin->summaryview),
1902 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1903 prefs_common.summaryview_width,
1904 prefs_common.summaryview_height);
1905 gtk_widget_set_usize(mainwin->window,
1906 prefs_common.mainview_width,
1907 prefs_common.mainwin_height);
1908 gtk_container_add(GTK_CONTAINER(folderwin),
1909 GTK_WIDGET_PTR(mainwin->folderview));
1910 gtk_container_add(GTK_CONTAINER(messagewin),
1911 GTK_WIDGET_PTR(mainwin->messageview));
1913 mainwin->win.sep_both.folderwin = folderwin;
1914 mainwin->win.sep_both.messagewin = messagewin;
1916 gtk_widget_show_all(folderwin);
1917 gtk_widget_show_all(messagewin);
1919 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1920 * lose track of its visibility state */
1921 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1922 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1926 /* rehide quick search if necessary */
1927 if (!prefs_common.show_searchbar)
1928 gtk_widget_hide(mainwin->summaryview->hbox_search);
1930 mainwin->type = type;
1932 mainwin->messageview->visible = TRUE;
1934 /* toggle menu state */
1935 menuitem = gtk_item_factory_get_item
1936 (ifactory, "/View/Show or hide/Folder tree");
1937 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1938 menuitem = gtk_item_factory_get_item
1939 (ifactory, "/View/Show or hide/Message view");
1940 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1942 menuitem = gtk_item_factory_get_item
1943 (ifactory, "/View/Separate folder tree");
1944 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1945 ((type & SEPARATE_FOLDER) != 0));
1946 menuitem = gtk_item_factory_get_item
1947 (ifactory, "/View/Separate message view");
1948 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1949 ((type & SEPARATE_MESSAGE) != 0));
1951 debug_print("done.\n");
1954 void main_window_destroy_all(void)
1956 while (mainwin_list != NULL) {
1957 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1959 /* free toolbar stuff */
1960 toolbar_clear_list(TOOLBAR_MAIN);
1961 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1962 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1964 g_free(mainwin->toolbar);
1967 mainwin_list = g_list_remove(mainwin_list, mainwin);
1969 g_list_free(mainwin_list);
1973 static void toolbar_account_button_pressed(GtkWidget *widget,
1974 GdkEventButton *event,
1977 MainWindow *mainwin = (MainWindow *)data;
1980 if (event->button != 3) return;
1982 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1983 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1986 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1987 menu_button_position, widget,
1988 event->button, event->time);
1992 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1995 MainWindow *mainwin = (MainWindow *)data;
1999 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2000 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2003 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2004 menu_button_position, widget,
2005 event->button, event->time);
2008 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2010 MainWindow *mainwin = (MainWindow *)data;
2013 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2014 if (!button) return;
2015 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2016 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2017 manage_window_focus_in(mainwin->window, NULL, NULL);
2020 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2023 MainWindow *mainwin = (MainWindow *)data;
2025 if (mainwin->lock_count == 0)
2026 app_exit_cb(data, 0, widget);
2031 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2034 MainWindow *mainwin = (MainWindow *)data;
2035 GtkWidget *menuitem;
2037 menuitem = gtk_item_factory_get_item
2038 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2039 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2044 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2047 MainWindow *mainwin = (MainWindow *)data;
2048 GtkWidget *menuitem;
2050 menuitem = gtk_item_factory_get_item
2051 (mainwin->menu_factory, "/View/Show or hide/Message view");
2052 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2057 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2060 main_window_add_mailbox(mainwin);
2063 static void add_mbox_cb(MainWindow *mainwin, guint action,
2066 main_window_add_mbox(mainwin);
2069 static void update_folderview_cb(MainWindow *mainwin, guint action,
2072 summary_show(mainwin->summaryview, NULL);
2073 folderview_check_new_all();
2076 static void new_folder_cb(MainWindow *mainwin, guint action,
2079 folderview_new_folder(mainwin->folderview);
2082 static void rename_folder_cb(MainWindow *mainwin, guint action,
2085 folderview_rename_folder(mainwin->folderview);
2088 static void delete_folder_cb(MainWindow *mainwin, guint action,
2091 folderview_delete_folder(mainwin->folderview);
2094 static void import_mbox_cb(MainWindow *mainwin, guint action,
2097 import_mbox(mainwin->summaryview->folder_item);
2100 static void export_mbox_cb(MainWindow *mainwin, guint action,
2103 export_mbox(mainwin->summaryview->folder_item);
2106 static void empty_trash_cb(MainWindow *mainwin, guint action,
2109 main_window_empty_trash(mainwin, TRUE);
2112 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2114 summary_save_as(mainwin->summaryview);
2117 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2119 summary_print(mainwin->summaryview);
2122 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2124 if (prefs_common.confirm_on_exit) {
2125 if (alertpanel(_("Exit"), _("Exit this program?"),
2126 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2128 manage_window_focus_in(mainwin->window, NULL, NULL);
2131 app_will_exit(widget, mainwin);
2134 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2137 summary_search(mainwin->summaryview);
2139 message_search(mainwin->messageview);
2142 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2147 active = GTK_CHECK_MENU_ITEM(widget)->active;
2149 switch (mainwin->type) {
2151 case SEPARATE_MESSAGE:
2154 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2156 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2159 case SEPARATE_FOLDER:
2160 debug_print("separate folder\n");
2162 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2164 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2168 gtk_widget_show(mainwin->win.sep_both.folderwin);
2170 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2175 static void toggle_message_cb(MainWindow *mainwin, guint action,
2180 active = GTK_CHECK_MENU_ITEM(widget)->active;
2182 if (active != messageview_is_visible(mainwin->messageview))
2183 summary_toggle_view(mainwin->summaryview);
2186 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2189 toolbar_toggle(action, mainwin);
2192 void main_window_reply_cb(MainWindow *mainwin, guint action,
2195 MessageView *msgview = (MessageView*)mainwin->messageview;
2196 GSList *msginfo_list = NULL;
2199 g_return_if_fail(msgview != NULL);
2201 msginfo_list = summary_get_selection(mainwin->summaryview);
2202 g_return_if_fail(msginfo_list != NULL);
2204 body = messageview_get_selection(msgview);
2205 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2207 g_slist_free(msginfo_list);
2211 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2214 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2215 gtk_widget_show(mainwin->hbox_stat);
2216 prefs_common.show_statusbar = TRUE;
2218 gtk_widget_hide(mainwin->hbox_stat);
2219 prefs_common.show_statusbar = FALSE;
2223 static void separate_widget_cb(MainWindow *mainwin, guint action,
2228 if (GTK_CHECK_MENU_ITEM(widget)->active)
2229 type = mainwin->type | action;
2231 type = mainwin->type & ~action;
2233 main_window_separation_change(mainwin, type);
2235 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2236 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2239 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2242 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2244 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2247 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2249 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2252 static void online_switch_clicked (GtkButton *btn, gpointer data)
2254 MainWindow *mainwin;
2255 GtkItemFactory *ifactory;
2256 GtkCheckMenuItem *menuitem;
2258 mainwin = (MainWindow *) data;
2260 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2261 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2263 g_return_if_fail(mainwin != NULL);
2264 g_return_if_fail(menuitem != NULL);
2266 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2268 gtk_widget_hide (mainwin->online_switch);
2269 gtk_widget_show (mainwin->offline_switch);
2270 menuitem->active = TRUE;
2271 prefs_common.work_offline = TRUE;
2272 inc_autocheck_timer_remove();
2275 gtk_widget_hide (mainwin->offline_switch);
2276 gtk_widget_show (mainwin->online_switch);
2277 menuitem->active = FALSE;
2278 prefs_common.work_offline = FALSE;
2279 inc_autocheck_timer_set();
2283 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2286 addressbook_open(NULL);
2289 static void log_window_show_cb(MainWindow *mainwin, guint action,
2292 log_window_show(mainwin->logwin);
2295 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2300 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2302 summary_move_to(mainwin->summaryview);
2305 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2307 summary_copy_to(mainwin->summaryview);
2310 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2312 summary_delete(mainwin->summaryview);
2315 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2317 summary_cancel(mainwin->summaryview);
2320 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2322 summary_open_msg(mainwin->summaryview);
2325 static void view_source_cb(MainWindow *mainwin, guint action,
2328 summary_view_source(mainwin->summaryview);
2331 static void show_all_header_cb(MainWindow *mainwin, guint action,
2334 if (mainwin->menu_lock_count) return;
2335 summary_display_msg_selected(mainwin->summaryview,
2336 GTK_CHECK_MENU_ITEM(widget)->active);
2339 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2341 summary_reedit(mainwin->summaryview);
2344 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2346 summary_mark(mainwin->summaryview);
2349 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2351 summary_unmark(mainwin->summaryview);
2354 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2357 summary_mark_as_unread(mainwin->summaryview);
2360 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2363 summary_mark_as_read(mainwin->summaryview);
2366 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2369 summary_mark_all_read(mainwin->summaryview);
2372 static void add_address_cb(MainWindow *mainwin, guint action,
2375 summary_add_address(mainwin->summaryview);
2378 static void set_charset_cb(MainWindow *mainwin, guint action,
2383 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2384 str = conv_get_charset_str((CharSet)action);
2385 g_free(prefs_common.force_charset);
2386 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2388 summary_redisplay_msg(mainwin->summaryview);
2390 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2394 static void hide_read_messages (MainWindow *mainwin, guint action,
2397 if (!mainwin->summaryview->folder_item
2398 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2400 summary_toggle_show_read_messages(mainwin->summaryview);
2403 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2405 if (mainwin->menu_lock_count) return;
2406 if (!mainwin->summaryview->folder_item) return;
2408 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2409 summary_thread_build(mainwin->summaryview);
2410 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2412 summary_unthread(mainwin->summaryview);
2413 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2417 static void expand_threads_cb(MainWindow *mainwin, guint action,
2420 summary_expand_threads(mainwin->summaryview);
2423 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2426 summary_collapse_threads(mainwin->summaryview);
2429 static void set_display_item_cb(MainWindow *mainwin, guint action,
2432 prefs_summary_column_open();
2435 static void sort_summary_cb(MainWindow *mainwin, guint action,
2438 FolderItem *item = mainwin->summaryview->folder_item;
2439 GtkWidget *menuitem;
2441 if (mainwin->menu_lock_count) return;
2443 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2444 menuitem = gtk_item_factory_get_item
2445 (mainwin->menu_factory, "/View/Sort/Ascending");
2446 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2447 GTK_CHECK_MENU_ITEM(menuitem)->active
2448 ? SORT_ASCENDING : SORT_DESCENDING);
2452 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2455 FolderItem *item = mainwin->summaryview->folder_item;
2457 if (mainwin->menu_lock_count) return;
2459 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2460 summary_sort(mainwin->summaryview,
2461 item->sort_key, (FolderSortType)action);
2464 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2467 summary_attract_by_subject(mainwin->summaryview);
2470 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2473 summary_delete_duplicated(mainwin->summaryview);
2476 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2478 summary_filter(mainwin->summaryview);
2481 static void execute_summary_cb(MainWindow *mainwin, guint action,
2484 summary_execute(mainwin->summaryview);
2487 static void update_summary_cb(MainWindow *mainwin, guint action,
2491 FolderView *folderview = mainwin->folderview;
2493 if (!mainwin->summaryview->folder_item) return;
2494 if (!folderview->opened) return;
2496 folder_update_op_count();
2498 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2499 folderview->opened);
2502 folder_item_scan(fitem);
2503 summary_show(mainwin->summaryview, fitem);
2506 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2508 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2511 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2513 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2516 static void prev_unread_cb(MainWindow *mainwin, guint action,
2519 summary_select_prev_unread(mainwin->summaryview);
2522 static void next_unread_cb(MainWindow *mainwin, guint action,
2525 summary_select_next_unread(mainwin->summaryview);
2528 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2530 summary_select_prev_new(mainwin->summaryview);
2533 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2535 summary_select_next_new(mainwin->summaryview);
2538 static void prev_marked_cb(MainWindow *mainwin, guint action,
2541 summary_select_prev_marked(mainwin->summaryview);
2544 static void next_marked_cb(MainWindow *mainwin, guint action,
2547 summary_select_next_marked(mainwin->summaryview);
2550 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2553 summary_select_prev_labeled(mainwin->summaryview);
2556 static void next_labeled_cb(MainWindow *mainwin, guint action,
2559 summary_select_next_labeled(mainwin->summaryview);
2562 static void goto_folder_cb(MainWindow *mainwin, guint action,
2565 FolderItem *to_folder;
2567 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2570 folderview_select(mainwin->folderview, to_folder);
2573 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2575 messageview_copy_clipboard(mainwin->messageview);
2578 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2580 MessageView *msgview = mainwin->messageview;
2582 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2583 summary_select_all(mainwin->summaryview);
2584 else if (messageview_is_visible(msgview) &&
2585 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2586 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2587 messageview_select_all(mainwin->messageview);
2590 static void select_thread_cb(MainWindow *mainwin, guint action,
2593 summary_select_thread(mainwin->summaryview);
2596 static void create_filter_cb(MainWindow *mainwin, guint action,
2599 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2602 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2605 prefs_common_open();
2608 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2611 prefs_scoring_open(NULL);
2614 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2617 prefs_filtering_open(NULL, NULL, NULL);
2620 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2623 prefs_template_open();
2626 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2629 prefs_actions_open(mainwin);
2632 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2635 ssl_manager_open(mainwin);
2638 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2642 new_account_cb(mainwin, 0, widget);
2644 account_open(cur_account);
2648 static void new_account_cb(MainWindow *mainwin, guint action,
2651 account_edit_open();
2652 if (!compose_get_compose_list()) account_add();
2655 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2657 cur_account = (PrefsAccount *)data;
2658 main_window_reflect_prefs_all();
2661 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2666 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2668 pluginwindow_create();
2671 static void manual_open_cb(MainWindow *mainwin, guint action,
2674 manual_open((ManualType)action);
2677 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2679 MainWindow *mainwin = (MainWindow *)data;
2683 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2684 LOCAL_FOLDER(folder)->rootpath,
2688 str = g_strdup_printf(_("Scanning folder %s ..."),
2689 LOCAL_FOLDER(folder)->rootpath);
2691 STATUSBAR_PUSH(mainwin, str);
2692 STATUSBAR_POP(mainwin);
2696 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2699 SummaryView *summary;
2701 g_return_val_if_fail(data, FALSE);
2702 summary = ((MainWindow *)data)->summaryview;
2703 g_return_val_if_fail(summary, FALSE);
2704 if (summary->selected != summary->displayed)
2705 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2709 #define BREAK_ON_MODIFIER_KEY() \
2710 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2712 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2715 MainWindow *mainwin = (MainWindow*) data;
2717 if (!mainwin || !event) return;
2719 switch (event->keyval) {
2720 case GDK_Q: /* Quit */
2721 BREAK_ON_MODIFIER_KEY();
2723 app_exit_cb(mainwin, 0, NULL);
2726 if (mainwin->folderview && mainwin->summaryview
2727 && !mainwin->summaryview->displayed) {
2728 summary_lock(mainwin->summaryview);
2729 folderview_select_next_unread(mainwin->folderview);
2730 summary_unlock(mainwin->summaryview);
2738 #undef BREAK_ON_MODIFIER_KEY
2741 * Harvest addresses for selected folder.
2743 static void addr_harvest_cb( MainWindow *mainwin,
2747 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2751 * Harvest addresses for selected messages in summary view.
2753 static void addr_harvest_msg_cb( MainWindow *mainwin,
2757 summary_harvest_address( mainwin->summaryview );
2761 *\brief get a MainWindow
2763 *\return MainWindow * The first mainwindow in the mainwin_list
2765 MainWindow *mainwindow_get_mainwindow(void)
2767 if (mainwin_list && mainwin_list->data)
2768 return (MainWindow *)(mainwin_list->data);
2773 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2775 ProgressData *data = (ProgressData *) source;
2776 MainWindow *mainwin = (MainWindow *) userdata;
2778 switch (data->cmd) {
2779 case PROGRESS_COMMAND_START:
2780 case PROGRESS_COMMAND_STOP:
2781 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2783 case PROGRESS_COMMAND_SET_PERCENTAGE:
2784 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2787 while (gtk_events_pending()) gtk_main_iteration ();