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_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
71 #include "prefs_toolbar.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
85 #include "selective_download.h"
88 #define AC_LABEL_WIDTH 240
90 /* list of all instantiated MainWindow */
91 static GList *mainwin_list = NULL;
93 static GdkCursor *watch_cursor;
95 static void main_window_menu_callback_block (MainWindow *mainwin);
96 static void main_window_menu_callback_unblock (MainWindow *mainwin);
98 static void main_window_show_cur_account (MainWindow *mainwin);
100 static void main_window_set_widgets (MainWindow *mainwin,
104 static void toolbar_account_button_pressed (GtkWidget *widget,
105 GdkEventButton *event,
108 static void ac_label_button_pressed (GtkWidget *widget,
109 GdkEventButton *event,
111 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
114 static gint main_window_close_cb (GtkWidget *widget,
117 static gint folder_window_close_cb (GtkWidget *widget,
120 static gint message_window_close_cb (GtkWidget *widget,
124 static void add_mailbox_cb (MainWindow *mainwin,
127 static void add_mbox_cb (MainWindow *mainwin,
130 static void update_folderview_cb (MainWindow *mainwin,
133 static void new_folder_cb (MainWindow *mainwin,
136 static void rename_folder_cb (MainWindow *mainwin,
139 static void delete_folder_cb (MainWindow *mainwin,
142 static void import_mbox_cb (MainWindow *mainwin,
145 static void export_mbox_cb (MainWindow *mainwin,
148 static void empty_trash_cb (MainWindow *mainwin,
152 static void save_as_cb (MainWindow *mainwin,
155 static void print_cb (MainWindow *mainwin,
158 static void app_exit_cb (MainWindow *mainwin,
162 static void search_cb (MainWindow *mainwin,
166 static void toggle_folder_cb (MainWindow *mainwin,
169 static void toggle_message_cb (MainWindow *mainwin,
172 static void toggle_toolbar_cb (MainWindow *mainwin,
175 static void toggle_statusbar_cb (MainWindow *mainwin,
178 static void toggle_searchbar_cb (MainWindow *mainwin,
181 static void separate_widget_cb (MainWindow *mainwin,
185 static void addressbook_open_cb (MainWindow *mainwin,
188 static void log_window_show_cb (MainWindow *mainwin,
191 static void sel_download_cb (MainWindow *mainwin,
194 static void prefs_toolbar_cb (MainWindow *mainwin,
199 static void inc_cancel_cb (MainWindow *mainwin,
203 static void open_msg_cb (MainWindow *mainwin,
207 static void view_source_cb (MainWindow *mainwin,
211 static void show_all_header_cb (MainWindow *mainwin,
215 static void reedit_cb (MainWindow *mainwin,
219 static void move_to_cb (MainWindow *mainwin,
222 static void copy_to_cb (MainWindow *mainwin,
225 static void delete_cb (MainWindow *mainwin,
229 static void mark_cb (MainWindow *mainwin,
232 static void unmark_cb (MainWindow *mainwin,
236 static void mark_as_unread_cb (MainWindow *mainwin,
239 static void mark_as_read_cb (MainWindow *mainwin,
242 static void mark_all_read_cb (MainWindow *mainwin,
245 static void add_address_cb (MainWindow *mainwin,
249 static void set_charset_cb (MainWindow *mainwin,
253 static void hide_read_messages (MainWindow *mainwin,
257 static void thread_cb (MainWindow *mainwin,
260 static void expand_threads_cb (MainWindow *mainwin,
263 static void collapse_threads_cb (MainWindow *mainwin,
267 static void set_display_item_cb (MainWindow *mainwin,
270 static void sort_summary_cb (MainWindow *mainwin,
273 static void sort_summary_type_cb (MainWindow *mainwin,
276 static void attract_by_subject_cb(MainWindow *mainwin,
280 static void delete_duplicated_cb (MainWindow *mainwin,
283 static void filter_cb (MainWindow *mainwin,
286 static void execute_summary_cb (MainWindow *mainwin,
289 static void update_summary_cb (MainWindow *mainwin,
293 static void prev_cb (MainWindow *mainwin,
296 static void next_cb (MainWindow *mainwin,
300 static void prev_unread_cb (MainWindow *mainwin,
304 static void prev_new_cb (MainWindow *mainwin,
307 static void next_new_cb (MainWindow *mainwin,
310 static void prev_marked_cb (MainWindow *mainwin,
313 static void next_marked_cb (MainWindow *mainwin,
316 static void prev_labeled_cb (MainWindow *mainwin,
319 static void next_labeled_cb (MainWindow *mainwin,
323 static void goto_folder_cb (MainWindow *mainwin,
327 static void copy_cb (MainWindow *mainwin,
330 static void allsel_cb (MainWindow *mainwin,
333 static void selthread_cb (MainWindow *mainwin,
336 static void create_filter_cb (MainWindow *mainwin,
340 static void prefs_common_open_cb (MainWindow *mainwin,
343 static void prefs_filter_open_cb (MainWindow *mainwin,
346 static void prefs_template_open_cb (MainWindow *mainwin,
349 static void prefs_actions_open_cb (MainWindow *mainwin,
352 static void prefs_account_open_cb (MainWindow *mainwin,
355 static void prefs_scoring_open_cb (MainWindow *mainwin,
358 static void prefs_filtering_open_cb (MainWindow *mainwin,
362 static void new_account_cb (MainWindow *mainwin,
366 static void account_menu_cb (GtkMenuItem *menuitem,
369 static void online_switch_clicked(GtkButton *btn,
372 static void manual_open_cb (MainWindow *mainwin,
375 static void faq_open_cb (MainWindow *mainwin,
379 static void scan_tree_func (Folder *folder,
383 static void key_pressed (GtkWidget *widget,
387 static void set_toolbar_style(MainWindow *mainwin);
389 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
391 static void addr_harvest_cb ( MainWindow *mainwin,
395 static void addr_harvest_msg_cb ( MainWindow *mainwin,
399 #define SEPARATE_ACTION 500
401 static GtkItemFactoryEntry mainwin_entries[] =
403 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
404 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
405 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
406 {N_("/_File/_Check for new messages in all folders"),
407 NULL, update_folderview_cb, 0, NULL},
408 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
409 {N_("/_File/_Folder/Create _new folder..."),
410 NULL, new_folder_cb, 0, NULL},
411 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
412 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
413 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
414 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
415 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
416 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
417 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
418 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
419 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
420 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
421 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
422 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
424 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
425 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
426 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
427 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
428 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
429 {N_("/_Edit/_Find in current message..."),
430 "<control>F", search_cb, 0, NULL},
431 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
432 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
433 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
434 {N_("/_View/Show or hi_de/_Folder tree"),
435 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
436 {N_("/_View/Show or hi_de/_Message view"),
437 "V", toggle_message_cb, 0, "<ToggleItem>"},
438 {N_("/_View/Show or hi_de/_Toolbar"),
439 NULL, NULL, 0, "<Branch>"},
440 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
441 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
442 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
443 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
444 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
445 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
446 {N_("/_View/Show or hi_de/_Toolbar/_None"),
447 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
448 {N_("/_View/Show or hi_de/Status _bar"),
449 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
450 {N_("/_View/Show or hi_de/Quick _search"),
451 NULL, toggle_searchbar_cb, 0, "<ToggleItem>"},
452 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
453 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
454 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
455 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
456 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
457 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
458 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
459 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
460 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
461 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
462 {N_("/_View/_Sort/by _color label"),
463 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
464 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
465 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
466 {N_("/_View/_Sort/by a_ttachment"),
467 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
468 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
469 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
470 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
471 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
472 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
473 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
474 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
475 {N_("/_View/_Sort/_Attract by subject"),
476 NULL, attract_by_subject_cb, 0, NULL},
477 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
478 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
479 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
480 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
481 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
483 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
484 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
485 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
486 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
487 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
488 {N_("/_View/_Go to/P_rev unread message"),
489 "<shift>P", prev_unread_cb, 0, NULL},
490 {N_("/_View/_Go to/N_ext unread message"),
491 "<shift>N", next_unread_cb, 0, NULL},
492 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
494 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
495 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_View/_Go to/Prev _marked message"),
497 NULL, prev_marked_cb, 0, NULL},
498 {N_("/_View/_Go to/Next m_arked message"),
499 NULL, next_marked_cb, 0, NULL},
500 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
501 {N_("/_View/_Go to/Prev _labeled message"),
502 NULL, prev_labeled_cb, 0, NULL},
503 {N_("/_View/_Go to/Next la_beled message"),
504 NULL, next_labeled_cb, 0, NULL},
505 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
506 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
507 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
509 #define CODESET_SEPARATOR \
510 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
511 #define CODESET_ACTION(action) \
512 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
514 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_View/_Code set/_Auto detect"),
516 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
517 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
519 CODESET_ACTION(C_US_ASCII)},
522 {N_("/_View/_Code set/Unicode (_UTF-8)"),
523 CODESET_ACTION(C_UTF_8)},
526 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
527 CODESET_ACTION(C_ISO_8859_1)},
528 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
529 CODESET_ACTION(C_ISO_8859_15)},
532 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
533 CODESET_ACTION(C_ISO_8859_2)},
535 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
536 CODESET_ACTION(C_ISO_8859_13)},
537 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
538 CODESET_ACTION(C_ISO_8859_4)},
540 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
541 CODESET_ACTION(C_ISO_8859_7)},
543 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
544 CODESET_ACTION(C_ISO_8859_9)},
546 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
547 CODESET_ACTION(C_ISO_8859_5)},
548 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
549 CODESET_ACTION(C_KOI8_R)},
550 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
551 CODESET_ACTION(C_WINDOWS_1251)},
554 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
555 CODESET_ACTION(C_ISO_2022_JP)},
557 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
558 CODESET_ACTION(C_ISO_2022_JP_2)},
560 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
561 CODESET_ACTION(C_EUC_JP)},
562 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
563 CODESET_ACTION(C_SHIFT_JIS)},
566 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
567 CODESET_ACTION(C_GB2312)},
568 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
569 CODESET_ACTION(C_BIG5)},
570 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
571 CODESET_ACTION(C_EUC_TW)},
572 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
573 CODESET_ACTION(C_ISO_2022_CN)},
575 {N_("/_View/_Code set/Korean (EUC-_KR)"),
576 CODESET_ACTION(C_EUC_KR)},
577 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
578 CODESET_ACTION(C_ISO_2022_KR)},
580 {N_("/_View/_Code set/Thai (TIS-620)"),
581 CODESET_ACTION(C_TIS_620)},
582 {N_("/_View/_Code set/Thai (Windows-874)"),
583 CODESET_ACTION(C_WINDOWS_874)},
586 #undef CODESET_SEPARATOR
587 #undef CODESET_ACTION
589 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
591 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
592 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
593 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
594 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
596 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
597 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
598 {N_("/_Message/Get from _all accounts"),
599 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
600 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
601 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
602 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
603 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
605 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
606 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
607 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
608 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
609 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
610 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
611 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
612 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
614 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
616 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
617 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
618 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
620 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
621 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
622 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
624 {N_("/_Message/_Mark/Mark as rea_d"),
625 NULL, mark_as_read_cb, 0, NULL},
626 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
628 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
629 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
630 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
632 {N_("/_Tools/Add sender to address boo_k"),
633 NULL, add_address_cb, 0, NULL},
634 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
635 {N_("/_Tools/_Harvest addresses/from _Folder..."),
636 NULL, addr_harvest_cb, 0, NULL},
637 {N_("/_Tools/_Harvest addresses/from _Messages..."),
638 NULL, addr_harvest_msg_cb, 0, NULL},
639 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
641 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
642 {N_("/_Tools/_Create filter rule/_Automatically"),
643 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
644 {N_("/_Tools/_Create filter rule/by _From"),
645 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
646 {N_("/_Tools/_Create filter rule/by _To"),
647 NULL, create_filter_cb, FILTER_BY_TO, NULL},
648 {N_("/_Tools/_Create filter rule/by _Subject"),
649 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
650 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
651 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
652 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Tools/Delete du_plicated messages"),
654 NULL, delete_duplicated_cb, 0, NULL},
655 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
656 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
657 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
658 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
660 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
661 {N_("/_Configuration/_Common preferences..."),
662 NULL, prefs_common_open_cb, 0, NULL},
663 {N_("/_Configuration/C_ustom toolbar..."),
664 NULL, prefs_toolbar_cb, 0, NULL},
665 {N_("/_Configuration/_Filter setting..."),
666 NULL, prefs_filter_open_cb, 0, NULL},
667 {N_("/_Configuration/_Scoring..."),
668 NULL, prefs_scoring_open_cb, 0, NULL},
669 {N_("/_Configuration/_Filtering..."),
670 NULL, prefs_filtering_open_cb, 0, NULL},
671 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
672 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
673 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Configuration/_Preferences for current account..."),
675 NULL, prefs_account_open_cb, 0, NULL},
676 {N_("/_Configuration/Create _new account..."),
677 NULL, new_account_cb, 0, NULL},
678 {N_("/_Configuration/_Edit accounts..."),
679 NULL, account_edit_open, 0, NULL},
680 {N_("/_Configuration/C_hange current account"),
681 NULL, NULL, 0, "<Branch>"},
683 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
684 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
685 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
686 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
687 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
688 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
689 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
690 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
691 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
692 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
693 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
694 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
695 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
696 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
697 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
700 MainWindow *main_window_create(SeparateType type)
706 GtkWidget *handlebox;
707 GtkWidget *vbox_body;
708 GtkWidget *hbox_stat;
709 GtkWidget *statusbar;
710 GtkWidget *progressbar;
711 GtkWidget *statuslabel;
712 GtkWidget *ac_button;
714 GtkWidget *online_status;
715 GtkWidget *offline_status;
716 GtkWidget *online_switch;
717 GtkWidget *offline_switch;
719 FolderView *folderview;
720 SummaryView *summaryview;
721 MessageView *messageview;
722 GdkColormap *colormap;
725 GtkItemFactory *ifactory;
729 guint n_menu_entries;
731 static GdkGeometry geometry;
733 debug_print("Creating main window...\n");
734 mainwin = g_new0(MainWindow, 1);
737 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
738 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
739 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
740 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
742 if (!geometry.min_height) {
743 geometry.min_width = 320;
744 geometry.min_height = 200;
746 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
749 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
750 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
751 MANAGE_WINDOW_SIGNALS_CONNECT(window);
752 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
753 GTK_SIGNAL_FUNC(key_pressed), mainwin);
755 gtk_widget_realize(window);
756 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
759 gtkut_widget_set_app_icon(window);
761 vbox = gtk_vbox_new(FALSE, 0);
762 gtk_widget_show(vbox);
763 gtk_container_add(GTK_CONTAINER(window), vbox);
766 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
767 menubar = menubar_create(window, mainwin_entries,
768 n_menu_entries, "<Main>", mainwin);
769 gtk_widget_show(menubar);
770 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
771 ifactory = gtk_item_factory_from_widget(menubar);
773 handlebox = gtk_handle_box_new();
774 gtk_widget_show(handlebox);
775 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
778 toolbar_create(mainwin, handlebox);
780 /* vbox that contains body */
781 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
782 gtk_widget_show(vbox_body);
783 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
784 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
786 hbox_stat = gtk_hbox_new(FALSE, 2);
787 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
789 statusbar = statusbar_create();
790 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
792 progressbar = gtk_progress_bar_new();
793 gtk_widget_set_usize(progressbar, 120, 1);
794 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
796 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
797 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
798 online_switch = gtk_button_new ();
799 offline_switch = gtk_button_new ();
800 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
801 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
802 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
803 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
804 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
805 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
806 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
807 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
809 statuslabel = gtk_label_new("");
810 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
812 ac_button = gtk_button_new();
813 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
814 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
815 gtk_widget_set_usize(ac_button, -1, 1);
816 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
817 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
818 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
820 ac_label = gtk_label_new("");
821 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
823 gtk_widget_show_all(hbox_stat);
825 gtk_widget_hide(offline_switch);
827 mainwin->folderview = folderview = folderview_create();
828 mainwin->summaryview = summaryview = summary_create();
829 mainwin->messageview = messageview = messageview_create();
830 mainwin->logwin = log_window_create();
832 folderview->mainwin = mainwin;
833 folderview->summaryview = summaryview;
835 summaryview->mainwin = mainwin;
836 summaryview->folderview = folderview;
837 summaryview->messageview = messageview;
838 summaryview->window = window;
840 messageview->mainwin = mainwin;
842 mainwin->window = window;
843 mainwin->vbox = vbox;
844 mainwin->menubar = menubar;
845 mainwin->menu_factory = ifactory;
846 mainwin->handlebox = handlebox;
847 mainwin->vbox_body = vbox_body;
848 mainwin->hbox_stat = hbox_stat;
849 mainwin->statusbar = statusbar;
850 mainwin->progressbar = progressbar;
851 mainwin->statuslabel = statuslabel;
852 mainwin->ac_button = ac_button;
853 mainwin->ac_label = ac_label;
855 mainwin->online_switch = online_switch;
856 mainwin->offline_switch = offline_switch;
858 /* set context IDs for status bar */
859 mainwin->mainwin_cid = gtk_statusbar_get_context_id
860 (GTK_STATUSBAR(statusbar), "Main Window");
861 mainwin->folderview_cid = gtk_statusbar_get_context_id
862 (GTK_STATUSBAR(statusbar), "Folder View");
863 mainwin->summaryview_cid = gtk_statusbar_get_context_id
864 (GTK_STATUSBAR(statusbar), "Summary View");
866 /* allocate colors for summary view and folder view */
867 summaryview->color_marked.red = summaryview->color_marked.green = 0;
868 summaryview->color_marked.blue = (guint16)65535;
870 summaryview->color_dim.red = summaryview->color_dim.green =
871 summaryview->color_dim.blue = COLOR_DIM;
873 folderview->color_new.red = (guint16)55000;
874 folderview->color_new.green = folderview->color_new.blue = 15000;
876 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
877 &folderview->color_op);
879 summaryview->color_important.red = 0;
880 summaryview->color_important.green = 0;
881 summaryview->color_important.blue = (guint16)65535;
883 color[0] = summaryview->color_marked;
884 color[1] = summaryview->color_dim;
885 color[2] = folderview->color_new;
886 color[3] = folderview->color_op;
888 colormap = gdk_window_get_colormap(window->window);
889 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
890 for (i = 0; i < 4; i++) {
891 if (success[i] == FALSE)
892 g_warning(_("MainWindow: color allocation %d failed\n"), i);
895 debug_print("done.\n");
897 messageview->visible = TRUE;
899 main_window_set_widgets(mainwin, type);
902 menuitem = gtk_item_factory_get_item
903 (ifactory, "/View/Code set/Auto detect");
904 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
906 switch (prefs_common.toolbar_style) {
908 menuitem = gtk_item_factory_get_item
909 (ifactory, "/View/Show or hide/Toolbar/None");
912 menuitem = gtk_item_factory_get_item
913 (ifactory, "/View/Show or hide/Toolbar/Icon");
916 menuitem = gtk_item_factory_get_item
917 (ifactory, "/View/Show or hide/Toolbar/Text");
920 menuitem = gtk_item_factory_get_item
921 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
923 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
925 gtk_widget_hide(mainwin->hbox_stat);
926 menuitem = gtk_item_factory_get_item
927 (ifactory, "/View/Show or hide/Status bar");
928 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
929 prefs_common.show_statusbar);
931 gtk_widget_hide(mainwin->summaryview->hbox_search);
932 menuitem = gtk_item_factory_get_item
933 (ifactory, "/View/Show or hide/Quick search");
934 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
935 prefs_common.show_searchbar);
937 /* set account selection menu */
938 ac_menu = gtk_item_factory_get_widget
939 (ifactory, "/Configuration/Change current account");
940 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
941 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
942 mainwin->ac_menu = ac_menu;
944 toolbar_set_sensitive(mainwin);
946 /* create actions menu */
947 update_mainwin_actions_menu(ifactory, mainwin);
949 /* show main window */
950 gtk_widget_set_uposition(mainwin->window,
951 prefs_common.mainwin_x,
952 prefs_common.mainwin_y);
953 gtk_widget_set_usize(window, prefs_common.mainwin_width,
954 prefs_common.mainwin_height);
955 gtk_widget_show(mainwin->window);
957 /* initialize views */
958 folderview_init(folderview);
959 summary_init(summaryview);
960 messageview_init(messageview);
961 log_window_init(mainwin->logwin);
963 mainwin->lock_count = 0;
964 mainwin->menu_lock_count = 0;
965 mainwin->cursor_count = 0;
968 watch_cursor = gdk_cursor_new(GDK_WATCH);
970 mainwin_list = g_list_append(mainwin_list, mainwin);
972 /* init work_offline */
973 if (prefs_common.work_offline)
974 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
979 void main_window_cursor_wait(MainWindow *mainwin)
982 if (mainwin->cursor_count == 0)
983 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
985 mainwin->cursor_count++;
990 void main_window_cursor_normal(MainWindow *mainwin)
992 if (mainwin->cursor_count)
993 mainwin->cursor_count--;
995 if (mainwin->cursor_count == 0)
996 gdk_window_set_cursor(mainwin->window->window, NULL);
1001 /* lock / unlock the user-interface */
1002 void main_window_lock(MainWindow *mainwin)
1004 if (mainwin->lock_count == 0)
1005 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1007 mainwin->lock_count++;
1009 main_window_set_menu_sensitive(mainwin);
1010 toolbar_set_sensitive(mainwin);
1013 void main_window_unlock(MainWindow *mainwin)
1015 if (mainwin->lock_count)
1016 mainwin->lock_count--;
1018 main_window_set_menu_sensitive(mainwin);
1019 toolbar_set_sensitive(mainwin);
1021 if (mainwin->lock_count == 0)
1022 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1025 static void main_window_menu_callback_block(MainWindow *mainwin)
1027 mainwin->menu_lock_count++;
1030 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1032 if (mainwin->menu_lock_count)
1033 mainwin->menu_lock_count--;
1036 void main_window_reflect_prefs_all(void)
1038 main_window_reflect_prefs_all_real(FALSE);
1041 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1044 MainWindow *mainwin;
1046 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1047 mainwin = (MainWindow *)cur->data;
1049 main_window_show_cur_account(mainwin);
1050 main_window_set_menu_sensitive(mainwin);
1051 toolbar_set_sensitive(mainwin);
1054 if (pixmap_theme_changed) {
1056 set_toolbar_style(mainwin);
1057 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1058 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1061 if (prefs_common.immediate_exec)
1062 gtk_widget_hide(mainwin->toolbar->exec_btn);
1064 gtk_widget_show(mainwin->toolbar->exec_btn);
1066 summary_redisplay_msg(mainwin->summaryview);
1067 headerview_set_visibility(mainwin->messageview->headerview,
1068 prefs_common.display_header_pane);
1072 void main_window_set_summary_column(void)
1075 MainWindow *mainwin;
1077 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1078 mainwin = (MainWindow *)cur->data;
1079 summary_set_column_order(mainwin->summaryview);
1083 void main_window_set_account_menu(GList *account_list)
1085 GList *cur, *cur_ac, *cur_item;
1086 GtkWidget *menuitem;
1087 MainWindow *mainwin;
1088 PrefsAccount *ac_prefs;
1090 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1091 mainwin = (MainWindow *)cur->data;
1093 /* destroy all previous menu item */
1094 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1095 while (cur_item != NULL) {
1096 GList *next = cur_item->next;
1097 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1101 for (cur_ac = account_list; cur_ac != NULL;
1102 cur_ac = cur_ac->next) {
1103 ac_prefs = (PrefsAccount *)cur_ac->data;
1105 menuitem = gtk_menu_item_new_with_label
1106 (ac_prefs->account_name
1107 ? ac_prefs->account_name : _("Untitled"));
1108 gtk_widget_show(menuitem);
1109 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1110 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1111 GTK_SIGNAL_FUNC(account_menu_cb),
1117 static void main_window_show_cur_account(MainWindow *mainwin)
1122 ac_name = g_strdup(cur_account
1123 ? (cur_account->account_name
1124 ? cur_account->account_name : _("Untitled"))
1128 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1130 buf = g_strdup(PROG_VERSION);
1131 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1134 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1135 gtk_widget_queue_resize(mainwin->ac_button);
1140 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1142 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1143 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1144 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1146 debug_print("Changing window separation type from %d to %d\n",
1147 mainwin->type, type);
1149 if (mainwin->type == type) return;
1151 /* remove widgets from those containers */
1152 gtk_widget_ref(folder_wid);
1153 gtk_widget_ref(summary_wid);
1154 gtk_widget_ref(message_wid);
1155 gtkut_container_remove
1156 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1157 gtkut_container_remove
1158 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1159 gtkut_container_remove
1160 (GTK_CONTAINER(message_wid->parent), message_wid);
1162 /* clean containers */
1163 switch (mainwin->type) {
1165 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1167 case SEPARATE_FOLDER:
1168 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1169 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1171 case SEPARATE_MESSAGE:
1172 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1173 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1176 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1177 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1181 gtk_widget_hide(mainwin->window);
1182 main_window_set_widgets(mainwin, type);
1183 gtk_widget_show(mainwin->window);
1185 gtk_widget_unref(folder_wid);
1186 gtk_widget_unref(summary_wid);
1187 gtk_widget_unref(message_wid);
1190 void main_window_toggle_message_view(MainWindow *mainwin)
1192 SummaryView *summaryview = mainwin->summaryview;
1193 union CompositeWin *cwin = &mainwin->win;
1194 GtkWidget *vpaned = NULL;
1195 GtkWidget *container = NULL;
1196 GtkWidget *msgwin = NULL;
1198 switch (mainwin->type) {
1200 vpaned = cwin->sep_none.vpaned;
1201 container = cwin->sep_none.hpaned;
1203 case SEPARATE_FOLDER:
1204 vpaned = cwin->sep_folder.vpaned;
1205 container = mainwin->vbox_body;
1207 case SEPARATE_MESSAGE:
1208 msgwin = mainwin->win.sep_message.messagewin;
1211 msgwin = mainwin->win.sep_both.messagewin;
1216 if (GTK_WIDGET_VISIBLE(msgwin)) {
1217 gtk_widget_hide(msgwin);
1218 mainwin->messageview->visible = FALSE;
1219 summaryview->displayed = NULL;
1221 gtk_widget_show(msgwin);
1222 mainwin->messageview->visible = TRUE;
1224 } else if (vpaned->parent != NULL) {
1225 mainwin->messageview->visible = FALSE;
1226 summaryview->displayed = NULL;
1227 gtk_widget_ref(vpaned);
1228 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1229 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1230 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1231 GTK_ARROW_UP, GTK_SHADOW_OUT);
1233 mainwin->messageview->visible = TRUE;
1234 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1235 gtk_container_add(GTK_CONTAINER(container), vpaned);
1236 gtk_widget_unref(vpaned);
1237 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1238 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1241 main_window_set_menu_sensitive(mainwin);
1243 gtk_widget_grab_focus(summaryview->ctree);
1246 void main_window_get_size(MainWindow *mainwin)
1248 GtkAllocation *allocation;
1250 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1252 prefs_common.summaryview_width = allocation->width;
1254 if ((mainwin->type == SEPARATE_NONE ||
1255 mainwin->type == SEPARATE_FOLDER) &&
1256 messageview_is_visible(mainwin->messageview))
1257 prefs_common.summaryview_height = allocation->height;
1259 prefs_common.mainview_width = allocation->width;
1261 allocation = &mainwin->window->allocation;
1263 prefs_common.mainview_height = allocation->height;
1264 prefs_common.mainwin_width = allocation->width;
1265 prefs_common.mainwin_height = allocation->height;
1267 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1269 prefs_common.folderview_width = allocation->width;
1270 prefs_common.folderview_height = allocation->height;
1273 void main_window_get_position(MainWindow *mainwin)
1277 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1279 prefs_common.mainview_x = x;
1280 prefs_common.mainview_y = y;
1281 prefs_common.mainwin_x = x;
1282 prefs_common.mainwin_y = y;
1284 debug_print("window position: x = %d, y = %d\n", x, y);
1287 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1293 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1294 folder = FOLDER(list->data);
1295 if (folder && folder->trash && folder->trash->total > 0)
1299 if (!has_trash) return;
1302 if (alertpanel(_("Empty trash"),
1303 _("Empty all messages in trash?"),
1304 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1306 manage_window_focus_in(mainwin->window, NULL, NULL);
1309 procmsg_empty_trash();
1311 for (list = folder_get_list(); list != NULL; list = list->next) {
1312 folder = list->data;
1313 if (folder && folder->trash) {
1314 folderview_update_item(folder->trash, TRUE);
1318 if (mainwin->summaryview->folder_item &&
1319 mainwin->summaryview->folder_item->stype == F_TRASH)
1320 gtk_widget_grab_focus(mainwin->folderview->ctree);
1323 void main_window_add_mailbox(MainWindow *mainwin)
1328 path = input_dialog(_("Add mailbox"),
1329 _("Input the location of mailbox.\n"
1330 "If the existing mailbox is specified, it will be\n"
1331 "scanned automatically."),
1334 if (folder_find_from_path(path)) {
1335 alertpanel_error(_("The mailbox `%s' already exists."), path);
1339 if (!strcmp(path, "Mail"))
1340 folder = folder_new(F_MH, _("Mailbox"), path);
1342 folder = folder_new(F_MH, g_basename(path), path);
1345 if (folder->create_tree(folder) < 0) {
1346 alertpanel_error(_("Creation of the mailbox failed.\n"
1347 "Maybe some files already exist, or you don't have the permission to write there."));
1348 folder_destroy(folder);
1353 folder_set_ui_func(folder, scan_tree_func, mainwin);
1354 folder_scan_tree(folder);
1355 folder_set_ui_func(folder, NULL, NULL);
1357 folderview_set(mainwin->folderview);
1360 void main_window_add_mbox(MainWindow *mainwin)
1366 path = input_dialog(_("Add mbox mailbox"),
1367 _("Input the location of mailbox."),
1372 if (folder_find_from_path(path)) {
1373 alertpanel_error(_("The mailbox `%s' already exists."), path);
1379 if (!strcmp(path, "Mail"))
1380 folder = folder_new(F_MBOX, _("Mailbox"), path);
1384 folder = folder_new(F_MBOX, g_basename(path), path);
1387 if (folder->create_tree(folder) < 0) {
1388 alertpanel_error(_("Creation of the mailbox failed."));
1389 folder_destroy(folder);
1395 item = folder_item_new(folder, folder->name, NULL);
1396 item->folder = folder;
1397 folder->node = g_node_new(item);
1399 folder->create_folder(folder, item, "inbox");
1400 folder->create_folder(folder, item, "outbox");
1401 folder->create_folder(folder, item, "queue");
1402 folder->create_folder(folder, item, "draft");
1403 folder->create_folder(folder, item, "trash");
1405 folderview_set(mainwin->folderview);
1408 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1410 SensitiveCond state = 0;
1411 SummarySelection selection;
1412 FolderItem *item = mainwin->summaryview->folder_item;
1413 GList *account_list = account_get_list();
1415 selection = summary_get_selection_type(mainwin->summaryview);
1417 if (mainwin->lock_count == 0)
1418 state |= M_UNLOCKED;
1419 if (selection != SUMMARY_NONE)
1420 state |= M_MSG_EXIST;
1421 if (item && item->path && item->parent && !item->no_select) {
1423 /* if (item->folder->type != F_NEWS) */
1424 state |= M_ALLOW_DELETE;
1426 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1427 || selection != SUMMARY_NONE)
1428 state |= M_HIDE_READ_MSG;
1430 if (mainwin->summaryview->threaded)
1431 state |= M_THREADED;
1433 state |= M_UNTHREADED;
1434 if (selection == SUMMARY_SELECTED_SINGLE ||
1435 selection == SUMMARY_SELECTED_MULTIPLE)
1436 state |= M_TARGET_EXIST;
1437 if (selection == SUMMARY_SELECTED_SINGLE)
1438 state |= M_SINGLE_TARGET_EXIST;
1439 if (mainwin->summaryview->folder_item &&
1440 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1442 if (selection == SUMMARY_SELECTED_SINGLE &&
1444 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1445 item->stype == F_QUEUE)))
1446 state |= M_ALLOW_REEDIT;
1448 state |= M_HAVE_ACCOUNT;
1450 for ( ; account_list != NULL; account_list = account_list->next) {
1451 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1452 state |= M_HAVE_NEWS_ACCOUNT;
1457 if (inc_is_active())
1458 state |= M_INC_ACTIVE;
1465 void main_window_set_menu_sensitive(MainWindow *mainwin)
1467 GtkItemFactory *ifactory = mainwin->menu_factory;
1468 SensitiveCond state;
1470 GtkWidget *menuitem;
1471 SummaryView *summaryview;
1475 static const struct {
1479 {"/File/Add mailbox..." , M_UNLOCKED},
1480 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1481 {"/File/Check for new messages in all folders", M_UNLOCKED},
1482 {"/File/Folder" , M_UNLOCKED},
1483 {"/File/Import mbox file..." , M_UNLOCKED},
1484 {"/File/Export to mbox file..." , M_UNLOCKED},
1485 {"/File/Empty trash" , M_UNLOCKED},
1486 {"/File/Work offline" , M_UNLOCKED},
1488 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1489 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1490 /* {"/File/Close" , M_UNLOCKED}, */
1491 {"/File/Exit" , M_UNLOCKED},
1493 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1494 {"/View/Sort" , M_EXEC},
1495 {"/View/Thread view" , M_EXEC},
1496 {"/View/Expand all threads" , M_MSG_EXIST},
1497 {"/View/Collapse all threads" , M_MSG_EXIST},
1498 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1499 {"/View/Go to/Prev message" , M_MSG_EXIST},
1500 {"/View/Go to/Next message" , M_MSG_EXIST},
1501 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1502 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1503 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1504 {"/View/Go to/Next new message" , M_MSG_EXIST},
1505 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1506 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1507 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1508 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1509 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1510 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1511 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1513 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1514 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1515 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1516 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1517 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1518 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1519 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1520 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1521 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1522 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1523 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1524 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1525 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1526 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1527 {"/Message/Mark" , M_TARGET_EXIST},
1529 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1530 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1531 {"/Tools/Harvest addresses" , M_UNLOCKED},
1532 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1533 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1534 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1535 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1536 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1538 {"/Configuration", M_UNLOCKED},
1543 state = main_window_get_current_state(mainwin);
1545 for (i = 0; entry[i].entry != NULL; i++) {
1546 sensitive = ((entry[i].cond & state) == entry[i].cond);
1547 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1550 main_window_menu_callback_block(mainwin);
1552 #define SET_CHECK_MENU_ACTIVE(path, active) \
1554 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1555 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1558 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1559 messageview_is_visible(mainwin->messageview));
1561 summaryview = mainwin->summaryview;
1562 menu_path = "/View/Sort/Don't sort";
1564 switch (summaryview->sort_key) {
1565 case SORT_BY_NUMBER:
1566 menu_path = "/View/Sort/by number"; break;
1568 menu_path = "/View/Sort/by size"; break;
1570 menu_path = "/View/Sort/by date"; break;
1572 menu_path = "/View/Sort/by from"; break;
1573 case SORT_BY_SUBJECT:
1574 menu_path = "/View/Sort/by subject"; break;
1576 menu_path = "/View/Sort/by color label"; break;
1578 menu_path = "/View/Sort/by mark"; break;
1579 case SORT_BY_UNREAD:
1580 menu_path = "/View/Sort/by unread"; break;
1582 menu_path = "/View/Sort/by attachment"; break;
1584 menu_path = "/View/Sort/by score"; break;
1585 case SORT_BY_LOCKED:
1586 menu_path = "/View/Sort/by locked"; break;
1589 menu_path = "/View/Sort/Don't sort"; break;
1591 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1593 if (summaryview->sort_type == SORT_ASCENDING) {
1594 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1596 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1599 if (summaryview->sort_key != SORT_BY_NONE) {
1600 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1601 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1603 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1604 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1607 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1608 mainwin->messageview->textview->show_all_headers);
1609 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1611 #undef SET_CHECK_MENU_ACTIVE
1613 main_window_menu_callback_unblock(mainwin);
1616 void main_window_popup(MainWindow *mainwin)
1622 gdk_window_get_origin(mainwin->window->window, &x, &y);
1623 sx = gdk_screen_width();
1624 sy = gdk_screen_height();
1625 x %= sx; if (x < 0) x = 0;
1626 y %= sy; if (y < 0) y = 0;
1627 gdk_window_move(mainwin->window->window, x, y);
1628 gdk_window_raise(mainwin->window->window);
1629 gdk_window_show(mainwin->window->window);
1631 debug_print("window position: x = %d, y = %d\n", x, y);
1633 switch (mainwin->type) {
1634 case SEPARATE_FOLDER:
1635 widget = mainwin->win.sep_folder.folderwin;
1636 gdk_window_get_origin(widget->window, &x, &y);
1637 x %= sx; if (x < 0) x = 0;
1638 y %= sy; if (y < 0) y = 0;
1639 gdk_window_move(widget->window, x, y);
1640 gdk_window_raise(widget->window);
1642 case SEPARATE_MESSAGE:
1643 widget = mainwin->win.sep_message.messagewin;
1644 gdk_window_get_origin(widget->window, &x, &y);
1645 x %= sx; if (x < 0) x = 0;
1646 y %= sy; if (y < 0) y = 0;
1647 gdk_window_move(widget->window, x, y);
1648 gdk_window_raise(widget->window);
1651 widget = mainwin->win.sep_both.folderwin;
1652 gdk_window_get_origin(widget->window, &x, &y);
1653 x %= sx; if (x < 0) x = 0;
1654 y %= sy; if (y < 0) y = 0;
1655 gdk_window_move(widget->window, x, y);
1656 gdk_window_raise(widget->window);
1657 widget = mainwin->win.sep_both.messagewin;
1658 gdk_window_get_origin(widget->window, &x, &y);
1659 x %= sx; if (x < 0) x = 0;
1660 y %= sy; if (y < 0) y = 0;
1661 gdk_window_move(widget->window, x, y);
1662 gdk_window_raise(widget->window);
1669 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1671 GtkWidget *folderwin = NULL;
1672 GtkWidget *messagewin = NULL;
1675 GtkWidget *vbox_body = mainwin->vbox_body;
1676 GtkItemFactory *ifactory = mainwin->menu_factory;
1677 GtkWidget *menuitem;
1679 debug_print("Setting widgets...");
1681 /* create separated window(s) if needed */
1682 if (type & SEPARATE_FOLDER) {
1683 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1684 gtk_window_set_title(GTK_WINDOW(folderwin),
1685 _("Sylpheed - Folder View"));
1686 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1687 "folder_view", "Sylpheed");
1688 gtk_window_set_policy(GTK_WINDOW(folderwin),
1690 gtk_widget_set_usize(folderwin, -1,
1691 prefs_common.mainview_height);
1692 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1694 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1695 GTK_SIGNAL_FUNC(folder_window_close_cb),
1698 if (type & SEPARATE_MESSAGE) {
1699 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1700 gtk_window_set_title(GTK_WINDOW(messagewin),
1701 _("Sylpheed - Message View"));
1702 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1703 "message_view", "Sylpheed");
1704 gtk_window_set_policy(GTK_WINDOW(messagewin),
1706 gtk_widget_set_usize
1707 (messagewin, prefs_common.mainview_width,
1708 prefs_common.mainview_height
1709 - prefs_common.summaryview_height
1710 + DEFAULT_HEADERVIEW_HEIGHT);
1711 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1713 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1714 GTK_SIGNAL_FUNC(message_window_close_cb),
1720 hpaned = gtk_hpaned_new();
1721 gtk_widget_show(hpaned);
1722 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1723 gtk_paned_add1(GTK_PANED(hpaned),
1724 GTK_WIDGET_PTR(mainwin->folderview));
1726 vpaned = gtk_vpaned_new();
1727 if (messageview_is_visible(mainwin->messageview)) {
1728 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1729 gtk_paned_add1(GTK_PANED(vpaned),
1730 GTK_WIDGET_PTR(mainwin->summaryview));
1732 gtk_paned_add2(GTK_PANED(hpaned),
1733 GTK_WIDGET_PTR(mainwin->summaryview));
1734 gtk_widget_ref(vpaned);
1736 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1737 prefs_common.summaryview_width,
1738 prefs_common.summaryview_height);
1739 gtk_paned_add2(GTK_PANED(vpaned),
1740 GTK_WIDGET_PTR(mainwin->messageview));
1741 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1742 prefs_common.mainview_width, -1);
1743 gtk_widget_set_usize(mainwin->window,
1744 prefs_common.folderview_width +
1745 prefs_common.mainview_width,
1746 prefs_common.mainwin_height);
1747 gtk_widget_show_all(vpaned);
1749 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1750 * lose track of its visibility state */
1751 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1752 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1754 mainwin->win.sep_none.hpaned = hpaned;
1755 mainwin->win.sep_none.vpaned = vpaned;
1757 case SEPARATE_FOLDER:
1758 vpaned = gtk_vpaned_new();
1759 if (messageview_is_visible(mainwin->messageview)) {
1760 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1762 gtk_paned_add1(GTK_PANED(vpaned),
1763 GTK_WIDGET_PTR(mainwin->summaryview));
1765 gtk_box_pack_start(GTK_BOX(vbox_body),
1766 GTK_WIDGET_PTR(mainwin->summaryview),
1768 gtk_widget_ref(vpaned);
1770 gtk_paned_add2(GTK_PANED(vpaned),
1771 GTK_WIDGET_PTR(mainwin->messageview));
1772 gtk_widget_show_all(vpaned);
1773 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1774 prefs_common.summaryview_width,
1775 prefs_common.summaryview_height);
1776 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1777 prefs_common.mainview_width, -1);
1778 gtk_widget_set_usize(mainwin->window,
1779 prefs_common.mainview_width,
1780 prefs_common.mainview_height);
1782 gtk_container_add(GTK_CONTAINER(folderwin),
1783 GTK_WIDGET_PTR(mainwin->folderview));
1785 mainwin->win.sep_folder.folderwin = folderwin;
1786 mainwin->win.sep_folder.vpaned = vpaned;
1788 gtk_widget_show_all(folderwin);
1790 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1791 * lose track of its visibility state */
1792 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1793 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1795 case SEPARATE_MESSAGE:
1796 hpaned = gtk_hpaned_new();
1797 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1799 gtk_paned_add1(GTK_PANED(hpaned),
1800 GTK_WIDGET_PTR(mainwin->folderview));
1801 gtk_paned_add2(GTK_PANED(hpaned),
1802 GTK_WIDGET_PTR(mainwin->summaryview));
1803 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1804 prefs_common.summaryview_width,
1805 prefs_common.summaryview_height);
1806 gtk_widget_set_usize(mainwin->window,
1807 prefs_common.folderview_width +
1808 prefs_common.mainview_width,
1809 prefs_common.mainwin_height);
1810 gtk_widget_show_all(hpaned);
1811 gtk_container_add(GTK_CONTAINER(messagewin),
1812 GTK_WIDGET_PTR(mainwin->messageview));
1814 mainwin->win.sep_message.messagewin = messagewin;
1815 mainwin->win.sep_message.hpaned = hpaned;
1817 gtk_widget_show_all(messagewin);
1819 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1820 * lose track of its visibility state */
1821 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1822 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1825 gtk_box_pack_start(GTK_BOX(vbox_body),
1826 GTK_WIDGET_PTR(mainwin->summaryview),
1828 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1829 prefs_common.summaryview_width,
1830 prefs_common.summaryview_height);
1831 gtk_widget_set_usize(mainwin->window,
1832 prefs_common.mainview_width,
1833 prefs_common.mainwin_height);
1834 gtk_container_add(GTK_CONTAINER(folderwin),
1835 GTK_WIDGET_PTR(mainwin->folderview));
1836 gtk_container_add(GTK_CONTAINER(messagewin),
1837 GTK_WIDGET_PTR(mainwin->messageview));
1839 mainwin->win.sep_both.folderwin = folderwin;
1840 mainwin->win.sep_both.messagewin = messagewin;
1842 gtk_widget_show_all(folderwin);
1843 gtk_widget_show_all(messagewin);
1845 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1846 * lose track of its visibility state */
1847 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1848 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1852 mainwin->type = type;
1854 mainwin->messageview->visible = TRUE;
1856 /* toggle menu state */
1857 menuitem = gtk_item_factory_get_item
1858 (ifactory, "/View/Show or hide/Folder tree");
1859 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1860 menuitem = gtk_item_factory_get_item
1861 (ifactory, "/View/Show or hide/Message view");
1862 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1864 menuitem = gtk_item_factory_get_item
1865 (ifactory, "/View/Separate folder tree");
1866 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1867 ((type & SEPARATE_FOLDER) != 0));
1868 menuitem = gtk_item_factory_get_item
1869 (ifactory, "/View/Separate message view");
1870 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1871 ((type & SEPARATE_MESSAGE) != 0));
1873 debug_print("done.\n");
1877 static void toolbar_account_button_pressed(GtkWidget *widget,
1878 GdkEventButton *event,
1881 MainWindow *mainwin = (MainWindow *)data;
1884 if (event->button != 3) return;
1886 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1887 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1890 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1891 menu_button_position, widget,
1892 event->button, event->time);
1896 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1899 MainWindow *mainwin = (MainWindow *)data;
1903 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1904 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1907 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1908 menu_button_position, widget,
1909 event->button, event->time);
1912 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
1914 MainWindow *mainwin = (MainWindow *)data;
1917 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
1918 if (!button) return;
1919 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1920 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
1921 manage_window_focus_in(mainwin->window, NULL, NULL);
1924 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1927 MainWindow *mainwin = (MainWindow *)data;
1929 if (mainwin->lock_count == 0)
1930 app_exit_cb(data, 0, widget);
1935 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1938 MainWindow *mainwin = (MainWindow *)data;
1939 GtkWidget *menuitem;
1941 menuitem = gtk_item_factory_get_item
1942 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
1943 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1948 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1951 MainWindow *mainwin = (MainWindow *)data;
1952 GtkWidget *menuitem;
1954 menuitem = gtk_item_factory_get_item
1955 (mainwin->menu_factory, "/View/Show or hide/Message view");
1956 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1961 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1964 main_window_add_mailbox(mainwin);
1967 static void add_mbox_cb(MainWindow *mainwin, guint action,
1970 main_window_add_mbox(mainwin);
1973 static void update_folderview_cb(MainWindow *mainwin, guint action,
1976 summary_show(mainwin->summaryview, NULL);
1977 folderview_check_new_all();
1980 static void new_folder_cb(MainWindow *mainwin, guint action,
1983 folderview_new_folder(mainwin->folderview);
1986 static void rename_folder_cb(MainWindow *mainwin, guint action,
1989 folderview_rename_folder(mainwin->folderview);
1992 static void delete_folder_cb(MainWindow *mainwin, guint action,
1995 folderview_delete_folder(mainwin->folderview);
1998 static void import_mbox_cb(MainWindow *mainwin, guint action,
2001 import_mbox(mainwin->summaryview->folder_item);
2004 static void export_mbox_cb(MainWindow *mainwin, guint action,
2007 export_mbox(mainwin->summaryview->folder_item);
2010 static void empty_trash_cb(MainWindow *mainwin, guint action,
2013 main_window_empty_trash(mainwin, TRUE);
2016 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2018 summary_save_as(mainwin->summaryview);
2021 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2023 summary_print(mainwin->summaryview);
2026 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2028 if (prefs_common.confirm_on_exit) {
2029 if (alertpanel(_("Exit"), _("Exit this program?"),
2030 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2032 manage_window_focus_in(mainwin->window, NULL, NULL);
2035 app_will_exit(widget, mainwin);
2038 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2041 summary_search(mainwin->summaryview);
2043 message_search(mainwin->messageview);
2046 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2051 active = GTK_CHECK_MENU_ITEM(widget)->active;
2053 switch (mainwin->type) {
2055 case SEPARATE_MESSAGE:
2058 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2060 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2063 case SEPARATE_FOLDER:
2064 debug_print("separate folder\n");
2066 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2068 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2072 gtk_widget_show(mainwin->win.sep_both.folderwin);
2074 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2079 static void toggle_message_cb(MainWindow *mainwin, guint action,
2084 active = GTK_CHECK_MENU_ITEM(widget)->active;
2086 if (active != messageview_is_visible(mainwin->messageview))
2087 summary_toggle_view(mainwin->summaryview);
2090 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2093 switch ((ToolbarStyle)action) {
2095 gtk_widget_hide(mainwin->handlebox);
2097 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2101 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2105 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2110 if (action != TOOLBAR_NONE) {
2111 gtk_widget_show(mainwin->handlebox);
2112 gtk_widget_queue_resize(mainwin->handlebox);
2115 mainwin->toolbar_style = (ToolbarStyle)action;
2116 prefs_common.toolbar_style = (ToolbarStyle)action;
2119 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2122 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2123 gtk_widget_show(mainwin->hbox_stat);
2124 prefs_common.show_statusbar = TRUE;
2126 gtk_widget_hide(mainwin->hbox_stat);
2127 prefs_common.show_statusbar = FALSE;
2131 static void toggle_searchbar_cb(MainWindow *mainwin, guint action,
2134 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2135 gtk_widget_show(mainwin->summaryview->hbox_search);
2136 prefs_common.show_searchbar = TRUE;
2138 gtk_widget_hide(mainwin->summaryview->hbox_search);
2139 prefs_common.show_searchbar = FALSE;
2143 static void separate_widget_cb(MainWindow *mainwin, guint action,
2148 if (GTK_CHECK_MENU_ITEM(widget)->active)
2149 type = mainwin->type | action;
2151 type = mainwin->type & ~action;
2153 main_window_separation_change(mainwin, type);
2155 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2156 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2159 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2161 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2162 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2164 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2168 static void online_switch_clicked (GtkButton *btn, gpointer data)
2170 MainWindow *mainwin;
2171 GtkItemFactory *ifactory;
2172 GtkCheckMenuItem *menuitem;
2174 mainwin = (MainWindow *) data;
2176 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2177 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2179 g_return_if_fail(mainwin != NULL);
2180 g_return_if_fail(menuitem != NULL);
2182 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2184 gtk_widget_hide (mainwin->online_switch);
2185 gtk_widget_show (mainwin->offline_switch);
2186 menuitem->active = TRUE;
2187 prefs_common.work_offline = TRUE;
2188 inc_autocheck_timer_remove();
2191 gtk_widget_hide (mainwin->offline_switch);
2192 gtk_widget_show (mainwin->online_switch);
2193 menuitem->active = FALSE;
2194 prefs_common.work_offline = FALSE;
2195 inc_autocheck_timer_set();
2199 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2202 addressbook_open(NULL);
2205 static void log_window_show_cb(MainWindow *mainwin, guint action,
2208 log_window_show(mainwin->logwin);
2211 static void sel_download_cb(MainWindow *mainwin, guint action,
2214 selective_download(mainwin);
2217 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
2224 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2226 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2229 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2232 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2235 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2240 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2244 if (prefs_common.work_offline)
2245 if (alertpanel(_("Offline warning"),
2246 _("You're working offline. Override?"),
2247 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2250 for (list = folder_get_list(); list != NULL; list = list->next) {
2251 Folder *folder = list->data;
2253 if (folder->queue) {
2254 if (procmsg_send_queue
2255 (folder->queue, prefs_common.savemsg) < 0)
2256 alertpanel_error(_("Some errors occurred while sending queued messages."));
2257 statusbar_pop_all();
2258 folder_item_scan(folder->queue);
2259 folderview_update_item(folder->queue, TRUE);
2264 void compose_mail_cb(MainWindow *mainwin, guint action,
2271 if (mainwin->summaryview->folder_item) {
2272 ac = mainwin->summaryview->folder_item->folder->account;
2273 if (ac && ac->protocol != A_NNTP) {
2274 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2279 if(cur_account && (cur_account->protocol != A_NNTP)) {
2280 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2284 list = account_get_list();
2285 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2286 ac = (PrefsAccount *) cur->data;
2287 if (ac->protocol != A_NNTP) {
2288 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2294 void compose_news_cb(MainWindow *mainwin, guint action,
2297 PrefsAccount * ac = NULL;
2301 if (mainwin->summaryview->folder_item) {
2302 ac = mainwin->summaryview->folder_item->folder->account;
2303 if (ac && ac->protocol == A_NNTP) {
2305 mainwin->summaryview->folder_item->path,
2311 list = account_get_list();
2312 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2313 ac = (PrefsAccount *) cur->data;
2314 if (ac->protocol == A_NNTP) {
2315 compose_new(ac, NULL, NULL);
2321 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2323 summary_reply(mainwin->summaryview, (ComposeMode)action);
2326 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2328 summary_move_to(mainwin->summaryview);
2331 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2333 summary_copy_to(mainwin->summaryview);
2336 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2338 summary_delete(mainwin->summaryview);
2341 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2343 summary_open_msg(mainwin->summaryview);
2346 static void view_source_cb(MainWindow *mainwin, guint action,
2349 summary_view_source(mainwin->summaryview);
2352 static void show_all_header_cb(MainWindow *mainwin, guint action,
2355 if (mainwin->menu_lock_count) return;
2356 summary_display_msg_selected(mainwin->summaryview,
2357 GTK_CHECK_MENU_ITEM(widget)->active);
2360 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2362 summary_reedit(mainwin->summaryview);
2365 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2367 summary_mark(mainwin->summaryview);
2370 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2372 summary_unmark(mainwin->summaryview);
2375 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2378 summary_mark_as_unread(mainwin->summaryview);
2381 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2384 summary_mark_as_read(mainwin->summaryview);
2387 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2390 summary_mark_all_read(mainwin->summaryview);
2393 static void add_address_cb(MainWindow *mainwin, guint action,
2396 summary_add_address(mainwin->summaryview);
2399 static void set_charset_cb(MainWindow *mainwin, guint action,
2404 str = conv_get_charset_str((CharSet)action);
2405 g_free(prefs_common.force_charset);
2406 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2408 summary_redisplay_msg(mainwin->summaryview);
2410 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2413 static void hide_read_messages (MainWindow *mainwin, guint action,
2416 if (!mainwin->summaryview->folder_item
2417 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2419 summary_toggle_show_read_messages(mainwin->summaryview);
2422 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2424 if (mainwin->menu_lock_count) return;
2425 if (!mainwin->summaryview->folder_item) return;
2427 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2428 summary_thread_build(mainwin->summaryview);
2429 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2431 summary_unthread(mainwin->summaryview);
2432 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2436 static void expand_threads_cb(MainWindow *mainwin, guint action,
2439 summary_expand_threads(mainwin->summaryview);
2442 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2445 summary_collapse_threads(mainwin->summaryview);
2448 static void set_display_item_cb(MainWindow *mainwin, guint action,
2451 prefs_summary_column_open();
2454 static void sort_summary_cb(MainWindow *mainwin, guint action,
2457 FolderItem *item = mainwin->summaryview->folder_item;
2458 GtkWidget *menuitem;
2460 if (mainwin->menu_lock_count) return;
2462 menuitem = gtk_item_factory_get_item
2463 (mainwin->menu_factory, "/View/Sort/Ascending");
2464 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2465 GTK_CHECK_MENU_ITEM(menuitem)->active
2466 ? SORT_ASCENDING : SORT_DESCENDING);
2470 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2473 FolderItem *item = mainwin->summaryview->folder_item;
2475 if (mainwin->menu_lock_count) return;
2477 summary_sort(mainwin->summaryview,
2478 item->sort_key, (FolderSortType)action);
2481 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2484 summary_attract_by_subject(mainwin->summaryview);
2487 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2490 summary_delete_duplicated(mainwin->summaryview);
2493 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2495 summary_filter(mainwin->summaryview);
2498 static void execute_summary_cb(MainWindow *mainwin, guint action,
2501 summary_execute(mainwin->summaryview);
2504 static void update_summary_cb(MainWindow *mainwin, guint action,
2508 FolderView *folderview = mainwin->folderview;
2510 if (!mainwin->summaryview->folder_item) return;
2511 if (!folderview->opened) return;
2513 folder_update_op_count();
2515 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2516 folderview->opened);
2519 folder_item_scan(fitem);
2520 summary_show(mainwin->summaryview, fitem);
2523 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2525 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2528 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2530 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2533 static void prev_unread_cb(MainWindow *mainwin, guint action,
2536 summary_select_prev_unread(mainwin->summaryview);
2539 void next_unread_cb(MainWindow *mainwin, guint action,
2542 summary_select_next_unread(mainwin->summaryview);
2545 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2547 summary_select_prev_new(mainwin->summaryview);
2550 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2552 summary_select_next_new(mainwin->summaryview);
2555 static void prev_marked_cb(MainWindow *mainwin, guint action,
2558 summary_select_prev_marked(mainwin->summaryview);
2561 static void next_marked_cb(MainWindow *mainwin, guint action,
2564 summary_select_next_marked(mainwin->summaryview);
2567 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2570 summary_select_prev_labeled(mainwin->summaryview);
2573 static void next_labeled_cb(MainWindow *mainwin, guint action,
2576 summary_select_next_labeled(mainwin->summaryview);
2579 static void goto_folder_cb(MainWindow *mainwin, guint action,
2582 FolderItem *to_folder;
2584 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2587 folderview_select(mainwin->folderview, to_folder);
2590 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2592 messageview_copy_clipboard(mainwin->messageview);
2595 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2597 MessageView *msgview = mainwin->messageview;
2599 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2600 summary_select_all(mainwin->summaryview);
2601 else if (messageview_is_visible(msgview) &&
2602 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2603 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2604 messageview_select_all(mainwin->messageview);
2607 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2609 if (messageview_is_visible(mainwin->summaryview->messageview))
2610 summary_select_thread(mainwin->summaryview);
2613 static void create_filter_cb(MainWindow *mainwin, guint action,
2616 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2619 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2622 prefs_common_open();
2625 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2628 prefs_filter_open(NULL, NULL);
2631 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2634 prefs_scoring_open(NULL);
2637 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2640 prefs_filtering_open(NULL, NULL, NULL);
2643 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2646 prefs_template_open();
2649 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2652 prefs_actions_open(mainwin);
2655 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2659 new_account_cb(mainwin, 0, widget);
2661 gboolean prev_default = cur_account->is_default;
2663 prefs_account_open(cur_account);
2664 if (!prev_default && cur_account->is_default)
2665 account_set_as_default(cur_account);
2666 account_save_config_all();
2668 main_window_reflect_prefs_all();
2672 static void new_account_cb(MainWindow *mainwin, guint action,
2675 account_edit_open();
2676 if (!compose_get_compose_list()) account_add();
2679 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2681 cur_account = (PrefsAccount *)data;
2682 main_window_reflect_prefs_all();
2685 static void manual_open_cb(MainWindow *mainwin, guint action,
2688 manual_open((ManualLang)action);
2691 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2693 faq_open((ManualLang)action);
2696 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2698 MainWindow *mainwin = (MainWindow *)data;
2702 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2703 LOCAL_FOLDER(folder)->rootpath,
2707 str = g_strdup_printf(_("Scanning folder %s ..."),
2708 LOCAL_FOLDER(folder)->rootpath);
2710 STATUSBAR_PUSH(mainwin, str);
2711 STATUSBAR_POP(mainwin);
2715 #define BREAK_ON_MODIFIER_KEY() \
2716 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2718 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2720 MainWindow *mainwin = (MainWindow*) data;
2722 if (!mainwin || !event) return;
2724 switch (event->keyval) {
2725 case GDK_Q: /* Quit */
2726 BREAK_ON_MODIFIER_KEY();
2728 app_exit_cb(mainwin, 0, NULL);
2735 #undef BREAK_ON_MODIFIER_KEY
2737 static void set_toolbar_style(MainWindow *mainwin)
2739 switch (prefs_common.toolbar_style) {
2741 gtk_widget_hide(mainwin->handlebox);
2744 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2748 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2752 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2757 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
2758 gtk_widget_show(mainwin->handlebox);
2759 gtk_widget_queue_resize(mainwin->handlebox);
2764 * Harvest addresses for selected folder.
2766 static void addr_harvest_cb( MainWindow *mainwin,
2770 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2774 * Harvest addresses for selected messages in summary view.
2776 static void addr_harvest_msg_cb( MainWindow *mainwin,
2780 summary_harvest_address( mainwin->summaryview );