2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_actions.h"
64 #include "prefs_filtering.h"
65 #include "prefs_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "ssl_manager.h"
84 #include "sslcertwindow.h"
85 #include "prefs_gtk.h"
86 #include "pluginwindow.h"
88 #include "progressindicator.h"
90 #define AC_LABEL_WIDTH 240
92 /* list of all instantiated MainWindow */
93 static GList *mainwin_list = NULL;
95 static GdkCursor *watch_cursor;
97 static void main_window_menu_callback_block (MainWindow *mainwin);
98 static void main_window_menu_callback_unblock (MainWindow *mainwin);
100 static void main_window_show_cur_account (MainWindow *mainwin);
102 static void main_window_set_widgets (MainWindow *mainwin,
106 static void toolbar_account_button_pressed (GtkWidget *widget,
107 GdkEventButton *event,
110 static void ac_label_button_pressed (GtkWidget *widget,
111 GdkEventButton *event,
113 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
116 static gint main_window_close_cb (GtkWidget *widget,
119 static gint folder_window_close_cb (GtkWidget *widget,
122 static gint message_window_close_cb (GtkWidget *widget,
126 static void main_window_size_allocate_cb(GtkWidget *widget,
127 GtkAllocation *allocation,
130 static void new_folder_cb (MainWindow *mainwin,
133 static void add_mbox_cb (MainWindow *mainwin,
136 static void rename_folder_cb (MainWindow *mainwin,
139 static void delete_folder_cb (MainWindow *mainwin,
142 static void update_folderview_cb (MainWindow *mainwin,
145 static void add_mailbox_cb (MainWindow *mainwin,
148 static void import_mbox_cb (MainWindow *mainwin,
151 static void export_mbox_cb (MainWindow *mainwin,
154 static void empty_trash_cb (MainWindow *mainwin,
158 static void save_as_cb (MainWindow *mainwin,
161 static void print_cb (MainWindow *mainwin,
164 static void app_exit_cb (MainWindow *mainwin,
168 static void search_cb (MainWindow *mainwin,
172 static void toggle_folder_cb (MainWindow *mainwin,
175 static void toggle_message_cb (MainWindow *mainwin,
178 static void toggle_toolbar_cb (MainWindow *mainwin,
181 static void toggle_statusbar_cb (MainWindow *mainwin,
184 static void separate_widget_cb (MainWindow *mainwin,
188 static void addressbook_open_cb (MainWindow *mainwin,
191 static void log_window_show_cb (MainWindow *mainwin,
195 static void inc_cancel_cb (MainWindow *mainwin,
199 static void open_msg_cb (MainWindow *mainwin,
203 static void view_source_cb (MainWindow *mainwin,
207 static void show_all_header_cb (MainWindow *mainwin,
211 static void reedit_cb (MainWindow *mainwin,
215 static void move_to_cb (MainWindow *mainwin,
218 static void copy_to_cb (MainWindow *mainwin,
221 static void delete_cb (MainWindow *mainwin,
225 static void cancel_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,
299 static void next_unread_cb (MainWindow *mainwin,
302 static void prev_unread_cb (MainWindow *mainwin,
306 static void prev_new_cb (MainWindow *mainwin,
309 static void next_new_cb (MainWindow *mainwin,
312 static void prev_marked_cb (MainWindow *mainwin,
315 static void next_marked_cb (MainWindow *mainwin,
318 static void prev_labeled_cb (MainWindow *mainwin,
321 static void next_labeled_cb (MainWindow *mainwin,
325 static void goto_folder_cb (MainWindow *mainwin,
329 static void copy_cb (MainWindow *mainwin,
332 static void allsel_cb (MainWindow *mainwin,
335 static void select_thread_cb (MainWindow *mainwin,
339 static void create_filter_cb (MainWindow *mainwin,
343 static void prefs_common_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 ssl_manager_open_cb (MainWindow *mainwin,
366 static void new_account_cb (MainWindow *mainwin,
370 static void account_menu_cb (GtkMenuItem *menuitem,
373 static void prefs_open_cb (GtkMenuItem *menuitem,
375 static void plugins_open_cb (GtkMenuItem *menuitem,
378 static void online_switch_clicked(GtkButton *btn,
381 static void manual_open_cb (MainWindow *mainwin,
385 static void scan_tree_func (Folder *folder,
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 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
400 GdkEventFocus *focus,
402 void main_window_reply_cb (MainWindow *mainwin,
405 gboolean mainwindow_progressindicator_hook (gpointer source,
407 #define SEPARATE_ACTION 500
409 static GtkItemFactoryEntry mainwin_entries[] =
411 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
412 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
413 {N_("/_File/_Folder/Create _new folder..."),
414 NULL, new_folder_cb, 0, NULL},
415 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
416 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
417 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
418 {N_("/_File/_Folder/_Check for new messages in all folders"),
419 NULL, update_folderview_cb, 0, NULL},
420 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
421 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
422 {N_("/_File/_Add mailbox/mbox..."), NULL, add_mbox_cb, 0, NULL},
423 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
424 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
425 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
426 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
427 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
428 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
429 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
430 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
431 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
432 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
434 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
435 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
436 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
437 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
438 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
439 {N_("/_Edit/_Find in current message..."),
440 "<control>F", search_cb, 0, NULL},
441 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
442 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
443 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
444 {N_("/_View/Show or hi_de/_Folder tree"),
445 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
446 {N_("/_View/Show or hi_de/_Message view"),
447 "V", toggle_message_cb, 0, "<ToggleItem>"},
448 {N_("/_View/Show or hi_de/_Toolbar"),
449 NULL, NULL, 0, "<Branch>"},
450 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
451 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
452 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
453 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
454 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
455 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
456 {N_("/_View/Show or hi_de/_Toolbar/_None"),
457 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
458 {N_("/_View/Show or hi_de/Status _bar"),
459 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
460 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
461 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
462 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
463 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
464 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
465 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
466 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
467 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
468 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
469 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
470 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
471 {N_("/_View/_Sort/by _color label"),
472 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
473 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
474 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
475 {N_("/_View/_Sort/by a_ttachment"),
476 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
477 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
478 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
479 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
480 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
481 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
482 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
483 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
484 {N_("/_View/_Sort/_Attract by subject"),
485 NULL, attract_by_subject_cb, 0, NULL},
486 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
487 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
488 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
489 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
490 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
492 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
494 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
495 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
496 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
497 {N_("/_View/_Go to/P_rev unread message"),
498 "<shift>P", prev_unread_cb, 0, NULL},
499 {N_("/_View/_Go to/N_ext unread message"),
500 "<shift>N", next_unread_cb, 0, NULL},
501 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
503 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
504 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
505 {N_("/_View/_Go to/Prev _marked message"),
506 NULL, prev_marked_cb, 0, NULL},
507 {N_("/_View/_Go to/Next m_arked message"),
508 NULL, next_marked_cb, 0, NULL},
509 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_View/_Go to/Prev _labeled message"),
511 NULL, prev_labeled_cb, 0, NULL},
512 {N_("/_View/_Go to/Next la_beled message"),
513 NULL, next_labeled_cb, 0, NULL},
514 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
515 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
516 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
518 #define CODESET_SEPARATOR \
519 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
520 #define CODESET_ACTION(action) \
521 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
523 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
524 {N_("/_View/_Code set/_Auto detect"),
525 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
526 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
527 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
528 CODESET_ACTION(C_US_ASCII)},
531 {N_("/_View/_Code set/Unicode (_UTF-8)"),
532 CODESET_ACTION(C_UTF_8)},
535 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
536 CODESET_ACTION(C_ISO_8859_1)},
537 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
538 CODESET_ACTION(C_ISO_8859_15)},
541 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
542 CODESET_ACTION(C_ISO_8859_2)},
544 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
545 CODESET_ACTION(C_ISO_8859_13)},
546 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
547 CODESET_ACTION(C_ISO_8859_4)},
549 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
550 CODESET_ACTION(C_ISO_8859_7)},
552 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
553 CODESET_ACTION(C_ISO_8859_9)},
555 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
556 CODESET_ACTION(C_ISO_8859_5)},
557 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
558 CODESET_ACTION(C_KOI8_R)},
559 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
560 CODESET_ACTION(C_WINDOWS_1251)},
563 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
564 CODESET_ACTION(C_ISO_2022_JP)},
566 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
567 CODESET_ACTION(C_ISO_2022_JP_2)},
569 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
570 CODESET_ACTION(C_EUC_JP)},
571 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
572 CODESET_ACTION(C_SHIFT_JIS)},
575 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
576 CODESET_ACTION(C_GB2312)},
577 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
578 CODESET_ACTION(C_BIG5)},
579 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
580 CODESET_ACTION(C_EUC_TW)},
581 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
582 CODESET_ACTION(C_ISO_2022_CN)},
584 {N_("/_View/_Code set/Korean (EUC-_KR)"),
585 CODESET_ACTION(C_EUC_KR)},
586 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
587 CODESET_ACTION(C_ISO_2022_KR)},
589 {N_("/_View/_Code set/Thai (TIS-620)"),
590 CODESET_ACTION(C_TIS_620)},
591 {N_("/_View/_Code set/Thai (Windows-874)"),
592 CODESET_ACTION(C_WINDOWS_874)},
595 #undef CODESET_SEPARATOR
596 #undef CODESET_ACTION
598 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
600 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
601 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
602 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
605 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
606 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
607 {N_("/_Message/Get from _all accounts"),
608 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
609 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
610 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
611 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
612 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
614 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
615 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
616 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
617 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
618 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
619 {N_("/_Message/Repl_y to/mailing _list"),
620 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
621 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
622 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
624 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
625 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
626 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
627 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
629 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
630 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
631 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
632 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
633 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
634 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
635 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
636 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
637 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
638 {N_("/_Message/_Mark/Mark as rea_d"),
639 NULL, mark_as_read_cb, 0, NULL},
640 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
642 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
643 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
644 {N_("/_Tools/Add sender to address boo_k"),
645 NULL, add_address_cb, 0, NULL},
646 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
647 {N_("/_Tools/_Harvest addresses/from _Folder..."),
648 NULL, addr_harvest_cb, 0, NULL},
649 {N_("/_Tools/_Harvest addresses/from _Messages..."),
650 NULL, addr_harvest_msg_cb, 0, NULL},
651 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
653 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
654 {N_("/_Tools/_Create filter rule/_Automatically"),
655 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
656 {N_("/_Tools/_Create filter rule/by _From"),
657 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
658 {N_("/_Tools/_Create filter rule/by _To"),
659 NULL, create_filter_cb, FILTER_BY_TO, NULL},
660 {N_("/_Tools/_Create filter rule/by _Subject"),
661 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
662 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
663 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
664 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
665 {N_("/_Tools/Delete du_plicated messages"),
666 NULL, delete_duplicated_cb, 0, NULL},
667 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
670 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Tools/SSL certi_ficates..."),
672 NULL, ssl_manager_open_cb, 0, NULL},
674 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
675 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
677 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
678 {N_("/_Configuration/C_hange current account"),
679 NULL, NULL, 0, "<Branch>"},
680 {N_("/_Configuration/_Preferences for current account..."),
681 NULL, prefs_account_open_cb, 0, NULL},
682 {N_("/_Configuration/Create _new account..."),
683 NULL, new_account_cb, 0, NULL},
684 {N_("/_Configuration/_Edit accounts..."),
685 NULL, account_edit_open, 0, NULL},
686 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
687 {N_("/_Configuration/_Common preferences..."),
688 NULL, prefs_common_open_cb, 0, NULL},
689 {N_("/_Configuration/_Scoring..."),
690 NULL, prefs_scoring_open_cb, 0, NULL},
691 {N_("/_Configuration/_Filtering..."),
692 NULL, prefs_filtering_open_cb, 0, NULL},
693 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
694 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
695 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
696 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
698 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
699 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
700 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
701 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
702 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
703 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
704 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
705 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
706 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
707 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
711 MainWindow *main_window_create(SeparateType type)
717 GtkWidget *handlebox;
718 GtkWidget *vbox_body;
719 GtkWidget *hbox_stat;
720 GtkWidget *statusbar;
721 GtkWidget *progressbar;
722 GtkWidget *statuslabel;
723 GtkWidget *ac_button;
725 GtkWidget *online_pixmap;
726 GtkWidget *offline_pixmap;
727 GtkWidget *online_switch;
728 GtkWidget *offline_switch;
729 GtkTooltips *offline_tip;
730 GtkTooltips *online_tip;
731 GtkTooltips *sel_ac_tip;
733 FolderView *folderview;
734 SummaryView *summaryview;
735 MessageView *messageview;
736 GdkColormap *colormap;
739 GtkItemFactory *ifactory;
743 guint n_menu_entries;
745 static GdkGeometry geometry;
747 debug_print("Creating main window...\n");
748 mainwin = g_new0(MainWindow, 1);
751 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
752 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
753 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
754 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
756 if (!geometry.min_height) {
757 geometry.min_width = 320;
758 geometry.min_height = 200;
760 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
763 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
764 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
765 MANAGE_WINDOW_SIGNALS_CONNECT(window);
766 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
767 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
769 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
770 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
772 gtk_widget_realize(window);
773 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
776 gtkut_widget_set_app_icon(window);
778 vbox = gtk_vbox_new(FALSE, 0);
779 gtk_widget_show(vbox);
780 gtk_container_add(GTK_CONTAINER(window), vbox);
783 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
784 menubar = menubar_create(window, mainwin_entries,
785 n_menu_entries, "<Main>", mainwin);
786 gtk_widget_show(menubar);
787 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
788 ifactory = gtk_item_factory_from_widget(menubar);
790 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
791 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
793 handlebox = gtk_handle_box_new();
794 gtk_widget_show(handlebox);
795 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
797 /* link window to mainwin->window to avoid gdk warnings */
798 mainwin->window = window;
801 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
805 /* vbox that contains body */
806 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
807 gtk_widget_show(vbox_body);
808 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
809 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
811 hbox_stat = gtk_hbox_new(FALSE, 2);
812 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
814 statusbar = statusbar_create();
815 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
817 progressbar = gtk_progress_bar_new();
818 gtk_widget_set_usize(progressbar, 120, 1);
819 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
821 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
822 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
823 online_tip = gtk_tooltips_new();
824 online_switch = gtk_button_new ();
825 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
826 online_switch, _("Go offline"), NULL);
827 offline_tip = gtk_tooltips_new();
828 offline_switch = gtk_button_new ();
829 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
830 offline_switch, _("Go online"), NULL);
831 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
832 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
833 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
834 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
835 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
836 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
837 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
838 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
840 statuslabel = gtk_label_new("");
841 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
843 sel_ac_tip = gtk_tooltips_new();
844 ac_button = gtk_button_new();
845 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
846 ac_button, _("Select account"), NULL);
847 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
848 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
849 gtk_widget_set_usize(ac_button, -1, 1);
850 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
851 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
852 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
854 ac_label = gtk_label_new("");
855 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
857 gtk_widget_show_all(hbox_stat);
859 gtk_widget_hide(offline_switch);
861 mainwin->folderview = folderview = folderview_create();
862 mainwin->summaryview = summaryview = summary_create();
863 mainwin->messageview = messageview = messageview_create(mainwin);
864 mainwin->logwin = log_window_create();
866 folderview->mainwin = mainwin;
867 folderview->summaryview = summaryview;
869 summaryview->mainwin = mainwin;
870 summaryview->folderview = folderview;
871 summaryview->messageview = messageview;
872 summaryview->window = window;
874 mainwin->vbox = vbox;
875 mainwin->menubar = menubar;
876 mainwin->menu_factory = ifactory;
877 mainwin->handlebox = handlebox;
878 mainwin->vbox_body = vbox_body;
879 mainwin->hbox_stat = hbox_stat;
880 mainwin->statusbar = statusbar;
881 mainwin->progressbar = progressbar;
882 mainwin->statuslabel = statuslabel;
883 mainwin->ac_button = ac_button;
884 mainwin->ac_label = ac_label;
886 mainwin->online_switch = online_switch;
887 mainwin->offline_switch = offline_switch;
888 mainwin->online_pixmap = online_pixmap;
889 mainwin->offline_pixmap = offline_pixmap;
891 /* set context IDs for status bar */
892 mainwin->mainwin_cid = gtk_statusbar_get_context_id
893 (GTK_STATUSBAR(statusbar), "Main Window");
894 mainwin->folderview_cid = gtk_statusbar_get_context_id
895 (GTK_STATUSBAR(statusbar), "Folder View");
896 mainwin->summaryview_cid = gtk_statusbar_get_context_id
897 (GTK_STATUSBAR(statusbar), "Summary View");
899 /* allocate colors for summary view and folder view */
900 summaryview->color_marked.red = summaryview->color_marked.green = 0;
901 summaryview->color_marked.blue = (guint16)65535;
903 summaryview->color_dim.red = summaryview->color_dim.green =
904 summaryview->color_dim.blue = COLOR_DIM;
906 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
907 &folderview->color_new);
909 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
910 &folderview->color_op);
912 summaryview->color_important.red = 0;
913 summaryview->color_important.green = 0;
914 summaryview->color_important.blue = (guint16)65535;
916 color[0] = summaryview->color_marked;
917 color[1] = summaryview->color_dim;
918 color[2] = folderview->color_new;
919 color[3] = folderview->color_op;
921 colormap = gdk_window_get_colormap(window->window);
922 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
923 for (i = 0; i < 4; i++) {
924 if (success[i] == FALSE)
925 g_warning("MainWindow: color allocation %d failed\n", i);
928 debug_print("done.\n");
930 messageview->visible = TRUE;
932 main_window_set_widgets(mainwin, type);
934 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
935 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
939 menuitem = gtk_item_factory_get_item
940 (ifactory, "/View/Code set/Auto detect");
941 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
943 switch (prefs_common.toolbar_style) {
945 menuitem = gtk_item_factory_get_item
946 (ifactory, "/View/Show or hide/Toolbar/None");
949 menuitem = gtk_item_factory_get_item
950 (ifactory, "/View/Show or hide/Toolbar/Icon");
953 menuitem = gtk_item_factory_get_item
954 (ifactory, "/View/Show or hide/Toolbar/Text");
957 menuitem = gtk_item_factory_get_item
958 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
960 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
962 gtk_widget_hide(mainwin->hbox_stat);
963 menuitem = gtk_item_factory_get_item
964 (ifactory, "/View/Show or hide/Status bar");
965 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
966 prefs_common.show_statusbar);
968 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
970 if (prefs_common.show_searchbar) {
971 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
972 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
973 gtk_widget_hide(summaryview->search_description);
976 /* set account selection menu */
977 ac_menu = gtk_item_factory_get_widget
978 (ifactory, "/Configuration/Change current account");
979 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
980 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
981 mainwin->ac_menu = ac_menu;
983 toolbar_main_set_sensitive(mainwin);
985 /* create actions menu */
986 action_update_mainwin_menu(ifactory, mainwin);
988 /* attach accel groups to main window */
989 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
990 gtk_window_add_accel_group \
992 gtk_item_factory_from_widget(menu)->accel_group)
994 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
996 /* connect the accelerators for equivalent
997 menu items in different menus */
998 menu_connect_identical_items();
1002 /* show main window */
1003 gtk_widget_show(mainwin->window);
1005 /* initialize views */
1006 folderview_init(folderview);
1007 summary_init(summaryview);
1008 messageview_init(messageview);
1009 log_window_init(mainwin->logwin);
1011 sslcertwindow_register_hook();
1013 mainwin->lock_count = 0;
1014 mainwin->menu_lock_count = 0;
1015 mainwin->cursor_count = 0;
1017 mainwin->progressindicator_hook =
1018 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1021 watch_cursor = gdk_cursor_new(GDK_WATCH);
1023 mainwin_list = g_list_append(mainwin_list, mainwin);
1025 /* init work_offline */
1026 if (prefs_common.work_offline)
1027 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1032 void main_window_cursor_wait(MainWindow *mainwin)
1035 if (mainwin->cursor_count == 0)
1036 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1038 mainwin->cursor_count++;
1043 void main_window_cursor_normal(MainWindow *mainwin)
1045 if (mainwin->cursor_count)
1046 mainwin->cursor_count--;
1048 if (mainwin->cursor_count == 0)
1049 gdk_window_set_cursor(mainwin->window->window, NULL);
1054 /* lock / unlock the user-interface */
1055 void main_window_lock(MainWindow *mainwin)
1057 if (mainwin->lock_count == 0)
1058 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1060 mainwin->lock_count++;
1062 main_window_set_menu_sensitive(mainwin);
1063 toolbar_main_set_sensitive(mainwin);
1066 void main_window_unlock(MainWindow *mainwin)
1068 if (mainwin->lock_count)
1069 mainwin->lock_count--;
1071 main_window_set_menu_sensitive(mainwin);
1072 toolbar_main_set_sensitive(mainwin);
1074 if (mainwin->lock_count == 0)
1075 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1078 static void main_window_menu_callback_block(MainWindow *mainwin)
1080 mainwin->menu_lock_count++;
1083 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1085 if (mainwin->menu_lock_count)
1086 mainwin->menu_lock_count--;
1089 void main_window_reflect_prefs_all(void)
1091 main_window_reflect_prefs_all_real(FALSE);
1094 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1097 MainWindow *mainwin;
1100 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1101 mainwin = (MainWindow *)cur->data;
1103 main_window_show_cur_account(mainwin);
1104 main_window_set_menu_sensitive(mainwin);
1105 toolbar_main_set_sensitive(mainwin);
1108 if (pixmap_theme_changed) {
1109 toolbar_update(TOOLBAR_MAIN, mainwin);
1110 messageview_reflect_prefs_pixmap_theme();
1111 compose_reflect_prefs_pixmap_theme();
1112 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1113 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1115 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1116 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1117 mainwin->online_pixmap);
1118 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1119 gtk_widget_show(pixmap);
1120 mainwin->online_pixmap = pixmap;
1121 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1122 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1123 mainwin->offline_pixmap);
1124 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1125 gtk_widget_show(pixmap);
1126 mainwin->offline_pixmap = pixmap;
1129 summary_redisplay_msg(mainwin->summaryview);
1130 headerview_set_visibility(mainwin->messageview->headerview,
1131 prefs_common.display_header_pane);
1135 void main_window_set_summary_column(void)
1138 MainWindow *mainwin;
1140 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1141 mainwin = (MainWindow *)cur->data;
1142 summary_set_column_order(mainwin->summaryview);
1146 void main_window_set_account_menu(GList *account_list)
1148 GList *cur, *cur_ac, *cur_item;
1149 GtkWidget *menuitem;
1150 MainWindow *mainwin;
1151 PrefsAccount *ac_prefs;
1153 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1154 mainwin = (MainWindow *)cur->data;
1156 /* destroy all previous menu item */
1157 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1158 while (cur_item != NULL) {
1159 GList *next = cur_item->next;
1160 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1164 for (cur_ac = account_list; cur_ac != NULL;
1165 cur_ac = cur_ac->next) {
1166 ac_prefs = (PrefsAccount *)cur_ac->data;
1168 menuitem = gtk_menu_item_new_with_label
1169 (ac_prefs->account_name
1170 ? ac_prefs->account_name : _("Untitled"));
1171 gtk_widget_show(menuitem);
1172 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1173 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1174 GTK_SIGNAL_FUNC(account_menu_cb),
1180 static void main_window_show_cur_account(MainWindow *mainwin)
1185 ac_name = g_strdup(cur_account
1186 ? (cur_account->account_name
1187 ? cur_account->account_name : _("Untitled"))
1191 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1193 buf = g_strdup(PROG_VERSION);
1194 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1197 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1198 gtk_widget_queue_resize(mainwin->ac_button);
1203 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1205 switch (mainwin->type) {
1206 case SEPARATE_FOLDER:
1207 return mainwin->win.sep_folder.folderwin;
1209 return mainwin->win.sep_both.folderwin;
1215 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1217 switch (mainwin->type) {
1218 case SEPARATE_MESSAGE:
1219 return mainwin->win.sep_message.messagewin;
1221 return mainwin->win.sep_both.messagewin;
1227 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1229 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1230 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1231 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1232 GtkWidget *message_wid = mainwin->messageview->vbox;
1234 debug_print("Changing window separation type from %d to %d\n",
1235 mainwin->type, type);
1237 if (mainwin->type == type) return;
1239 /* remove widgets from those containers */
1240 gtk_widget_ref(folder_wid);
1241 gtk_widget_ref(summary_wid);
1242 gtk_widget_ref(message_wid);
1243 gtkut_container_remove
1244 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1245 gtkut_container_remove
1246 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1247 gtkut_container_remove
1248 (GTK_CONTAINER(message_wid->parent), message_wid);
1250 /* clean containers */
1251 switch (mainwin->type) {
1253 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1255 case SEPARATE_FOLDER:
1256 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1257 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1259 case SEPARATE_MESSAGE:
1260 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1261 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1264 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1265 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1269 gtk_widget_hide(mainwin->window);
1270 main_window_set_widgets(mainwin, type);
1271 gtk_widget_show(mainwin->window);
1273 gtk_widget_unref(folder_wid);
1274 gtk_widget_unref(summary_wid);
1275 gtk_widget_unref(message_wid);
1278 void main_window_toggle_message_view(MainWindow *mainwin)
1280 SummaryView *summaryview = mainwin->summaryview;
1281 union CompositeWin *cwin = &mainwin->win;
1282 GtkWidget *vpaned = NULL;
1283 GtkWidget *container = NULL;
1284 GtkWidget *msgwin = NULL;
1286 switch (mainwin->type) {
1288 vpaned = cwin->sep_none.vpaned;
1289 container = cwin->sep_none.hpaned;
1291 case SEPARATE_FOLDER:
1292 vpaned = cwin->sep_folder.vpaned;
1293 container = mainwin->vbox_body;
1295 case SEPARATE_MESSAGE:
1296 msgwin = mainwin->win.sep_message.messagewin;
1299 msgwin = mainwin->win.sep_both.messagewin;
1304 if (GTK_WIDGET_VISIBLE(msgwin)) {
1305 gtk_widget_hide(msgwin);
1306 mainwin->messageview->visible = FALSE;
1307 summaryview->displayed = NULL;
1309 gtk_widget_show(msgwin);
1310 mainwin->messageview->visible = TRUE;
1312 } else if (vpaned->parent != NULL) {
1313 mainwin->messageview->visible = FALSE;
1314 summaryview->displayed = NULL;
1315 gtk_widget_ref(vpaned);
1316 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1317 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1318 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1319 GTK_ARROW_UP, GTK_SHADOW_OUT);
1321 mainwin->messageview->visible = TRUE;
1322 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1323 gtk_container_add(GTK_CONTAINER(container), vpaned);
1324 gtk_widget_unref(vpaned);
1325 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1326 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1329 main_window_set_menu_sensitive(mainwin);
1331 gtk_widget_grab_focus(summaryview->ctree);
1334 void main_window_get_size(MainWindow *mainwin)
1336 GtkAllocation *allocation;
1338 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1340 prefs_common.summaryview_width = allocation->width;
1342 if ((mainwin->type == SEPARATE_NONE ||
1343 mainwin->type == SEPARATE_FOLDER) &&
1344 messageview_is_visible(mainwin->messageview))
1345 prefs_common.summaryview_height = allocation->height;
1347 prefs_common.mainview_width = allocation->width;
1349 allocation = &mainwin->window->allocation;
1350 prefs_common.mainview_height = allocation->height;
1351 prefs_common.mainwin_width = allocation->width;
1352 prefs_common.mainwin_height = allocation->height;
1354 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1355 prefs_common.folderview_width = allocation->width;
1356 prefs_common.folderview_height = allocation->height;
1358 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1359 prefs_common.msgview_width = allocation->width;
1360 prefs_common.msgview_height = allocation->height;
1363 void main_window_get_position(MainWindow *mainwin)
1368 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1370 prefs_common.mainview_x = x;
1371 prefs_common.mainview_y = y;
1372 prefs_common.mainwin_x = x;
1373 prefs_common.mainwin_y = y;
1375 debug_print("window position: x = %d, y = %d\n", x, y);
1377 window = main_window_get_folder_window(mainwin);
1379 gtkut_widget_get_uposition(window, &x, &y);
1380 prefs_common.folderwin_x = x;
1381 prefs_common.folderwin_y = y;
1383 window = main_window_get_message_window(mainwin);
1385 gtkut_widget_get_uposition(window, &x, &y);
1386 prefs_common.main_msgwin_x = x;
1387 prefs_common.main_msgwin_y = y;
1391 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1397 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1398 folder = FOLDER(list->data);
1399 if (folder && folder->trash && folder->trash->total_msgs > 0)
1403 if (!has_trash) return;
1406 if (alertpanel(_("Empty trash"),
1407 _("Empty all messages in trash?"),
1408 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1410 manage_window_focus_in(mainwin->window, NULL, NULL);
1413 procmsg_empty_trash();
1415 if (mainwin->summaryview->folder_item &&
1416 mainwin->summaryview->folder_item->stype == F_TRASH)
1417 gtk_widget_grab_focus(mainwin->folderview->ctree);
1420 void main_window_add_mailbox(MainWindow *mainwin)
1425 path = input_dialog(_("Add mailbox"),
1426 _("Input the location of mailbox.\n"
1427 "If the existing mailbox is specified, it will be\n"
1428 "scanned automatically."),
1431 if (folder_find_from_path(path)) {
1432 alertpanel_error(_("The mailbox `%s' already exists."), path);
1436 folder = folder_new(folder_get_class_from_string("mh"),
1437 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1441 if (folder->klass->create_tree(folder) < 0) {
1442 alertpanel_error(_("Creation of the mailbox failed.\n"
1443 "Maybe some files already exist, or you don't have the permission to write there."));
1444 folder_destroy(folder);
1449 folder_set_ui_func(folder, scan_tree_func, mainwin);
1450 folder_scan_tree(folder);
1451 folder_set_ui_func(folder, NULL, NULL);
1453 folderview_set(mainwin->folderview);
1456 void main_window_add_mbox(MainWindow *mainwin)
1462 path = input_dialog(_("Add mbox mailbox"),
1463 _("Input the location of mailbox."),
1468 if (folder_find_from_path(path)) {
1469 alertpanel_error(_("The mailbox `%s' already exists."), path);
1474 folder = folder_new(folder_get_class_from_string("mbox"),
1475 g_basename(path), path);
1478 if (folder->klass->create_tree(folder) < 0) {
1479 alertpanel_error(_("Creation of the mailbox failed."));
1480 folder_destroy(folder);
1486 item = folder_item_new(folder, folder->name, NULL);
1487 item->folder = folder;
1488 folder->node = g_node_new(item);
1490 folder_create_folder(item, "inbox");
1491 folder_create_folder(item, "outbox");
1492 folder_create_folder(item, "queue");
1493 folder_create_folder(item, "draft");
1494 folder_create_folder(item, "trash");
1496 folderview_set(mainwin->folderview);
1499 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1501 SensitiveCond state = 0;
1502 SummarySelection selection;
1503 FolderItem *item = mainwin->summaryview->folder_item;
1504 GList *account_list = account_get_list();
1506 selection = summary_get_selection_type(mainwin->summaryview);
1508 if (mainwin->lock_count == 0)
1509 state |= M_UNLOCKED;
1510 if (selection != SUMMARY_NONE)
1511 state |= M_MSG_EXIST;
1512 if (item && item->path && item->parent && !item->no_select) {
1514 /* if (item->folder->type != F_NEWS) */
1515 state |= M_ALLOW_DELETE;
1517 if (prefs_common.immediate_exec == 0
1518 && mainwin->lock_count == 0)
1519 state |= M_DELAY_EXEC;
1521 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1522 || selection != SUMMARY_NONE)
1523 state |= M_HIDE_READ_MSG;
1525 if (mainwin->summaryview->threaded)
1526 state |= M_THREADED;
1528 state |= M_UNTHREADED;
1529 if (selection == SUMMARY_SELECTED_SINGLE ||
1530 selection == SUMMARY_SELECTED_MULTIPLE)
1531 state |= M_TARGET_EXIST;
1532 if (selection == SUMMARY_SELECTED_SINGLE)
1533 state |= M_SINGLE_TARGET_EXIST;
1534 if (mainwin->summaryview->folder_item &&
1535 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1538 state |= M_NOT_NEWS;
1539 if (selection == SUMMARY_SELECTED_SINGLE &&
1541 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1542 item->stype == F_QUEUE)))
1543 state |= M_ALLOW_REEDIT;
1545 state |= M_HAVE_ACCOUNT;
1547 for ( ; account_list != NULL; account_list = account_list->next) {
1548 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1549 state |= M_HAVE_NEWS_ACCOUNT;
1554 if (inc_is_active())
1555 state |= M_INC_ACTIVE;
1562 void main_window_set_menu_sensitive(MainWindow *mainwin)
1564 GtkItemFactory *ifactory = mainwin->menu_factory;
1565 SensitiveCond state;
1567 GtkWidget *menuitem;
1568 SummaryView *summaryview;
1572 static const struct {
1576 {"/File/Folder" , M_UNLOCKED},
1577 {"/File/Add mailbox" , M_UNLOCKED},
1579 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1580 {"/File/Add mailbox/mbox..." , M_UNLOCKED},
1581 {"/File/Export to mbox file..." , M_UNLOCKED},
1582 {"/File/Empty trash" , M_UNLOCKED},
1583 {"/File/Work offline" , M_UNLOCKED},
1585 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1586 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1587 /* {"/File/Close" , M_UNLOCKED}, */
1588 {"/File/Exit" , M_UNLOCKED},
1590 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1592 {"/View/Sort" , M_EXEC},
1593 {"/View/Thread view" , M_EXEC},
1594 {"/View/Expand all threads" , M_MSG_EXIST},
1595 {"/View/Collapse all threads" , M_MSG_EXIST},
1596 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1597 {"/View/Go to/Prev message" , M_MSG_EXIST},
1598 {"/View/Go to/Next message" , M_MSG_EXIST},
1599 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1600 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1601 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1602 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1603 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1604 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1605 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1606 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1607 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1609 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1610 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1611 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1612 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1613 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1614 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1615 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1616 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1617 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1618 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1619 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1620 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1621 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1622 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1623 {"/Message/Mark" , M_TARGET_EXIST},
1625 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1626 {"/Tools/Harvest addresses" , M_UNLOCKED},
1627 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1628 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1629 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1630 {"/Tools/Execute" , M_DELAY_EXEC},
1631 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1633 {"/Configuration", M_UNLOCKED},
1638 state = main_window_get_current_state(mainwin);
1640 for (i = 0; entry[i].entry != NULL; i++) {
1641 sensitive = ((entry[i].cond & state) == entry[i].cond);
1642 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1645 main_window_menu_callback_block(mainwin);
1647 #define SET_CHECK_MENU_ACTIVE(path, active) \
1649 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1650 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1653 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1654 messageview_is_visible(mainwin->messageview));
1656 summaryview = mainwin->summaryview;
1657 menu_path = "/View/Sort/Don't sort";
1659 switch (summaryview->sort_key) {
1660 case SORT_BY_NUMBER:
1661 menu_path = "/View/Sort/by number"; break;
1663 menu_path = "/View/Sort/by size"; break;
1665 menu_path = "/View/Sort/by date"; break;
1667 menu_path = "/View/Sort/by from"; break;
1669 menu_path = "/View/Sort/by recipient"; break;
1670 case SORT_BY_SUBJECT:
1671 menu_path = "/View/Sort/by subject"; break;
1673 menu_path = "/View/Sort/by color label"; break;
1675 menu_path = "/View/Sort/by mark"; break;
1676 case SORT_BY_STATUS:
1677 menu_path = "/View/Sort/by status"; break;
1679 menu_path = "/View/Sort/by attachment"; break;
1681 menu_path = "/View/Sort/by score"; break;
1682 case SORT_BY_LOCKED:
1683 menu_path = "/View/Sort/by locked"; break;
1686 menu_path = "/View/Sort/Don't sort"; break;
1688 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1690 if (summaryview->sort_type == SORT_ASCENDING) {
1691 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1693 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1696 if (summaryview->sort_key != SORT_BY_NONE) {
1697 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1698 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1700 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1701 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1704 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1705 mainwin->messageview->textview->show_all_headers);
1706 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1708 #undef SET_CHECK_MENU_ACTIVE
1710 main_window_menu_callback_unblock(mainwin);
1713 void main_window_popup(MainWindow *mainwin)
1715 gtkut_window_popup(mainwin->window);
1717 switch (mainwin->type) {
1718 case SEPARATE_FOLDER:
1719 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1721 case SEPARATE_MESSAGE:
1722 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1725 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1726 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1733 void main_window_show(MainWindow *mainwin)
1735 gtk_widget_show(mainwin->window);
1736 gtk_widget_show(mainwin->vbox_body);
1738 gtk_widget_set_uposition(mainwin->window,
1739 prefs_common.mainwin_x,
1740 prefs_common.mainwin_y);
1742 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1743 prefs_common.folderview_width,
1744 prefs_common.folderview_height);
1745 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1746 prefs_common.summaryview_width,
1747 prefs_common.summaryview_height);
1748 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1749 prefs_common.msgview_width,
1750 prefs_common.msgview_height);
1752 if (mainwin->type & SEPARATE_FOLDER) {
1753 GtkWidget *folderwin;
1755 folderwin = main_window_get_folder_window(mainwin);
1756 gtk_widget_show(folderwin);
1757 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1758 prefs_common.folderwin_y);
1761 if (mainwin->type & SEPARATE_MESSAGE) {
1762 GtkWidget *messagewin;
1764 messagewin = main_window_get_message_window(mainwin);
1765 gtk_widget_show(messagewin);
1766 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1767 prefs_common.main_msgwin_y);
1771 void main_window_hide(MainWindow *mainwin)
1773 main_window_get_size(mainwin);
1774 main_window_get_position(mainwin);
1776 gtk_widget_hide(mainwin->window);
1777 gtk_widget_hide(mainwin->vbox_body);
1779 if (mainwin->type & SEPARATE_FOLDER) {
1780 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1783 if (mainwin->type & SEPARATE_MESSAGE) {
1784 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1788 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1790 GtkWidget *folderwin = NULL;
1791 GtkWidget *messagewin = NULL;
1794 GtkWidget *vbox_body = mainwin->vbox_body;
1795 GtkItemFactory *ifactory = mainwin->menu_factory;
1796 GtkWidget *menuitem;
1797 GtkItemFactory *msgview_ifactory;
1799 debug_print("Setting widgets...");
1801 /* create separated window(s) if needed */
1802 if (type & SEPARATE_FOLDER) {
1803 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1804 gtk_window_set_title(GTK_WINDOW(folderwin),
1805 _("Sylpheed - Folder View"));
1806 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1807 "folder_view", "Sylpheed");
1808 gtk_window_set_policy(GTK_WINDOW(folderwin),
1810 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1811 prefs_common.folderwin_y);
1812 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1814 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1815 GTK_SIGNAL_FUNC(folder_window_close_cb),
1818 if (type & SEPARATE_MESSAGE) {
1819 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1820 gtk_window_set_title(GTK_WINDOW(messagewin),
1821 _("Sylpheed - Message View"));
1822 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1823 "message_view", "Sylpheed");
1824 gtk_window_set_policy(GTK_WINDOW(messagewin),
1826 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1827 prefs_common.main_msgwin_y);
1828 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1830 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1831 GTK_SIGNAL_FUNC(message_window_close_cb),
1835 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1836 prefs_common.folderview_width,
1837 prefs_common.folderview_height);
1838 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1839 prefs_common.summaryview_width,
1840 prefs_common.summaryview_height);
1841 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1842 prefs_common.msgview_width,
1843 prefs_common.msgview_height);
1847 hpaned = gtk_hpaned_new();
1848 gtk_widget_show(hpaned);
1849 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1850 gtk_paned_add1(GTK_PANED(hpaned),
1851 GTK_WIDGET_PTR(mainwin->folderview));
1853 vpaned = gtk_vpaned_new();
1854 if (messageview_is_visible(mainwin->messageview)) {
1855 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1856 gtk_paned_add1(GTK_PANED(vpaned),
1857 GTK_WIDGET_PTR(mainwin->summaryview));
1859 gtk_paned_add2(GTK_PANED(hpaned),
1860 GTK_WIDGET_PTR(mainwin->summaryview));
1861 gtk_widget_ref(vpaned);
1863 gtk_paned_add2(GTK_PANED(vpaned),
1864 GTK_WIDGET_PTR(mainwin->messageview));
1865 gtk_widget_show(vpaned);
1867 mainwin->win.sep_none.hpaned = hpaned;
1868 mainwin->win.sep_none.vpaned = vpaned;
1870 /* remove headerview if not in prefs */
1871 headerview_set_visibility(mainwin->messageview->headerview,
1872 prefs_common.display_header_pane);
1874 case SEPARATE_FOLDER:
1875 vpaned = gtk_vpaned_new();
1876 if (messageview_is_visible(mainwin->messageview)) {
1877 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1879 gtk_paned_add1(GTK_PANED(vpaned),
1880 GTK_WIDGET_PTR(mainwin->summaryview));
1882 gtk_box_pack_start(GTK_BOX(vbox_body),
1883 GTK_WIDGET_PTR(mainwin->summaryview),
1885 gtk_widget_ref(vpaned);
1887 gtk_paned_add2(GTK_PANED(vpaned),
1888 GTK_WIDGET_PTR(mainwin->messageview));
1889 gtk_widget_show(vpaned);
1891 gtk_container_add(GTK_CONTAINER(folderwin),
1892 GTK_WIDGET_PTR(mainwin->folderview));
1894 mainwin->win.sep_folder.folderwin = folderwin;
1895 mainwin->win.sep_folder.vpaned = vpaned;
1897 gtk_widget_show_all(folderwin);
1899 /* remove headerview if not in prefs */
1900 headerview_set_visibility(mainwin->messageview->headerview,
1901 prefs_common.display_header_pane);
1904 case SEPARATE_MESSAGE:
1905 hpaned = gtk_hpaned_new();
1906 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1908 gtk_paned_add1(GTK_PANED(hpaned),
1909 GTK_WIDGET_PTR(mainwin->folderview));
1910 gtk_paned_add2(GTK_PANED(hpaned),
1911 GTK_WIDGET_PTR(mainwin->summaryview));
1912 gtk_widget_show(hpaned);
1914 messageview_add_toolbar(mainwin->messageview, messagewin);
1915 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1916 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1918 mainwin->win.sep_message.messagewin = messagewin;
1919 mainwin->win.sep_message.hpaned = hpaned;
1921 gtk_widget_show(messagewin);
1924 gtk_box_pack_start(GTK_BOX(vbox_body),
1925 GTK_WIDGET_PTR(mainwin->summaryview),
1927 gtk_container_add(GTK_CONTAINER(folderwin),
1928 GTK_WIDGET_PTR(mainwin->folderview));
1929 gtk_container_add(GTK_CONTAINER(messagewin),
1930 GTK_WIDGET_PTR(mainwin->messageview));
1932 mainwin->win.sep_both.folderwin = folderwin;
1933 mainwin->win.sep_both.messagewin = messagewin;
1935 gtk_widget_show(folderwin);
1936 gtk_widget_show(messagewin);
1940 gtk_widget_set_uposition(mainwin->window,
1941 prefs_common.mainwin_x,
1942 prefs_common.mainwin_y);
1944 gtk_widget_queue_resize(vbox_body);
1945 gtk_widget_queue_resize(mainwin->window);
1946 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1947 * and mimeview icon list/ctree lose track of their visibility states */
1948 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1949 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1950 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
1951 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
1953 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
1955 /* rehide quick search if necessary */
1956 if (!prefs_common.show_searchbar)
1957 gtk_widget_hide(mainwin->summaryview->hbox_search);
1959 mainwin->type = type;
1961 mainwin->messageview->visible = TRUE;
1963 /* toggle menu state */
1964 menuitem = gtk_item_factory_get_item
1965 (ifactory, "/View/Show or hide/Folder tree");
1966 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1967 menuitem = gtk_item_factory_get_item
1968 (ifactory, "/View/Show or hide/Message view");
1969 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1971 menuitem = gtk_item_factory_get_item
1972 (ifactory, "/View/Separate folder tree");
1973 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1974 ((type & SEPARATE_FOLDER) != 0));
1975 menuitem = gtk_item_factory_get_item
1976 (ifactory, "/View/Separate message view");
1977 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1978 ((type & SEPARATE_MESSAGE) != 0));
1980 debug_print("done.\n");
1983 void main_window_destroy_all(void)
1985 while (mainwin_list != NULL) {
1986 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1988 /* free toolbar stuff */
1989 toolbar_clear_list(TOOLBAR_MAIN);
1990 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1991 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1993 g_free(mainwin->toolbar);
1996 mainwin_list = g_list_remove(mainwin_list, mainwin);
1998 g_list_free(mainwin_list);
2002 static void toolbar_account_button_pressed(GtkWidget *widget,
2003 GdkEventButton *event,
2006 MainWindow *mainwin = (MainWindow *)data;
2009 if (event->button != 3) return;
2011 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2012 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2015 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2016 menu_button_position, widget,
2017 event->button, event->time);
2021 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2024 MainWindow *mainwin = (MainWindow *)data;
2028 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2029 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2032 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2033 menu_button_position, widget,
2034 event->button, event->time);
2037 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2039 MainWindow *mainwin = (MainWindow *)data;
2042 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2043 if (!button) return;
2044 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2045 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2046 manage_window_focus_in(mainwin->window, NULL, NULL);
2049 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2052 MainWindow *mainwin = (MainWindow *)data;
2054 if (mainwin->lock_count == 0)
2055 app_exit_cb(data, 0, widget);
2060 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2063 MainWindow *mainwin = (MainWindow *)data;
2064 GtkWidget *menuitem;
2066 menuitem = gtk_item_factory_get_item
2067 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2068 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2073 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2076 MainWindow *mainwin = (MainWindow *)data;
2077 GtkWidget *menuitem;
2079 menuitem = gtk_item_factory_get_item
2080 (mainwin->menu_factory, "/View/Show or hide/Message view");
2081 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2086 static void main_window_size_allocate_cb(GtkWidget *widget,
2087 GtkAllocation *allocation,
2090 MainWindow *mainwin = (MainWindow *)data;
2092 main_window_get_size(mainwin);
2095 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2098 main_window_add_mailbox(mainwin);
2101 static void add_mbox_cb(MainWindow *mainwin, guint action,
2104 main_window_add_mbox(mainwin);
2107 static void update_folderview_cb(MainWindow *mainwin, guint action,
2110 summary_show(mainwin->summaryview, NULL);
2111 folderview_check_new_all();
2114 static void new_folder_cb(MainWindow *mainwin, guint action,
2117 folderview_new_folder(mainwin->folderview);
2120 static void rename_folder_cb(MainWindow *mainwin, guint action,
2123 folderview_rename_folder(mainwin->folderview);
2126 static void delete_folder_cb(MainWindow *mainwin, guint action,
2129 folderview_delete_folder(mainwin->folderview);
2132 static void import_mbox_cb(MainWindow *mainwin, guint action,
2135 import_mbox(mainwin->summaryview->folder_item);
2138 static void export_mbox_cb(MainWindow *mainwin, guint action,
2141 export_mbox(mainwin->summaryview->folder_item);
2144 static void empty_trash_cb(MainWindow *mainwin, guint action,
2147 main_window_empty_trash(mainwin, TRUE);
2150 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2152 summary_save_as(mainwin->summaryview);
2155 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2157 summary_print(mainwin->summaryview);
2160 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2162 if (prefs_common.confirm_on_exit) {
2163 if (alertpanel(_("Exit"), _("Exit this program?"),
2164 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2166 manage_window_focus_in(mainwin->window, NULL, NULL);
2169 app_will_exit(widget, mainwin);
2172 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2175 summary_search(mainwin->summaryview);
2177 message_search(mainwin->messageview);
2180 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2185 active = GTK_CHECK_MENU_ITEM(widget)->active;
2187 switch (mainwin->type) {
2189 case SEPARATE_MESSAGE:
2192 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2194 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2197 case SEPARATE_FOLDER:
2198 debug_print("separate folder\n");
2200 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2202 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2206 gtk_widget_show(mainwin->win.sep_both.folderwin);
2208 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2213 static void toggle_message_cb(MainWindow *mainwin, guint action,
2218 active = GTK_CHECK_MENU_ITEM(widget)->active;
2220 if (active != messageview_is_visible(mainwin->messageview))
2221 summary_toggle_view(mainwin->summaryview);
2224 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2227 toolbar_toggle(action, mainwin);
2230 void main_window_reply_cb(MainWindow *mainwin, guint action,
2233 MessageView *msgview = (MessageView*)mainwin->messageview;
2234 GSList *msginfo_list = NULL;
2237 g_return_if_fail(msgview != NULL);
2239 msginfo_list = summary_get_selection(mainwin->summaryview);
2240 g_return_if_fail(msginfo_list != NULL);
2242 body = messageview_get_selection(msgview);
2243 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2245 g_slist_free(msginfo_list);
2249 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2252 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2253 gtk_widget_show(mainwin->hbox_stat);
2254 prefs_common.show_statusbar = TRUE;
2256 gtk_widget_hide(mainwin->hbox_stat);
2257 prefs_common.show_statusbar = FALSE;
2261 static void separate_widget_cb(MainWindow *mainwin, guint action,
2266 if (GTK_CHECK_MENU_ITEM(widget)->active)
2267 type = mainwin->type | action;
2269 type = mainwin->type & ~action;
2271 main_window_separation_change(mainwin, type);
2273 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2274 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2277 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2280 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2282 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2285 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2287 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2290 static void online_switch_clicked (GtkButton *btn, gpointer data)
2292 MainWindow *mainwin;
2293 GtkItemFactory *ifactory;
2294 GtkCheckMenuItem *menuitem;
2296 mainwin = (MainWindow *) data;
2298 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2299 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2301 g_return_if_fail(mainwin != NULL);
2302 g_return_if_fail(menuitem != NULL);
2304 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2306 gtk_widget_hide (mainwin->online_switch);
2307 gtk_widget_show (mainwin->offline_switch);
2308 menuitem->active = TRUE;
2309 prefs_common.work_offline = TRUE;
2310 inc_autocheck_timer_remove();
2313 gtk_widget_hide (mainwin->offline_switch);
2314 gtk_widget_show (mainwin->online_switch);
2315 menuitem->active = FALSE;
2316 prefs_common.work_offline = FALSE;
2317 inc_autocheck_timer_set();
2321 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2324 addressbook_open(NULL);
2327 static void log_window_show_cb(MainWindow *mainwin, guint action,
2330 log_window_show(mainwin->logwin);
2333 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2338 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2340 summary_move_to(mainwin->summaryview);
2343 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2345 summary_copy_to(mainwin->summaryview);
2348 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2350 summary_delete(mainwin->summaryview);
2353 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2355 summary_cancel(mainwin->summaryview);
2358 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2360 summary_open_msg(mainwin->summaryview);
2363 static void view_source_cb(MainWindow *mainwin, guint action,
2366 summary_view_source(mainwin->summaryview);
2369 static void show_all_header_cb(MainWindow *mainwin, guint action,
2372 if (mainwin->menu_lock_count) return;
2373 summary_display_msg_selected(mainwin->summaryview,
2374 GTK_CHECK_MENU_ITEM(widget)->active);
2377 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2379 summary_reedit(mainwin->summaryview);
2382 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2384 summary_mark(mainwin->summaryview);
2387 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2389 summary_unmark(mainwin->summaryview);
2392 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2395 summary_mark_as_unread(mainwin->summaryview);
2398 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2401 summary_mark_as_read(mainwin->summaryview);
2404 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2407 summary_mark_all_read(mainwin->summaryview);
2410 static void add_address_cb(MainWindow *mainwin, guint action,
2413 summary_add_address(mainwin->summaryview);
2416 static void set_charset_cb(MainWindow *mainwin, guint action,
2421 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2422 str = conv_get_charset_str((CharSet)action);
2423 g_free(prefs_common.force_charset);
2424 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2426 summary_redisplay_msg(mainwin->summaryview);
2428 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2432 static void hide_read_messages (MainWindow *mainwin, guint action,
2435 if (!mainwin->summaryview->folder_item
2436 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2438 summary_toggle_show_read_messages(mainwin->summaryview);
2441 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2443 if (mainwin->menu_lock_count) return;
2444 if (!mainwin->summaryview->folder_item) return;
2446 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2447 summary_thread_build(mainwin->summaryview);
2448 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2450 summary_unthread(mainwin->summaryview);
2451 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2455 static void expand_threads_cb(MainWindow *mainwin, guint action,
2458 summary_expand_threads(mainwin->summaryview);
2461 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2464 summary_collapse_threads(mainwin->summaryview);
2467 static void set_display_item_cb(MainWindow *mainwin, guint action,
2470 prefs_summary_column_open();
2473 static void sort_summary_cb(MainWindow *mainwin, guint action,
2476 FolderItem *item = mainwin->summaryview->folder_item;
2477 GtkWidget *menuitem;
2479 if (mainwin->menu_lock_count) return;
2481 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2482 menuitem = gtk_item_factory_get_item
2483 (mainwin->menu_factory, "/View/Sort/Ascending");
2484 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2485 GTK_CHECK_MENU_ITEM(menuitem)->active
2486 ? SORT_ASCENDING : SORT_DESCENDING);
2490 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2493 FolderItem *item = mainwin->summaryview->folder_item;
2495 if (mainwin->menu_lock_count) return;
2497 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2498 summary_sort(mainwin->summaryview,
2499 item->sort_key, (FolderSortType)action);
2502 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2505 summary_attract_by_subject(mainwin->summaryview);
2508 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2511 summary_delete_duplicated(mainwin->summaryview);
2514 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2516 summary_filter(mainwin->summaryview);
2519 static void execute_summary_cb(MainWindow *mainwin, guint action,
2522 summary_execute(mainwin->summaryview);
2525 static void update_summary_cb(MainWindow *mainwin, guint action,
2529 FolderView *folderview = mainwin->folderview;
2531 if (!mainwin->summaryview->folder_item) return;
2532 if (!folderview->opened) return;
2534 folder_update_op_count();
2536 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2537 folderview->opened);
2540 folder_item_scan(fitem);
2541 summary_show(mainwin->summaryview, fitem);
2544 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2546 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2549 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2551 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2554 static void prev_unread_cb(MainWindow *mainwin, guint action,
2557 summary_select_prev_unread(mainwin->summaryview);
2560 static void next_unread_cb(MainWindow *mainwin, guint action,
2563 summary_select_next_unread(mainwin->summaryview);
2566 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2568 summary_select_prev_new(mainwin->summaryview);
2571 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2573 summary_select_next_new(mainwin->summaryview);
2576 static void prev_marked_cb(MainWindow *mainwin, guint action,
2579 summary_select_prev_marked(mainwin->summaryview);
2582 static void next_marked_cb(MainWindow *mainwin, guint action,
2585 summary_select_next_marked(mainwin->summaryview);
2588 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2591 summary_select_prev_labeled(mainwin->summaryview);
2594 static void next_labeled_cb(MainWindow *mainwin, guint action,
2597 summary_select_next_labeled(mainwin->summaryview);
2600 static void goto_folder_cb(MainWindow *mainwin, guint action,
2603 FolderItem *to_folder;
2605 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2608 folderview_select(mainwin->folderview, to_folder);
2611 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2613 messageview_copy_clipboard(mainwin->messageview);
2616 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2618 MessageView *msgview = mainwin->messageview;
2620 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2621 summary_select_all(mainwin->summaryview);
2622 else if (messageview_is_visible(msgview) &&
2623 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2624 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2625 messageview_select_all(mainwin->messageview);
2628 static void select_thread_cb(MainWindow *mainwin, guint action,
2631 summary_select_thread(mainwin->summaryview);
2634 static void create_filter_cb(MainWindow *mainwin, guint action,
2637 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2640 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2643 prefs_common_open();
2646 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2649 prefs_scoring_open(NULL);
2652 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2655 prefs_filtering_open(NULL, NULL, NULL);
2658 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2661 prefs_template_open();
2664 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2667 prefs_actions_open(mainwin);
2670 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2673 ssl_manager_open(mainwin);
2676 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2680 new_account_cb(mainwin, 0, widget);
2682 account_open(cur_account);
2686 static void new_account_cb(MainWindow *mainwin, guint action,
2689 account_edit_open();
2690 if (!compose_get_compose_list()) account_add();
2693 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2695 cur_account = (PrefsAccount *)data;
2696 main_window_reflect_prefs_all();
2699 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2704 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2706 pluginwindow_create();
2709 static void manual_open_cb(MainWindow *mainwin, guint action,
2712 manual_open((ManualType)action);
2715 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2717 MainWindow *mainwin = (MainWindow *)data;
2721 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2722 LOCAL_FOLDER(folder)->rootpath,
2726 str = g_strdup_printf(_("Scanning folder %s ..."),
2727 LOCAL_FOLDER(folder)->rootpath);
2729 STATUSBAR_PUSH(mainwin, str);
2730 STATUSBAR_POP(mainwin);
2734 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2737 SummaryView *summary;
2739 g_return_val_if_fail(data, FALSE);
2740 summary = ((MainWindow *)data)->summaryview;
2741 g_return_val_if_fail(summary, FALSE);
2742 if (summary->selected != summary->displayed)
2743 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2747 #define BREAK_ON_MODIFIER_KEY() \
2748 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2750 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2753 MainWindow *mainwin = (MainWindow*) data;
2755 if (!mainwin || !event) return;
2757 switch (event->keyval) {
2758 case GDK_Q: /* Quit */
2759 BREAK_ON_MODIFIER_KEY();
2761 app_exit_cb(mainwin, 0, NULL);
2764 if (mainwin->folderview && mainwin->summaryview
2765 && !mainwin->summaryview->displayed) {
2766 summary_lock(mainwin->summaryview);
2767 folderview_select_next_unread(mainwin->folderview);
2768 summary_unlock(mainwin->summaryview);
2776 #undef BREAK_ON_MODIFIER_KEY
2779 * Harvest addresses for selected folder.
2781 static void addr_harvest_cb( MainWindow *mainwin,
2785 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2789 * Harvest addresses for selected messages in summary view.
2791 static void addr_harvest_msg_cb( MainWindow *mainwin,
2795 summary_harvest_address( mainwin->summaryview );
2799 *\brief get a MainWindow
2801 *\return MainWindow * The first mainwindow in the mainwin_list
2803 MainWindow *mainwindow_get_mainwindow(void)
2805 if (mainwin_list && mainwin_list->data)
2806 return (MainWindow *)(mainwin_list->data);
2811 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2813 ProgressData *data = (ProgressData *) source;
2814 MainWindow *mainwin = (MainWindow *) userdata;
2816 switch (data->cmd) {
2817 case PROGRESS_COMMAND_START:
2818 case PROGRESS_COMMAND_STOP:
2819 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2821 case PROGRESS_COMMAND_SET_PERCENTAGE:
2822 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2825 while (gtk_events_pending()) gtk_main_iteration ();