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_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"
90 #define AC_LABEL_WIDTH 240
92 /* list of all instantiated MainWindow */
93 static GList *mainwin_list = NULL;
95 static GdkCursor *watch_cursor;
97 static void main_window_menu_callback_block (MainWindow *mainwin);
98 static void main_window_menu_callback_unblock (MainWindow *mainwin);
100 static void main_window_show_cur_account (MainWindow *mainwin);
102 static void main_window_set_widgets (MainWindow *mainwin,
106 static void toolbar_account_button_pressed (GtkWidget *widget,
107 GdkEventButton *event,
110 static void ac_label_button_pressed (GtkWidget *widget,
111 GdkEventButton *event,
113 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
116 static gint main_window_close_cb (GtkWidget *widget,
119 static gint folder_window_close_cb (GtkWidget *widget,
122 static gint message_window_close_cb (GtkWidget *widget,
126 static void new_folder_cb (MainWindow *mainwin,
129 static void add_mbox_cb (MainWindow *mainwin,
132 static void rename_folder_cb (MainWindow *mainwin,
135 static void delete_folder_cb (MainWindow *mainwin,
138 static void update_folderview_cb (MainWindow *mainwin,
141 static void add_mailbox_cb (MainWindow *mainwin,
144 static void import_mbox_cb (MainWindow *mainwin,
147 static void export_mbox_cb (MainWindow *mainwin,
150 static void empty_trash_cb (MainWindow *mainwin,
154 static void save_as_cb (MainWindow *mainwin,
157 static void print_cb (MainWindow *mainwin,
160 static void app_exit_cb (MainWindow *mainwin,
164 static void search_cb (MainWindow *mainwin,
168 static void toggle_folder_cb (MainWindow *mainwin,
171 static void toggle_message_cb (MainWindow *mainwin,
174 static void toggle_toolbar_cb (MainWindow *mainwin,
177 static void toggle_statusbar_cb (MainWindow *mainwin,
180 static void separate_widget_cb (MainWindow *mainwin,
184 static void addressbook_open_cb (MainWindow *mainwin,
187 static void log_window_show_cb (MainWindow *mainwin,
191 static void inc_cancel_cb (MainWindow *mainwin,
195 static void open_msg_cb (MainWindow *mainwin,
199 static void view_source_cb (MainWindow *mainwin,
203 static void show_all_header_cb (MainWindow *mainwin,
207 static void reedit_cb (MainWindow *mainwin,
211 static void move_to_cb (MainWindow *mainwin,
214 static void copy_to_cb (MainWindow *mainwin,
217 static void delete_cb (MainWindow *mainwin,
221 static void cancel_cb (MainWindow *mainwin,
225 static void mark_cb (MainWindow *mainwin,
228 static void unmark_cb (MainWindow *mainwin,
232 static void mark_as_unread_cb (MainWindow *mainwin,
235 static void mark_as_read_cb (MainWindow *mainwin,
238 static void mark_all_read_cb (MainWindow *mainwin,
241 static void add_address_cb (MainWindow *mainwin,
245 static void set_charset_cb (MainWindow *mainwin,
249 static void hide_read_messages (MainWindow *mainwin,
253 static void thread_cb (MainWindow *mainwin,
256 static void expand_threads_cb (MainWindow *mainwin,
259 static void collapse_threads_cb (MainWindow *mainwin,
263 static void set_display_item_cb (MainWindow *mainwin,
266 static void sort_summary_cb (MainWindow *mainwin,
269 static void sort_summary_type_cb (MainWindow *mainwin,
272 static void attract_by_subject_cb(MainWindow *mainwin,
276 static void delete_duplicated_cb (MainWindow *mainwin,
279 static void filter_cb (MainWindow *mainwin,
282 static void execute_summary_cb (MainWindow *mainwin,
285 static void update_summary_cb (MainWindow *mainwin,
289 static void prev_cb (MainWindow *mainwin,
292 static void next_cb (MainWindow *mainwin,
295 static void next_unread_cb (MainWindow *mainwin,
298 static void prev_unread_cb (MainWindow *mainwin,
302 static void prev_new_cb (MainWindow *mainwin,
305 static void next_new_cb (MainWindow *mainwin,
308 static void prev_marked_cb (MainWindow *mainwin,
311 static void next_marked_cb (MainWindow *mainwin,
314 static void prev_labeled_cb (MainWindow *mainwin,
317 static void next_labeled_cb (MainWindow *mainwin,
321 static void goto_folder_cb (MainWindow *mainwin,
325 static void copy_cb (MainWindow *mainwin,
328 static void allsel_cb (MainWindow *mainwin,
331 static void select_thread_cb (MainWindow *mainwin,
335 static void create_filter_cb (MainWindow *mainwin,
339 static void prefs_common_open_cb (MainWindow *mainwin,
342 static void prefs_template_open_cb (MainWindow *mainwin,
345 static void prefs_actions_open_cb (MainWindow *mainwin,
348 static void prefs_account_open_cb (MainWindow *mainwin,
351 static void prefs_scoring_open_cb (MainWindow *mainwin,
354 static void prefs_filtering_open_cb (MainWindow *mainwin,
358 static void ssl_manager_open_cb (MainWindow *mainwin,
362 static void new_account_cb (MainWindow *mainwin,
366 static void account_menu_cb (GtkMenuItem *menuitem,
369 static void prefs_open_cb (GtkMenuItem *menuitem,
371 static void plugins_open_cb (GtkMenuItem *menuitem,
374 static void online_switch_clicked(GtkButton *btn,
377 static void manual_open_cb (MainWindow *mainwin,
381 static void scan_tree_func (Folder *folder,
385 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
387 static void addr_harvest_cb ( MainWindow *mainwin,
391 static void addr_harvest_msg_cb ( MainWindow *mainwin,
395 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
396 GdkEventFocus *focus,
398 void main_window_reply_cb (MainWindow *mainwin,
401 gboolean mainwindow_progressindicator_hook (gpointer source,
403 #define SEPARATE_ACTION 500
405 static GtkItemFactoryEntry mainwin_entries[] =
407 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
408 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
409 {N_("/_File/_Folder/Create _new folder..."),
410 NULL, new_folder_cb, 0, NULL},
411 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
412 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
413 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
414 {N_("/_File/_Folder/_Check for new messages in all folders"),
415 NULL, update_folderview_cb, 0, NULL},
416 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
417 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
418 {N_("/_File/_Add mailbox/mbox..."), 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/_Claws FAQ (Claws Documentation)"),
702 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
703 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
707 MainWindow *main_window_create(SeparateType type)
713 GtkWidget *handlebox;
714 GtkWidget *vbox_body;
715 GtkWidget *hbox_stat;
716 GtkWidget *statusbar;
717 GtkWidget *progressbar;
718 GtkWidget *statuslabel;
719 GtkWidget *ac_button;
721 GtkWidget *online_pixmap;
722 GtkWidget *offline_pixmap;
723 GtkWidget *online_switch;
724 GtkWidget *offline_switch;
725 GtkTooltips *offline_tip;
726 GtkTooltips *online_tip;
727 GtkTooltips *sel_ac_tip;
729 FolderView *folderview;
730 SummaryView *summaryview;
731 MessageView *messageview;
732 GdkColormap *colormap;
735 GtkItemFactory *ifactory;
739 guint n_menu_entries;
741 static GdkGeometry geometry;
743 debug_print("Creating main window...\n");
744 mainwin = g_new0(MainWindow, 1);
747 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
748 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
749 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
750 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
752 if (!geometry.min_height) {
753 geometry.min_width = 320;
754 geometry.min_height = 200;
756 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
759 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
760 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
761 MANAGE_WINDOW_SIGNALS_CONNECT(window);
762 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
763 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
765 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
766 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
768 gtk_widget_realize(window);
769 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
772 gtkut_widget_set_app_icon(window);
774 vbox = gtk_vbox_new(FALSE, 0);
775 gtk_widget_show(vbox);
776 gtk_container_add(GTK_CONTAINER(window), vbox);
779 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
780 menubar = menubar_create(window, mainwin_entries,
781 n_menu_entries, "<Main>", mainwin);
782 gtk_widget_show(menubar);
783 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
784 ifactory = gtk_item_factory_from_widget(menubar);
786 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
787 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
789 handlebox = gtk_handle_box_new();
790 gtk_widget_show(handlebox);
791 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
793 /* link window to mainwin->window to avoid gdk warnings */
794 mainwin->window = window;
797 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
801 /* vbox that contains body */
802 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
803 gtk_widget_show(vbox_body);
804 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
805 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
807 hbox_stat = gtk_hbox_new(FALSE, 2);
808 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
810 statusbar = statusbar_create();
811 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
813 progressbar = gtk_progress_bar_new();
814 gtk_widget_set_usize(progressbar, 120, 1);
815 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
817 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
818 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
819 online_tip = gtk_tooltips_new();
820 online_switch = gtk_button_new ();
821 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
822 online_switch, _("Go offline"), NULL);
823 offline_tip = gtk_tooltips_new();
824 offline_switch = gtk_button_new ();
825 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
826 offline_switch, _("Go online"), NULL);
827 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
828 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
829 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
830 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
831 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
832 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
833 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
834 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
836 statuslabel = gtk_label_new("");
837 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
839 sel_ac_tip = gtk_tooltips_new();
840 ac_button = gtk_button_new();
841 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
842 ac_button, _("Select account"), NULL);
843 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
844 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
845 gtk_widget_set_usize(ac_button, -1, 1);
846 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
847 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
848 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
850 ac_label = gtk_label_new("");
851 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
853 gtk_widget_show_all(hbox_stat);
855 gtk_widget_hide(offline_switch);
857 mainwin->folderview = folderview = folderview_create();
858 mainwin->summaryview = summaryview = summary_create();
859 mainwin->messageview = messageview = messageview_create(mainwin);
860 mainwin->logwin = log_window_create();
862 folderview->mainwin = mainwin;
863 folderview->summaryview = summaryview;
865 summaryview->mainwin = mainwin;
866 summaryview->folderview = folderview;
867 summaryview->messageview = messageview;
868 summaryview->window = window;
870 mainwin->vbox = vbox;
871 mainwin->menubar = menubar;
872 mainwin->menu_factory = ifactory;
873 mainwin->handlebox = handlebox;
874 mainwin->vbox_body = vbox_body;
875 mainwin->hbox_stat = hbox_stat;
876 mainwin->statusbar = statusbar;
877 mainwin->progressbar = progressbar;
878 mainwin->statuslabel = statuslabel;
879 mainwin->ac_button = ac_button;
880 mainwin->ac_label = ac_label;
882 mainwin->online_switch = online_switch;
883 mainwin->offline_switch = offline_switch;
884 mainwin->online_pixmap = online_pixmap;
885 mainwin->offline_pixmap = offline_pixmap;
887 /* set context IDs for status bar */
888 mainwin->mainwin_cid = gtk_statusbar_get_context_id
889 (GTK_STATUSBAR(statusbar), "Main Window");
890 mainwin->folderview_cid = gtk_statusbar_get_context_id
891 (GTK_STATUSBAR(statusbar), "Folder View");
892 mainwin->summaryview_cid = gtk_statusbar_get_context_id
893 (GTK_STATUSBAR(statusbar), "Summary View");
895 /* allocate colors for summary view and folder view */
896 summaryview->color_marked.red = summaryview->color_marked.green = 0;
897 summaryview->color_marked.blue = (guint16)65535;
899 summaryview->color_dim.red = summaryview->color_dim.green =
900 summaryview->color_dim.blue = COLOR_DIM;
902 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
903 &folderview->color_new);
905 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
906 &folderview->color_op);
908 summaryview->color_important.red = 0;
909 summaryview->color_important.green = 0;
910 summaryview->color_important.blue = (guint16)65535;
912 color[0] = summaryview->color_marked;
913 color[1] = summaryview->color_dim;
914 color[2] = folderview->color_new;
915 color[3] = folderview->color_op;
917 colormap = gdk_window_get_colormap(window->window);
918 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
919 for (i = 0; i < 4; i++) {
920 if (success[i] == FALSE)
921 g_warning("MainWindow: color allocation %d failed\n", i);
924 debug_print("done.\n");
926 messageview->visible = TRUE;
928 main_window_set_widgets(mainwin, type);
931 menuitem = gtk_item_factory_get_item
932 (ifactory, "/View/Code set/Auto detect");
933 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
935 switch (prefs_common.toolbar_style) {
937 menuitem = gtk_item_factory_get_item
938 (ifactory, "/View/Show or hide/Toolbar/None");
941 menuitem = gtk_item_factory_get_item
942 (ifactory, "/View/Show or hide/Toolbar/Icon");
945 menuitem = gtk_item_factory_get_item
946 (ifactory, "/View/Show or hide/Toolbar/Text");
949 menuitem = gtk_item_factory_get_item
950 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
952 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
954 gtk_widget_hide(mainwin->hbox_stat);
955 menuitem = gtk_item_factory_get_item
956 (ifactory, "/View/Show or hide/Status bar");
957 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
958 prefs_common.show_statusbar);
960 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
962 if (prefs_common.show_searchbar) {
963 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
964 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
965 gtk_widget_hide(summaryview->search_description);
968 /* set account selection menu */
969 ac_menu = gtk_item_factory_get_widget
970 (ifactory, "/Configuration/Change current account");
971 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
972 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
973 mainwin->ac_menu = ac_menu;
975 toolbar_main_set_sensitive(mainwin);
977 /* create actions menu */
978 action_update_mainwin_menu(ifactory, mainwin);
980 /* attach accel groups to main window */
981 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
982 gtk_window_add_accel_group \
984 gtk_item_factory_from_widget(menu)->accel_group)
986 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
988 /* connect the accelerators for equivalent
989 menu items in different menus */
990 menu_connect_identical_items();
994 /* show main window */
995 gtk_widget_set_uposition(mainwin->window,
996 prefs_common.mainwin_x,
997 prefs_common.mainwin_y);
998 gtk_widget_set_usize(window, prefs_common.mainwin_width,
999 prefs_common.mainwin_height);
1000 gtk_widget_show(mainwin->window);
1002 /* initialize views */
1003 folderview_init(folderview);
1004 summary_init(summaryview);
1005 messageview_init(messageview);
1006 log_window_init(mainwin->logwin);
1008 sslcertwindow_register_hook();
1010 mainwin->lock_count = 0;
1011 mainwin->menu_lock_count = 0;
1012 mainwin->cursor_count = 0;
1014 mainwin->progressindicator_hook =
1015 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1018 watch_cursor = gdk_cursor_new(GDK_WATCH);
1020 mainwin_list = g_list_append(mainwin_list, mainwin);
1022 /* init work_offline */
1023 if (prefs_common.work_offline)
1024 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1029 void main_window_cursor_wait(MainWindow *mainwin)
1032 if (mainwin->cursor_count == 0)
1033 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1035 mainwin->cursor_count++;
1040 void main_window_cursor_normal(MainWindow *mainwin)
1042 if (mainwin->cursor_count)
1043 mainwin->cursor_count--;
1045 if (mainwin->cursor_count == 0)
1046 gdk_window_set_cursor(mainwin->window->window, NULL);
1051 /* lock / unlock the user-interface */
1052 void main_window_lock(MainWindow *mainwin)
1054 if (mainwin->lock_count == 0)
1055 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1057 mainwin->lock_count++;
1059 main_window_set_menu_sensitive(mainwin);
1060 toolbar_main_set_sensitive(mainwin);
1063 void main_window_unlock(MainWindow *mainwin)
1065 if (mainwin->lock_count)
1066 mainwin->lock_count--;
1068 main_window_set_menu_sensitive(mainwin);
1069 toolbar_main_set_sensitive(mainwin);
1071 if (mainwin->lock_count == 0)
1072 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1075 static void main_window_menu_callback_block(MainWindow *mainwin)
1077 mainwin->menu_lock_count++;
1080 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1082 if (mainwin->menu_lock_count)
1083 mainwin->menu_lock_count--;
1086 void main_window_reflect_prefs_all(void)
1088 main_window_reflect_prefs_all_real(FALSE);
1091 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1094 MainWindow *mainwin;
1097 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1098 mainwin = (MainWindow *)cur->data;
1100 main_window_show_cur_account(mainwin);
1101 main_window_set_menu_sensitive(mainwin);
1102 toolbar_main_set_sensitive(mainwin);
1105 if (pixmap_theme_changed) {
1106 toolbar_update(TOOLBAR_MAIN, mainwin);
1107 messageview_reflect_prefs_pixmap_theme();
1108 compose_reflect_prefs_pixmap_theme();
1109 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1110 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1112 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1113 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1114 mainwin->online_pixmap);
1115 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1116 gtk_widget_show(pixmap);
1117 mainwin->online_pixmap = pixmap;
1118 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1119 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1120 mainwin->offline_pixmap);
1121 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1122 gtk_widget_show(pixmap);
1123 mainwin->offline_pixmap = pixmap;
1126 summary_redisplay_msg(mainwin->summaryview);
1127 headerview_set_visibility(mainwin->messageview->headerview,
1128 prefs_common.display_header_pane);
1132 void main_window_set_summary_column(void)
1135 MainWindow *mainwin;
1137 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1138 mainwin = (MainWindow *)cur->data;
1139 summary_set_column_order(mainwin->summaryview);
1143 void main_window_set_account_menu(GList *account_list)
1145 GList *cur, *cur_ac, *cur_item;
1146 GtkWidget *menuitem;
1147 MainWindow *mainwin;
1148 PrefsAccount *ac_prefs;
1150 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1151 mainwin = (MainWindow *)cur->data;
1153 /* destroy all previous menu item */
1154 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1155 while (cur_item != NULL) {
1156 GList *next = cur_item->next;
1157 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1161 for (cur_ac = account_list; cur_ac != NULL;
1162 cur_ac = cur_ac->next) {
1163 ac_prefs = (PrefsAccount *)cur_ac->data;
1165 menuitem = gtk_menu_item_new_with_label
1166 (ac_prefs->account_name
1167 ? ac_prefs->account_name : _("Untitled"));
1168 gtk_widget_show(menuitem);
1169 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1170 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1171 GTK_SIGNAL_FUNC(account_menu_cb),
1177 static void main_window_show_cur_account(MainWindow *mainwin)
1182 ac_name = g_strdup(cur_account
1183 ? (cur_account->account_name
1184 ? cur_account->account_name : _("Untitled"))
1188 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1190 buf = g_strdup(PROG_VERSION);
1191 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1194 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1195 gtk_widget_queue_resize(mainwin->ac_button);
1200 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1202 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1203 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1204 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1205 GtkWidget *message_wid = mainwin->messageview->vbox;
1207 debug_print("Changing window separation type from %d to %d\n",
1208 mainwin->type, type);
1210 if (mainwin->type == type) return;
1212 /* remove widgets from those containers */
1213 gtk_widget_ref(folder_wid);
1214 gtk_widget_ref(summary_wid);
1215 gtk_widget_ref(message_wid);
1216 gtkut_container_remove
1217 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1218 gtkut_container_remove
1219 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1220 gtkut_container_remove
1221 (GTK_CONTAINER(message_wid->parent), message_wid);
1223 /* clean containers */
1224 switch (mainwin->type) {
1226 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1228 case SEPARATE_FOLDER:
1229 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1230 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1232 case SEPARATE_MESSAGE:
1233 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1234 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1237 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1238 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1242 gtk_widget_hide(mainwin->window);
1243 main_window_set_widgets(mainwin, type);
1244 gtk_widget_show(mainwin->window);
1246 gtk_widget_unref(folder_wid);
1247 gtk_widget_unref(summary_wid);
1248 gtk_widget_unref(message_wid);
1251 void main_window_toggle_message_view(MainWindow *mainwin)
1253 SummaryView *summaryview = mainwin->summaryview;
1254 union CompositeWin *cwin = &mainwin->win;
1255 GtkWidget *vpaned = NULL;
1256 GtkWidget *container = NULL;
1257 GtkWidget *msgwin = NULL;
1259 switch (mainwin->type) {
1261 vpaned = cwin->sep_none.vpaned;
1262 container = cwin->sep_none.hpaned;
1264 case SEPARATE_FOLDER:
1265 vpaned = cwin->sep_folder.vpaned;
1266 container = mainwin->vbox_body;
1268 case SEPARATE_MESSAGE:
1269 msgwin = mainwin->win.sep_message.messagewin;
1272 msgwin = mainwin->win.sep_both.messagewin;
1277 if (GTK_WIDGET_VISIBLE(msgwin)) {
1278 gtk_widget_hide(msgwin);
1279 mainwin->messageview->visible = FALSE;
1280 summaryview->displayed = NULL;
1282 gtk_widget_show(msgwin);
1283 mainwin->messageview->visible = TRUE;
1285 } else if (vpaned->parent != NULL) {
1286 mainwin->messageview->visible = FALSE;
1287 summaryview->displayed = NULL;
1288 gtk_widget_ref(vpaned);
1289 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1290 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1291 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1292 GTK_ARROW_UP, GTK_SHADOW_OUT);
1294 mainwin->messageview->visible = TRUE;
1295 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1296 gtk_container_add(GTK_CONTAINER(container), vpaned);
1297 gtk_widget_unref(vpaned);
1298 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1299 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1302 main_window_set_menu_sensitive(mainwin);
1304 gtk_widget_grab_focus(summaryview->ctree);
1307 void main_window_get_size(MainWindow *mainwin)
1309 GtkAllocation *allocation;
1311 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1313 prefs_common.summaryview_width = allocation->width;
1315 if ((mainwin->type == SEPARATE_NONE ||
1316 mainwin->type == SEPARATE_FOLDER) &&
1317 messageview_is_visible(mainwin->messageview))
1318 prefs_common.summaryview_height = allocation->height;
1320 prefs_common.mainview_width = allocation->width;
1322 allocation = &mainwin->window->allocation;
1324 prefs_common.mainview_height = allocation->height;
1325 prefs_common.mainwin_width = allocation->width;
1326 prefs_common.mainwin_height = allocation->height;
1328 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1330 prefs_common.folderview_width = allocation->width;
1331 prefs_common.folderview_height = allocation->height;
1334 void main_window_get_position(MainWindow *mainwin)
1338 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1340 prefs_common.mainview_x = x;
1341 prefs_common.mainview_y = y;
1342 prefs_common.mainwin_x = x;
1343 prefs_common.mainwin_y = y;
1345 debug_print("window position: x = %d, y = %d\n", x, y);
1348 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1354 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1355 folder = FOLDER(list->data);
1356 if (folder && folder->trash && folder->trash->total_msgs > 0)
1360 if (!has_trash) return;
1363 if (alertpanel(_("Empty trash"),
1364 _("Empty all messages in trash?"),
1365 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1367 manage_window_focus_in(mainwin->window, NULL, NULL);
1370 procmsg_empty_trash();
1372 if (mainwin->summaryview->folder_item &&
1373 mainwin->summaryview->folder_item->stype == F_TRASH)
1374 gtk_widget_grab_focus(mainwin->folderview->ctree);
1377 void main_window_add_mailbox(MainWindow *mainwin)
1382 path = input_dialog(_("Add mailbox"),
1383 _("Input the location of mailbox.\n"
1384 "If the existing mailbox is specified, it will be\n"
1385 "scanned automatically."),
1388 if (folder_find_from_path(path)) {
1389 alertpanel_error(_("The mailbox `%s' already exists."), path);
1393 folder = folder_new(folder_get_class_from_string("mh"),
1394 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1398 if (folder->klass->create_tree(folder) < 0) {
1399 alertpanel_error(_("Creation of the mailbox failed.\n"
1400 "Maybe some files already exist, or you don't have the permission to write there."));
1401 folder_destroy(folder);
1406 folder_set_ui_func(folder, scan_tree_func, mainwin);
1407 folder_scan_tree(folder);
1408 folder_set_ui_func(folder, NULL, NULL);
1410 folderview_set(mainwin->folderview);
1413 void main_window_add_mbox(MainWindow *mainwin)
1419 path = input_dialog(_("Add mbox mailbox"),
1420 _("Input the location of mailbox."),
1425 if (folder_find_from_path(path)) {
1426 alertpanel_error(_("The mailbox `%s' already exists."), path);
1431 folder = folder_new(folder_get_class_from_string("mbox"),
1432 g_basename(path), path);
1435 if (folder->klass->create_tree(folder) < 0) {
1436 alertpanel_error(_("Creation of the mailbox failed."));
1437 folder_destroy(folder);
1443 item = folder_item_new(folder, folder->name, NULL);
1444 item->folder = folder;
1445 folder->node = g_node_new(item);
1447 folder_create_folder(item, "inbox");
1448 folder_create_folder(item, "outbox");
1449 folder_create_folder(item, "queue");
1450 folder_create_folder(item, "draft");
1451 folder_create_folder(item, "trash");
1453 folderview_set(mainwin->folderview);
1456 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1458 SensitiveCond state = 0;
1459 SummarySelection selection;
1460 FolderItem *item = mainwin->summaryview->folder_item;
1461 GList *account_list = account_get_list();
1463 selection = summary_get_selection_type(mainwin->summaryview);
1465 if (mainwin->lock_count == 0)
1466 state |= M_UNLOCKED;
1467 if (selection != SUMMARY_NONE)
1468 state |= M_MSG_EXIST;
1469 if (item && item->path && item->parent && !item->no_select) {
1471 /* if (item->folder->type != F_NEWS) */
1472 state |= M_ALLOW_DELETE;
1474 if (prefs_common.immediate_exec == 0
1475 && mainwin->lock_count == 0)
1476 state |= M_DELAY_EXEC;
1478 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1479 || selection != SUMMARY_NONE)
1480 state |= M_HIDE_READ_MSG;
1482 if (mainwin->summaryview->threaded)
1483 state |= M_THREADED;
1485 state |= M_UNTHREADED;
1486 if (selection == SUMMARY_SELECTED_SINGLE ||
1487 selection == SUMMARY_SELECTED_MULTIPLE)
1488 state |= M_TARGET_EXIST;
1489 if (selection == SUMMARY_SELECTED_SINGLE)
1490 state |= M_SINGLE_TARGET_EXIST;
1491 if (mainwin->summaryview->folder_item &&
1492 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1495 state |= M_NOT_NEWS;
1496 if (selection == SUMMARY_SELECTED_SINGLE &&
1498 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1499 item->stype == F_QUEUE)))
1500 state |= M_ALLOW_REEDIT;
1502 state |= M_HAVE_ACCOUNT;
1504 for ( ; account_list != NULL; account_list = account_list->next) {
1505 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1506 state |= M_HAVE_NEWS_ACCOUNT;
1511 if (inc_is_active())
1512 state |= M_INC_ACTIVE;
1519 void main_window_set_menu_sensitive(MainWindow *mainwin)
1521 GtkItemFactory *ifactory = mainwin->menu_factory;
1522 SensitiveCond state;
1524 GtkWidget *menuitem;
1525 SummaryView *summaryview;
1529 static const struct {
1533 {"/File/Folder" , M_UNLOCKED},
1534 {"/File/Add mailbox" , M_UNLOCKED},
1536 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1537 {"/File/Add mailbox/mbox..." , M_UNLOCKED},
1538 {"/File/Export to mbox file..." , M_UNLOCKED},
1539 {"/File/Empty trash" , M_UNLOCKED},
1540 {"/File/Work offline" , M_UNLOCKED},
1542 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1543 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1544 /* {"/File/Close" , M_UNLOCKED}, */
1545 {"/File/Exit" , M_UNLOCKED},
1547 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1549 {"/View/Sort" , M_EXEC},
1550 {"/View/Thread view" , M_EXEC},
1551 {"/View/Expand all threads" , M_MSG_EXIST},
1552 {"/View/Collapse all threads" , M_MSG_EXIST},
1553 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1554 {"/View/Go to/Prev message" , M_MSG_EXIST},
1555 {"/View/Go to/Next message" , M_MSG_EXIST},
1556 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1557 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1558 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1559 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1560 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1561 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1562 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1563 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1564 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1566 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1567 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1568 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1569 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1570 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1571 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1572 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1573 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1574 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1575 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1576 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1577 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1578 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1579 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1580 {"/Message/Mark" , M_TARGET_EXIST},
1582 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1583 {"/Tools/Harvest addresses" , M_UNLOCKED},
1584 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1585 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1586 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1587 {"/Tools/Execute" , M_DELAY_EXEC},
1588 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1590 {"/Configuration", M_UNLOCKED},
1595 state = main_window_get_current_state(mainwin);
1597 for (i = 0; entry[i].entry != NULL; i++) {
1598 sensitive = ((entry[i].cond & state) == entry[i].cond);
1599 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1602 main_window_menu_callback_block(mainwin);
1604 #define SET_CHECK_MENU_ACTIVE(path, active) \
1606 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1607 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1610 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1611 messageview_is_visible(mainwin->messageview));
1613 summaryview = mainwin->summaryview;
1614 menu_path = "/View/Sort/Don't sort";
1616 switch (summaryview->sort_key) {
1617 case SORT_BY_NUMBER:
1618 menu_path = "/View/Sort/by number"; break;
1620 menu_path = "/View/Sort/by size"; break;
1622 menu_path = "/View/Sort/by date"; break;
1624 menu_path = "/View/Sort/by from"; break;
1626 menu_path = "/View/Sort/by recipient"; break;
1627 case SORT_BY_SUBJECT:
1628 menu_path = "/View/Sort/by subject"; break;
1630 menu_path = "/View/Sort/by color label"; break;
1632 menu_path = "/View/Sort/by mark"; break;
1633 case SORT_BY_STATUS:
1634 menu_path = "/View/Sort/by status"; break;
1636 menu_path = "/View/Sort/by attachment"; break;
1638 menu_path = "/View/Sort/by score"; break;
1639 case SORT_BY_LOCKED:
1640 menu_path = "/View/Sort/by locked"; break;
1643 menu_path = "/View/Sort/Don't sort"; break;
1645 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1647 if (summaryview->sort_type == SORT_ASCENDING) {
1648 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1650 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1653 if (summaryview->sort_key != SORT_BY_NONE) {
1654 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1655 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1657 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1658 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1661 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1662 mainwin->messageview->textview->show_all_headers);
1663 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1665 #undef SET_CHECK_MENU_ACTIVE
1667 main_window_menu_callback_unblock(mainwin);
1670 void main_window_popup(MainWindow *mainwin)
1672 gtkut_window_popup(mainwin->window);
1674 switch (mainwin->type) {
1675 case SEPARATE_FOLDER:
1676 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1678 case SEPARATE_MESSAGE:
1679 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1682 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1683 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1690 void main_window_show(MainWindow *mainwin)
1692 gtk_widget_show(mainwin->window);
1693 gtk_widget_show(mainwin->vbox_body);
1695 switch (mainwin->type) {
1696 case SEPARATE_FOLDER:
1697 gtk_widget_show(mainwin->win.sep_folder.folderwin);
1699 case SEPARATE_MESSAGE:
1700 gtk_widget_show(mainwin->win.sep_message.messagewin);
1703 gtk_widget_show(mainwin->win.sep_both.folderwin);
1704 gtk_widget_show(mainwin->win.sep_both.messagewin);
1711 void main_window_hide(MainWindow *mainwin)
1713 gtk_widget_hide(mainwin->window);
1714 gtk_widget_hide(mainwin->vbox_body);
1716 switch (mainwin->type) {
1717 case SEPARATE_FOLDER:
1718 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1720 case SEPARATE_MESSAGE:
1721 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1724 gtk_widget_hide(mainwin->win.sep_both.folderwin);
1725 gtk_widget_hide(mainwin->win.sep_both.messagewin);
1732 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1734 GtkWidget *folderwin = NULL;
1735 GtkWidget *messagewin = NULL;
1738 GtkWidget *vbox_body = mainwin->vbox_body;
1739 GtkItemFactory *ifactory = mainwin->menu_factory;
1740 GtkWidget *menuitem;
1741 GtkItemFactory *msgview_ifactory;
1743 debug_print("Setting widgets...");
1745 /* create separated window(s) if needed */
1746 if (type & SEPARATE_FOLDER) {
1747 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1748 gtk_window_set_title(GTK_WINDOW(folderwin),
1749 _("Sylpheed - Folder View"));
1750 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1751 "folder_view", "Sylpheed");
1752 gtk_window_set_policy(GTK_WINDOW(folderwin),
1754 gtk_widget_set_usize(folderwin, -1,
1755 prefs_common.mainview_height);
1756 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1758 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1759 GTK_SIGNAL_FUNC(folder_window_close_cb),
1762 if (type & SEPARATE_MESSAGE) {
1763 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1764 gtk_window_set_title(GTK_WINDOW(messagewin),
1765 _("Sylpheed - Message View"));
1766 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1767 "message_view", "Sylpheed");
1768 gtk_window_set_policy(GTK_WINDOW(messagewin),
1770 gtk_widget_set_usize
1771 (messagewin, prefs_common.mainview_width,
1772 prefs_common.mainview_height
1773 - prefs_common.summaryview_height
1774 + DEFAULT_HEADERVIEW_HEIGHT);
1775 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1777 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1778 GTK_SIGNAL_FUNC(message_window_close_cb),
1784 hpaned = gtk_hpaned_new();
1785 gtk_widget_show(hpaned);
1786 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1787 gtk_paned_add1(GTK_PANED(hpaned),
1788 GTK_WIDGET_PTR(mainwin->folderview));
1790 vpaned = gtk_vpaned_new();
1791 if (messageview_is_visible(mainwin->messageview)) {
1792 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1793 gtk_paned_add1(GTK_PANED(vpaned),
1794 GTK_WIDGET_PTR(mainwin->summaryview));
1796 gtk_paned_add2(GTK_PANED(hpaned),
1797 GTK_WIDGET_PTR(mainwin->summaryview));
1798 gtk_widget_ref(vpaned);
1800 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1801 prefs_common.summaryview_width,
1802 prefs_common.summaryview_height);
1803 gtk_paned_add2(GTK_PANED(vpaned),
1804 GTK_WIDGET_PTR(mainwin->messageview));
1805 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1806 prefs_common.mainview_width, -1);
1807 gtk_widget_set_usize(mainwin->window,
1808 prefs_common.folderview_width +
1809 prefs_common.mainview_width,
1810 prefs_common.mainwin_height);
1811 gtk_widget_show_all(vpaned);
1813 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1814 * lose track of its visibility state */
1815 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1816 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1818 mainwin->win.sep_none.hpaned = hpaned;
1819 mainwin->win.sep_none.vpaned = vpaned;
1821 /* remove headerview if not in prefs */
1822 headerview_set_visibility(mainwin->messageview->headerview,
1823 prefs_common.display_header_pane);
1825 case SEPARATE_FOLDER:
1826 vpaned = gtk_vpaned_new();
1827 if (messageview_is_visible(mainwin->messageview)) {
1828 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1830 gtk_paned_add1(GTK_PANED(vpaned),
1831 GTK_WIDGET_PTR(mainwin->summaryview));
1833 gtk_box_pack_start(GTK_BOX(vbox_body),
1834 GTK_WIDGET_PTR(mainwin->summaryview),
1836 gtk_widget_ref(vpaned);
1838 gtk_paned_add2(GTK_PANED(vpaned),
1839 GTK_WIDGET_PTR(mainwin->messageview));
1840 gtk_widget_show_all(vpaned);
1841 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1842 prefs_common.summaryview_width,
1843 prefs_common.summaryview_height);
1844 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1845 prefs_common.mainview_width, -1);
1846 gtk_widget_set_usize(mainwin->window,
1847 prefs_common.mainview_width,
1848 prefs_common.mainview_height);
1850 gtk_container_add(GTK_CONTAINER(folderwin),
1851 GTK_WIDGET_PTR(mainwin->folderview));
1853 mainwin->win.sep_folder.folderwin = folderwin;
1854 mainwin->win.sep_folder.vpaned = vpaned;
1856 gtk_widget_show_all(folderwin);
1858 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1859 * lose track of its visibility state */
1860 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1861 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1863 /* remove headerview if not in prefs */
1864 headerview_set_visibility(mainwin->messageview->headerview,
1865 prefs_common.display_header_pane);
1868 case SEPARATE_MESSAGE:
1869 hpaned = gtk_hpaned_new();
1870 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1872 gtk_paned_add1(GTK_PANED(hpaned),
1873 GTK_WIDGET_PTR(mainwin->folderview));
1874 gtk_paned_add2(GTK_PANED(hpaned),
1875 GTK_WIDGET_PTR(mainwin->summaryview));
1876 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1877 prefs_common.summaryview_width,
1878 prefs_common.summaryview_height);
1879 gtk_widget_set_usize(mainwin->window,
1880 prefs_common.folderview_width +
1881 prefs_common.mainview_width,
1882 prefs_common.mainwin_height);
1883 gtk_widget_show_all(hpaned);
1885 messageview_add_toolbar(mainwin->messageview, messagewin);
1886 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1887 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1889 mainwin->win.sep_message.messagewin = messagewin;
1890 mainwin->win.sep_message.hpaned = hpaned;
1892 gtk_widget_show_all(messagewin);
1894 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1895 * lose track of its visibility state */
1896 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1897 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1900 gtk_box_pack_start(GTK_BOX(vbox_body),
1901 GTK_WIDGET_PTR(mainwin->summaryview),
1903 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1904 prefs_common.summaryview_width,
1905 prefs_common.summaryview_height);
1906 gtk_widget_set_usize(mainwin->window,
1907 prefs_common.mainview_width,
1908 prefs_common.mainwin_height);
1909 gtk_container_add(GTK_CONTAINER(folderwin),
1910 GTK_WIDGET_PTR(mainwin->folderview));
1911 gtk_container_add(GTK_CONTAINER(messagewin),
1912 GTK_WIDGET_PTR(mainwin->messageview));
1914 mainwin->win.sep_both.folderwin = folderwin;
1915 mainwin->win.sep_both.messagewin = messagewin;
1917 gtk_widget_show_all(folderwin);
1918 gtk_widget_show_all(messagewin);
1920 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1921 * lose track of its visibility state */
1922 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1923 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1927 /* rehide quick search if necessary */
1928 if (!prefs_common.show_searchbar)
1929 gtk_widget_hide(mainwin->summaryview->hbox_search);
1931 mainwin->type = type;
1933 mainwin->messageview->visible = TRUE;
1935 /* toggle menu state */
1936 menuitem = gtk_item_factory_get_item
1937 (ifactory, "/View/Show or hide/Folder tree");
1938 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1939 menuitem = gtk_item_factory_get_item
1940 (ifactory, "/View/Show or hide/Message view");
1941 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1943 menuitem = gtk_item_factory_get_item
1944 (ifactory, "/View/Separate folder tree");
1945 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1946 ((type & SEPARATE_FOLDER) != 0));
1947 menuitem = gtk_item_factory_get_item
1948 (ifactory, "/View/Separate message view");
1949 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1950 ((type & SEPARATE_MESSAGE) != 0));
1952 debug_print("done.\n");
1955 void main_window_destroy_all(void)
1957 while (mainwin_list != NULL) {
1958 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1960 /* free toolbar stuff */
1961 toolbar_clear_list(TOOLBAR_MAIN);
1962 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1963 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1965 g_free(mainwin->toolbar);
1968 mainwin_list = g_list_remove(mainwin_list, mainwin);
1970 g_list_free(mainwin_list);
1974 static void toolbar_account_button_pressed(GtkWidget *widget,
1975 GdkEventButton *event,
1978 MainWindow *mainwin = (MainWindow *)data;
1981 if (event->button != 3) return;
1983 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1984 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1987 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1988 menu_button_position, widget,
1989 event->button, event->time);
1993 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1996 MainWindow *mainwin = (MainWindow *)data;
2000 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2001 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2004 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2005 menu_button_position, widget,
2006 event->button, event->time);
2009 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2011 MainWindow *mainwin = (MainWindow *)data;
2014 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2015 if (!button) return;
2016 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2017 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2018 manage_window_focus_in(mainwin->window, NULL, NULL);
2021 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2024 MainWindow *mainwin = (MainWindow *)data;
2026 if (mainwin->lock_count == 0)
2027 app_exit_cb(data, 0, widget);
2032 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2035 MainWindow *mainwin = (MainWindow *)data;
2036 GtkWidget *menuitem;
2038 menuitem = gtk_item_factory_get_item
2039 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2040 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2045 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2048 MainWindow *mainwin = (MainWindow *)data;
2049 GtkWidget *menuitem;
2051 menuitem = gtk_item_factory_get_item
2052 (mainwin->menu_factory, "/View/Show or hide/Message view");
2053 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2058 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2061 main_window_add_mailbox(mainwin);
2064 static void add_mbox_cb(MainWindow *mainwin, guint action,
2067 main_window_add_mbox(mainwin);
2070 static void update_folderview_cb(MainWindow *mainwin, guint action,
2073 summary_show(mainwin->summaryview, NULL);
2074 folderview_check_new_all();
2077 static void new_folder_cb(MainWindow *mainwin, guint action,
2080 folderview_new_folder(mainwin->folderview);
2083 static void rename_folder_cb(MainWindow *mainwin, guint action,
2086 folderview_rename_folder(mainwin->folderview);
2089 static void delete_folder_cb(MainWindow *mainwin, guint action,
2092 folderview_delete_folder(mainwin->folderview);
2095 static void import_mbox_cb(MainWindow *mainwin, guint action,
2098 import_mbox(mainwin->summaryview->folder_item);
2101 static void export_mbox_cb(MainWindow *mainwin, guint action,
2104 export_mbox(mainwin->summaryview->folder_item);
2107 static void empty_trash_cb(MainWindow *mainwin, guint action,
2110 main_window_empty_trash(mainwin, TRUE);
2113 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2115 summary_save_as(mainwin->summaryview);
2118 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2120 summary_print(mainwin->summaryview);
2123 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2125 if (prefs_common.confirm_on_exit) {
2126 if (alertpanel(_("Exit"), _("Exit this program?"),
2127 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2129 manage_window_focus_in(mainwin->window, NULL, NULL);
2132 app_will_exit(widget, mainwin);
2135 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2138 summary_search(mainwin->summaryview);
2140 message_search(mainwin->messageview);
2143 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2148 active = GTK_CHECK_MENU_ITEM(widget)->active;
2150 switch (mainwin->type) {
2152 case SEPARATE_MESSAGE:
2155 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2157 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2160 case SEPARATE_FOLDER:
2161 debug_print("separate folder\n");
2163 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2165 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2169 gtk_widget_show(mainwin->win.sep_both.folderwin);
2171 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2176 static void toggle_message_cb(MainWindow *mainwin, guint action,
2181 active = GTK_CHECK_MENU_ITEM(widget)->active;
2183 if (active != messageview_is_visible(mainwin->messageview))
2184 summary_toggle_view(mainwin->summaryview);
2187 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2190 toolbar_toggle(action, mainwin);
2193 void main_window_reply_cb(MainWindow *mainwin, guint action,
2196 MessageView *msgview = (MessageView*)mainwin->messageview;
2197 GSList *msginfo_list = NULL;
2200 g_return_if_fail(msgview != NULL);
2202 msginfo_list = summary_get_selection(mainwin->summaryview);
2203 g_return_if_fail(msginfo_list != NULL);
2205 body = messageview_get_selection(msgview);
2206 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2208 g_slist_free(msginfo_list);
2212 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2215 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2216 gtk_widget_show(mainwin->hbox_stat);
2217 prefs_common.show_statusbar = TRUE;
2219 gtk_widget_hide(mainwin->hbox_stat);
2220 prefs_common.show_statusbar = FALSE;
2224 static void separate_widget_cb(MainWindow *mainwin, guint action,
2229 if (GTK_CHECK_MENU_ITEM(widget)->active)
2230 type = mainwin->type | action;
2232 type = mainwin->type & ~action;
2234 main_window_separation_change(mainwin, type);
2236 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2237 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2240 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2243 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2245 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2248 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2250 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2253 static void online_switch_clicked (GtkButton *btn, gpointer data)
2255 MainWindow *mainwin;
2256 GtkItemFactory *ifactory;
2257 GtkCheckMenuItem *menuitem;
2259 mainwin = (MainWindow *) data;
2261 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2262 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2264 g_return_if_fail(mainwin != NULL);
2265 g_return_if_fail(menuitem != NULL);
2267 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2269 gtk_widget_hide (mainwin->online_switch);
2270 gtk_widget_show (mainwin->offline_switch);
2271 menuitem->active = TRUE;
2272 prefs_common.work_offline = TRUE;
2273 inc_autocheck_timer_remove();
2276 gtk_widget_hide (mainwin->offline_switch);
2277 gtk_widget_show (mainwin->online_switch);
2278 menuitem->active = FALSE;
2279 prefs_common.work_offline = FALSE;
2280 inc_autocheck_timer_set();
2284 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2287 addressbook_open(NULL);
2290 static void log_window_show_cb(MainWindow *mainwin, guint action,
2293 log_window_show(mainwin->logwin);
2296 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2301 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2303 summary_move_to(mainwin->summaryview);
2306 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2308 summary_copy_to(mainwin->summaryview);
2311 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2313 summary_delete(mainwin->summaryview);
2316 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2318 summary_cancel(mainwin->summaryview);
2321 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2323 summary_open_msg(mainwin->summaryview);
2326 static void view_source_cb(MainWindow *mainwin, guint action,
2329 summary_view_source(mainwin->summaryview);
2332 static void show_all_header_cb(MainWindow *mainwin, guint action,
2335 if (mainwin->menu_lock_count) return;
2336 summary_display_msg_selected(mainwin->summaryview,
2337 GTK_CHECK_MENU_ITEM(widget)->active);
2340 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2342 summary_reedit(mainwin->summaryview);
2345 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2347 summary_mark(mainwin->summaryview);
2350 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2352 summary_unmark(mainwin->summaryview);
2355 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2358 summary_mark_as_unread(mainwin->summaryview);
2361 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2364 summary_mark_as_read(mainwin->summaryview);
2367 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2370 summary_mark_all_read(mainwin->summaryview);
2373 static void add_address_cb(MainWindow *mainwin, guint action,
2376 summary_add_address(mainwin->summaryview);
2379 static void set_charset_cb(MainWindow *mainwin, guint action,
2384 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2385 str = conv_get_charset_str((CharSet)action);
2386 g_free(prefs_common.force_charset);
2387 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2389 summary_redisplay_msg(mainwin->summaryview);
2391 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2395 static void hide_read_messages (MainWindow *mainwin, guint action,
2398 if (!mainwin->summaryview->folder_item
2399 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2401 summary_toggle_show_read_messages(mainwin->summaryview);
2404 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 if (mainwin->menu_lock_count) return;
2407 if (!mainwin->summaryview->folder_item) return;
2409 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2410 summary_thread_build(mainwin->summaryview);
2411 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2413 summary_unthread(mainwin->summaryview);
2414 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2418 static void expand_threads_cb(MainWindow *mainwin, guint action,
2421 summary_expand_threads(mainwin->summaryview);
2424 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2427 summary_collapse_threads(mainwin->summaryview);
2430 static void set_display_item_cb(MainWindow *mainwin, guint action,
2433 prefs_summary_column_open();
2436 static void sort_summary_cb(MainWindow *mainwin, guint action,
2439 FolderItem *item = mainwin->summaryview->folder_item;
2440 GtkWidget *menuitem;
2442 if (mainwin->menu_lock_count) return;
2444 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2445 menuitem = gtk_item_factory_get_item
2446 (mainwin->menu_factory, "/View/Sort/Ascending");
2447 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2448 GTK_CHECK_MENU_ITEM(menuitem)->active
2449 ? SORT_ASCENDING : SORT_DESCENDING);
2453 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2456 FolderItem *item = mainwin->summaryview->folder_item;
2458 if (mainwin->menu_lock_count) return;
2460 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2461 summary_sort(mainwin->summaryview,
2462 item->sort_key, (FolderSortType)action);
2465 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2468 summary_attract_by_subject(mainwin->summaryview);
2471 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2474 summary_delete_duplicated(mainwin->summaryview);
2477 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2479 summary_filter(mainwin->summaryview);
2482 static void execute_summary_cb(MainWindow *mainwin, guint action,
2485 summary_execute(mainwin->summaryview);
2488 static void update_summary_cb(MainWindow *mainwin, guint action,
2492 FolderView *folderview = mainwin->folderview;
2494 if (!mainwin->summaryview->folder_item) return;
2495 if (!folderview->opened) return;
2497 folder_update_op_count();
2499 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2500 folderview->opened);
2503 folder_item_scan(fitem);
2504 summary_show(mainwin->summaryview, fitem);
2507 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2509 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2512 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2514 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2517 static void prev_unread_cb(MainWindow *mainwin, guint action,
2520 summary_select_prev_unread(mainwin->summaryview);
2523 static void next_unread_cb(MainWindow *mainwin, guint action,
2526 summary_select_next_unread(mainwin->summaryview);
2529 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2531 summary_select_prev_new(mainwin->summaryview);
2534 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2536 summary_select_next_new(mainwin->summaryview);
2539 static void prev_marked_cb(MainWindow *mainwin, guint action,
2542 summary_select_prev_marked(mainwin->summaryview);
2545 static void next_marked_cb(MainWindow *mainwin, guint action,
2548 summary_select_next_marked(mainwin->summaryview);
2551 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2554 summary_select_prev_labeled(mainwin->summaryview);
2557 static void next_labeled_cb(MainWindow *mainwin, guint action,
2560 summary_select_next_labeled(mainwin->summaryview);
2563 static void goto_folder_cb(MainWindow *mainwin, guint action,
2566 FolderItem *to_folder;
2568 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2571 folderview_select(mainwin->folderview, to_folder);
2574 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2576 messageview_copy_clipboard(mainwin->messageview);
2579 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2581 MessageView *msgview = mainwin->messageview;
2583 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2584 summary_select_all(mainwin->summaryview);
2585 else if (messageview_is_visible(msgview) &&
2586 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2587 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2588 messageview_select_all(mainwin->messageview);
2591 static void select_thread_cb(MainWindow *mainwin, guint action,
2594 summary_select_thread(mainwin->summaryview);
2597 static void create_filter_cb(MainWindow *mainwin, guint action,
2600 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2603 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2606 prefs_common_open();
2609 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2612 prefs_scoring_open(NULL);
2615 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2618 prefs_filtering_open(NULL, NULL, NULL);
2621 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2624 prefs_template_open();
2627 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2630 prefs_actions_open(mainwin);
2633 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2636 ssl_manager_open(mainwin);
2639 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2643 new_account_cb(mainwin, 0, widget);
2645 account_open(cur_account);
2649 static void new_account_cb(MainWindow *mainwin, guint action,
2652 account_edit_open();
2653 if (!compose_get_compose_list()) account_add();
2656 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2658 cur_account = (PrefsAccount *)data;
2659 main_window_reflect_prefs_all();
2662 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2667 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2669 pluginwindow_create();
2672 static void manual_open_cb(MainWindow *mainwin, guint action,
2675 manual_open((ManualType)action);
2678 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2680 MainWindow *mainwin = (MainWindow *)data;
2684 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2685 LOCAL_FOLDER(folder)->rootpath,
2689 str = g_strdup_printf(_("Scanning folder %s ..."),
2690 LOCAL_FOLDER(folder)->rootpath);
2692 STATUSBAR_PUSH(mainwin, str);
2693 STATUSBAR_POP(mainwin);
2697 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2700 SummaryView *summary;
2702 g_return_val_if_fail(data, FALSE);
2703 summary = ((MainWindow *)data)->summaryview;
2704 g_return_val_if_fail(summary, FALSE);
2705 if (summary->selected != summary->displayed)
2706 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2710 #define BREAK_ON_MODIFIER_KEY() \
2711 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2713 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2716 MainWindow *mainwin = (MainWindow*) data;
2718 if (!mainwin || !event) return;
2720 switch (event->keyval) {
2721 case GDK_Q: /* Quit */
2722 BREAK_ON_MODIFIER_KEY();
2724 app_exit_cb(mainwin, 0, NULL);
2727 if (mainwin->folderview && mainwin->summaryview
2728 && !mainwin->summaryview->displayed) {
2729 summary_lock(mainwin->summaryview);
2730 folderview_select_next_unread(mainwin->folderview);
2731 summary_unlock(mainwin->summaryview);
2739 #undef BREAK_ON_MODIFIER_KEY
2742 * Harvest addresses for selected folder.
2744 static void addr_harvest_cb( MainWindow *mainwin,
2748 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2752 * Harvest addresses for selected messages in summary view.
2754 static void addr_harvest_msg_cb( MainWindow *mainwin,
2758 summary_harvest_address( mainwin->summaryview );
2762 *\brief get a MainWindow
2764 *\return MainWindow * The first mainwindow in the mainwin_list
2766 MainWindow *mainwindow_get_mainwindow(void)
2768 if (mainwin_list && mainwin_list->data)
2769 return (MainWindow *)(mainwin_list->data);
2774 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2776 ProgressData *data = (ProgressData *) source;
2777 MainWindow *mainwin = (MainWindow *) userdata;
2779 switch (data->cmd) {
2780 case PROGRESS_COMMAND_START:
2781 case PROGRESS_COMMAND_STOP:
2782 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2784 case PROGRESS_COMMAND_SET_PERCENTAGE:
2785 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2788 while (gtk_events_pending()) gtk_main_iteration ();