2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_actions.h"
64 #include "prefs_filtering.h"
65 #include "prefs_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_folder_item.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_template.h"
70 #include "prefs_toolbar.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.h"
87 #include "prefswindow.h"
88 #include "pluginwindow.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 add_mailbox_cb (MainWindow *mainwin,
129 static void add_mbox_cb (MainWindow *mainwin,
132 static void update_folderview_cb (MainWindow *mainwin,
135 static void new_folder_cb (MainWindow *mainwin,
138 static void rename_folder_cb (MainWindow *mainwin,
141 static void delete_folder_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,
190 static void sel_download_cb (MainWindow *mainwin,
193 static void prefs_toolbar_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,
406 #define SEPARATE_ACTION 500
408 static GtkItemFactoryEntry mainwin_entries[] =
410 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
411 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
412 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
413 {N_("/_File/_Check for new messages in all folders"),
414 NULL, update_folderview_cb, 0, NULL},
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/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
421 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
422 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
423 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
424 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
425 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
426 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
427 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
428 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
429 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
431 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
432 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
433 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
434 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
435 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
436 {N_("/_Edit/_Find in current message..."),
437 "<control>F", search_cb, 0, NULL},
438 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
439 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
440 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
441 {N_("/_View/Show or hi_de/_Folder tree"),
442 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
443 {N_("/_View/Show or hi_de/_Message view"),
444 "V", toggle_message_cb, 0, "<ToggleItem>"},
445 {N_("/_View/Show or hi_de/_Toolbar"),
446 NULL, NULL, 0, "<Branch>"},
447 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
448 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
449 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
450 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
451 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
452 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
453 {N_("/_View/Show or hi_de/_Toolbar/_None"),
454 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
455 {N_("/_View/Show or hi_de/Status _bar"),
456 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
457 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
459 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
460 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
461 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
462 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
463 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
464 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
465 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
466 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
467 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
468 {N_("/_View/_Sort/by _color label"),
469 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
470 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
471 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
472 {N_("/_View/_Sort/by a_ttachment"),
473 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
474 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
475 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
476 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
477 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
479 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
480 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
481 {N_("/_View/_Sort/_Attract by subject"),
482 NULL, attract_by_subject_cb, 0, NULL},
483 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
484 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
485 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
486 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
487 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
489 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
492 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
493 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_View/_Go to/P_rev unread message"),
495 "<shift>P", prev_unread_cb, 0, NULL},
496 {N_("/_View/_Go to/N_ext unread message"),
497 "<shift>N", next_unread_cb, 0, NULL},
498 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
500 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
501 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_View/_Go to/Prev _marked message"),
503 NULL, prev_marked_cb, 0, NULL},
504 {N_("/_View/_Go to/Next m_arked message"),
505 NULL, next_marked_cb, 0, NULL},
506 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_View/_Go to/Prev _labeled message"),
508 NULL, prev_labeled_cb, 0, NULL},
509 {N_("/_View/_Go to/Next la_beled message"),
510 NULL, next_labeled_cb, 0, NULL},
511 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
513 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
515 #define CODESET_SEPARATOR \
516 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
517 #define CODESET_ACTION(action) \
518 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
520 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
521 {N_("/_View/_Code set/_Auto detect"),
522 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
523 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
525 CODESET_ACTION(C_US_ASCII)},
528 {N_("/_View/_Code set/Unicode (_UTF-8)"),
529 CODESET_ACTION(C_UTF_8)},
532 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
533 CODESET_ACTION(C_ISO_8859_1)},
534 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
535 CODESET_ACTION(C_ISO_8859_15)},
538 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
539 CODESET_ACTION(C_ISO_8859_2)},
541 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
542 CODESET_ACTION(C_ISO_8859_13)},
543 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
544 CODESET_ACTION(C_ISO_8859_4)},
546 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
547 CODESET_ACTION(C_ISO_8859_7)},
549 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
550 CODESET_ACTION(C_ISO_8859_9)},
552 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
553 CODESET_ACTION(C_ISO_8859_5)},
554 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
555 CODESET_ACTION(C_KOI8_R)},
556 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
557 CODESET_ACTION(C_WINDOWS_1251)},
560 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
561 CODESET_ACTION(C_ISO_2022_JP)},
563 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
564 CODESET_ACTION(C_ISO_2022_JP_2)},
566 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
567 CODESET_ACTION(C_EUC_JP)},
568 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
569 CODESET_ACTION(C_SHIFT_JIS)},
572 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
573 CODESET_ACTION(C_GB2312)},
574 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
575 CODESET_ACTION(C_BIG5)},
576 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
577 CODESET_ACTION(C_EUC_TW)},
578 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
579 CODESET_ACTION(C_ISO_2022_CN)},
581 {N_("/_View/_Code set/Korean (EUC-_KR)"),
582 CODESET_ACTION(C_EUC_KR)},
583 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
584 CODESET_ACTION(C_ISO_2022_KR)},
586 {N_("/_View/_Code set/Thai (TIS-620)"),
587 CODESET_ACTION(C_TIS_620)},
588 {N_("/_View/_Code set/Thai (Windows-874)"),
589 CODESET_ACTION(C_WINDOWS_874)},
592 #undef CODESET_SEPARATOR
593 #undef CODESET_ACTION
595 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
596 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
597 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
598 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
599 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
600 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
602 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
603 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
604 {N_("/_Message/Get from _all accounts"),
605 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
606 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
607 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
608 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
609 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
611 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
612 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
613 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
614 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
615 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
616 {N_("/_Message/Repl_y to/mailing _list"),
617 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
618 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
619 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
621 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
622 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
624 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
626 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
627 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
628 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
629 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
631 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
632 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
633 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
634 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
635 {N_("/_Message/_Mark/Mark as rea_d"),
636 NULL, mark_as_read_cb, 0, NULL},
637 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
639 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
640 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
641 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
642 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
643 {N_("/_Tools/Add sender to address boo_k"),
644 NULL, add_address_cb, 0, NULL},
645 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
646 {N_("/_Tools/_Harvest addresses/from _Folder..."),
647 NULL, addr_harvest_cb, 0, NULL},
648 {N_("/_Tools/_Harvest addresses/from _Messages..."),
649 NULL, addr_harvest_msg_cb, 0, NULL},
650 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
651 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
652 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
653 {N_("/_Tools/_Create filter rule/_Automatically"),
654 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
655 {N_("/_Tools/_Create filter rule/by _From"),
656 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
657 {N_("/_Tools/_Create filter rule/by _To"),
658 NULL, create_filter_cb, FILTER_BY_TO, NULL},
659 {N_("/_Tools/_Create filter rule/by _Subject"),
660 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
661 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
663 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Tools/Delete du_plicated messages"),
665 NULL, delete_duplicated_cb, 0, NULL},
666 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
669 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
670 {N_("/_Tools/SSL certi_ficates..."),
671 NULL, ssl_manager_open_cb, 0, NULL},
673 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
676 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
677 {N_("/_Configuration/_Common preferences..."),
678 NULL, prefs_common_open_cb, 0, NULL},
679 {N_("/_Configuration/C_ustomize toolbars"),
680 NULL, NULL, 0, "<Branch>"},
681 {N_("/_Configuration/C_ustomize toolbars/_Main window..."),
682 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
683 {N_("/_Configuration/C_ustomize toolbars/_Compose window..."),
684 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
685 {N_("/_Configuration/C_ustomize toolbars/M_essage view..."),
686 NULL, prefs_toolbar_cb, TOOLBAR_MSGVIEW, NULL},
687 {N_("/_Configuration/_Scoring..."),
688 NULL, prefs_scoring_open_cb, 0, NULL},
689 {N_("/_Configuration/_Filtering..."),
690 NULL, prefs_filtering_open_cb, 0, NULL},
691 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
692 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
693 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
694 {N_("/_Configuration/_Preferences for current account..."),
695 NULL, prefs_account_open_cb, 0, NULL},
696 {N_("/_Configuration/Create _new account..."),
697 NULL, new_account_cb, 0, NULL},
698 {N_("/_Configuration/_Edit accounts..."),
699 NULL, account_edit_open, 0, NULL},
700 {N_("/_Configuration/C_hange current account"),
701 NULL, NULL, 0, "<Branch>"},
702 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
703 {N_("/_Configuration/Preferences..."), NULL, prefs_open_cb, 0, NULL},
704 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
706 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
708 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
709 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
710 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
711 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
712 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
713 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
714 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
717 MainWindow *main_window_create(SeparateType type)
723 GtkWidget *handlebox;
724 GtkWidget *vbox_body;
725 GtkWidget *hbox_stat;
726 GtkWidget *statusbar;
727 GtkWidget *progressbar;
728 GtkWidget *statuslabel;
729 GtkWidget *ac_button;
731 GtkWidget *online_pixmap;
732 GtkWidget *offline_pixmap;
733 GtkWidget *online_switch;
734 GtkWidget *offline_switch;
736 FolderView *folderview;
737 SummaryView *summaryview;
738 MessageView *messageview;
739 GdkColormap *colormap;
742 GtkItemFactory *ifactory;
746 guint n_menu_entries;
748 static GdkGeometry geometry;
750 debug_print("Creating main window...\n");
751 mainwin = g_new0(MainWindow, 1);
754 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
755 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
756 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
757 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
759 if (!geometry.min_height) {
760 geometry.min_width = 320;
761 geometry.min_height = 200;
763 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
766 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
767 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
768 MANAGE_WINDOW_SIGNALS_CONNECT(window);
769 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
770 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
772 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
773 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
775 gtk_widget_realize(window);
776 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
779 gtkut_widget_set_app_icon(window);
781 vbox = gtk_vbox_new(FALSE, 0);
782 gtk_widget_show(vbox);
783 gtk_container_add(GTK_CONTAINER(window), vbox);
786 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
787 menubar = menubar_create(window, mainwin_entries,
788 n_menu_entries, "<Main>", mainwin);
789 gtk_widget_show(menubar);
790 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
791 ifactory = gtk_item_factory_from_widget(menubar);
793 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
794 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
796 handlebox = gtk_handle_box_new();
797 gtk_widget_show(handlebox);
798 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
800 /* link window to mainwin->window to avoid gdk warnings */
801 mainwin->window = window;
804 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
808 /* vbox that contains body */
809 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
810 gtk_widget_show(vbox_body);
811 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
812 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
814 hbox_stat = gtk_hbox_new(FALSE, 2);
815 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
817 statusbar = statusbar_create();
818 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
820 progressbar = gtk_progress_bar_new();
821 gtk_widget_set_usize(progressbar, 120, 1);
822 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
824 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
825 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
826 online_switch = gtk_button_new ();
827 offline_switch = gtk_button_new ();
828 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
829 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
830 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
831 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
832 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
833 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
834 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
835 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
837 statuslabel = gtk_label_new("");
838 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
840 ac_button = gtk_button_new();
841 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
842 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
843 gtk_widget_set_usize(ac_button, -1, 1);
844 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
845 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
846 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
848 ac_label = gtk_label_new("");
849 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
851 gtk_widget_show_all(hbox_stat);
853 gtk_widget_hide(offline_switch);
855 mainwin->folderview = folderview = folderview_create();
856 mainwin->summaryview = summaryview = summary_create();
857 mainwin->messageview = messageview = messageview_create(mainwin);
858 mainwin->logwin = log_window_create();
860 folderview->mainwin = mainwin;
861 folderview->summaryview = summaryview;
863 summaryview->mainwin = mainwin;
864 summaryview->folderview = folderview;
865 summaryview->messageview = messageview;
866 summaryview->window = window;
868 mainwin->vbox = vbox;
869 mainwin->menubar = menubar;
870 mainwin->menu_factory = ifactory;
871 mainwin->handlebox = handlebox;
872 mainwin->vbox_body = vbox_body;
873 mainwin->hbox_stat = hbox_stat;
874 mainwin->statusbar = statusbar;
875 mainwin->progressbar = progressbar;
876 mainwin->statuslabel = statuslabel;
877 mainwin->ac_button = ac_button;
878 mainwin->ac_label = ac_label;
880 mainwin->online_switch = online_switch;
881 mainwin->offline_switch = offline_switch;
882 mainwin->online_pixmap = online_pixmap;
883 mainwin->offline_pixmap = offline_pixmap;
885 /* set context IDs for status bar */
886 mainwin->mainwin_cid = gtk_statusbar_get_context_id
887 (GTK_STATUSBAR(statusbar), "Main Window");
888 mainwin->folderview_cid = gtk_statusbar_get_context_id
889 (GTK_STATUSBAR(statusbar), "Folder View");
890 mainwin->summaryview_cid = gtk_statusbar_get_context_id
891 (GTK_STATUSBAR(statusbar), "Summary View");
893 /* allocate colors for summary view and folder view */
894 summaryview->color_marked.red = summaryview->color_marked.green = 0;
895 summaryview->color_marked.blue = (guint16)65535;
897 summaryview->color_dim.red = summaryview->color_dim.green =
898 summaryview->color_dim.blue = COLOR_DIM;
900 folderview->color_new.red = (guint16)55000;
901 folderview->color_new.green = folderview->color_new.blue = 15000;
903 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
904 &folderview->color_op);
906 summaryview->color_important.red = 0;
907 summaryview->color_important.green = 0;
908 summaryview->color_important.blue = (guint16)65535;
910 color[0] = summaryview->color_marked;
911 color[1] = summaryview->color_dim;
912 color[2] = folderview->color_new;
913 color[3] = folderview->color_op;
915 colormap = gdk_window_get_colormap(window->window);
916 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
917 for (i = 0; i < 4; i++) {
918 if (success[i] == FALSE)
919 g_warning("MainWindow: color allocation %d failed\n", i);
922 debug_print("done.\n");
924 messageview->visible = TRUE;
926 main_window_set_widgets(mainwin, type);
929 menuitem = gtk_item_factory_get_item
930 (ifactory, "/View/Code set/Auto detect");
931 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
933 switch (prefs_common.toolbar_style) {
935 menuitem = gtk_item_factory_get_item
936 (ifactory, "/View/Show or hide/Toolbar/None");
939 menuitem = gtk_item_factory_get_item
940 (ifactory, "/View/Show or hide/Toolbar/Icon");
943 menuitem = gtk_item_factory_get_item
944 (ifactory, "/View/Show or hide/Toolbar/Text");
947 menuitem = gtk_item_factory_get_item
948 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
950 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
952 gtk_widget_hide(mainwin->hbox_stat);
953 menuitem = gtk_item_factory_get_item
954 (ifactory, "/View/Show or hide/Status bar");
955 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
956 prefs_common.show_statusbar);
958 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
960 if (prefs_common.show_searchbar)
961 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
964 /* set account selection menu */
965 ac_menu = gtk_item_factory_get_widget
966 (ifactory, "/Configuration/Change current account");
967 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
968 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
969 mainwin->ac_menu = ac_menu;
971 toolbar_main_set_sensitive(mainwin);
973 /* create actions menu */
974 update_mainwin_actions_menu(ifactory, mainwin);
976 /* attach accel groups to main window */
977 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
978 gtk_window_add_accel_group \
980 gtk_item_factory_from_widget(menu)->accel_group)
982 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
984 /* connect the accelerators for equivalent
985 menu items in different menus */
986 menu_connect_identical_items();
990 /* show main window */
991 gtk_widget_set_uposition(mainwin->window,
992 prefs_common.mainwin_x,
993 prefs_common.mainwin_y);
994 gtk_widget_set_usize(window, prefs_common.mainwin_width,
995 prefs_common.mainwin_height);
996 gtk_widget_show(mainwin->window);
998 /* initialize views */
999 folderview_init(folderview);
1000 summary_init(summaryview);
1001 messageview_init(messageview);
1002 log_window_init(mainwin->logwin);
1004 sslcertwindow_register_hook();
1006 mainwin->lock_count = 0;
1007 mainwin->menu_lock_count = 0;
1008 mainwin->cursor_count = 0;
1011 watch_cursor = gdk_cursor_new(GDK_WATCH);
1013 mainwin_list = g_list_append(mainwin_list, mainwin);
1015 /* init work_offline */
1016 if (prefs_common.work_offline)
1017 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1022 void main_window_cursor_wait(MainWindow *mainwin)
1025 if (mainwin->cursor_count == 0)
1026 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1028 mainwin->cursor_count++;
1033 void main_window_cursor_normal(MainWindow *mainwin)
1035 if (mainwin->cursor_count)
1036 mainwin->cursor_count--;
1038 if (mainwin->cursor_count == 0)
1039 gdk_window_set_cursor(mainwin->window->window, NULL);
1044 /* lock / unlock the user-interface */
1045 void main_window_lock(MainWindow *mainwin)
1047 if (mainwin->lock_count == 0)
1048 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1050 mainwin->lock_count++;
1052 main_window_set_menu_sensitive(mainwin);
1053 toolbar_main_set_sensitive(mainwin);
1056 void main_window_unlock(MainWindow *mainwin)
1058 if (mainwin->lock_count)
1059 mainwin->lock_count--;
1061 main_window_set_menu_sensitive(mainwin);
1062 toolbar_main_set_sensitive(mainwin);
1064 if (mainwin->lock_count == 0)
1065 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1068 static void main_window_menu_callback_block(MainWindow *mainwin)
1070 mainwin->menu_lock_count++;
1073 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1075 if (mainwin->menu_lock_count)
1076 mainwin->menu_lock_count--;
1079 void main_window_reflect_prefs_all(void)
1081 main_window_reflect_prefs_all_real(FALSE);
1084 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1087 MainWindow *mainwin;
1090 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1091 mainwin = (MainWindow *)cur->data;
1093 main_window_show_cur_account(mainwin);
1094 main_window_set_menu_sensitive(mainwin);
1095 toolbar_main_set_sensitive(mainwin);
1098 if (pixmap_theme_changed) {
1099 toolbar_update(TOOLBAR_MAIN, mainwin);
1100 messageview_reflect_prefs_pixmap_theme();
1101 compose_reflect_prefs_pixmap_theme();
1102 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1103 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1105 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1106 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1107 mainwin->online_pixmap);
1108 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1109 gtk_widget_show(pixmap);
1110 mainwin->online_pixmap = pixmap;
1111 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1112 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1113 mainwin->offline_pixmap);
1114 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1115 gtk_widget_show(pixmap);
1116 mainwin->offline_pixmap = pixmap;
1119 summary_redisplay_msg(mainwin->summaryview);
1120 headerview_set_visibility(mainwin->messageview->headerview,
1121 prefs_common.display_header_pane);
1125 void main_window_set_summary_column(void)
1128 MainWindow *mainwin;
1130 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1131 mainwin = (MainWindow *)cur->data;
1132 summary_set_column_order(mainwin->summaryview);
1136 void main_window_set_account_menu(GList *account_list)
1138 GList *cur, *cur_ac, *cur_item;
1139 GtkWidget *menuitem;
1140 MainWindow *mainwin;
1141 PrefsAccount *ac_prefs;
1143 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1144 mainwin = (MainWindow *)cur->data;
1146 /* destroy all previous menu item */
1147 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1148 while (cur_item != NULL) {
1149 GList *next = cur_item->next;
1150 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1154 for (cur_ac = account_list; cur_ac != NULL;
1155 cur_ac = cur_ac->next) {
1156 ac_prefs = (PrefsAccount *)cur_ac->data;
1158 menuitem = gtk_menu_item_new_with_label
1159 (ac_prefs->account_name
1160 ? ac_prefs->account_name : _("Untitled"));
1161 gtk_widget_show(menuitem);
1162 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1163 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1164 GTK_SIGNAL_FUNC(account_menu_cb),
1170 static void main_window_show_cur_account(MainWindow *mainwin)
1175 ac_name = g_strdup(cur_account
1176 ? (cur_account->account_name
1177 ? cur_account->account_name : _("Untitled"))
1181 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1183 buf = g_strdup(PROG_VERSION);
1184 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1187 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1188 gtk_widget_queue_resize(mainwin->ac_button);
1193 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1195 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1196 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1197 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1198 GtkWidget *message_wid = mainwin->messageview->vbox;
1200 debug_print("Changing window separation type from %d to %d\n",
1201 mainwin->type, type);
1203 if (mainwin->type == type) return;
1205 /* remove widgets from those containers */
1206 gtk_widget_ref(folder_wid);
1207 gtk_widget_ref(summary_wid);
1208 gtk_widget_ref(message_wid);
1209 gtkut_container_remove
1210 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1211 gtkut_container_remove
1212 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1213 gtkut_container_remove
1214 (GTK_CONTAINER(message_wid->parent), message_wid);
1216 /* clean containers */
1217 switch (mainwin->type) {
1219 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1221 case SEPARATE_FOLDER:
1222 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1223 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1225 case SEPARATE_MESSAGE:
1226 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1227 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1230 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1231 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1235 gtk_widget_hide(mainwin->window);
1236 main_window_set_widgets(mainwin, type);
1237 gtk_widget_show(mainwin->window);
1239 gtk_widget_unref(folder_wid);
1240 gtk_widget_unref(summary_wid);
1241 gtk_widget_unref(message_wid);
1244 void main_window_toggle_message_view(MainWindow *mainwin)
1246 SummaryView *summaryview = mainwin->summaryview;
1247 union CompositeWin *cwin = &mainwin->win;
1248 GtkWidget *vpaned = NULL;
1249 GtkWidget *container = NULL;
1250 GtkWidget *msgwin = NULL;
1252 switch (mainwin->type) {
1254 vpaned = cwin->sep_none.vpaned;
1255 container = cwin->sep_none.hpaned;
1257 case SEPARATE_FOLDER:
1258 vpaned = cwin->sep_folder.vpaned;
1259 container = mainwin->vbox_body;
1261 case SEPARATE_MESSAGE:
1262 msgwin = mainwin->win.sep_message.messagewin;
1265 msgwin = mainwin->win.sep_both.messagewin;
1270 if (GTK_WIDGET_VISIBLE(msgwin)) {
1271 gtk_widget_hide(msgwin);
1272 mainwin->messageview->visible = FALSE;
1273 summaryview->displayed = NULL;
1275 gtk_widget_show(msgwin);
1276 mainwin->messageview->visible = TRUE;
1278 } else if (vpaned->parent != NULL) {
1279 mainwin->messageview->visible = FALSE;
1280 summaryview->displayed = NULL;
1281 gtk_widget_ref(vpaned);
1282 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1283 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1284 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1285 GTK_ARROW_UP, GTK_SHADOW_OUT);
1287 mainwin->messageview->visible = TRUE;
1288 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1289 gtk_container_add(GTK_CONTAINER(container), vpaned);
1290 gtk_widget_unref(vpaned);
1291 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1292 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1295 main_window_set_menu_sensitive(mainwin);
1297 gtk_widget_grab_focus(summaryview->ctree);
1300 void main_window_get_size(MainWindow *mainwin)
1302 GtkAllocation *allocation;
1304 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1306 prefs_common.summaryview_width = allocation->width;
1308 if ((mainwin->type == SEPARATE_NONE ||
1309 mainwin->type == SEPARATE_FOLDER) &&
1310 messageview_is_visible(mainwin->messageview))
1311 prefs_common.summaryview_height = allocation->height;
1313 prefs_common.mainview_width = allocation->width;
1315 allocation = &mainwin->window->allocation;
1317 prefs_common.mainview_height = allocation->height;
1318 prefs_common.mainwin_width = allocation->width;
1319 prefs_common.mainwin_height = allocation->height;
1321 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1323 prefs_common.folderview_width = allocation->width;
1324 prefs_common.folderview_height = allocation->height;
1327 void main_window_get_position(MainWindow *mainwin)
1331 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1333 prefs_common.mainview_x = x;
1334 prefs_common.mainview_y = y;
1335 prefs_common.mainwin_x = x;
1336 prefs_common.mainwin_y = y;
1338 debug_print("window position: x = %d, y = %d\n", x, y);
1341 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1347 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1348 folder = FOLDER(list->data);
1349 if (folder && folder->trash && folder->trash->total > 0)
1353 if (!has_trash) return;
1356 if (alertpanel(_("Empty trash"),
1357 _("Empty all messages in trash?"),
1358 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1360 manage_window_focus_in(mainwin->window, NULL, NULL);
1363 procmsg_empty_trash();
1365 for (list = folder_get_list(); list != NULL; list = list->next) {
1366 folder = list->data;
1367 if (folder && folder->trash) {
1368 folder_update_item(folder->trash, TRUE);
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 if (!strcmp(path, "Mail"))
1394 folder = folder_new(F_MH, _("Mailbox"), path);
1396 folder = folder_new(F_MH, g_basename(path), path);
1399 if (folder->create_tree(folder) < 0) {
1400 alertpanel_error(_("Creation of the mailbox failed.\n"
1401 "Maybe some files already exist, or you don't have the permission to write there."));
1402 folder_destroy(folder);
1407 folder_set_ui_func(folder, scan_tree_func, mainwin);
1408 folder_scan_tree(folder);
1409 folder_set_ui_func(folder, NULL, NULL);
1411 folderview_set(mainwin->folderview);
1414 void main_window_add_mbox(MainWindow *mainwin)
1420 path = input_dialog(_("Add mbox mailbox"),
1421 _("Input the location of mailbox."),
1426 if (folder_find_from_path(path)) {
1427 alertpanel_error(_("The mailbox `%s' already exists."), path);
1433 if (!strcmp(path, "Mail"))
1434 folder = folder_new(F_MBOX, _("Mailbox"), path);
1438 folder = folder_new(F_MBOX, g_basename(path), path);
1441 if (folder->create_tree(folder) < 0) {
1442 alertpanel_error(_("Creation of the mailbox failed."));
1443 folder_destroy(folder);
1449 item = folder_item_new(folder, folder->name, NULL);
1450 item->folder = folder;
1451 folder->node = g_node_new(item);
1453 folder_create_folder(item, "inbox");
1454 folder_create_folder(item, "outbox");
1455 folder_create_folder(item, "queue");
1456 folder_create_folder(item, "draft");
1457 folder_create_folder(item, "trash");
1459 folderview_set(mainwin->folderview);
1462 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1464 SensitiveCond state = 0;
1465 SummarySelection selection;
1466 FolderItem *item = mainwin->summaryview->folder_item;
1467 GList *account_list = account_get_list();
1469 selection = summary_get_selection_type(mainwin->summaryview);
1471 if (mainwin->lock_count == 0)
1472 state |= M_UNLOCKED;
1473 if (selection != SUMMARY_NONE)
1474 state |= M_MSG_EXIST;
1475 if (item && item->path && item->parent && !item->no_select) {
1477 /* if (item->folder->type != F_NEWS) */
1478 state |= M_ALLOW_DELETE;
1480 if (prefs_common.immediate_exec == 0
1481 && mainwin->lock_count == 0)
1482 state |= M_DELAY_EXEC;
1484 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1485 || selection != SUMMARY_NONE)
1486 state |= M_HIDE_READ_MSG;
1488 if (mainwin->summaryview->threaded)
1489 state |= M_THREADED;
1491 state |= M_UNTHREADED;
1492 if (selection == SUMMARY_SELECTED_SINGLE ||
1493 selection == SUMMARY_SELECTED_MULTIPLE)
1494 state |= M_TARGET_EXIST;
1495 if (selection == SUMMARY_SELECTED_SINGLE)
1496 state |= M_SINGLE_TARGET_EXIST;
1497 if (mainwin->summaryview->folder_item &&
1498 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1501 state |= M_NOT_NEWS;
1502 if (selection == SUMMARY_SELECTED_SINGLE &&
1504 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1505 item->stype == F_QUEUE)))
1506 state |= M_ALLOW_REEDIT;
1508 state |= M_HAVE_ACCOUNT;
1510 for ( ; account_list != NULL; account_list = account_list->next) {
1511 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1512 state |= M_HAVE_NEWS_ACCOUNT;
1517 if (inc_is_active())
1518 state |= M_INC_ACTIVE;
1525 void main_window_set_menu_sensitive(MainWindow *mainwin)
1527 GtkItemFactory *ifactory = mainwin->menu_factory;
1528 SensitiveCond state;
1530 GtkWidget *menuitem;
1531 SummaryView *summaryview;
1535 static const struct {
1539 {"/File/Add mailbox..." , M_UNLOCKED},
1540 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1541 {"/File/Check for new messages in all folders", M_UNLOCKED},
1542 {"/File/Folder" , M_UNLOCKED},
1543 {"/File/Import mbox file..." , M_UNLOCKED},
1544 {"/File/Export to mbox file..." , M_UNLOCKED},
1545 {"/File/Empty trash" , M_UNLOCKED},
1546 {"/File/Work offline" , M_UNLOCKED},
1548 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1549 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1550 /* {"/File/Close" , M_UNLOCKED}, */
1551 {"/File/Exit" , M_UNLOCKED},
1553 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1555 {"/View/Sort" , M_EXEC},
1556 {"/View/Thread view" , M_EXEC},
1557 {"/View/Expand all threads" , M_MSG_EXIST},
1558 {"/View/Collapse all threads" , M_MSG_EXIST},
1559 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1560 {"/View/Go to/Prev message" , M_MSG_EXIST},
1561 {"/View/Go to/Next message" , M_MSG_EXIST},
1562 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1563 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1564 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1565 {"/View/Go to/Next new message" , M_MSG_EXIST},
1566 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1567 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1568 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1569 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1570 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1571 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1572 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1574 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1575 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1576 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1577 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1578 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1579 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1580 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1581 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1582 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1583 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1584 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1585 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1586 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1587 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1588 {"/Message/Mark" , M_TARGET_EXIST},
1590 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1591 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1592 {"/Tools/Harvest addresses" , M_UNLOCKED},
1593 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1594 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1595 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1596 {"/Tools/Execute" , M_DELAY_EXEC},
1597 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1599 {"/Configuration", M_UNLOCKED},
1604 state = main_window_get_current_state(mainwin);
1606 for (i = 0; entry[i].entry != NULL; i++) {
1607 sensitive = ((entry[i].cond & state) == entry[i].cond);
1608 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1611 main_window_menu_callback_block(mainwin);
1613 #define SET_CHECK_MENU_ACTIVE(path, active) \
1615 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1616 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1619 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1620 messageview_is_visible(mainwin->messageview));
1622 summaryview = mainwin->summaryview;
1623 menu_path = "/View/Sort/Don't sort";
1625 switch (summaryview->sort_key) {
1626 case SORT_BY_NUMBER:
1627 menu_path = "/View/Sort/by number"; break;
1629 menu_path = "/View/Sort/by size"; break;
1631 menu_path = "/View/Sort/by date"; break;
1633 menu_path = "/View/Sort/by from"; break;
1635 menu_path = "/View/Sort/by recipient"; break;
1636 case SORT_BY_SUBJECT:
1637 menu_path = "/View/Sort/by subject"; break;
1639 menu_path = "/View/Sort/by color label"; break;
1641 menu_path = "/View/Sort/by mark"; break;
1642 case SORT_BY_UNREAD:
1643 menu_path = "/View/Sort/by unread"; break;
1645 menu_path = "/View/Sort/by attachment"; break;
1647 menu_path = "/View/Sort/by score"; break;
1648 case SORT_BY_LOCKED:
1649 menu_path = "/View/Sort/by locked"; break;
1652 menu_path = "/View/Sort/Don't sort"; break;
1654 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1656 if (summaryview->sort_type == SORT_ASCENDING) {
1657 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1659 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1662 if (summaryview->sort_key != SORT_BY_NONE) {
1663 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1664 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1666 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1667 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1670 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1671 mainwin->messageview->textview->show_all_headers);
1672 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1674 #undef SET_CHECK_MENU_ACTIVE
1676 main_window_menu_callback_unblock(mainwin);
1679 void main_window_popup(MainWindow *mainwin)
1681 gtkut_window_popup(mainwin->window);
1683 switch (mainwin->type) {
1684 case SEPARATE_FOLDER:
1685 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1687 case SEPARATE_MESSAGE:
1688 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1691 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1692 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1699 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1701 GtkWidget *folderwin = NULL;
1702 GtkWidget *messagewin = NULL;
1705 GtkWidget *vbox_body = mainwin->vbox_body;
1706 GtkItemFactory *ifactory = mainwin->menu_factory;
1707 GtkWidget *menuitem;
1708 GtkItemFactory *msgview_ifactory;
1710 debug_print("Setting widgets...");
1712 /* create separated window(s) if needed */
1713 if (type & SEPARATE_FOLDER) {
1714 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1715 gtk_window_set_title(GTK_WINDOW(folderwin),
1716 _("Sylpheed - Folder View"));
1717 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1718 "folder_view", "Sylpheed");
1719 gtk_window_set_policy(GTK_WINDOW(folderwin),
1721 gtk_widget_set_usize(folderwin, -1,
1722 prefs_common.mainview_height);
1723 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1725 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1726 GTK_SIGNAL_FUNC(folder_window_close_cb),
1729 if (type & SEPARATE_MESSAGE) {
1730 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1731 gtk_window_set_title(GTK_WINDOW(messagewin),
1732 _("Sylpheed - Message View"));
1733 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1734 "message_view", "Sylpheed");
1735 gtk_window_set_policy(GTK_WINDOW(messagewin),
1737 gtk_widget_set_usize
1738 (messagewin, prefs_common.mainview_width,
1739 prefs_common.mainview_height
1740 - prefs_common.summaryview_height
1741 + DEFAULT_HEADERVIEW_HEIGHT);
1742 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1744 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1745 GTK_SIGNAL_FUNC(message_window_close_cb),
1751 hpaned = gtk_hpaned_new();
1752 gtk_widget_show(hpaned);
1753 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1754 gtk_paned_add1(GTK_PANED(hpaned),
1755 GTK_WIDGET_PTR(mainwin->folderview));
1757 vpaned = gtk_vpaned_new();
1758 if (messageview_is_visible(mainwin->messageview)) {
1759 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1760 gtk_paned_add1(GTK_PANED(vpaned),
1761 GTK_WIDGET_PTR(mainwin->summaryview));
1763 gtk_paned_add2(GTK_PANED(hpaned),
1764 GTK_WIDGET_PTR(mainwin->summaryview));
1765 gtk_widget_ref(vpaned);
1767 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1768 prefs_common.summaryview_width,
1769 prefs_common.summaryview_height);
1770 gtk_paned_add2(GTK_PANED(vpaned),
1771 GTK_WIDGET_PTR(mainwin->messageview));
1772 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1773 prefs_common.mainview_width, -1);
1774 gtk_widget_set_usize(mainwin->window,
1775 prefs_common.folderview_width +
1776 prefs_common.mainview_width,
1777 prefs_common.mainwin_height);
1778 gtk_widget_show_all(vpaned);
1780 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1781 * lose track of its visibility state */
1782 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1783 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1785 mainwin->win.sep_none.hpaned = hpaned;
1786 mainwin->win.sep_none.vpaned = vpaned;
1788 /* remove headerview if not in prefs */
1789 headerview_set_visibility(mainwin->messageview->headerview,
1790 prefs_common.display_header_pane);
1792 case SEPARATE_FOLDER:
1793 vpaned = gtk_vpaned_new();
1794 if (messageview_is_visible(mainwin->messageview)) {
1795 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1797 gtk_paned_add1(GTK_PANED(vpaned),
1798 GTK_WIDGET_PTR(mainwin->summaryview));
1800 gtk_box_pack_start(GTK_BOX(vbox_body),
1801 GTK_WIDGET_PTR(mainwin->summaryview),
1803 gtk_widget_ref(vpaned);
1805 gtk_paned_add2(GTK_PANED(vpaned),
1806 GTK_WIDGET_PTR(mainwin->messageview));
1807 gtk_widget_show_all(vpaned);
1808 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1809 prefs_common.summaryview_width,
1810 prefs_common.summaryview_height);
1811 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1812 prefs_common.mainview_width, -1);
1813 gtk_widget_set_usize(mainwin->window,
1814 prefs_common.mainview_width,
1815 prefs_common.mainview_height);
1817 gtk_container_add(GTK_CONTAINER(folderwin),
1818 GTK_WIDGET_PTR(mainwin->folderview));
1820 mainwin->win.sep_folder.folderwin = folderwin;
1821 mainwin->win.sep_folder.vpaned = vpaned;
1823 gtk_widget_show_all(folderwin);
1825 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1826 * lose track of its visibility state */
1827 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1828 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1830 /* remove headerview if not in prefs */
1831 headerview_set_visibility(mainwin->messageview->headerview,
1832 prefs_common.display_header_pane);
1835 case SEPARATE_MESSAGE:
1836 hpaned = gtk_hpaned_new();
1837 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1839 gtk_paned_add1(GTK_PANED(hpaned),
1840 GTK_WIDGET_PTR(mainwin->folderview));
1841 gtk_paned_add2(GTK_PANED(hpaned),
1842 GTK_WIDGET_PTR(mainwin->summaryview));
1843 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1844 prefs_common.summaryview_width,
1845 prefs_common.summaryview_height);
1846 gtk_widget_set_usize(mainwin->window,
1847 prefs_common.folderview_width +
1848 prefs_common.mainview_width,
1849 prefs_common.mainwin_height);
1850 gtk_widget_show_all(hpaned);
1852 messageview_add_toolbar(mainwin->messageview, messagewin);
1853 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1854 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1856 mainwin->win.sep_message.messagewin = messagewin;
1857 mainwin->win.sep_message.hpaned = hpaned;
1859 gtk_widget_show_all(messagewin);
1861 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1862 * lose track of its visibility state */
1863 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1864 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1867 gtk_box_pack_start(GTK_BOX(vbox_body),
1868 GTK_WIDGET_PTR(mainwin->summaryview),
1870 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1871 prefs_common.summaryview_width,
1872 prefs_common.summaryview_height);
1873 gtk_widget_set_usize(mainwin->window,
1874 prefs_common.mainview_width,
1875 prefs_common.mainwin_height);
1876 gtk_container_add(GTK_CONTAINER(folderwin),
1877 GTK_WIDGET_PTR(mainwin->folderview));
1878 gtk_container_add(GTK_CONTAINER(messagewin),
1879 GTK_WIDGET_PTR(mainwin->messageview));
1881 mainwin->win.sep_both.folderwin = folderwin;
1882 mainwin->win.sep_both.messagewin = messagewin;
1884 gtk_widget_show_all(folderwin);
1885 gtk_widget_show_all(messagewin);
1887 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1888 * lose track of its visibility state */
1889 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1890 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1894 /* rehide quick search if necessary */
1895 if (!prefs_common.show_searchbar)
1896 gtk_widget_hide(mainwin->summaryview->hbox_search);
1898 mainwin->type = type;
1900 mainwin->messageview->visible = TRUE;
1902 /* toggle menu state */
1903 menuitem = gtk_item_factory_get_item
1904 (ifactory, "/View/Show or hide/Folder tree");
1905 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1906 menuitem = gtk_item_factory_get_item
1907 (ifactory, "/View/Show or hide/Message view");
1908 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1910 menuitem = gtk_item_factory_get_item
1911 (ifactory, "/View/Separate folder tree");
1912 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1913 ((type & SEPARATE_FOLDER) != 0));
1914 menuitem = gtk_item_factory_get_item
1915 (ifactory, "/View/Separate message view");
1916 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1917 ((type & SEPARATE_MESSAGE) != 0));
1919 debug_print("done.\n");
1922 void main_window_destroy_all(void)
1924 while (mainwin_list != NULL) {
1925 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1927 /* free toolbar stuff */
1928 toolbar_clear_list(TOOLBAR_MAIN);
1929 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1930 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1932 g_free(mainwin->toolbar);
1935 mainwin_list = g_list_remove(mainwin_list, mainwin);
1937 g_list_free(mainwin_list);
1941 static void toolbar_account_button_pressed(GtkWidget *widget,
1942 GdkEventButton *event,
1945 MainWindow *mainwin = (MainWindow *)data;
1948 if (event->button != 3) return;
1950 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1951 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1954 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1955 menu_button_position, widget,
1956 event->button, event->time);
1960 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1963 MainWindow *mainwin = (MainWindow *)data;
1967 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1968 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1971 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1972 menu_button_position, widget,
1973 event->button, event->time);
1976 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
1978 MainWindow *mainwin = (MainWindow *)data;
1981 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
1982 if (!button) return;
1983 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1984 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
1985 manage_window_focus_in(mainwin->window, NULL, NULL);
1988 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1991 MainWindow *mainwin = (MainWindow *)data;
1993 if (mainwin->lock_count == 0)
1994 app_exit_cb(data, 0, widget);
1999 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2002 MainWindow *mainwin = (MainWindow *)data;
2003 GtkWidget *menuitem;
2005 menuitem = gtk_item_factory_get_item
2006 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2007 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2012 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2015 MainWindow *mainwin = (MainWindow *)data;
2016 GtkWidget *menuitem;
2018 menuitem = gtk_item_factory_get_item
2019 (mainwin->menu_factory, "/View/Show or hide/Message view");
2020 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2025 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2028 main_window_add_mailbox(mainwin);
2031 static void add_mbox_cb(MainWindow *mainwin, guint action,
2034 main_window_add_mbox(mainwin);
2037 static void update_folderview_cb(MainWindow *mainwin, guint action,
2040 summary_show(mainwin->summaryview, NULL);
2041 folderview_check_new_all();
2044 static void new_folder_cb(MainWindow *mainwin, guint action,
2047 folderview_new_folder(mainwin->folderview);
2050 static void rename_folder_cb(MainWindow *mainwin, guint action,
2053 folderview_rename_folder(mainwin->folderview);
2056 static void delete_folder_cb(MainWindow *mainwin, guint action,
2059 folderview_delete_folder(mainwin->folderview);
2062 static void import_mbox_cb(MainWindow *mainwin, guint action,
2065 import_mbox(mainwin->summaryview->folder_item);
2068 static void export_mbox_cb(MainWindow *mainwin, guint action,
2071 export_mbox(mainwin->summaryview->folder_item);
2074 static void empty_trash_cb(MainWindow *mainwin, guint action,
2077 main_window_empty_trash(mainwin, TRUE);
2080 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2082 summary_save_as(mainwin->summaryview);
2085 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2087 summary_print(mainwin->summaryview);
2090 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2092 if (prefs_common.confirm_on_exit) {
2093 if (alertpanel(_("Exit"), _("Exit this program?"),
2094 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2096 manage_window_focus_in(mainwin->window, NULL, NULL);
2099 app_will_exit(widget, mainwin);
2102 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2105 summary_search(mainwin->summaryview);
2107 message_search(mainwin->messageview);
2110 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2115 active = GTK_CHECK_MENU_ITEM(widget)->active;
2117 switch (mainwin->type) {
2119 case SEPARATE_MESSAGE:
2122 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2124 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2127 case SEPARATE_FOLDER:
2128 debug_print("separate folder\n");
2130 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2132 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2136 gtk_widget_show(mainwin->win.sep_both.folderwin);
2138 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2143 static void toggle_message_cb(MainWindow *mainwin, guint action,
2148 active = GTK_CHECK_MENU_ITEM(widget)->active;
2150 if (active != messageview_is_visible(mainwin->messageview))
2151 summary_toggle_view(mainwin->summaryview);
2154 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2157 toolbar_toggle(action, mainwin);
2160 /* END Toolbar Stuff */
2162 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2165 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2166 gtk_widget_show(mainwin->hbox_stat);
2167 prefs_common.show_statusbar = TRUE;
2169 gtk_widget_hide(mainwin->hbox_stat);
2170 prefs_common.show_statusbar = FALSE;
2174 static void separate_widget_cb(MainWindow *mainwin, guint action,
2179 if (GTK_CHECK_MENU_ITEM(widget)->active)
2180 type = mainwin->type | action;
2182 type = mainwin->type & ~action;
2184 main_window_separation_change(mainwin, type);
2186 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2187 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2190 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2193 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2195 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2198 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2200 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2203 static void online_switch_clicked (GtkButton *btn, gpointer data)
2205 MainWindow *mainwin;
2206 GtkItemFactory *ifactory;
2207 GtkCheckMenuItem *menuitem;
2209 mainwin = (MainWindow *) data;
2211 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2212 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2214 g_return_if_fail(mainwin != NULL);
2215 g_return_if_fail(menuitem != NULL);
2217 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2219 gtk_widget_hide (mainwin->online_switch);
2220 gtk_widget_show (mainwin->offline_switch);
2221 menuitem->active = TRUE;
2222 prefs_common.work_offline = TRUE;
2223 inc_autocheck_timer_remove();
2226 gtk_widget_hide (mainwin->offline_switch);
2227 gtk_widget_show (mainwin->online_switch);
2228 menuitem->active = FALSE;
2229 prefs_common.work_offline = FALSE;
2230 inc_autocheck_timer_set();
2234 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2237 addressbook_open(NULL);
2240 static void log_window_show_cb(MainWindow *mainwin, guint action,
2243 log_window_show(mainwin->logwin);
2246 static void sel_download_cb(MainWindow *mainwin, guint action,
2249 selective_download(mainwin);
2252 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
2255 prefs_toolbar_open((ToolbarType)action);
2258 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2263 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2265 summary_move_to(mainwin->summaryview);
2268 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2270 summary_copy_to(mainwin->summaryview);
2273 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2275 summary_delete(mainwin->summaryview);
2278 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2280 summary_cancel(mainwin->summaryview);
2283 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2285 summary_open_msg(mainwin->summaryview);
2288 static void view_source_cb(MainWindow *mainwin, guint action,
2291 summary_view_source(mainwin->summaryview);
2294 static void show_all_header_cb(MainWindow *mainwin, guint action,
2297 if (mainwin->menu_lock_count) return;
2298 summary_display_msg_selected(mainwin->summaryview,
2299 GTK_CHECK_MENU_ITEM(widget)->active);
2302 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2304 summary_reedit(mainwin->summaryview);
2307 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2309 summary_mark(mainwin->summaryview);
2312 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2314 summary_unmark(mainwin->summaryview);
2317 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2320 summary_mark_as_unread(mainwin->summaryview);
2323 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2326 summary_mark_as_read(mainwin->summaryview);
2329 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2332 summary_mark_all_read(mainwin->summaryview);
2335 static void add_address_cb(MainWindow *mainwin, guint action,
2338 summary_add_address(mainwin->summaryview);
2341 static void set_charset_cb(MainWindow *mainwin, guint action,
2346 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2347 str = conv_get_charset_str((CharSet)action);
2348 g_free(prefs_common.force_charset);
2349 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2351 summary_redisplay_msg(mainwin->summaryview);
2353 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2357 static void hide_read_messages (MainWindow *mainwin, guint action,
2360 if (!mainwin->summaryview->folder_item
2361 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2363 summary_toggle_show_read_messages(mainwin->summaryview);
2366 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2368 if (mainwin->menu_lock_count) return;
2369 if (!mainwin->summaryview->folder_item) return;
2371 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2372 summary_thread_build(mainwin->summaryview);
2373 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2375 summary_unthread(mainwin->summaryview);
2376 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2380 static void expand_threads_cb(MainWindow *mainwin, guint action,
2383 summary_expand_threads(mainwin->summaryview);
2386 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2389 summary_collapse_threads(mainwin->summaryview);
2392 static void set_display_item_cb(MainWindow *mainwin, guint action,
2395 prefs_summary_column_open();
2398 static void sort_summary_cb(MainWindow *mainwin, guint action,
2401 FolderItem *item = mainwin->summaryview->folder_item;
2402 GtkWidget *menuitem;
2404 if (mainwin->menu_lock_count) return;
2406 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2407 menuitem = gtk_item_factory_get_item
2408 (mainwin->menu_factory, "/View/Sort/Ascending");
2409 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2410 GTK_CHECK_MENU_ITEM(menuitem)->active
2411 ? SORT_ASCENDING : SORT_DESCENDING);
2415 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2418 FolderItem *item = mainwin->summaryview->folder_item;
2420 if (mainwin->menu_lock_count) return;
2422 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2423 summary_sort(mainwin->summaryview,
2424 item->sort_key, (FolderSortType)action);
2427 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2430 summary_attract_by_subject(mainwin->summaryview);
2433 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2436 summary_delete_duplicated(mainwin->summaryview);
2439 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2441 summary_filter(mainwin->summaryview);
2444 static void execute_summary_cb(MainWindow *mainwin, guint action,
2447 summary_execute(mainwin->summaryview);
2450 static void update_summary_cb(MainWindow *mainwin, guint action,
2454 FolderView *folderview = mainwin->folderview;
2456 if (!mainwin->summaryview->folder_item) return;
2457 if (!folderview->opened) return;
2459 folder_update_op_count();
2461 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2462 folderview->opened);
2465 folder_item_scan(fitem);
2466 summary_show(mainwin->summaryview, fitem);
2469 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2471 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2474 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2476 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2479 static void prev_unread_cb(MainWindow *mainwin, guint action,
2482 summary_select_prev_unread(mainwin->summaryview);
2485 static void next_unread_cb(MainWindow *mainwin, guint action,
2488 summary_select_next_unread(mainwin->summaryview);
2491 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2493 summary_select_prev_new(mainwin->summaryview);
2496 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2498 summary_select_next_new(mainwin->summaryview);
2501 static void prev_marked_cb(MainWindow *mainwin, guint action,
2504 summary_select_prev_marked(mainwin->summaryview);
2507 static void next_marked_cb(MainWindow *mainwin, guint action,
2510 summary_select_next_marked(mainwin->summaryview);
2513 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2516 summary_select_prev_labeled(mainwin->summaryview);
2519 static void next_labeled_cb(MainWindow *mainwin, guint action,
2522 summary_select_next_labeled(mainwin->summaryview);
2525 static void goto_folder_cb(MainWindow *mainwin, guint action,
2528 FolderItem *to_folder;
2530 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2533 folderview_select(mainwin->folderview, to_folder);
2536 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2538 messageview_copy_clipboard(mainwin->messageview);
2541 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2543 MessageView *msgview = mainwin->messageview;
2545 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2546 summary_select_all(mainwin->summaryview);
2547 else if (messageview_is_visible(msgview) &&
2548 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2549 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2550 messageview_select_all(mainwin->messageview);
2553 static void select_thread_cb(MainWindow *mainwin, guint action,
2556 summary_select_thread(mainwin->summaryview);
2559 static void create_filter_cb(MainWindow *mainwin, guint action,
2562 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2565 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2568 prefs_common_open();
2571 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2574 prefs_scoring_open(NULL);
2577 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2580 prefs_filtering_open(NULL, NULL, NULL);
2583 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2586 prefs_template_open();
2589 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2592 prefs_actions_open(mainwin);
2595 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2598 ssl_manager_open(mainwin);
2601 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2605 new_account_cb(mainwin, 0, widget);
2607 account_open(cur_account);
2611 static void new_account_cb(MainWindow *mainwin, guint action,
2614 account_edit_open();
2615 if (!compose_get_compose_list()) account_add();
2618 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2620 cur_account = (PrefsAccount *)data;
2621 main_window_reflect_prefs_all();
2624 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2626 prefswindow_create();
2629 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2631 pluginwindow_create();
2634 static void manual_open_cb(MainWindow *mainwin, guint action,
2637 manual_open((ManualType)action);
2640 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2642 MainWindow *mainwin = (MainWindow *)data;
2646 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2647 LOCAL_FOLDER(folder)->rootpath,
2651 str = g_strdup_printf(_("Scanning folder %s ..."),
2652 LOCAL_FOLDER(folder)->rootpath);
2654 STATUSBAR_PUSH(mainwin, str);
2655 STATUSBAR_POP(mainwin);
2659 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2662 SummaryView *summary;
2664 g_return_val_if_fail(data, FALSE);
2665 summary = ((MainWindow *)data)->summaryview;
2666 g_return_val_if_fail(summary, FALSE);
2667 if (summary->selected != summary->displayed)
2668 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2672 #define BREAK_ON_MODIFIER_KEY() \
2673 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2675 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2678 MainWindow *mainwin = (MainWindow*) data;
2680 if (!mainwin || !event) return;
2682 switch (event->keyval) {
2683 case GDK_Q: /* Quit */
2684 BREAK_ON_MODIFIER_KEY();
2686 app_exit_cb(mainwin, 0, NULL);
2689 if (mainwin->folderview && mainwin->summaryview
2690 && !mainwin->summaryview->displayed) {
2691 summary_lock(mainwin->summaryview);
2692 folderview_select_next_unread(mainwin->folderview);
2693 summary_unlock(mainwin->summaryview);
2701 #undef BREAK_ON_MODIFIER_KEY
2704 * Harvest addresses for selected folder.
2706 static void addr_harvest_cb( MainWindow *mainwin,
2710 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2714 * Harvest addresses for selected messages in summary view.
2716 static void addr_harvest_msg_cb( MainWindow *mainwin,
2720 summary_harvest_address( mainwin->summaryview );