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 main_window_size_allocate_cb (GtkWidget *widget,
127 GtkAllocation *allocation,
129 static void folder_window_size_allocate_cb (GtkWidget *widget,
130 GtkAllocation *allocation,
132 static void message_window_size_allocate_cb (GtkWidget *widget,
133 GtkAllocation *allocation,
136 static void new_folder_cb (MainWindow *mainwin,
139 static void rename_folder_cb (MainWindow *mainwin,
142 static void delete_folder_cb (MainWindow *mainwin,
145 static void update_folderview_cb (MainWindow *mainwin,
148 static void add_mailbox_cb (MainWindow *mainwin,
151 static void import_mbox_cb (MainWindow *mainwin,
154 static void export_mbox_cb (MainWindow *mainwin,
157 static void empty_trash_cb (MainWindow *mainwin,
161 static void save_as_cb (MainWindow *mainwin,
164 static void print_cb (MainWindow *mainwin,
167 static void app_exit_cb (MainWindow *mainwin,
171 static void search_cb (MainWindow *mainwin,
175 static void toggle_folder_cb (MainWindow *mainwin,
178 static void toggle_message_cb (MainWindow *mainwin,
181 static void toggle_toolbar_cb (MainWindow *mainwin,
184 static void toggle_statusbar_cb (MainWindow *mainwin,
187 static void separate_widget_cb (MainWindow *mainwin,
191 static void addressbook_open_cb (MainWindow *mainwin,
194 static void log_window_show_cb (MainWindow *mainwin,
198 static void inc_cancel_cb (MainWindow *mainwin,
202 static void open_msg_cb (MainWindow *mainwin,
206 static void view_source_cb (MainWindow *mainwin,
210 static void show_all_header_cb (MainWindow *mainwin,
214 static void reedit_cb (MainWindow *mainwin,
218 static void move_to_cb (MainWindow *mainwin,
221 static void copy_to_cb (MainWindow *mainwin,
224 static void delete_cb (MainWindow *mainwin,
228 static void cancel_cb (MainWindow *mainwin,
232 static void mark_cb (MainWindow *mainwin,
235 static void unmark_cb (MainWindow *mainwin,
239 static void mark_as_unread_cb (MainWindow *mainwin,
242 static void mark_as_read_cb (MainWindow *mainwin,
245 static void mark_all_read_cb (MainWindow *mainwin,
248 static void add_address_cb (MainWindow *mainwin,
252 static void set_charset_cb (MainWindow *mainwin,
256 static void hide_read_messages (MainWindow *mainwin,
260 static void thread_cb (MainWindow *mainwin,
263 static void expand_threads_cb (MainWindow *mainwin,
266 static void collapse_threads_cb (MainWindow *mainwin,
270 static void set_display_item_cb (MainWindow *mainwin,
273 static void sort_summary_cb (MainWindow *mainwin,
276 static void sort_summary_type_cb (MainWindow *mainwin,
279 static void attract_by_subject_cb(MainWindow *mainwin,
283 static void delete_duplicated_cb (MainWindow *mainwin,
286 static void filter_cb (MainWindow *mainwin,
289 static void execute_summary_cb (MainWindow *mainwin,
292 static void update_summary_cb (MainWindow *mainwin,
296 static void prev_cb (MainWindow *mainwin,
299 static void next_cb (MainWindow *mainwin,
302 static void next_unread_cb (MainWindow *mainwin,
305 static void prev_unread_cb (MainWindow *mainwin,
309 static void prev_new_cb (MainWindow *mainwin,
312 static void next_new_cb (MainWindow *mainwin,
315 static void prev_marked_cb (MainWindow *mainwin,
318 static void next_marked_cb (MainWindow *mainwin,
321 static void prev_labeled_cb (MainWindow *mainwin,
324 static void next_labeled_cb (MainWindow *mainwin,
328 static void goto_folder_cb (MainWindow *mainwin,
332 static void copy_cb (MainWindow *mainwin,
335 static void allsel_cb (MainWindow *mainwin,
338 static void select_thread_cb (MainWindow *mainwin,
342 static void create_filter_cb (MainWindow *mainwin,
346 static void prefs_common_open_cb (MainWindow *mainwin,
349 static void prefs_template_open_cb (MainWindow *mainwin,
352 static void prefs_actions_open_cb (MainWindow *mainwin,
355 static void prefs_account_open_cb (MainWindow *mainwin,
358 static void prefs_scoring_open_cb (MainWindow *mainwin,
361 static void prefs_filtering_open_cb (MainWindow *mainwin,
365 static void ssl_manager_open_cb (MainWindow *mainwin,
369 static void new_account_cb (MainWindow *mainwin,
373 static void account_menu_cb (GtkMenuItem *menuitem,
376 static void prefs_open_cb (GtkMenuItem *menuitem,
378 static void plugins_open_cb (GtkMenuItem *menuitem,
381 static void online_switch_clicked(GtkButton *btn,
384 static void manual_open_cb (MainWindow *mainwin,
388 static void scan_tree_func (Folder *folder,
392 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
394 static void addr_harvest_cb ( MainWindow *mainwin,
398 static void addr_harvest_msg_cb ( MainWindow *mainwin,
402 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
403 GdkEventFocus *focus,
405 void main_window_reply_cb (MainWindow *mainwin,
408 gboolean mainwindow_progressindicator_hook (gpointer source,
410 #define SEPARATE_ACTION 500
412 static GtkItemFactoryEntry mainwin_entries[] =
414 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
415 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
416 {N_("/_File/_Folder/Create _new folder..."),
417 NULL, new_folder_cb, 0, NULL},
418 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
419 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
420 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
421 {N_("/_File/_Folder/_Check for new messages in all folders"),
422 NULL, update_folderview_cb, 0, NULL},
423 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
424 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
425 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
426 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
427 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
428 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
429 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
430 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
431 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
432 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
433 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
434 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
436 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
437 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
438 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
439 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
440 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
441 {N_("/_Edit/_Find in current message..."),
442 "<control>F", search_cb, 0, NULL},
443 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
444 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
445 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
446 {N_("/_View/Show or hi_de/_Folder tree"),
447 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
448 {N_("/_View/Show or hi_de/_Message view"),
449 "V", toggle_message_cb, 0, "<ToggleItem>"},
450 {N_("/_View/Show or hi_de/_Toolbar"),
451 NULL, NULL, 0, "<Branch>"},
452 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
453 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
454 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
455 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
456 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
457 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
458 {N_("/_View/Show or hi_de/_Toolbar/_None"),
459 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
460 {N_("/_View/Show or hi_de/Status _bar"),
461 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
462 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
463 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
464 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
465 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
466 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
467 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
468 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
469 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
470 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
471 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
472 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
473 {N_("/_View/_Sort/by _color label"),
474 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
475 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
476 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
477 {N_("/_View/_Sort/by a_ttachment"),
478 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
479 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
480 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
481 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
482 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
483 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
484 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
485 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
486 {N_("/_View/_Sort/_Attract by subject"),
487 NULL, attract_by_subject_cb, 0, NULL},
488 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
489 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
490 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
491 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
492 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
494 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
495 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
496 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
497 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
498 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_View/_Go to/P_rev unread message"),
500 "<shift>P", prev_unread_cb, 0, NULL},
501 {N_("/_View/_Go to/N_ext unread message"),
502 "<shift>N", next_unread_cb, 0, NULL},
503 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
505 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
506 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_View/_Go to/Prev _marked message"),
508 NULL, prev_marked_cb, 0, NULL},
509 {N_("/_View/_Go to/Next m_arked message"),
510 NULL, next_marked_cb, 0, NULL},
511 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_View/_Go to/Prev _labeled message"),
513 NULL, prev_labeled_cb, 0, NULL},
514 {N_("/_View/_Go to/Next la_beled message"),
515 NULL, next_labeled_cb, 0, NULL},
516 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
517 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
518 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
520 #define CODESET_SEPARATOR \
521 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
522 #define CODESET_ACTION(action) \
523 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
525 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
526 {N_("/_View/_Code set/_Auto detect"),
527 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
528 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
530 CODESET_ACTION(C_US_ASCII)},
533 {N_("/_View/_Code set/Unicode (_UTF-8)"),
534 CODESET_ACTION(C_UTF_8)},
537 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
538 CODESET_ACTION(C_ISO_8859_1)},
539 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
540 CODESET_ACTION(C_ISO_8859_15)},
543 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
544 CODESET_ACTION(C_ISO_8859_2)},
546 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
547 CODESET_ACTION(C_ISO_8859_13)},
548 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
549 CODESET_ACTION(C_ISO_8859_4)},
551 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
552 CODESET_ACTION(C_ISO_8859_7)},
554 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
555 CODESET_ACTION(C_ISO_8859_9)},
557 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
558 CODESET_ACTION(C_ISO_8859_5)},
559 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
560 CODESET_ACTION(C_KOI8_R)},
561 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
562 CODESET_ACTION(C_WINDOWS_1251)},
565 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
566 CODESET_ACTION(C_ISO_2022_JP)},
568 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
569 CODESET_ACTION(C_ISO_2022_JP_2)},
571 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
572 CODESET_ACTION(C_EUC_JP)},
573 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
574 CODESET_ACTION(C_SHIFT_JIS)},
577 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
578 CODESET_ACTION(C_GB2312)},
579 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
580 CODESET_ACTION(C_BIG5)},
581 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
582 CODESET_ACTION(C_EUC_TW)},
583 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
584 CODESET_ACTION(C_ISO_2022_CN)},
586 {N_("/_View/_Code set/Korean (EUC-_KR)"),
587 CODESET_ACTION(C_EUC_KR)},
588 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
589 CODESET_ACTION(C_ISO_2022_KR)},
591 {N_("/_View/_Code set/Thai (TIS-620)"),
592 CODESET_ACTION(C_TIS_620)},
593 {N_("/_View/_Code set/Thai (Windows-874)"),
594 CODESET_ACTION(C_WINDOWS_874)},
597 #undef CODESET_SEPARATOR
598 #undef CODESET_ACTION
600 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
601 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
602 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
603 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
604 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
607 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
608 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
609 {N_("/_Message/Get from _all accounts"),
610 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
611 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
612 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
614 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
616 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
617 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
618 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
619 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
620 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
621 {N_("/_Message/Repl_y to/mailing _list"),
622 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
623 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
624 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
626 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
627 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
629 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
631 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
632 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
633 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
634 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
636 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
637 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
638 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
640 {N_("/_Message/_Mark/Mark as rea_d"),
641 NULL, mark_as_read_cb, 0, NULL},
642 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
644 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
645 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
646 {N_("/_Tools/Add sender to address boo_k"),
647 NULL, add_address_cb, 0, NULL},
648 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
649 {N_("/_Tools/_Harvest addresses/from _Folder..."),
650 NULL, addr_harvest_cb, 0, NULL},
651 {N_("/_Tools/_Harvest addresses/from _Messages..."),
652 NULL, addr_harvest_msg_cb, 0, NULL},
653 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
655 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
656 {N_("/_Tools/_Create filter rule/_Automatically"),
657 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
658 {N_("/_Tools/_Create filter rule/by _From"),
659 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
660 {N_("/_Tools/_Create filter rule/by _To"),
661 NULL, create_filter_cb, FILTER_BY_TO, NULL},
662 {N_("/_Tools/_Create filter rule/by _Subject"),
663 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
664 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
665 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
666 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_Tools/Delete du_plicated messages"),
668 NULL, delete_duplicated_cb, 0, NULL},
669 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
670 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
672 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Tools/SSL certi_ficates..."),
674 NULL, ssl_manager_open_cb, 0, NULL},
676 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
677 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
679 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
680 {N_("/_Configuration/C_hange current account"),
681 NULL, NULL, 0, "<Branch>"},
682 {N_("/_Configuration/_Preferences for current account..."),
683 NULL, prefs_account_open_cb, 0, NULL},
684 {N_("/_Configuration/Create _new account..."),
685 NULL, new_account_cb, 0, NULL},
686 {N_("/_Configuration/_Edit accounts..."),
687 NULL, account_edit_open, 0, NULL},
688 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
689 {N_("/_Configuration/_Common preferences..."),
690 NULL, prefs_common_open_cb, 0, NULL},
691 {N_("/_Configuration/_Scoring..."),
692 NULL, prefs_scoring_open_cb, 0, NULL},
693 {N_("/_Configuration/_Filtering..."),
694 NULL, prefs_filtering_open_cb, 0, NULL},
695 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
696 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
697 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
698 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
700 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
701 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
702 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
703 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
704 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
705 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
706 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
707 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
708 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
709 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
710 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
713 MainWindow *main_window_create(SeparateType type)
719 GtkWidget *handlebox;
720 GtkWidget *vbox_body;
721 GtkWidget *hbox_stat;
722 GtkWidget *statusbar;
723 GtkWidget *progressbar;
724 GtkWidget *statuslabel;
725 GtkWidget *ac_button;
727 GtkWidget *online_pixmap;
728 GtkWidget *offline_pixmap;
729 GtkWidget *online_switch;
730 GtkWidget *offline_switch;
731 GtkTooltips *offline_tip;
732 GtkTooltips *online_tip;
733 GtkTooltips *sel_ac_tip;
735 FolderView *folderview;
736 SummaryView *summaryview;
737 MessageView *messageview;
738 GdkColormap *colormap;
741 GtkItemFactory *ifactory;
745 guint n_menu_entries;
747 static GdkGeometry geometry;
749 debug_print("Creating main window...\n");
750 mainwin = g_new0(MainWindow, 1);
753 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
754 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
755 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
756 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
758 if (!geometry.min_height) {
759 geometry.min_width = 320;
760 geometry.min_height = 200;
762 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
765 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
766 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
767 MANAGE_WINDOW_SIGNALS_CONNECT(window);
768 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
769 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
771 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
772 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
774 gtk_widget_realize(window);
775 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
778 gtkut_widget_set_app_icon(window);
780 vbox = gtk_vbox_new(FALSE, 0);
781 gtk_widget_show(vbox);
782 gtk_container_add(GTK_CONTAINER(window), vbox);
785 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
786 menubar = menubar_create(window, mainwin_entries,
787 n_menu_entries, "<Main>", mainwin);
788 gtk_widget_show(menubar);
789 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
790 ifactory = gtk_item_factory_from_widget(menubar);
792 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
793 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
795 handlebox = gtk_handle_box_new();
796 gtk_widget_show(handlebox);
797 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
799 /* link window to mainwin->window to avoid gdk warnings */
800 mainwin->window = window;
803 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
807 /* vbox that contains body */
808 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
809 gtk_widget_show(vbox_body);
810 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
811 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
813 hbox_stat = gtk_hbox_new(FALSE, 2);
814 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
816 statusbar = statusbar_create();
817 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
819 progressbar = gtk_progress_bar_new();
820 gtk_widget_set_usize(progressbar, 120, 1);
821 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
823 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
824 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
825 online_tip = gtk_tooltips_new();
826 online_switch = gtk_button_new ();
827 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
828 online_switch, _("Go offline"), NULL);
829 offline_tip = gtk_tooltips_new();
830 offline_switch = gtk_button_new ();
831 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
832 offline_switch, _("Go online"), NULL);
833 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
834 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
835 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
836 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
837 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
838 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
839 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
840 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
842 statuslabel = gtk_label_new("");
843 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
845 sel_ac_tip = gtk_tooltips_new();
846 ac_button = gtk_button_new();
847 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
848 ac_button, _("Select account"), NULL);
849 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
850 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
851 gtk_widget_set_usize(ac_button, -1, 1);
852 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
853 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
854 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
856 ac_label = gtk_label_new("");
857 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
859 gtk_widget_show_all(hbox_stat);
861 gtk_widget_hide(offline_switch);
863 mainwin->folderview = folderview = folderview_create();
864 mainwin->summaryview = summaryview = summary_create();
865 mainwin->messageview = messageview = messageview_create(mainwin);
866 mainwin->logwin = log_window_create();
868 folderview->mainwin = mainwin;
869 folderview->summaryview = summaryview;
871 summaryview->mainwin = mainwin;
872 summaryview->folderview = folderview;
873 summaryview->messageview = messageview;
874 summaryview->window = window;
876 mainwin->vbox = vbox;
877 mainwin->menubar = menubar;
878 mainwin->menu_factory = ifactory;
879 mainwin->handlebox = handlebox;
880 mainwin->vbox_body = vbox_body;
881 mainwin->hbox_stat = hbox_stat;
882 mainwin->statusbar = statusbar;
883 mainwin->progressbar = progressbar;
884 mainwin->statuslabel = statuslabel;
885 mainwin->ac_button = ac_button;
886 mainwin->ac_label = ac_label;
888 mainwin->online_switch = online_switch;
889 mainwin->offline_switch = offline_switch;
890 mainwin->online_pixmap = online_pixmap;
891 mainwin->offline_pixmap = offline_pixmap;
893 /* set context IDs for status bar */
894 mainwin->mainwin_cid = gtk_statusbar_get_context_id
895 (GTK_STATUSBAR(statusbar), "Main Window");
896 mainwin->folderview_cid = gtk_statusbar_get_context_id
897 (GTK_STATUSBAR(statusbar), "Folder View");
898 mainwin->summaryview_cid = gtk_statusbar_get_context_id
899 (GTK_STATUSBAR(statusbar), "Summary View");
901 /* allocate colors for summary view and folder view */
902 summaryview->color_marked.red = summaryview->color_marked.green = 0;
903 summaryview->color_marked.blue = (guint16)65535;
905 summaryview->color_dim.red = summaryview->color_dim.green =
906 summaryview->color_dim.blue = COLOR_DIM;
908 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
909 &folderview->color_new);
911 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
912 &folderview->color_op);
914 summaryview->color_important.red = 0;
915 summaryview->color_important.green = 0;
916 summaryview->color_important.blue = (guint16)65535;
918 color[0] = summaryview->color_marked;
919 color[1] = summaryview->color_dim;
920 color[2] = folderview->color_new;
921 color[3] = folderview->color_op;
923 colormap = gdk_window_get_colormap(window->window);
924 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
925 for (i = 0; i < 4; i++) {
926 if (success[i] == FALSE)
927 g_warning("MainWindow: color allocation %d failed\n", i);
930 debug_print("done.\n");
932 messageview->visible = prefs_common.msgview_visible;
934 main_window_set_widgets(mainwin, type);
936 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
937 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
941 menuitem = gtk_item_factory_get_item
942 (ifactory, "/View/Code set/Auto detect");
943 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
945 switch (prefs_common.toolbar_style) {
947 menuitem = gtk_item_factory_get_item
948 (ifactory, "/View/Show or hide/Toolbar/None");
951 menuitem = gtk_item_factory_get_item
952 (ifactory, "/View/Show or hide/Toolbar/Icon");
955 menuitem = gtk_item_factory_get_item
956 (ifactory, "/View/Show or hide/Toolbar/Text");
959 menuitem = gtk_item_factory_get_item
960 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
962 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
964 gtk_widget_hide(mainwin->hbox_stat);
965 menuitem = gtk_item_factory_get_item
966 (ifactory, "/View/Show or hide/Status bar");
967 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
968 prefs_common.show_statusbar);
970 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
972 if (prefs_common.show_searchbar) {
973 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
974 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
975 gtk_widget_hide(summaryview->search_description);
978 /* set account selection menu */
979 ac_menu = gtk_item_factory_get_widget
980 (ifactory, "/Configuration/Change current account");
981 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
982 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
983 mainwin->ac_menu = ac_menu;
985 toolbar_main_set_sensitive(mainwin);
987 /* create actions menu */
988 action_update_mainwin_menu(ifactory, mainwin);
990 /* attach accel groups to main window */
991 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
992 gtk_window_add_accel_group \
994 gtk_item_factory_from_widget(menu)->accel_group)
996 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
998 /* connect the accelerators for equivalent
999 menu items in different menus */
1000 menu_connect_identical_items();
1004 /* show main window */
1005 gtk_widget_show(mainwin->window);
1007 /* initialize views */
1008 folderview_init(folderview);
1009 summary_init(summaryview);
1010 messageview_init(messageview);
1011 log_window_init(mainwin->logwin);
1012 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1013 prefs_common.loglength);
1015 sslcertwindow_register_hook();
1017 mainwin->lock_count = 0;
1018 mainwin->menu_lock_count = 0;
1019 mainwin->cursor_count = 0;
1021 mainwin->progressindicator_hook =
1022 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1025 watch_cursor = gdk_cursor_new(GDK_WATCH);
1027 mainwin_list = g_list_append(mainwin_list, mainwin);
1029 /* init work_offline */
1030 if (prefs_common.work_offline)
1031 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1036 void main_window_cursor_wait(MainWindow *mainwin)
1039 if (mainwin->cursor_count == 0)
1040 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1042 mainwin->cursor_count++;
1047 void main_window_cursor_normal(MainWindow *mainwin)
1049 if (mainwin->cursor_count)
1050 mainwin->cursor_count--;
1052 if (mainwin->cursor_count == 0)
1053 gdk_window_set_cursor(mainwin->window->window, NULL);
1058 /* lock / unlock the user-interface */
1059 void main_window_lock(MainWindow *mainwin)
1061 if (mainwin->lock_count == 0)
1062 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1064 mainwin->lock_count++;
1066 main_window_set_menu_sensitive(mainwin);
1067 toolbar_main_set_sensitive(mainwin);
1070 void main_window_unlock(MainWindow *mainwin)
1072 if (mainwin->lock_count)
1073 mainwin->lock_count--;
1075 main_window_set_menu_sensitive(mainwin);
1076 toolbar_main_set_sensitive(mainwin);
1078 if (mainwin->lock_count == 0)
1079 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1082 static void main_window_menu_callback_block(MainWindow *mainwin)
1084 mainwin->menu_lock_count++;
1087 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1089 if (mainwin->menu_lock_count)
1090 mainwin->menu_lock_count--;
1093 void main_window_reflect_prefs_all(void)
1095 main_window_reflect_prefs_all_real(FALSE);
1098 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1101 MainWindow *mainwin;
1104 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1105 mainwin = (MainWindow *)cur->data;
1107 main_window_show_cur_account(mainwin);
1108 main_window_set_menu_sensitive(mainwin);
1109 toolbar_main_set_sensitive(mainwin);
1112 if (pixmap_theme_changed) {
1113 toolbar_update(TOOLBAR_MAIN, mainwin);
1114 messageview_reflect_prefs_pixmap_theme();
1115 compose_reflect_prefs_pixmap_theme();
1116 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1117 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1119 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1120 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1121 mainwin->online_pixmap);
1122 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1123 gtk_widget_show(pixmap);
1124 mainwin->online_pixmap = pixmap;
1125 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1126 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1127 mainwin->offline_pixmap);
1128 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1129 gtk_widget_show(pixmap);
1130 mainwin->offline_pixmap = pixmap;
1133 summary_redisplay_msg(mainwin->summaryview);
1134 headerview_set_visibility(mainwin->messageview->headerview,
1135 prefs_common.display_header_pane);
1139 void main_window_set_summary_column(void)
1142 MainWindow *mainwin;
1144 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1145 mainwin = (MainWindow *)cur->data;
1146 summary_set_column_order(mainwin->summaryview);
1150 void main_window_set_account_menu(GList *account_list)
1152 GList *cur, *cur_ac, *cur_item;
1153 GtkWidget *menuitem;
1154 MainWindow *mainwin;
1155 PrefsAccount *ac_prefs;
1157 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1158 mainwin = (MainWindow *)cur->data;
1160 /* destroy all previous menu item */
1161 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1162 while (cur_item != NULL) {
1163 GList *next = cur_item->next;
1164 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1168 for (cur_ac = account_list; cur_ac != NULL;
1169 cur_ac = cur_ac->next) {
1170 ac_prefs = (PrefsAccount *)cur_ac->data;
1172 menuitem = gtk_menu_item_new_with_label
1173 (ac_prefs->account_name
1174 ? ac_prefs->account_name : _("Untitled"));
1175 gtk_widget_show(menuitem);
1176 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1177 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1178 GTK_SIGNAL_FUNC(account_menu_cb),
1184 static void main_window_show_cur_account(MainWindow *mainwin)
1189 ac_name = g_strdup(cur_account
1190 ? (cur_account->account_name
1191 ? cur_account->account_name : _("Untitled"))
1195 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1197 buf = g_strdup(PROG_VERSION);
1198 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1201 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1202 gtk_widget_queue_resize(mainwin->ac_button);
1207 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1209 switch (mainwin->type) {
1210 case SEPARATE_FOLDER:
1211 return mainwin->win.sep_folder.folderwin;
1213 return mainwin->win.sep_both.folderwin;
1219 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1221 switch (mainwin->type) {
1222 case SEPARATE_MESSAGE:
1223 return mainwin->win.sep_message.messagewin;
1225 return mainwin->win.sep_both.messagewin;
1231 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1233 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1234 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1235 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1236 GtkWidget *message_wid = mainwin->messageview->vbox;
1238 debug_print("Changing window separation type from %d to %d\n",
1239 mainwin->type, type);
1241 if (mainwin->type == type) return;
1243 /* remove widgets from those containers */
1244 gtk_widget_ref(folder_wid);
1245 gtk_widget_ref(summary_wid);
1246 gtk_widget_ref(message_wid);
1247 gtkut_container_remove
1248 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1249 gtkut_container_remove
1250 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1251 gtkut_container_remove
1252 (GTK_CONTAINER(message_wid->parent), message_wid);
1254 /* clean containers */
1255 switch (mainwin->type) {
1257 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1259 case SEPARATE_FOLDER:
1260 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1261 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1263 case SEPARATE_MESSAGE:
1264 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1265 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1268 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1269 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1273 gtk_widget_hide(mainwin->window);
1274 main_window_set_widgets(mainwin, type);
1275 gtk_widget_show(mainwin->window);
1277 gtk_widget_unref(folder_wid);
1278 gtk_widget_unref(summary_wid);
1279 gtk_widget_unref(message_wid);
1282 void main_window_toggle_message_view(MainWindow *mainwin)
1284 SummaryView *summaryview = mainwin->summaryview;
1285 union CompositeWin *cwin = &mainwin->win;
1286 GtkWidget *vpaned = NULL;
1287 GtkWidget *container = NULL;
1288 GtkWidget *msgwin = NULL;
1290 switch (mainwin->type) {
1292 vpaned = cwin->sep_none.vpaned;
1293 container = cwin->sep_none.hpaned;
1295 case SEPARATE_FOLDER:
1296 vpaned = cwin->sep_folder.vpaned;
1297 container = mainwin->vbox_body;
1299 case SEPARATE_MESSAGE:
1300 msgwin = mainwin->win.sep_message.messagewin;
1303 msgwin = mainwin->win.sep_both.messagewin;
1308 if (GTK_WIDGET_VISIBLE(msgwin)) {
1309 gtk_widget_hide(msgwin);
1310 mainwin->messageview->visible = FALSE;
1311 summaryview->displayed = NULL;
1313 gtk_widget_show(msgwin);
1314 mainwin->messageview->visible = TRUE;
1316 } else if (vpaned->parent != NULL) {
1317 mainwin->messageview->visible = FALSE;
1318 summaryview->displayed = NULL;
1319 gtk_widget_ref(vpaned);
1320 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1321 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1322 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1323 GTK_ARROW_UP, GTK_SHADOW_OUT);
1325 mainwin->messageview->visible = TRUE;
1326 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1327 gtk_container_add(GTK_CONTAINER(container), vpaned);
1328 gtk_widget_unref(vpaned);
1329 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1330 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1333 main_window_set_menu_sensitive(mainwin);
1335 prefs_common.msgview_visible = mainwin->messageview->visible;
1337 gtk_widget_grab_focus(summaryview->ctree);
1340 void main_window_get_size(MainWindow *mainwin)
1342 GtkAllocation *allocation;
1344 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1346 if (allocation->width > 1 && allocation->height > 1) {
1347 prefs_common.summaryview_width = allocation->width;
1349 if ((mainwin->type == SEPARATE_NONE ||
1350 mainwin->type == SEPARATE_FOLDER) &&
1351 messageview_is_visible(mainwin->messageview))
1352 prefs_common.summaryview_height = allocation->height;
1354 prefs_common.mainview_width = allocation->width;
1357 allocation = &mainwin->window->allocation;
1358 if (allocation->width > 1 && allocation->height > 1) {
1359 prefs_common.mainview_height = allocation->height;
1360 prefs_common.mainwin_width = allocation->width;
1361 prefs_common.mainwin_height = allocation->height;
1364 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1365 if (allocation->width > 1 && allocation->height > 1) {
1366 prefs_common.folderview_width = allocation->width;
1367 prefs_common.folderview_height = allocation->height;
1370 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1371 if (allocation->width > 1 && allocation->height > 1) {
1372 prefs_common.msgview_width = allocation->width;
1373 prefs_common.msgview_height = allocation->height;
1376 debug_print("summaryview size: %d x %d\n",
1377 prefs_common.summaryview_width,
1378 prefs_common.summaryview_height);
1379 debug_print("folderview size: %d x %d\n",
1380 prefs_common.folderview_width,
1381 prefs_common.folderview_height);
1382 debug_print("messageview size: %d x %d\n",
1383 prefs_common.msgview_width,
1384 prefs_common.msgview_height);
1387 void main_window_get_position(MainWindow *mainwin)
1392 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1394 prefs_common.mainview_x = x;
1395 prefs_common.mainview_y = y;
1396 prefs_common.mainwin_x = x;
1397 prefs_common.mainwin_y = y;
1399 debug_print("main window position: %d, %d\n", x, y);
1401 window = main_window_get_folder_window(mainwin);
1403 gtkut_widget_get_uposition(window, &x, &y);
1404 prefs_common.folderwin_x = x;
1405 prefs_common.folderwin_y = y;
1406 debug_print("folder window position: %d, %d\n", x, y);
1408 window = main_window_get_message_window(mainwin);
1410 gtkut_widget_get_uposition(window, &x, &y);
1411 prefs_common.main_msgwin_x = x;
1412 prefs_common.main_msgwin_y = y;
1413 debug_print("message window position: %d, %d\n", x, y);
1417 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1423 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1424 folder = FOLDER(list->data);
1425 if (folder && folder->trash && folder->trash->total_msgs > 0)
1429 if (!has_trash) return;
1432 if (alertpanel(_("Empty trash"),
1433 _("Empty all messages in trash?"),
1434 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1436 manage_window_focus_in(mainwin->window, NULL, NULL);
1439 procmsg_empty_trash();
1441 if (mainwin->summaryview->folder_item &&
1442 mainwin->summaryview->folder_item->stype == F_TRASH)
1443 gtk_widget_grab_focus(mainwin->folderview->ctree);
1446 void main_window_add_mailbox(MainWindow *mainwin)
1451 path = input_dialog(_("Add mailbox"),
1452 _("Input the location of mailbox.\n"
1453 "If the existing mailbox is specified, it will be\n"
1454 "scanned automatically."),
1457 if (folder_find_from_path(path)) {
1458 alertpanel_error(_("The mailbox `%s' already exists."), path);
1462 folder = folder_new(folder_get_class_from_string("mh"),
1463 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1467 if (folder->klass->create_tree(folder) < 0) {
1468 alertpanel_error(_("Creation of the mailbox failed.\n"
1469 "Maybe some files already exist, or you don't have the permission to write there."));
1470 folder_destroy(folder);
1475 folder_set_ui_func(folder, scan_tree_func, mainwin);
1476 folder_scan_tree(folder);
1477 folder_set_ui_func(folder, NULL, NULL);
1479 folderview_set(mainwin->folderview);
1482 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1484 SensitiveCond state = 0;
1485 SummarySelection selection;
1486 FolderItem *item = mainwin->summaryview->folder_item;
1487 GList *account_list = account_get_list();
1489 selection = summary_get_selection_type(mainwin->summaryview);
1491 if (mainwin->lock_count == 0)
1492 state |= M_UNLOCKED;
1493 if (selection != SUMMARY_NONE)
1494 state |= M_MSG_EXIST;
1495 if (item && item->path && item->parent && !item->no_select) {
1497 /* if (item->folder->type != F_NEWS) */
1498 state |= M_ALLOW_DELETE;
1500 if (prefs_common.immediate_exec == 0
1501 && mainwin->lock_count == 0)
1502 state |= M_DELAY_EXEC;
1504 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1505 || selection != SUMMARY_NONE)
1506 state |= M_HIDE_READ_MSG;
1508 if (mainwin->summaryview->threaded)
1509 state |= M_THREADED;
1511 state |= M_UNTHREADED;
1512 if (selection == SUMMARY_SELECTED_SINGLE ||
1513 selection == SUMMARY_SELECTED_MULTIPLE)
1514 state |= M_TARGET_EXIST;
1515 if (selection == SUMMARY_SELECTED_SINGLE)
1516 state |= M_SINGLE_TARGET_EXIST;
1517 if (mainwin->summaryview->folder_item &&
1518 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1521 state |= M_NOT_NEWS;
1522 if (selection == SUMMARY_SELECTED_SINGLE &&
1524 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1525 item->stype == F_QUEUE)))
1526 state |= M_ALLOW_REEDIT;
1528 state |= M_HAVE_ACCOUNT;
1530 for ( ; account_list != NULL; account_list = account_list->next) {
1531 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1532 state |= M_HAVE_NEWS_ACCOUNT;
1537 if (inc_is_active())
1538 state |= M_INC_ACTIVE;
1545 void main_window_set_menu_sensitive(MainWindow *mainwin)
1547 GtkItemFactory *ifactory = mainwin->menu_factory;
1548 SensitiveCond state;
1550 GtkWidget *menuitem;
1551 SummaryView *summaryview;
1555 static const struct {
1559 {"/File/Folder" , M_UNLOCKED},
1560 {"/File/Add mailbox" , M_UNLOCKED},
1562 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1563 {"/File/Export to mbox file..." , M_UNLOCKED},
1564 {"/File/Empty trash" , M_UNLOCKED},
1565 {"/File/Work offline" , M_UNLOCKED},
1567 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1568 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1569 /* {"/File/Close" , M_UNLOCKED}, */
1570 {"/File/Exit" , M_UNLOCKED},
1572 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1574 {"/View/Sort" , M_EXEC},
1575 {"/View/Thread view" , M_EXEC},
1576 {"/View/Expand all threads" , M_MSG_EXIST},
1577 {"/View/Collapse all threads" , M_MSG_EXIST},
1578 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1579 {"/View/Go to/Prev message" , M_MSG_EXIST},
1580 {"/View/Go to/Next message" , M_MSG_EXIST},
1581 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1582 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1583 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1584 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1585 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1586 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1587 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1588 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1589 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1591 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1592 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1593 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1594 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1595 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1596 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1597 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1598 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1599 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1600 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1601 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1602 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1603 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1604 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1605 {"/Message/Mark" , M_TARGET_EXIST},
1607 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1608 {"/Tools/Harvest addresses" , M_UNLOCKED},
1609 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1610 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1611 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1612 {"/Tools/Execute" , M_DELAY_EXEC},
1613 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1615 {"/Configuration", M_UNLOCKED},
1620 state = main_window_get_current_state(mainwin);
1622 for (i = 0; entry[i].entry != NULL; i++) {
1623 sensitive = ((entry[i].cond & state) == entry[i].cond);
1624 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1627 main_window_menu_callback_block(mainwin);
1629 #define SET_CHECK_MENU_ACTIVE(path, active) \
1631 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1632 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1635 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1636 messageview_is_visible(mainwin->messageview));
1638 summaryview = mainwin->summaryview;
1639 menu_path = "/View/Sort/Don't sort";
1641 switch (summaryview->sort_key) {
1642 case SORT_BY_NUMBER:
1643 menu_path = "/View/Sort/by number"; break;
1645 menu_path = "/View/Sort/by size"; break;
1647 menu_path = "/View/Sort/by date"; break;
1649 menu_path = "/View/Sort/by from"; break;
1651 menu_path = "/View/Sort/by recipient"; break;
1652 case SORT_BY_SUBJECT:
1653 menu_path = "/View/Sort/by subject"; break;
1655 menu_path = "/View/Sort/by color label"; break;
1657 menu_path = "/View/Sort/by mark"; break;
1658 case SORT_BY_STATUS:
1659 menu_path = "/View/Sort/by status"; break;
1661 menu_path = "/View/Sort/by attachment"; break;
1663 menu_path = "/View/Sort/by score"; break;
1664 case SORT_BY_LOCKED:
1665 menu_path = "/View/Sort/by locked"; break;
1668 menu_path = "/View/Sort/Don't sort"; break;
1670 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1672 if (summaryview->sort_type == SORT_ASCENDING) {
1673 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1675 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1678 if (summaryview->sort_key != SORT_BY_NONE) {
1679 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1680 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1682 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1683 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1686 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1687 mainwin->messageview->mimeview->textview->show_all_headers);
1688 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1690 #undef SET_CHECK_MENU_ACTIVE
1692 main_window_menu_callback_unblock(mainwin);
1695 void main_window_popup(MainWindow *mainwin)
1697 gtkut_window_popup(mainwin->window);
1699 switch (mainwin->type) {
1700 case SEPARATE_FOLDER:
1701 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1703 case SEPARATE_MESSAGE:
1704 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1707 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1708 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1715 void main_window_show(MainWindow *mainwin)
1717 gtk_widget_show(mainwin->window);
1718 gtk_widget_show(mainwin->vbox_body);
1720 gtk_widget_set_uposition(mainwin->window,
1721 prefs_common.mainwin_x,
1722 prefs_common.mainwin_y);
1724 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1725 prefs_common.folderview_width,
1726 prefs_common.folderview_height);
1727 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1728 prefs_common.summaryview_width,
1729 prefs_common.summaryview_height);
1730 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1731 prefs_common.msgview_width,
1732 prefs_common.msgview_height);
1734 if (mainwin->type & SEPARATE_FOLDER) {
1735 GtkWidget *folderwin;
1737 folderwin = main_window_get_folder_window(mainwin);
1738 gtk_widget_show(folderwin);
1739 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1740 prefs_common.folderwin_y);
1743 if (mainwin->type & SEPARATE_MESSAGE) {
1744 GtkWidget *messagewin;
1746 messagewin = main_window_get_message_window(mainwin);
1747 gtk_widget_show(messagewin);
1748 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1749 prefs_common.main_msgwin_y);
1753 void main_window_hide(MainWindow *mainwin)
1755 main_window_get_size(mainwin);
1756 main_window_get_position(mainwin);
1758 gtk_widget_hide(mainwin->window);
1759 gtk_widget_hide(mainwin->vbox_body);
1761 if (mainwin->type & SEPARATE_FOLDER) {
1762 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1765 if (mainwin->type & SEPARATE_MESSAGE) {
1766 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1770 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1772 GtkWidget *folderwin = NULL;
1773 GtkWidget *messagewin = NULL;
1776 GtkWidget *vbox_body = mainwin->vbox_body;
1777 GtkItemFactory *ifactory = mainwin->menu_factory;
1778 GtkWidget *menuitem;
1779 GtkItemFactory *msgview_ifactory;
1781 debug_print("Setting widgets... ");
1783 /* create separated window(s) if needed */
1784 if (type & SEPARATE_FOLDER) {
1785 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1786 gtk_window_set_title(GTK_WINDOW(folderwin),
1787 _("Sylpheed - Folder View"));
1788 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1789 "folder_view", "Sylpheed");
1790 gtk_window_set_policy(GTK_WINDOW(folderwin),
1792 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1793 prefs_common.folderwin_y);
1794 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1796 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1797 GTK_SIGNAL_FUNC(folder_window_close_cb),
1799 gtk_container_add(GTK_CONTAINER(folderwin),
1800 GTK_WIDGET_PTR(mainwin->folderview));
1801 gtk_widget_realize(folderwin);
1802 if (prefs_common.folderview_visible)
1803 gtk_widget_show(folderwin);
1805 if (type & SEPARATE_MESSAGE) {
1806 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1807 gtk_window_set_title(GTK_WINDOW(messagewin),
1808 _("Sylpheed - Message View"));
1809 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1810 "message_view", "Sylpheed");
1811 gtk_window_set_policy(GTK_WINDOW(messagewin),
1813 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1814 prefs_common.main_msgwin_y);
1815 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1817 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1818 GTK_SIGNAL_FUNC(message_window_close_cb),
1820 if (messageview_is_visible(mainwin->messageview))
1821 gtk_widget_show(messagewin);
1824 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1825 prefs_common.folderview_width,
1826 prefs_common.folderview_height);
1827 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1828 prefs_common.summaryview_width,
1829 prefs_common.summaryview_height);
1830 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1831 prefs_common.msgview_width,
1832 prefs_common.msgview_height);
1836 hpaned = gtk_hpaned_new();
1837 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1838 gtk_paned_add1(GTK_PANED(hpaned),
1839 GTK_WIDGET_PTR(mainwin->folderview));
1840 gtk_widget_show(hpaned);
1841 gtk_widget_queue_resize(hpaned);
1843 vpaned = gtk_vpaned_new();
1844 if (messageview_is_visible(mainwin->messageview)) {
1845 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1846 gtk_paned_add1(GTK_PANED(vpaned),
1847 GTK_WIDGET_PTR(mainwin->summaryview));
1849 gtk_paned_add2(GTK_PANED(hpaned),
1850 GTK_WIDGET_PTR(mainwin->summaryview));
1851 gtk_widget_ref(vpaned);
1853 gtk_paned_add2(GTK_PANED(vpaned),
1854 GTK_WIDGET_PTR(mainwin->messageview));
1855 gtk_widget_show(vpaned);
1856 gtk_widget_queue_resize(vpaned);
1858 mainwin->win.sep_none.hpaned = hpaned;
1859 mainwin->win.sep_none.vpaned = vpaned;
1861 /* remove headerview if not in prefs */
1862 headerview_set_visibility(mainwin->messageview->headerview,
1863 prefs_common.display_header_pane);
1865 case SEPARATE_FOLDER:
1866 vpaned = gtk_vpaned_new();
1867 if (messageview_is_visible(mainwin->messageview)) {
1868 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1870 gtk_paned_add1(GTK_PANED(vpaned),
1871 GTK_WIDGET_PTR(mainwin->summaryview));
1873 gtk_box_pack_start(GTK_BOX(vbox_body),
1874 GTK_WIDGET_PTR(mainwin->summaryview),
1876 gtk_widget_ref(vpaned);
1878 gtk_paned_add2(GTK_PANED(vpaned),
1879 GTK_WIDGET_PTR(mainwin->messageview));
1880 gtk_widget_show(vpaned);
1881 gtk_widget_queue_resize(vpaned);
1883 mainwin->win.sep_folder.folderwin = folderwin;
1884 mainwin->win.sep_folder.vpaned = vpaned;
1886 /* remove headerview if not in prefs */
1887 headerview_set_visibility(mainwin->messageview->headerview,
1888 prefs_common.display_header_pane);
1891 case SEPARATE_MESSAGE:
1892 hpaned = gtk_hpaned_new();
1893 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1894 gtk_paned_add1(GTK_PANED(hpaned),
1895 GTK_WIDGET_PTR(mainwin->folderview));
1896 gtk_paned_add2(GTK_PANED(hpaned),
1897 GTK_WIDGET_PTR(mainwin->summaryview));
1898 gtk_widget_show(hpaned);
1899 gtk_widget_queue_resize(hpaned);
1900 messageview_add_toolbar(mainwin->messageview, messagewin);
1901 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1902 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1904 mainwin->win.sep_message.messagewin = messagewin;
1905 mainwin->win.sep_message.hpaned = hpaned;
1907 gtk_widget_realize(messagewin);
1908 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1909 gtk_widget_show_all(messagewin);
1910 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1911 mainwin->messageview->handlebox,
1912 prefs_common.toolbar_style);
1916 messageview_add_toolbar(mainwin->messageview, messagewin);
1917 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1918 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1920 gtk_box_pack_start(GTK_BOX(vbox_body),
1921 GTK_WIDGET_PTR(mainwin->summaryview),
1924 mainwin->win.sep_both.folderwin = folderwin;
1925 mainwin->win.sep_both.messagewin = messagewin;
1927 gtk_widget_realize(messagewin);
1928 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1929 gtk_widget_show_all(messagewin);
1930 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1931 mainwin->messageview->handlebox,
1932 prefs_common.toolbar_style);
1937 gtk_widget_set_uposition(mainwin->window,
1938 prefs_common.mainwin_x,
1939 prefs_common.mainwin_y);
1941 gtk_widget_queue_resize(vbox_body);
1942 gtk_widget_queue_resize(mainwin->vbox);
1943 gtk_widget_queue_resize(mainwin->window);
1944 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1945 * and mimeview icon list/ctree lose track of their visibility states */
1946 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1947 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1948 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
1949 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
1950 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
1951 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
1953 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
1955 /* rehide quick search if necessary */
1956 if (!prefs_common.show_searchbar)
1957 gtk_widget_hide(mainwin->summaryview->hbox_search);
1959 mainwin->type = type;
1962 /* toggle menu state */
1963 menuitem = gtk_item_factory_get_item
1964 (ifactory, "/View/Show or hide/Folder tree");
1965 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1966 (type & SEPARATE_FOLDER) == 0 ? TRUE :
1967 prefs_common.folderview_visible);
1968 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
1969 menuitem = gtk_item_factory_get_item
1970 (ifactory, "/View/Show or hide/Message view");
1971 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1972 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
1973 prefs_common.msgview_visible);
1975 menuitem = gtk_item_factory_get_item
1976 (ifactory, "/View/Separate folder tree");
1977 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1978 ((type & SEPARATE_FOLDER) != 0));
1979 menuitem = gtk_item_factory_get_item
1980 (ifactory, "/View/Separate message view");
1981 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1982 ((type & SEPARATE_MESSAGE) != 0));
1986 (GTK_OBJECT(folderwin), "size_allocate",
1987 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
1992 (GTK_OBJECT(messagewin), "size_allocate",
1993 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
1997 debug_print("done.\n");
2000 void main_window_destroy_all(void)
2002 while (mainwin_list != NULL) {
2003 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2005 /* free toolbar stuff */
2006 toolbar_clear_list(TOOLBAR_MAIN);
2007 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2008 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2010 g_free(mainwin->toolbar);
2013 mainwin_list = g_list_remove(mainwin_list, mainwin);
2015 g_list_free(mainwin_list);
2019 static void toolbar_account_button_pressed(GtkWidget *widget,
2020 GdkEventButton *event,
2023 MainWindow *mainwin = (MainWindow *)data;
2026 if (event->button != 3) return;
2028 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2029 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2032 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2033 menu_button_position, widget,
2034 event->button, event->time);
2038 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2041 MainWindow *mainwin = (MainWindow *)data;
2045 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2046 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2049 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2050 menu_button_position, widget,
2051 event->button, event->time);
2054 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2056 MainWindow *mainwin = (MainWindow *)data;
2059 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2060 if (!button) return;
2061 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2062 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2063 manage_window_focus_in(mainwin->window, NULL, NULL);
2066 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2069 MainWindow *mainwin = (MainWindow *)data;
2071 if (mainwin->lock_count == 0)
2072 app_exit_cb(data, 0, widget);
2077 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2080 MainWindow *mainwin = (MainWindow *)data;
2081 GtkWidget *menuitem;
2083 menuitem = gtk_item_factory_get_item
2084 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2085 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2090 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2093 MainWindow *mainwin = (MainWindow *)data;
2094 GtkWidget *menuitem;
2096 menuitem = gtk_item_factory_get_item
2097 (mainwin->menu_factory, "/View/Show or hide/Message view");
2098 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2103 static void main_window_size_allocate_cb(GtkWidget *widget,
2104 GtkAllocation *allocation,
2107 MainWindow *mainwin = (MainWindow *)data;
2109 main_window_get_size(mainwin);
2112 static void folder_window_size_allocate_cb(GtkWidget *widget,
2113 GtkAllocation *allocation,
2116 MainWindow *mainwin = (MainWindow *)data;
2118 main_window_get_size(mainwin);
2121 static void message_window_size_allocate_cb(GtkWidget *widget,
2122 GtkAllocation *allocation,
2125 MainWindow *mainwin = (MainWindow *)data;
2127 main_window_get_size(mainwin);
2130 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2133 main_window_add_mailbox(mainwin);
2136 static void update_folderview_cb(MainWindow *mainwin, guint action,
2139 summary_show(mainwin->summaryview, NULL);
2140 folderview_check_new_all();
2143 static void new_folder_cb(MainWindow *mainwin, guint action,
2146 folderview_new_folder(mainwin->folderview);
2149 static void rename_folder_cb(MainWindow *mainwin, guint action,
2152 folderview_rename_folder(mainwin->folderview);
2155 static void delete_folder_cb(MainWindow *mainwin, guint action,
2158 folderview_delete_folder(mainwin->folderview);
2161 static void import_mbox_cb(MainWindow *mainwin, guint action,
2164 import_mbox(mainwin->summaryview->folder_item);
2167 static void export_mbox_cb(MainWindow *mainwin, guint action,
2170 export_mbox(mainwin->summaryview->folder_item);
2173 static void empty_trash_cb(MainWindow *mainwin, guint action,
2176 main_window_empty_trash(mainwin, TRUE);
2179 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2181 summary_save_as(mainwin->summaryview);
2184 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2186 summary_print(mainwin->summaryview);
2189 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2191 if (prefs_common.confirm_on_exit) {
2192 if (alertpanel(_("Exit"), _("Exit this program?"),
2193 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2195 manage_window_focus_in(mainwin->window, NULL, NULL);
2198 app_will_exit(widget, mainwin);
2201 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2204 summary_search(mainwin->summaryview);
2206 message_search(mainwin->messageview);
2209 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2214 active = GTK_CHECK_MENU_ITEM(widget)->active;
2216 switch (mainwin->type) {
2218 case SEPARATE_MESSAGE:
2221 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2223 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2226 case SEPARATE_FOLDER:
2227 debug_print("separate folder\n");
2229 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2231 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2235 gtk_widget_show(mainwin->win.sep_both.folderwin);
2237 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2241 prefs_common.folderview_visible = active;
2244 static void toggle_message_cb(MainWindow *mainwin, guint action,
2249 active = GTK_CHECK_MENU_ITEM(widget)->active;
2251 if (active != messageview_is_visible(mainwin->messageview))
2252 summary_toggle_view(mainwin->summaryview);
2255 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2258 toolbar_toggle(action, mainwin);
2261 void main_window_reply_cb(MainWindow *mainwin, guint action,
2264 MessageView *msgview = (MessageView*)mainwin->messageview;
2265 GSList *msginfo_list = NULL;
2268 g_return_if_fail(msgview != NULL);
2270 msginfo_list = summary_get_selection(mainwin->summaryview);
2271 g_return_if_fail(msginfo_list != NULL);
2273 body = messageview_get_selection(msgview);
2274 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2276 g_slist_free(msginfo_list);
2280 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2283 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2284 gtk_widget_show(mainwin->hbox_stat);
2285 prefs_common.show_statusbar = TRUE;
2287 gtk_widget_hide(mainwin->hbox_stat);
2288 prefs_common.show_statusbar = FALSE;
2292 static void separate_widget_cb(MainWindow *mainwin, guint action,
2297 if (GTK_CHECK_MENU_ITEM(widget)->active)
2298 type = mainwin->type | action;
2300 type = mainwin->type & ~action;
2302 main_window_separation_change(mainwin, type);
2304 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2305 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2308 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2311 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2313 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2316 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2318 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2321 static void online_switch_clicked (GtkButton *btn, gpointer data)
2323 MainWindow *mainwin;
2324 GtkItemFactory *ifactory;
2325 GtkCheckMenuItem *menuitem;
2327 mainwin = (MainWindow *) data;
2329 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2330 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2332 g_return_if_fail(mainwin != NULL);
2333 g_return_if_fail(menuitem != NULL);
2335 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2337 gtk_widget_hide (mainwin->online_switch);
2338 gtk_widget_show (mainwin->offline_switch);
2339 menuitem->active = TRUE;
2340 prefs_common.work_offline = TRUE;
2341 inc_autocheck_timer_remove();
2344 gtk_widget_hide (mainwin->offline_switch);
2345 gtk_widget_show (mainwin->online_switch);
2346 menuitem->active = FALSE;
2347 prefs_common.work_offline = FALSE;
2348 inc_autocheck_timer_set();
2352 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2355 addressbook_open(NULL);
2358 static void log_window_show_cb(MainWindow *mainwin, guint action,
2361 log_window_show(mainwin->logwin);
2364 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2369 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2371 summary_move_to(mainwin->summaryview);
2374 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2376 summary_copy_to(mainwin->summaryview);
2379 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2381 summary_delete(mainwin->summaryview);
2384 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2386 summary_cancel(mainwin->summaryview);
2389 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2391 summary_open_msg(mainwin->summaryview);
2394 static void view_source_cb(MainWindow *mainwin, guint action,
2397 summary_view_source(mainwin->summaryview);
2400 static void show_all_header_cb(MainWindow *mainwin, guint action,
2403 if (mainwin->menu_lock_count) return;
2404 summary_display_msg_selected(mainwin->summaryview,
2405 GTK_CHECK_MENU_ITEM(widget)->active);
2408 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2410 summary_reedit(mainwin->summaryview);
2413 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2415 summary_mark(mainwin->summaryview);
2418 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2420 summary_unmark(mainwin->summaryview);
2423 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2426 summary_mark_as_unread(mainwin->summaryview);
2429 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2432 summary_mark_as_read(mainwin->summaryview);
2435 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2438 summary_mark_all_read(mainwin->summaryview);
2441 static void add_address_cb(MainWindow *mainwin, guint action,
2444 summary_add_address(mainwin->summaryview);
2447 static void set_charset_cb(MainWindow *mainwin, guint action,
2452 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2453 str = conv_get_charset_str((CharSet)action);
2454 g_free(prefs_common.force_charset);
2455 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2457 summary_redisplay_msg(mainwin->summaryview);
2459 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2463 static void hide_read_messages (MainWindow *mainwin, guint action,
2466 if (!mainwin->summaryview->folder_item
2467 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2469 summary_toggle_show_read_messages(mainwin->summaryview);
2472 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2474 if (mainwin->menu_lock_count) return;
2475 if (!mainwin->summaryview->folder_item) return;
2477 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2478 summary_thread_build(mainwin->summaryview);
2479 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2481 summary_unthread(mainwin->summaryview);
2482 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2486 static void expand_threads_cb(MainWindow *mainwin, guint action,
2489 summary_expand_threads(mainwin->summaryview);
2492 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2495 summary_collapse_threads(mainwin->summaryview);
2498 static void set_display_item_cb(MainWindow *mainwin, guint action,
2501 prefs_summary_column_open();
2504 static void sort_summary_cb(MainWindow *mainwin, guint action,
2507 FolderItem *item = mainwin->summaryview->folder_item;
2508 GtkWidget *menuitem;
2510 if (mainwin->menu_lock_count) return;
2512 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2513 menuitem = gtk_item_factory_get_item
2514 (mainwin->menu_factory, "/View/Sort/Ascending");
2515 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2516 GTK_CHECK_MENU_ITEM(menuitem)->active
2517 ? SORT_ASCENDING : SORT_DESCENDING);
2521 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2524 FolderItem *item = mainwin->summaryview->folder_item;
2526 if (mainwin->menu_lock_count) return;
2528 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2529 summary_sort(mainwin->summaryview,
2530 item->sort_key, (FolderSortType)action);
2533 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2536 summary_attract_by_subject(mainwin->summaryview);
2539 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2542 summary_delete_duplicated(mainwin->summaryview);
2545 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2547 summary_filter(mainwin->summaryview);
2550 static void execute_summary_cb(MainWindow *mainwin, guint action,
2553 summary_execute(mainwin->summaryview);
2556 static void update_summary_cb(MainWindow *mainwin, guint action,
2560 FolderView *folderview = mainwin->folderview;
2562 if (!mainwin->summaryview->folder_item) return;
2563 if (!folderview->opened) return;
2565 folder_update_op_count();
2567 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2568 folderview->opened);
2571 folder_item_scan(fitem);
2572 summary_show(mainwin->summaryview, fitem);
2575 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2577 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2580 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2582 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2585 static void prev_unread_cb(MainWindow *mainwin, guint action,
2588 summary_select_prev_unread(mainwin->summaryview);
2591 static void next_unread_cb(MainWindow *mainwin, guint action,
2594 summary_select_next_unread(mainwin->summaryview);
2597 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2599 summary_select_prev_new(mainwin->summaryview);
2602 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2604 summary_select_next_new(mainwin->summaryview);
2607 static void prev_marked_cb(MainWindow *mainwin, guint action,
2610 summary_select_prev_marked(mainwin->summaryview);
2613 static void next_marked_cb(MainWindow *mainwin, guint action,
2616 summary_select_next_marked(mainwin->summaryview);
2619 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2622 summary_select_prev_labeled(mainwin->summaryview);
2625 static void next_labeled_cb(MainWindow *mainwin, guint action,
2628 summary_select_next_labeled(mainwin->summaryview);
2631 static void goto_folder_cb(MainWindow *mainwin, guint action,
2634 FolderItem *to_folder;
2636 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2639 folderview_select(mainwin->folderview, to_folder);
2642 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 messageview_copy_clipboard(mainwin->messageview);
2647 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2649 MessageView *msgview = mainwin->messageview;
2651 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2652 summary_select_all(mainwin->summaryview);
2653 else if (messageview_is_visible(msgview) &&
2654 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2655 messageview_select_all(mainwin->messageview);
2658 static void select_thread_cb(MainWindow *mainwin, guint action,
2661 summary_select_thread(mainwin->summaryview);
2664 static void create_filter_cb(MainWindow *mainwin, guint action,
2667 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2670 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2673 prefs_common_open();
2676 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2679 prefs_scoring_open(NULL);
2682 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2685 prefs_filtering_open(NULL, NULL, NULL);
2688 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2691 prefs_template_open();
2694 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2697 prefs_actions_open(mainwin);
2700 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2703 ssl_manager_open(mainwin);
2706 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2710 new_account_cb(mainwin, 0, widget);
2712 account_open(cur_account);
2716 static void new_account_cb(MainWindow *mainwin, guint action,
2719 account_edit_open();
2720 if (!compose_get_compose_list()) account_add();
2723 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2725 cur_account = (PrefsAccount *)data;
2726 main_window_reflect_prefs_all();
2729 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2734 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2736 pluginwindow_create();
2739 static void manual_open_cb(MainWindow *mainwin, guint action,
2742 manual_open((ManualType)action);
2745 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2747 MainWindow *mainwin = (MainWindow *)data;
2751 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2752 LOCAL_FOLDER(folder)->rootpath,
2756 str = g_strdup_printf(_("Scanning folder %s ..."),
2757 LOCAL_FOLDER(folder)->rootpath);
2759 STATUSBAR_PUSH(mainwin, str);
2760 STATUSBAR_POP(mainwin);
2764 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2767 SummaryView *summary;
2769 g_return_val_if_fail(data, FALSE);
2770 summary = ((MainWindow *)data)->summaryview;
2771 g_return_val_if_fail(summary, FALSE);
2773 if (GTK_CLIST(summary->ctree)->selection &&
2774 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2777 if (summary->selected != summary->displayed)
2778 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2782 #define BREAK_ON_MODIFIER_KEY() \
2783 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2785 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2788 MainWindow *mainwin = (MainWindow*) data;
2790 if (!mainwin || !event) return;
2792 switch (event->keyval) {
2793 case GDK_Q: /* Quit */
2794 BREAK_ON_MODIFIER_KEY();
2796 app_exit_cb(mainwin, 0, NULL);
2799 if (mainwin->folderview && mainwin->summaryview
2800 && !mainwin->summaryview->displayed) {
2801 summary_lock(mainwin->summaryview);
2802 folderview_select_next_unread(mainwin->folderview);
2803 summary_unlock(mainwin->summaryview);
2811 #undef BREAK_ON_MODIFIER_KEY
2814 * Harvest addresses for selected folder.
2816 static void addr_harvest_cb( MainWindow *mainwin,
2820 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2824 * Harvest addresses for selected messages in summary view.
2826 static void addr_harvest_msg_cb( MainWindow *mainwin,
2830 summary_harvest_address( mainwin->summaryview );
2834 *\brief get a MainWindow
2836 *\return MainWindow * The first mainwindow in the mainwin_list
2838 MainWindow *mainwindow_get_mainwindow(void)
2840 if (mainwin_list && mainwin_list->data)
2841 return (MainWindow *)(mainwin_list->data);
2846 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2848 ProgressData *data = (ProgressData *) source;
2849 MainWindow *mainwin = (MainWindow *) userdata;
2851 switch (data->cmd) {
2852 case PROGRESS_COMMAND_START:
2853 case PROGRESS_COMMAND_STOP:
2854 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2856 case PROGRESS_COMMAND_SET_PERCENTAGE:
2857 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2860 while (gtk_events_pending()) gtk_main_iteration ();