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"
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 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,
194 static void inc_cancel_cb (MainWindow *mainwin,
198 static void open_msg_cb (MainWindow *mainwin,
202 static void view_source_cb (MainWindow *mainwin,
206 static void show_all_header_cb (MainWindow *mainwin,
210 static void reedit_cb (MainWindow *mainwin,
214 static void move_to_cb (MainWindow *mainwin,
217 static void copy_to_cb (MainWindow *mainwin,
220 static void delete_cb (MainWindow *mainwin,
224 static void cancel_cb (MainWindow *mainwin,
228 static void mark_cb (MainWindow *mainwin,
231 static void unmark_cb (MainWindow *mainwin,
235 static void mark_as_unread_cb (MainWindow *mainwin,
238 static void mark_as_read_cb (MainWindow *mainwin,
241 static void mark_all_read_cb (MainWindow *mainwin,
244 static void add_address_cb (MainWindow *mainwin,
248 static void set_charset_cb (MainWindow *mainwin,
252 static void hide_read_messages (MainWindow *mainwin,
256 static void thread_cb (MainWindow *mainwin,
259 static void expand_threads_cb (MainWindow *mainwin,
262 static void collapse_threads_cb (MainWindow *mainwin,
266 static void set_display_item_cb (MainWindow *mainwin,
269 static void sort_summary_cb (MainWindow *mainwin,
272 static void sort_summary_type_cb (MainWindow *mainwin,
275 static void attract_by_subject_cb(MainWindow *mainwin,
279 static void delete_duplicated_cb (MainWindow *mainwin,
282 static void filter_cb (MainWindow *mainwin,
285 static void execute_summary_cb (MainWindow *mainwin,
288 static void update_summary_cb (MainWindow *mainwin,
292 static void prev_cb (MainWindow *mainwin,
295 static void next_cb (MainWindow *mainwin,
298 static void next_unread_cb (MainWindow *mainwin,
301 static void prev_unread_cb (MainWindow *mainwin,
305 static void prev_new_cb (MainWindow *mainwin,
308 static void next_new_cb (MainWindow *mainwin,
311 static void prev_marked_cb (MainWindow *mainwin,
314 static void next_marked_cb (MainWindow *mainwin,
317 static void prev_labeled_cb (MainWindow *mainwin,
320 static void next_labeled_cb (MainWindow *mainwin,
324 static void goto_folder_cb (MainWindow *mainwin,
328 static void copy_cb (MainWindow *mainwin,
331 static void allsel_cb (MainWindow *mainwin,
334 static void select_thread_cb (MainWindow *mainwin,
338 static void create_filter_cb (MainWindow *mainwin,
342 static void prefs_common_open_cb (MainWindow *mainwin,
345 static void prefs_template_open_cb (MainWindow *mainwin,
348 static void prefs_actions_open_cb (MainWindow *mainwin,
351 static void prefs_account_open_cb (MainWindow *mainwin,
354 static void prefs_scoring_open_cb (MainWindow *mainwin,
357 static void prefs_filtering_open_cb (MainWindow *mainwin,
361 static void ssl_manager_open_cb (MainWindow *mainwin,
365 static void new_account_cb (MainWindow *mainwin,
369 static void account_menu_cb (GtkMenuItem *menuitem,
372 static void prefs_open_cb (GtkMenuItem *menuitem,
374 static void plugins_open_cb (GtkMenuItem *menuitem,
377 static void online_switch_clicked(GtkButton *btn,
380 static void manual_open_cb (MainWindow *mainwin,
384 static void scan_tree_func (Folder *folder,
388 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
390 static void addr_harvest_cb ( MainWindow *mainwin,
394 static void addr_harvest_msg_cb ( MainWindow *mainwin,
398 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
399 GdkEventFocus *focus,
401 void main_window_reply_cb (MainWindow *mainwin,
404 gboolean mainwindow_progressindicator_hook (gpointer source,
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 _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/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", main_window_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", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
615 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
616 {N_("/_Message/Repl_y to/mailing _list"),
617 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
618 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
619 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
621 {N_("/_Message/Redirect"), NULL, main_window_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/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
641 {N_("/_Tools/Add sender to address boo_k"),
642 NULL, add_address_cb, 0, NULL},
643 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
644 {N_("/_Tools/_Harvest addresses/from _Folder..."),
645 NULL, addr_harvest_cb, 0, NULL},
646 {N_("/_Tools/_Harvest addresses/from _Messages..."),
647 NULL, addr_harvest_msg_cb, 0, NULL},
648 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
649 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
650 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
651 {N_("/_Tools/_Create filter rule/_Automatically"),
652 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
653 {N_("/_Tools/_Create filter rule/by _From"),
654 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
655 {N_("/_Tools/_Create filter rule/by _To"),
656 NULL, create_filter_cb, FILTER_BY_TO, NULL},
657 {N_("/_Tools/_Create filter rule/by _Subject"),
658 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
659 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
660 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
661 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Tools/Delete du_plicated messages"),
663 NULL, delete_duplicated_cb, 0, NULL},
664 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
665 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
667 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Tools/SSL certi_ficates..."),
669 NULL, ssl_manager_open_cb, 0, NULL},
671 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
672 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
674 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
675 {N_("/_Configuration/C_hange current account"),
676 NULL, NULL, 0, "<Branch>"},
677 {N_("/_Configuration/_Preferences for current account..."),
678 NULL, prefs_account_open_cb, 0, NULL},
679 {N_("/_Configuration/Create _new account..."),
680 NULL, new_account_cb, 0, NULL},
681 {N_("/_Configuration/_Edit accounts..."),
682 NULL, account_edit_open, 0, NULL},
683 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Configuration/_Common preferences..."),
685 NULL, prefs_common_open_cb, 0, NULL},
686 {N_("/_Configuration/_Scoring..."),
687 NULL, prefs_scoring_open_cb, 0, NULL},
688 {N_("/_Configuration/_Filtering..."),
689 NULL, prefs_filtering_open_cb, 0, NULL},
690 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
691 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
692 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
693 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
695 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
696 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
697 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
698 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
699 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
700 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
701 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
702 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
703 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
706 MainWindow *main_window_create(SeparateType type)
712 GtkWidget *handlebox;
713 GtkWidget *vbox_body;
714 GtkWidget *hbox_stat;
715 GtkWidget *statusbar;
716 GtkWidget *progressbar;
717 GtkWidget *statuslabel;
718 GtkWidget *ac_button;
720 GtkWidget *online_pixmap;
721 GtkWidget *offline_pixmap;
722 GtkWidget *online_switch;
723 GtkWidget *offline_switch;
724 GtkTooltips *offline_tip;
725 GtkTooltips *online_tip;
726 GtkTooltips *sel_ac_tip;
728 FolderView *folderview;
729 SummaryView *summaryview;
730 MessageView *messageview;
731 GdkColormap *colormap;
734 GtkItemFactory *ifactory;
738 guint n_menu_entries;
740 static GdkGeometry geometry;
742 debug_print("Creating main window...\n");
743 mainwin = g_new0(MainWindow, 1);
746 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
747 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
748 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
749 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
751 if (!geometry.min_height) {
752 geometry.min_width = 320;
753 geometry.min_height = 200;
755 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
758 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
759 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
760 MANAGE_WINDOW_SIGNALS_CONNECT(window);
761 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
762 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
764 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
765 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
767 gtk_widget_realize(window);
768 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
771 gtkut_widget_set_app_icon(window);
773 vbox = gtk_vbox_new(FALSE, 0);
774 gtk_widget_show(vbox);
775 gtk_container_add(GTK_CONTAINER(window), vbox);
778 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
779 menubar = menubar_create(window, mainwin_entries,
780 n_menu_entries, "<Main>", mainwin);
781 gtk_widget_show(menubar);
782 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
783 ifactory = gtk_item_factory_from_widget(menubar);
785 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
786 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
788 handlebox = gtk_handle_box_new();
789 gtk_widget_show(handlebox);
790 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
792 /* link window to mainwin->window to avoid gdk warnings */
793 mainwin->window = window;
796 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
800 /* vbox that contains body */
801 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
802 gtk_widget_show(vbox_body);
803 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
804 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
806 hbox_stat = gtk_hbox_new(FALSE, 2);
807 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
809 statusbar = statusbar_create();
810 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
812 progressbar = gtk_progress_bar_new();
813 gtk_widget_set_usize(progressbar, 120, 1);
814 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
816 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
817 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
818 online_tip = gtk_tooltips_new();
819 online_switch = gtk_button_new ();
820 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
821 online_switch, _("Go offline"), NULL);
822 offline_tip = gtk_tooltips_new();
823 offline_switch = gtk_button_new ();
824 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
825 offline_switch, _("Go online"), NULL);
826 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
827 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
828 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
829 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
830 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
831 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
832 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
833 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
835 statuslabel = gtk_label_new("");
836 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
838 sel_ac_tip = gtk_tooltips_new();
839 ac_button = gtk_button_new();
840 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
841 ac_button, _("Select account"), NULL);
842 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
843 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
844 gtk_widget_set_usize(ac_button, -1, 1);
845 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
846 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
847 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
849 ac_label = gtk_label_new("");
850 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
852 gtk_widget_show_all(hbox_stat);
854 gtk_widget_hide(offline_switch);
856 mainwin->folderview = folderview = folderview_create();
857 mainwin->summaryview = summaryview = summary_create();
858 mainwin->messageview = messageview = messageview_create(mainwin);
859 mainwin->logwin = log_window_create();
861 folderview->mainwin = mainwin;
862 folderview->summaryview = summaryview;
864 summaryview->mainwin = mainwin;
865 summaryview->folderview = folderview;
866 summaryview->messageview = messageview;
867 summaryview->window = window;
869 mainwin->vbox = vbox;
870 mainwin->menubar = menubar;
871 mainwin->menu_factory = ifactory;
872 mainwin->handlebox = handlebox;
873 mainwin->vbox_body = vbox_body;
874 mainwin->hbox_stat = hbox_stat;
875 mainwin->statusbar = statusbar;
876 mainwin->progressbar = progressbar;
877 mainwin->statuslabel = statuslabel;
878 mainwin->ac_button = ac_button;
879 mainwin->ac_label = ac_label;
881 mainwin->online_switch = online_switch;
882 mainwin->offline_switch = offline_switch;
883 mainwin->online_pixmap = online_pixmap;
884 mainwin->offline_pixmap = offline_pixmap;
886 /* set context IDs for status bar */
887 mainwin->mainwin_cid = gtk_statusbar_get_context_id
888 (GTK_STATUSBAR(statusbar), "Main Window");
889 mainwin->folderview_cid = gtk_statusbar_get_context_id
890 (GTK_STATUSBAR(statusbar), "Folder View");
891 mainwin->summaryview_cid = gtk_statusbar_get_context_id
892 (GTK_STATUSBAR(statusbar), "Summary View");
894 /* allocate colors for summary view and folder view */
895 summaryview->color_marked.red = summaryview->color_marked.green = 0;
896 summaryview->color_marked.blue = (guint16)65535;
898 summaryview->color_dim.red = summaryview->color_dim.green =
899 summaryview->color_dim.blue = COLOR_DIM;
901 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
902 &folderview->color_new);
904 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
905 &folderview->color_op);
907 summaryview->color_important.red = 0;
908 summaryview->color_important.green = 0;
909 summaryview->color_important.blue = (guint16)65535;
911 color[0] = summaryview->color_marked;
912 color[1] = summaryview->color_dim;
913 color[2] = folderview->color_new;
914 color[3] = folderview->color_op;
916 colormap = gdk_window_get_colormap(window->window);
917 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
918 for (i = 0; i < 4; i++) {
919 if (success[i] == FALSE)
920 g_warning("MainWindow: color allocation %d failed\n", i);
923 debug_print("done.\n");
925 messageview->visible = TRUE;
927 main_window_set_widgets(mainwin, type);
930 menuitem = gtk_item_factory_get_item
931 (ifactory, "/View/Code set/Auto detect");
932 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
934 switch (prefs_common.toolbar_style) {
936 menuitem = gtk_item_factory_get_item
937 (ifactory, "/View/Show or hide/Toolbar/None");
940 menuitem = gtk_item_factory_get_item
941 (ifactory, "/View/Show or hide/Toolbar/Icon");
944 menuitem = gtk_item_factory_get_item
945 (ifactory, "/View/Show or hide/Toolbar/Text");
948 menuitem = gtk_item_factory_get_item
949 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
951 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
953 gtk_widget_hide(mainwin->hbox_stat);
954 menuitem = gtk_item_factory_get_item
955 (ifactory, "/View/Show or hide/Status bar");
956 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
957 prefs_common.show_statusbar);
959 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
961 if (prefs_common.show_searchbar) {
962 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
963 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
964 gtk_widget_hide(summaryview->search_description);
967 /* set account selection menu */
968 ac_menu = gtk_item_factory_get_widget
969 (ifactory, "/Configuration/Change current account");
970 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
971 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
972 mainwin->ac_menu = ac_menu;
974 toolbar_main_set_sensitive(mainwin);
976 /* create actions menu */
977 update_mainwin_actions_menu(ifactory, mainwin);
979 /* attach accel groups to main window */
980 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
981 gtk_window_add_accel_group \
983 gtk_item_factory_from_widget(menu)->accel_group)
985 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
987 /* connect the accelerators for equivalent
988 menu items in different menus */
989 menu_connect_identical_items();
993 /* show main window */
994 gtk_widget_set_uposition(mainwin->window,
995 prefs_common.mainwin_x,
996 prefs_common.mainwin_y);
997 gtk_widget_set_usize(window, prefs_common.mainwin_width,
998 prefs_common.mainwin_height);
999 gtk_widget_show(mainwin->window);
1001 /* initialize views */
1002 folderview_init(folderview);
1003 summary_init(summaryview);
1004 messageview_init(messageview);
1005 log_window_init(mainwin->logwin);
1007 sslcertwindow_register_hook();
1009 mainwin->lock_count = 0;
1010 mainwin->menu_lock_count = 0;
1011 mainwin->cursor_count = 0;
1013 mainwin->progressindicator_hook =
1014 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1017 watch_cursor = gdk_cursor_new(GDK_WATCH);
1019 mainwin_list = g_list_append(mainwin_list, mainwin);
1021 /* init work_offline */
1022 if (prefs_common.work_offline)
1023 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1028 void main_window_cursor_wait(MainWindow *mainwin)
1031 if (mainwin->cursor_count == 0)
1032 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1034 mainwin->cursor_count++;
1039 void main_window_cursor_normal(MainWindow *mainwin)
1041 if (mainwin->cursor_count)
1042 mainwin->cursor_count--;
1044 if (mainwin->cursor_count == 0)
1045 gdk_window_set_cursor(mainwin->window->window, NULL);
1050 /* lock / unlock the user-interface */
1051 void main_window_lock(MainWindow *mainwin)
1053 if (mainwin->lock_count == 0)
1054 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1056 mainwin->lock_count++;
1058 main_window_set_menu_sensitive(mainwin);
1059 toolbar_main_set_sensitive(mainwin);
1062 void main_window_unlock(MainWindow *mainwin)
1064 if (mainwin->lock_count)
1065 mainwin->lock_count--;
1067 main_window_set_menu_sensitive(mainwin);
1068 toolbar_main_set_sensitive(mainwin);
1070 if (mainwin->lock_count == 0)
1071 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1074 static void main_window_menu_callback_block(MainWindow *mainwin)
1076 mainwin->menu_lock_count++;
1079 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1081 if (mainwin->menu_lock_count)
1082 mainwin->menu_lock_count--;
1085 void main_window_reflect_prefs_all(void)
1087 main_window_reflect_prefs_all_real(FALSE);
1090 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1093 MainWindow *mainwin;
1096 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1097 mainwin = (MainWindow *)cur->data;
1099 main_window_show_cur_account(mainwin);
1100 main_window_set_menu_sensitive(mainwin);
1101 toolbar_main_set_sensitive(mainwin);
1104 if (pixmap_theme_changed) {
1105 toolbar_update(TOOLBAR_MAIN, mainwin);
1106 messageview_reflect_prefs_pixmap_theme();
1107 compose_reflect_prefs_pixmap_theme();
1108 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1109 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1111 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1112 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1113 mainwin->online_pixmap);
1114 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1115 gtk_widget_show(pixmap);
1116 mainwin->online_pixmap = pixmap;
1117 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1118 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1119 mainwin->offline_pixmap);
1120 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1121 gtk_widget_show(pixmap);
1122 mainwin->offline_pixmap = pixmap;
1125 summary_redisplay_msg(mainwin->summaryview);
1126 headerview_set_visibility(mainwin->messageview->headerview,
1127 prefs_common.display_header_pane);
1131 void main_window_set_summary_column(void)
1134 MainWindow *mainwin;
1136 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1137 mainwin = (MainWindow *)cur->data;
1138 summary_set_column_order(mainwin->summaryview);
1142 void main_window_set_account_menu(GList *account_list)
1144 GList *cur, *cur_ac, *cur_item;
1145 GtkWidget *menuitem;
1146 MainWindow *mainwin;
1147 PrefsAccount *ac_prefs;
1149 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1150 mainwin = (MainWindow *)cur->data;
1152 /* destroy all previous menu item */
1153 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1154 while (cur_item != NULL) {
1155 GList *next = cur_item->next;
1156 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1160 for (cur_ac = account_list; cur_ac != NULL;
1161 cur_ac = cur_ac->next) {
1162 ac_prefs = (PrefsAccount *)cur_ac->data;
1164 menuitem = gtk_menu_item_new_with_label
1165 (ac_prefs->account_name
1166 ? ac_prefs->account_name : _("Untitled"));
1167 gtk_widget_show(menuitem);
1168 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1169 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1170 GTK_SIGNAL_FUNC(account_menu_cb),
1176 static void main_window_show_cur_account(MainWindow *mainwin)
1181 ac_name = g_strdup(cur_account
1182 ? (cur_account->account_name
1183 ? cur_account->account_name : _("Untitled"))
1187 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1189 buf = g_strdup(PROG_VERSION);
1190 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1193 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1194 gtk_widget_queue_resize(mainwin->ac_button);
1199 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1201 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1202 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1203 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1204 GtkWidget *message_wid = mainwin->messageview->vbox;
1206 debug_print("Changing window separation type from %d to %d\n",
1207 mainwin->type, type);
1209 if (mainwin->type == type) return;
1211 /* remove widgets from those containers */
1212 gtk_widget_ref(folder_wid);
1213 gtk_widget_ref(summary_wid);
1214 gtk_widget_ref(message_wid);
1215 gtkut_container_remove
1216 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1217 gtkut_container_remove
1218 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1219 gtkut_container_remove
1220 (GTK_CONTAINER(message_wid->parent), message_wid);
1222 /* clean containers */
1223 switch (mainwin->type) {
1225 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1227 case SEPARATE_FOLDER:
1228 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1229 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1231 case SEPARATE_MESSAGE:
1232 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1233 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1236 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1237 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1241 gtk_widget_hide(mainwin->window);
1242 main_window_set_widgets(mainwin, type);
1243 gtk_widget_show(mainwin->window);
1245 gtk_widget_unref(folder_wid);
1246 gtk_widget_unref(summary_wid);
1247 gtk_widget_unref(message_wid);
1250 void main_window_toggle_message_view(MainWindow *mainwin)
1252 SummaryView *summaryview = mainwin->summaryview;
1253 union CompositeWin *cwin = &mainwin->win;
1254 GtkWidget *vpaned = NULL;
1255 GtkWidget *container = NULL;
1256 GtkWidget *msgwin = NULL;
1258 switch (mainwin->type) {
1260 vpaned = cwin->sep_none.vpaned;
1261 container = cwin->sep_none.hpaned;
1263 case SEPARATE_FOLDER:
1264 vpaned = cwin->sep_folder.vpaned;
1265 container = mainwin->vbox_body;
1267 case SEPARATE_MESSAGE:
1268 msgwin = mainwin->win.sep_message.messagewin;
1271 msgwin = mainwin->win.sep_both.messagewin;
1276 if (GTK_WIDGET_VISIBLE(msgwin)) {
1277 gtk_widget_hide(msgwin);
1278 mainwin->messageview->visible = FALSE;
1279 summaryview->displayed = NULL;
1281 gtk_widget_show(msgwin);
1282 mainwin->messageview->visible = TRUE;
1284 } else if (vpaned->parent != NULL) {
1285 mainwin->messageview->visible = FALSE;
1286 summaryview->displayed = NULL;
1287 gtk_widget_ref(vpaned);
1288 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1289 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1290 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1291 GTK_ARROW_UP, GTK_SHADOW_OUT);
1293 mainwin->messageview->visible = TRUE;
1294 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1295 gtk_container_add(GTK_CONTAINER(container), vpaned);
1296 gtk_widget_unref(vpaned);
1297 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1298 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1301 main_window_set_menu_sensitive(mainwin);
1303 gtk_widget_grab_focus(summaryview->ctree);
1306 void main_window_get_size(MainWindow *mainwin)
1308 GtkAllocation *allocation;
1310 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1312 prefs_common.summaryview_width = allocation->width;
1314 if ((mainwin->type == SEPARATE_NONE ||
1315 mainwin->type == SEPARATE_FOLDER) &&
1316 messageview_is_visible(mainwin->messageview))
1317 prefs_common.summaryview_height = allocation->height;
1319 prefs_common.mainview_width = allocation->width;
1321 allocation = &mainwin->window->allocation;
1323 prefs_common.mainview_height = allocation->height;
1324 prefs_common.mainwin_width = allocation->width;
1325 prefs_common.mainwin_height = allocation->height;
1327 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1329 prefs_common.folderview_width = allocation->width;
1330 prefs_common.folderview_height = allocation->height;
1333 void main_window_get_position(MainWindow *mainwin)
1337 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1339 prefs_common.mainview_x = x;
1340 prefs_common.mainview_y = y;
1341 prefs_common.mainwin_x = x;
1342 prefs_common.mainwin_y = y;
1344 debug_print("window position: x = %d, y = %d\n", x, y);
1347 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1353 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1354 folder = FOLDER(list->data);
1355 if (folder && folder->trash && folder->trash->total > 0)
1359 if (!has_trash) return;
1362 if (alertpanel(_("Empty trash"),
1363 _("Empty all messages in trash?"),
1364 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1366 manage_window_focus_in(mainwin->window, NULL, NULL);
1369 procmsg_empty_trash();
1371 if (mainwin->summaryview->folder_item &&
1372 mainwin->summaryview->folder_item->stype == F_TRASH)
1373 gtk_widget_grab_focus(mainwin->folderview->ctree);
1376 void main_window_add_mailbox(MainWindow *mainwin)
1381 path = input_dialog(_("Add mailbox"),
1382 _("Input the location of mailbox.\n"
1383 "If the existing mailbox is specified, it will be\n"
1384 "scanned automatically."),
1387 if (folder_find_from_path(path)) {
1388 alertpanel_error(_("The mailbox `%s' already exists."), path);
1392 folder = folder_new(folder_get_class_from_string("mh"),
1393 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1397 if (folder->class->create_tree(folder) < 0) {
1398 alertpanel_error(_("Creation of the mailbox failed.\n"
1399 "Maybe some files already exist, or you don't have the permission to write there."));
1400 folder_destroy(folder);
1405 folder_set_ui_func(folder, scan_tree_func, mainwin);
1406 folder_scan_tree(folder);
1407 folder_set_ui_func(folder, NULL, NULL);
1409 folderview_set(mainwin->folderview);
1412 void main_window_add_mbox(MainWindow *mainwin)
1418 path = input_dialog(_("Add mbox mailbox"),
1419 _("Input the location of mailbox."),
1424 if (folder_find_from_path(path)) {
1425 alertpanel_error(_("The mailbox `%s' already exists."), path);
1430 folder = folder_new(folder_get_class_from_string("mbox"),
1431 g_basename(path), path);
1434 if (folder->class->create_tree(folder) < 0) {
1435 alertpanel_error(_("Creation of the mailbox failed."));
1436 folder_destroy(folder);
1442 item = folder_item_new(folder, folder->name, NULL);
1443 item->folder = folder;
1444 folder->node = g_node_new(item);
1446 folder_create_folder(item, "inbox");
1447 folder_create_folder(item, "outbox");
1448 folder_create_folder(item, "queue");
1449 folder_create_folder(item, "draft");
1450 folder_create_folder(item, "trash");
1452 folderview_set(mainwin->folderview);
1455 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1457 SensitiveCond state = 0;
1458 SummarySelection selection;
1459 FolderItem *item = mainwin->summaryview->folder_item;
1460 GList *account_list = account_get_list();
1462 selection = summary_get_selection_type(mainwin->summaryview);
1464 if (mainwin->lock_count == 0)
1465 state |= M_UNLOCKED;
1466 if (selection != SUMMARY_NONE)
1467 state |= M_MSG_EXIST;
1468 if (item && item->path && item->parent && !item->no_select) {
1470 /* if (item->folder->type != F_NEWS) */
1471 state |= M_ALLOW_DELETE;
1473 if (prefs_common.immediate_exec == 0
1474 && mainwin->lock_count == 0)
1475 state |= M_DELAY_EXEC;
1477 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1478 || selection != SUMMARY_NONE)
1479 state |= M_HIDE_READ_MSG;
1481 if (mainwin->summaryview->threaded)
1482 state |= M_THREADED;
1484 state |= M_UNTHREADED;
1485 if (selection == SUMMARY_SELECTED_SINGLE ||
1486 selection == SUMMARY_SELECTED_MULTIPLE)
1487 state |= M_TARGET_EXIST;
1488 if (selection == SUMMARY_SELECTED_SINGLE)
1489 state |= M_SINGLE_TARGET_EXIST;
1490 if (mainwin->summaryview->folder_item &&
1491 mainwin->summaryview->folder_item->folder->class->type == F_NEWS)
1494 state |= M_NOT_NEWS;
1495 if (selection == SUMMARY_SELECTED_SINGLE &&
1497 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1498 item->stype == F_QUEUE)))
1499 state |= M_ALLOW_REEDIT;
1501 state |= M_HAVE_ACCOUNT;
1503 for ( ; account_list != NULL; account_list = account_list->next) {
1504 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1505 state |= M_HAVE_NEWS_ACCOUNT;
1510 if (inc_is_active())
1511 state |= M_INC_ACTIVE;
1518 void main_window_set_menu_sensitive(MainWindow *mainwin)
1520 GtkItemFactory *ifactory = mainwin->menu_factory;
1521 SensitiveCond state;
1523 GtkWidget *menuitem;
1524 SummaryView *summaryview;
1528 static const struct {
1532 {"/File/Add mailbox..." , M_UNLOCKED},
1533 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1534 {"/File/Check for new messages in all folders", M_UNLOCKED},
1535 {"/File/Folder" , M_UNLOCKED},
1536 {"/File/Import mbox file..." , M_UNLOCKED},
1537 {"/File/Export to mbox file..." , M_UNLOCKED},
1538 {"/File/Empty trash" , M_UNLOCKED},
1539 {"/File/Work offline" , M_UNLOCKED},
1541 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1542 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1543 /* {"/File/Close" , M_UNLOCKED}, */
1544 {"/File/Exit" , M_UNLOCKED},
1546 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1548 {"/View/Sort" , M_EXEC},
1549 {"/View/Thread view" , M_EXEC},
1550 {"/View/Expand all threads" , M_MSG_EXIST},
1551 {"/View/Collapse all threads" , M_MSG_EXIST},
1552 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1553 {"/View/Go to/Prev message" , M_MSG_EXIST},
1554 {"/View/Go to/Next message" , M_MSG_EXIST},
1555 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1556 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1557 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1558 {"/View/Go to/Next new message" , M_MSG_EXIST},
1559 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1560 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1561 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1562 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1563 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1564 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1565 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1567 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1568 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1569 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1570 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1571 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1572 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1573 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1574 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1575 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1576 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1577 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1578 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1579 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1580 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1581 {"/Message/Mark" , M_TARGET_EXIST},
1583 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1584 {"/Tools/Harvest addresses" , M_UNLOCKED},
1585 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1586 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1587 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1588 {"/Tools/Execute" , M_DELAY_EXEC},
1589 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1591 {"/Configuration", M_UNLOCKED},
1596 state = main_window_get_current_state(mainwin);
1598 for (i = 0; entry[i].entry != NULL; i++) {
1599 sensitive = ((entry[i].cond & state) == entry[i].cond);
1600 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1603 main_window_menu_callback_block(mainwin);
1605 #define SET_CHECK_MENU_ACTIVE(path, active) \
1607 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1608 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1611 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1612 messageview_is_visible(mainwin->messageview));
1614 summaryview = mainwin->summaryview;
1615 menu_path = "/View/Sort/Don't sort";
1617 switch (summaryview->sort_key) {
1618 case SORT_BY_NUMBER:
1619 menu_path = "/View/Sort/by number"; break;
1621 menu_path = "/View/Sort/by size"; break;
1623 menu_path = "/View/Sort/by date"; break;
1625 menu_path = "/View/Sort/by from"; break;
1627 menu_path = "/View/Sort/by recipient"; break;
1628 case SORT_BY_SUBJECT:
1629 menu_path = "/View/Sort/by subject"; break;
1631 menu_path = "/View/Sort/by color label"; break;
1633 menu_path = "/View/Sort/by mark"; break;
1634 case SORT_BY_STATUS:
1635 menu_path = "/View/Sort/by status"; break;
1637 menu_path = "/View/Sort/by attachment"; break;
1639 menu_path = "/View/Sort/by score"; break;
1640 case SORT_BY_LOCKED:
1641 menu_path = "/View/Sort/by locked"; break;
1644 menu_path = "/View/Sort/Don't sort"; break;
1646 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1648 if (summaryview->sort_type == SORT_ASCENDING) {
1649 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1651 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1654 if (summaryview->sort_key != SORT_BY_NONE) {
1655 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1656 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1658 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1659 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1662 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1663 mainwin->messageview->textview->show_all_headers);
1664 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1666 #undef SET_CHECK_MENU_ACTIVE
1668 main_window_menu_callback_unblock(mainwin);
1671 void main_window_popup(MainWindow *mainwin)
1673 gtkut_window_popup(mainwin->window);
1675 switch (mainwin->type) {
1676 case SEPARATE_FOLDER:
1677 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1679 case SEPARATE_MESSAGE:
1680 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1683 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1684 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1691 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1693 GtkWidget *folderwin = NULL;
1694 GtkWidget *messagewin = NULL;
1697 GtkWidget *vbox_body = mainwin->vbox_body;
1698 GtkItemFactory *ifactory = mainwin->menu_factory;
1699 GtkWidget *menuitem;
1700 GtkItemFactory *msgview_ifactory;
1702 debug_print("Setting widgets...");
1704 /* create separated window(s) if needed */
1705 if (type & SEPARATE_FOLDER) {
1706 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1707 gtk_window_set_title(GTK_WINDOW(folderwin),
1708 _("Sylpheed - Folder View"));
1709 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1710 "folder_view", "Sylpheed");
1711 gtk_window_set_policy(GTK_WINDOW(folderwin),
1713 gtk_widget_set_usize(folderwin, -1,
1714 prefs_common.mainview_height);
1715 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1717 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1718 GTK_SIGNAL_FUNC(folder_window_close_cb),
1721 if (type & SEPARATE_MESSAGE) {
1722 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1723 gtk_window_set_title(GTK_WINDOW(messagewin),
1724 _("Sylpheed - Message View"));
1725 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1726 "message_view", "Sylpheed");
1727 gtk_window_set_policy(GTK_WINDOW(messagewin),
1729 gtk_widget_set_usize
1730 (messagewin, prefs_common.mainview_width,
1731 prefs_common.mainview_height
1732 - prefs_common.summaryview_height
1733 + DEFAULT_HEADERVIEW_HEIGHT);
1734 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1736 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1737 GTK_SIGNAL_FUNC(message_window_close_cb),
1743 hpaned = gtk_hpaned_new();
1744 gtk_widget_show(hpaned);
1745 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1746 gtk_paned_add1(GTK_PANED(hpaned),
1747 GTK_WIDGET_PTR(mainwin->folderview));
1749 vpaned = gtk_vpaned_new();
1750 if (messageview_is_visible(mainwin->messageview)) {
1751 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1752 gtk_paned_add1(GTK_PANED(vpaned),
1753 GTK_WIDGET_PTR(mainwin->summaryview));
1755 gtk_paned_add2(GTK_PANED(hpaned),
1756 GTK_WIDGET_PTR(mainwin->summaryview));
1757 gtk_widget_ref(vpaned);
1759 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1760 prefs_common.summaryview_width,
1761 prefs_common.summaryview_height);
1762 gtk_paned_add2(GTK_PANED(vpaned),
1763 GTK_WIDGET_PTR(mainwin->messageview));
1764 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1765 prefs_common.mainview_width, -1);
1766 gtk_widget_set_usize(mainwin->window,
1767 prefs_common.folderview_width +
1768 prefs_common.mainview_width,
1769 prefs_common.mainwin_height);
1770 gtk_widget_show_all(vpaned);
1772 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1773 * lose track of its visibility state */
1774 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1775 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1777 mainwin->win.sep_none.hpaned = hpaned;
1778 mainwin->win.sep_none.vpaned = vpaned;
1780 /* remove headerview if not in prefs */
1781 headerview_set_visibility(mainwin->messageview->headerview,
1782 prefs_common.display_header_pane);
1784 case SEPARATE_FOLDER:
1785 vpaned = gtk_vpaned_new();
1786 if (messageview_is_visible(mainwin->messageview)) {
1787 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1789 gtk_paned_add1(GTK_PANED(vpaned),
1790 GTK_WIDGET_PTR(mainwin->summaryview));
1792 gtk_box_pack_start(GTK_BOX(vbox_body),
1793 GTK_WIDGET_PTR(mainwin->summaryview),
1795 gtk_widget_ref(vpaned);
1797 gtk_paned_add2(GTK_PANED(vpaned),
1798 GTK_WIDGET_PTR(mainwin->messageview));
1799 gtk_widget_show_all(vpaned);
1800 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1801 prefs_common.summaryview_width,
1802 prefs_common.summaryview_height);
1803 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1804 prefs_common.mainview_width, -1);
1805 gtk_widget_set_usize(mainwin->window,
1806 prefs_common.mainview_width,
1807 prefs_common.mainview_height);
1809 gtk_container_add(GTK_CONTAINER(folderwin),
1810 GTK_WIDGET_PTR(mainwin->folderview));
1812 mainwin->win.sep_folder.folderwin = folderwin;
1813 mainwin->win.sep_folder.vpaned = vpaned;
1815 gtk_widget_show_all(folderwin);
1817 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1818 * lose track of its visibility state */
1819 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1820 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1822 /* remove headerview if not in prefs */
1823 headerview_set_visibility(mainwin->messageview->headerview,
1824 prefs_common.display_header_pane);
1827 case SEPARATE_MESSAGE:
1828 hpaned = gtk_hpaned_new();
1829 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1831 gtk_paned_add1(GTK_PANED(hpaned),
1832 GTK_WIDGET_PTR(mainwin->folderview));
1833 gtk_paned_add2(GTK_PANED(hpaned),
1834 GTK_WIDGET_PTR(mainwin->summaryview));
1835 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1836 prefs_common.summaryview_width,
1837 prefs_common.summaryview_height);
1838 gtk_widget_set_usize(mainwin->window,
1839 prefs_common.folderview_width +
1840 prefs_common.mainview_width,
1841 prefs_common.mainwin_height);
1842 gtk_widget_show_all(hpaned);
1844 messageview_add_toolbar(mainwin->messageview, messagewin);
1845 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1846 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1848 mainwin->win.sep_message.messagewin = messagewin;
1849 mainwin->win.sep_message.hpaned = hpaned;
1851 gtk_widget_show_all(messagewin);
1853 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1854 * lose track of its visibility state */
1855 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1856 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1859 gtk_box_pack_start(GTK_BOX(vbox_body),
1860 GTK_WIDGET_PTR(mainwin->summaryview),
1862 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1863 prefs_common.summaryview_width,
1864 prefs_common.summaryview_height);
1865 gtk_widget_set_usize(mainwin->window,
1866 prefs_common.mainview_width,
1867 prefs_common.mainwin_height);
1868 gtk_container_add(GTK_CONTAINER(folderwin),
1869 GTK_WIDGET_PTR(mainwin->folderview));
1870 gtk_container_add(GTK_CONTAINER(messagewin),
1871 GTK_WIDGET_PTR(mainwin->messageview));
1873 mainwin->win.sep_both.folderwin = folderwin;
1874 mainwin->win.sep_both.messagewin = messagewin;
1876 gtk_widget_show_all(folderwin);
1877 gtk_widget_show_all(messagewin);
1879 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1880 * lose track of its visibility state */
1881 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1882 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1886 /* rehide quick search if necessary */
1887 if (!prefs_common.show_searchbar)
1888 gtk_widget_hide(mainwin->summaryview->hbox_search);
1890 mainwin->type = type;
1892 mainwin->messageview->visible = TRUE;
1894 /* toggle menu state */
1895 menuitem = gtk_item_factory_get_item
1896 (ifactory, "/View/Show or hide/Folder tree");
1897 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1898 menuitem = gtk_item_factory_get_item
1899 (ifactory, "/View/Show or hide/Message view");
1900 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1902 menuitem = gtk_item_factory_get_item
1903 (ifactory, "/View/Separate folder tree");
1904 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1905 ((type & SEPARATE_FOLDER) != 0));
1906 menuitem = gtk_item_factory_get_item
1907 (ifactory, "/View/Separate message view");
1908 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1909 ((type & SEPARATE_MESSAGE) != 0));
1911 debug_print("done.\n");
1914 void main_window_destroy_all(void)
1916 while (mainwin_list != NULL) {
1917 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1919 /* free toolbar stuff */
1920 toolbar_clear_list(TOOLBAR_MAIN);
1921 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1922 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1924 g_free(mainwin->toolbar);
1927 mainwin_list = g_list_remove(mainwin_list, mainwin);
1929 g_list_free(mainwin_list);
1933 static void toolbar_account_button_pressed(GtkWidget *widget,
1934 GdkEventButton *event,
1937 MainWindow *mainwin = (MainWindow *)data;
1940 if (event->button != 3) return;
1942 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1943 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1946 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1947 menu_button_position, widget,
1948 event->button, event->time);
1952 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1955 MainWindow *mainwin = (MainWindow *)data;
1959 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1960 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1963 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1964 menu_button_position, widget,
1965 event->button, event->time);
1968 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
1970 MainWindow *mainwin = (MainWindow *)data;
1973 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
1974 if (!button) return;
1975 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1976 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
1977 manage_window_focus_in(mainwin->window, NULL, NULL);
1980 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1983 MainWindow *mainwin = (MainWindow *)data;
1985 if (mainwin->lock_count == 0)
1986 app_exit_cb(data, 0, widget);
1991 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1994 MainWindow *mainwin = (MainWindow *)data;
1995 GtkWidget *menuitem;
1997 menuitem = gtk_item_factory_get_item
1998 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
1999 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2004 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2007 MainWindow *mainwin = (MainWindow *)data;
2008 GtkWidget *menuitem;
2010 menuitem = gtk_item_factory_get_item
2011 (mainwin->menu_factory, "/View/Show or hide/Message view");
2012 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2017 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2020 main_window_add_mailbox(mainwin);
2023 static void add_mbox_cb(MainWindow *mainwin, guint action,
2026 main_window_add_mbox(mainwin);
2029 static void update_folderview_cb(MainWindow *mainwin, guint action,
2032 summary_show(mainwin->summaryview, NULL);
2033 folderview_check_new_all();
2036 static void new_folder_cb(MainWindow *mainwin, guint action,
2039 folderview_new_folder(mainwin->folderview);
2042 static void rename_folder_cb(MainWindow *mainwin, guint action,
2045 folderview_rename_folder(mainwin->folderview);
2048 static void delete_folder_cb(MainWindow *mainwin, guint action,
2051 folderview_delete_folder(mainwin->folderview);
2054 static void import_mbox_cb(MainWindow *mainwin, guint action,
2057 import_mbox(mainwin->summaryview->folder_item);
2060 static void export_mbox_cb(MainWindow *mainwin, guint action,
2063 export_mbox(mainwin->summaryview->folder_item);
2066 static void empty_trash_cb(MainWindow *mainwin, guint action,
2069 main_window_empty_trash(mainwin, TRUE);
2072 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2074 summary_save_as(mainwin->summaryview);
2077 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2079 summary_print(mainwin->summaryview);
2082 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2084 if (prefs_common.confirm_on_exit) {
2085 if (alertpanel(_("Exit"), _("Exit this program?"),
2086 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2088 manage_window_focus_in(mainwin->window, NULL, NULL);
2091 app_will_exit(widget, mainwin);
2094 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2097 summary_search(mainwin->summaryview);
2099 message_search(mainwin->messageview);
2102 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2107 active = GTK_CHECK_MENU_ITEM(widget)->active;
2109 switch (mainwin->type) {
2111 case SEPARATE_MESSAGE:
2114 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2116 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2119 case SEPARATE_FOLDER:
2120 debug_print("separate folder\n");
2122 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2124 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2128 gtk_widget_show(mainwin->win.sep_both.folderwin);
2130 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2135 static void toggle_message_cb(MainWindow *mainwin, guint action,
2140 active = GTK_CHECK_MENU_ITEM(widget)->active;
2142 if (active != messageview_is_visible(mainwin->messageview))
2143 summary_toggle_view(mainwin->summaryview);
2146 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2149 toolbar_toggle(action, mainwin);
2152 void main_window_reply_cb(MainWindow *mainwin, guint action,
2155 MessageView *msgview = (MessageView*)mainwin->messageview;
2156 GSList *msginfo_list = NULL;
2159 g_return_if_fail(msgview != NULL);
2161 msginfo_list = summary_get_selection(mainwin->summaryview);
2162 g_return_if_fail(msginfo_list != NULL);
2164 body = messageview_get_selection(msgview);
2165 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2167 g_slist_free(msginfo_list);
2171 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2174 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2175 gtk_widget_show(mainwin->hbox_stat);
2176 prefs_common.show_statusbar = TRUE;
2178 gtk_widget_hide(mainwin->hbox_stat);
2179 prefs_common.show_statusbar = FALSE;
2183 static void separate_widget_cb(MainWindow *mainwin, guint action,
2188 if (GTK_CHECK_MENU_ITEM(widget)->active)
2189 type = mainwin->type | action;
2191 type = mainwin->type & ~action;
2193 main_window_separation_change(mainwin, type);
2195 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2196 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2199 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2202 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2204 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2207 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2209 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2212 static void online_switch_clicked (GtkButton *btn, gpointer data)
2214 MainWindow *mainwin;
2215 GtkItemFactory *ifactory;
2216 GtkCheckMenuItem *menuitem;
2218 mainwin = (MainWindow *) data;
2220 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2221 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2223 g_return_if_fail(mainwin != NULL);
2224 g_return_if_fail(menuitem != NULL);
2226 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2228 gtk_widget_hide (mainwin->online_switch);
2229 gtk_widget_show (mainwin->offline_switch);
2230 menuitem->active = TRUE;
2231 prefs_common.work_offline = TRUE;
2232 inc_autocheck_timer_remove();
2235 gtk_widget_hide (mainwin->offline_switch);
2236 gtk_widget_show (mainwin->online_switch);
2237 menuitem->active = FALSE;
2238 prefs_common.work_offline = FALSE;
2239 inc_autocheck_timer_set();
2243 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2246 addressbook_open(NULL);
2249 static void log_window_show_cb(MainWindow *mainwin, guint action,
2252 log_window_show(mainwin->logwin);
2255 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2260 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2262 summary_move_to(mainwin->summaryview);
2265 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2267 summary_copy_to(mainwin->summaryview);
2270 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2272 summary_delete(mainwin->summaryview);
2275 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2277 summary_cancel(mainwin->summaryview);
2280 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2282 summary_open_msg(mainwin->summaryview);
2285 static void view_source_cb(MainWindow *mainwin, guint action,
2288 summary_view_source(mainwin->summaryview);
2291 static void show_all_header_cb(MainWindow *mainwin, guint action,
2294 if (mainwin->menu_lock_count) return;
2295 summary_display_msg_selected(mainwin->summaryview,
2296 GTK_CHECK_MENU_ITEM(widget)->active);
2299 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2301 summary_reedit(mainwin->summaryview);
2304 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2306 summary_mark(mainwin->summaryview);
2309 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2311 summary_unmark(mainwin->summaryview);
2314 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2317 summary_mark_as_unread(mainwin->summaryview);
2320 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2323 summary_mark_as_read(mainwin->summaryview);
2326 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2329 summary_mark_all_read(mainwin->summaryview);
2332 static void add_address_cb(MainWindow *mainwin, guint action,
2335 summary_add_address(mainwin->summaryview);
2338 static void set_charset_cb(MainWindow *mainwin, guint action,
2343 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2344 str = conv_get_charset_str((CharSet)action);
2345 g_free(prefs_common.force_charset);
2346 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2348 summary_redisplay_msg(mainwin->summaryview);
2350 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2354 static void hide_read_messages (MainWindow *mainwin, guint action,
2357 if (!mainwin->summaryview->folder_item
2358 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2360 summary_toggle_show_read_messages(mainwin->summaryview);
2363 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2365 if (mainwin->menu_lock_count) return;
2366 if (!mainwin->summaryview->folder_item) return;
2368 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2369 summary_thread_build(mainwin->summaryview);
2370 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2372 summary_unthread(mainwin->summaryview);
2373 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2377 static void expand_threads_cb(MainWindow *mainwin, guint action,
2380 summary_expand_threads(mainwin->summaryview);
2383 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2386 summary_collapse_threads(mainwin->summaryview);
2389 static void set_display_item_cb(MainWindow *mainwin, guint action,
2392 prefs_summary_column_open();
2395 static void sort_summary_cb(MainWindow *mainwin, guint action,
2398 FolderItem *item = mainwin->summaryview->folder_item;
2399 GtkWidget *menuitem;
2401 if (mainwin->menu_lock_count) return;
2403 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2404 menuitem = gtk_item_factory_get_item
2405 (mainwin->menu_factory, "/View/Sort/Ascending");
2406 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2407 GTK_CHECK_MENU_ITEM(menuitem)->active
2408 ? SORT_ASCENDING : SORT_DESCENDING);
2412 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2415 FolderItem *item = mainwin->summaryview->folder_item;
2417 if (mainwin->menu_lock_count) return;
2419 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2420 summary_sort(mainwin->summaryview,
2421 item->sort_key, (FolderSortType)action);
2424 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2427 summary_attract_by_subject(mainwin->summaryview);
2430 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2433 summary_delete_duplicated(mainwin->summaryview);
2436 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2438 summary_filter(mainwin->summaryview);
2441 static void execute_summary_cb(MainWindow *mainwin, guint action,
2444 summary_execute(mainwin->summaryview);
2447 static void update_summary_cb(MainWindow *mainwin, guint action,
2451 FolderView *folderview = mainwin->folderview;
2453 if (!mainwin->summaryview->folder_item) return;
2454 if (!folderview->opened) return;
2456 folder_update_op_count();
2458 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2459 folderview->opened);
2462 folder_item_scan(fitem);
2463 summary_show(mainwin->summaryview, fitem);
2466 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2468 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2471 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2473 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2476 static void prev_unread_cb(MainWindow *mainwin, guint action,
2479 summary_select_prev_unread(mainwin->summaryview);
2482 static void next_unread_cb(MainWindow *mainwin, guint action,
2485 summary_select_next_unread(mainwin->summaryview);
2488 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2490 summary_select_prev_new(mainwin->summaryview);
2493 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2495 summary_select_next_new(mainwin->summaryview);
2498 static void prev_marked_cb(MainWindow *mainwin, guint action,
2501 summary_select_prev_marked(mainwin->summaryview);
2504 static void next_marked_cb(MainWindow *mainwin, guint action,
2507 summary_select_next_marked(mainwin->summaryview);
2510 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2513 summary_select_prev_labeled(mainwin->summaryview);
2516 static void next_labeled_cb(MainWindow *mainwin, guint action,
2519 summary_select_next_labeled(mainwin->summaryview);
2522 static void goto_folder_cb(MainWindow *mainwin, guint action,
2525 FolderItem *to_folder;
2527 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2530 folderview_select(mainwin->folderview, to_folder);
2533 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2535 messageview_copy_clipboard(mainwin->messageview);
2538 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2540 MessageView *msgview = mainwin->messageview;
2542 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2543 summary_select_all(mainwin->summaryview);
2544 else if (messageview_is_visible(msgview) &&
2545 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2546 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2547 messageview_select_all(mainwin->messageview);
2550 static void select_thread_cb(MainWindow *mainwin, guint action,
2553 summary_select_thread(mainwin->summaryview);
2556 static void create_filter_cb(MainWindow *mainwin, guint action,
2559 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2562 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2565 prefs_common_open();
2568 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2571 prefs_scoring_open(NULL);
2574 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2577 prefs_filtering_open(NULL, NULL, NULL);
2580 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2583 prefs_template_open();
2586 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2589 prefs_actions_open(mainwin);
2592 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2595 ssl_manager_open(mainwin);
2598 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2602 new_account_cb(mainwin, 0, widget);
2604 account_open(cur_account);
2608 static void new_account_cb(MainWindow *mainwin, guint action,
2611 account_edit_open();
2612 if (!compose_get_compose_list()) account_add();
2615 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2617 cur_account = (PrefsAccount *)data;
2618 main_window_reflect_prefs_all();
2621 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2626 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2628 pluginwindow_create();
2631 static void manual_open_cb(MainWindow *mainwin, guint action,
2634 manual_open((ManualType)action);
2637 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2639 MainWindow *mainwin = (MainWindow *)data;
2643 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2644 LOCAL_FOLDER(folder)->rootpath,
2648 str = g_strdup_printf(_("Scanning folder %s ..."),
2649 LOCAL_FOLDER(folder)->rootpath);
2651 STATUSBAR_PUSH(mainwin, str);
2652 STATUSBAR_POP(mainwin);
2656 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2659 SummaryView *summary;
2661 g_return_val_if_fail(data, FALSE);
2662 summary = ((MainWindow *)data)->summaryview;
2663 g_return_val_if_fail(summary, FALSE);
2664 if (summary->selected != summary->displayed)
2665 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2669 #define BREAK_ON_MODIFIER_KEY() \
2670 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2672 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2675 MainWindow *mainwin = (MainWindow*) data;
2677 if (!mainwin || !event) return;
2679 switch (event->keyval) {
2680 case GDK_Q: /* Quit */
2681 BREAK_ON_MODIFIER_KEY();
2683 app_exit_cb(mainwin, 0, NULL);
2686 if (mainwin->folderview && mainwin->summaryview
2687 && !mainwin->summaryview->displayed) {
2688 summary_lock(mainwin->summaryview);
2689 folderview_select_next_unread(mainwin->folderview);
2690 summary_unlock(mainwin->summaryview);
2698 #undef BREAK_ON_MODIFIER_KEY
2701 * Harvest addresses for selected folder.
2703 static void addr_harvest_cb( MainWindow *mainwin,
2707 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2711 * Harvest addresses for selected messages in summary view.
2713 static void addr_harvest_msg_cb( MainWindow *mainwin,
2717 summary_harvest_address( mainwin->summaryview );
2721 *\brief get a MainWindow
2723 *\return MainWindow * The first mainwindow in the mainwin_list
2725 MainWindow *mainwindow_get_mainwindow(void)
2727 if (mainwin_list && mainwin_list->data)
2728 return (MainWindow *)(mainwin_list->data);
2733 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2735 ProgressData *data = (ProgressData *) source;
2736 MainWindow *mainwin = (MainWindow *) userdata;
2738 switch (data->cmd) {
2739 case PROGRESS_COMMAND_START:
2740 case PROGRESS_COMMAND_STOP:
2741 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2743 case PROGRESS_COMMAND_SET_PERCENTAGE:
2744 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2747 while (gtk_events_pending()) gtk_main_iteration ();