2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_actions.h"
64 #include "prefs_filtering.h"
65 #include "prefs_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "ssl_manager.h"
84 #include "sslcertwindow.h"
85 #include "prefs_gtk.h"
86 #include "pluginwindow.h"
88 #include "progressindicator.h"
90 #define AC_LABEL_WIDTH 240
92 /* list of all instantiated MainWindow */
93 static GList *mainwin_list = NULL;
95 static GdkCursor *watch_cursor;
97 static void main_window_menu_callback_block (MainWindow *mainwin);
98 static void main_window_menu_callback_unblock (MainWindow *mainwin);
100 static void main_window_show_cur_account (MainWindow *mainwin);
102 static void main_window_set_widgets (MainWindow *mainwin,
106 static void toolbar_account_button_pressed (GtkWidget *widget,
107 GdkEventButton *event,
110 static void ac_label_button_pressed (GtkWidget *widget,
111 GdkEventButton *event,
113 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
116 static gint main_window_close_cb (GtkWidget *widget,
119 static gint folder_window_close_cb (GtkWidget *widget,
122 static gint message_window_close_cb (GtkWidget *widget,
126 static void main_window_size_allocate_cb (GtkWidget *widget,
127 GtkAllocation *allocation,
129 static void folder_window_size_allocate_cb (GtkWidget *widget,
130 GtkAllocation *allocation,
132 static void message_window_size_allocate_cb (GtkWidget *widget,
133 GtkAllocation *allocation,
136 static void new_folder_cb (MainWindow *mainwin,
139 static void add_mbox_cb (MainWindow *mainwin,
142 static void rename_folder_cb (MainWindow *mainwin,
145 static void delete_folder_cb (MainWindow *mainwin,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void import_mbox_cb (MainWindow *mainwin,
157 static void export_mbox_cb (MainWindow *mainwin,
160 static void empty_trash_cb (MainWindow *mainwin,
164 static void save_as_cb (MainWindow *mainwin,
167 static void print_cb (MainWindow *mainwin,
170 static void app_exit_cb (MainWindow *mainwin,
174 static void search_cb (MainWindow *mainwin,
178 static void toggle_folder_cb (MainWindow *mainwin,
181 static void toggle_message_cb (MainWindow *mainwin,
184 static void toggle_toolbar_cb (MainWindow *mainwin,
187 static void toggle_statusbar_cb (MainWindow *mainwin,
190 static void separate_widget_cb (MainWindow *mainwin,
194 static void addressbook_open_cb (MainWindow *mainwin,
197 static void log_window_show_cb (MainWindow *mainwin,
201 static void inc_cancel_cb (MainWindow *mainwin,
205 static void open_msg_cb (MainWindow *mainwin,
209 static void view_source_cb (MainWindow *mainwin,
213 static void show_all_header_cb (MainWindow *mainwin,
217 static void reedit_cb (MainWindow *mainwin,
221 static void move_to_cb (MainWindow *mainwin,
224 static void copy_to_cb (MainWindow *mainwin,
227 static void delete_cb (MainWindow *mainwin,
231 static void cancel_cb (MainWindow *mainwin,
235 static void mark_cb (MainWindow *mainwin,
238 static void unmark_cb (MainWindow *mainwin,
242 static void mark_as_unread_cb (MainWindow *mainwin,
245 static void mark_as_read_cb (MainWindow *mainwin,
248 static void mark_all_read_cb (MainWindow *mainwin,
251 static void add_address_cb (MainWindow *mainwin,
255 static void set_charset_cb (MainWindow *mainwin,
259 static void hide_read_messages (MainWindow *mainwin,
263 static void thread_cb (MainWindow *mainwin,
266 static void expand_threads_cb (MainWindow *mainwin,
269 static void collapse_threads_cb (MainWindow *mainwin,
273 static void set_display_item_cb (MainWindow *mainwin,
276 static void sort_summary_cb (MainWindow *mainwin,
279 static void sort_summary_type_cb (MainWindow *mainwin,
282 static void attract_by_subject_cb(MainWindow *mainwin,
286 static void delete_duplicated_cb (MainWindow *mainwin,
289 static void filter_cb (MainWindow *mainwin,
292 static void execute_summary_cb (MainWindow *mainwin,
295 static void update_summary_cb (MainWindow *mainwin,
299 static void prev_cb (MainWindow *mainwin,
302 static void next_cb (MainWindow *mainwin,
305 static void next_unread_cb (MainWindow *mainwin,
308 static void prev_unread_cb (MainWindow *mainwin,
312 static void prev_new_cb (MainWindow *mainwin,
315 static void next_new_cb (MainWindow *mainwin,
318 static void prev_marked_cb (MainWindow *mainwin,
321 static void next_marked_cb (MainWindow *mainwin,
324 static void prev_labeled_cb (MainWindow *mainwin,
327 static void next_labeled_cb (MainWindow *mainwin,
331 static void goto_folder_cb (MainWindow *mainwin,
335 static void copy_cb (MainWindow *mainwin,
338 static void allsel_cb (MainWindow *mainwin,
341 static void select_thread_cb (MainWindow *mainwin,
345 static void create_filter_cb (MainWindow *mainwin,
349 static void prefs_common_open_cb (MainWindow *mainwin,
352 static void prefs_template_open_cb (MainWindow *mainwin,
355 static void prefs_actions_open_cb (MainWindow *mainwin,
358 static void prefs_account_open_cb (MainWindow *mainwin,
361 static void prefs_scoring_open_cb (MainWindow *mainwin,
364 static void prefs_filtering_open_cb (MainWindow *mainwin,
368 static void ssl_manager_open_cb (MainWindow *mainwin,
372 static void new_account_cb (MainWindow *mainwin,
376 static void account_menu_cb (GtkMenuItem *menuitem,
379 static void prefs_open_cb (GtkMenuItem *menuitem,
381 static void plugins_open_cb (GtkMenuItem *menuitem,
384 static void online_switch_clicked(GtkButton *btn,
387 static void manual_open_cb (MainWindow *mainwin,
391 static void scan_tree_func (Folder *folder,
395 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
397 static void addr_harvest_cb ( MainWindow *mainwin,
401 static void addr_harvest_msg_cb ( MainWindow *mainwin,
405 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
406 GdkEventFocus *focus,
408 void main_window_reply_cb (MainWindow *mainwin,
411 gboolean mainwindow_progressindicator_hook (gpointer source,
413 #define SEPARATE_ACTION 500
415 static GtkItemFactoryEntry mainwin_entries[] =
417 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
418 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
419 {N_("/_File/_Folder/Create _new folder..."),
420 NULL, new_folder_cb, 0, NULL},
421 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
422 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
423 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
424 {N_("/_File/_Folder/_Check for new messages in all folders"),
425 NULL, update_folderview_cb, 0, NULL},
426 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
427 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
428 {N_("/_File/_Add mailbox/mbox..."), NULL, add_mbox_cb, 0, NULL},
429 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
430 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
431 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
432 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
433 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
434 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
435 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
436 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
437 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
438 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
440 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
441 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
442 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
443 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
444 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
445 {N_("/_Edit/_Find in current message..."),
446 "<control>F", search_cb, 0, NULL},
447 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
448 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
449 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
450 {N_("/_View/Show or hi_de/_Folder tree"),
451 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
452 {N_("/_View/Show or hi_de/_Message view"),
453 "V", toggle_message_cb, 0, "<ToggleItem>"},
454 {N_("/_View/Show or hi_de/_Toolbar"),
455 NULL, NULL, 0, "<Branch>"},
456 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
457 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
458 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
459 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
460 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
461 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
462 {N_("/_View/Show or hi_de/_Toolbar/_None"),
463 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
464 {N_("/_View/Show or hi_de/Status _bar"),
465 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
466 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
467 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
468 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
469 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
470 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
471 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
472 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
473 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
474 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
475 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
476 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
477 {N_("/_View/_Sort/by _color label"),
478 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
479 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
480 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
481 {N_("/_View/_Sort/by a_ttachment"),
482 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
483 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
484 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
485 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
486 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
488 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
489 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_View/_Sort/_Attract by subject"),
491 NULL, attract_by_subject_cb, 0, NULL},
492 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
493 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
494 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
495 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
496 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
498 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
501 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
502 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
503 {N_("/_View/_Go to/P_rev unread message"),
504 "<shift>P", prev_unread_cb, 0, NULL},
505 {N_("/_View/_Go to/N_ext unread message"),
506 "<shift>N", next_unread_cb, 0, NULL},
507 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
509 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
510 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_View/_Go to/Prev _marked message"),
512 NULL, prev_marked_cb, 0, NULL},
513 {N_("/_View/_Go to/Next m_arked message"),
514 NULL, next_marked_cb, 0, NULL},
515 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_View/_Go to/Prev _labeled message"),
517 NULL, prev_labeled_cb, 0, NULL},
518 {N_("/_View/_Go to/Next la_beled message"),
519 NULL, next_labeled_cb, 0, NULL},
520 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
522 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
524 #define CODESET_SEPARATOR \
525 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
526 #define CODESET_ACTION(action) \
527 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
529 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
530 {N_("/_View/_Code set/_Auto detect"),
531 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
532 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
534 CODESET_ACTION(C_US_ASCII)},
537 {N_("/_View/_Code set/Unicode (_UTF-8)"),
538 CODESET_ACTION(C_UTF_8)},
541 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
542 CODESET_ACTION(C_ISO_8859_1)},
543 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
544 CODESET_ACTION(C_ISO_8859_15)},
547 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
548 CODESET_ACTION(C_ISO_8859_2)},
550 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
551 CODESET_ACTION(C_ISO_8859_13)},
552 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
553 CODESET_ACTION(C_ISO_8859_4)},
555 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
556 CODESET_ACTION(C_ISO_8859_7)},
558 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
559 CODESET_ACTION(C_ISO_8859_9)},
561 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
562 CODESET_ACTION(C_ISO_8859_5)},
563 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
564 CODESET_ACTION(C_KOI8_R)},
565 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
566 CODESET_ACTION(C_WINDOWS_1251)},
569 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
570 CODESET_ACTION(C_ISO_2022_JP)},
572 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
573 CODESET_ACTION(C_ISO_2022_JP_2)},
575 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
576 CODESET_ACTION(C_EUC_JP)},
577 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
578 CODESET_ACTION(C_SHIFT_JIS)},
581 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
582 CODESET_ACTION(C_GB2312)},
583 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
584 CODESET_ACTION(C_BIG5)},
585 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
586 CODESET_ACTION(C_EUC_TW)},
587 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
588 CODESET_ACTION(C_ISO_2022_CN)},
590 {N_("/_View/_Code set/Korean (EUC-_KR)"),
591 CODESET_ACTION(C_EUC_KR)},
592 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
593 CODESET_ACTION(C_ISO_2022_KR)},
595 {N_("/_View/_Code set/Thai (TIS-620)"),
596 CODESET_ACTION(C_TIS_620)},
597 {N_("/_View/_Code set/Thai (Windows-874)"),
598 CODESET_ACTION(C_WINDOWS_874)},
601 #undef CODESET_SEPARATOR
602 #undef CODESET_ACTION
604 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
606 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
607 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
608 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
611 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
612 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
613 {N_("/_Message/Get from _all accounts"),
614 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
615 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
616 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
617 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
618 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
620 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
621 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
622 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
623 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
624 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
625 {N_("/_Message/Repl_y to/mailing _list"),
626 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
627 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
628 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
629 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
630 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
631 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
632 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
633 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
634 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
635 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
636 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
637 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
638 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
640 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
641 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
642 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
643 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
644 {N_("/_Message/_Mark/Mark as rea_d"),
645 NULL, mark_as_read_cb, 0, NULL},
646 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
648 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
649 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
650 {N_("/_Tools/Add sender to address boo_k"),
651 NULL, add_address_cb, 0, NULL},
652 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
653 {N_("/_Tools/_Harvest addresses/from _Folder..."),
654 NULL, addr_harvest_cb, 0, NULL},
655 {N_("/_Tools/_Harvest addresses/from _Messages..."),
656 NULL, addr_harvest_msg_cb, 0, NULL},
657 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
658 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
659 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
660 {N_("/_Tools/_Create filter rule/_Automatically"),
661 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
662 {N_("/_Tools/_Create filter rule/by _From"),
663 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
664 {N_("/_Tools/_Create filter rule/by _To"),
665 NULL, create_filter_cb, FILTER_BY_TO, NULL},
666 {N_("/_Tools/_Create filter rule/by _Subject"),
667 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
668 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
669 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Tools/Delete du_plicated messages"),
672 NULL, delete_duplicated_cb, 0, NULL},
673 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
676 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
677 {N_("/_Tools/SSL certi_ficates..."),
678 NULL, ssl_manager_open_cb, 0, NULL},
680 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
683 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
684 {N_("/_Configuration/C_hange current account"),
685 NULL, NULL, 0, "<Branch>"},
686 {N_("/_Configuration/_Preferences for current account..."),
687 NULL, prefs_account_open_cb, 0, NULL},
688 {N_("/_Configuration/Create _new account..."),
689 NULL, new_account_cb, 0, NULL},
690 {N_("/_Configuration/_Edit accounts..."),
691 NULL, account_edit_open, 0, NULL},
692 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
693 {N_("/_Configuration/_Common preferences..."),
694 NULL, prefs_common_open_cb, 0, NULL},
695 {N_("/_Configuration/_Scoring..."),
696 NULL, prefs_scoring_open_cb, 0, NULL},
697 {N_("/_Configuration/_Filtering..."),
698 NULL, prefs_filtering_open_cb, 0, NULL},
699 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
700 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
701 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
702 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
704 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
705 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
706 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
707 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
708 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
709 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
710 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
711 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
712 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
713 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
714 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
717 MainWindow *main_window_create(SeparateType type)
723 GtkWidget *handlebox;
724 GtkWidget *vbox_body;
725 GtkWidget *hbox_stat;
726 GtkWidget *statusbar;
727 GtkWidget *progressbar;
728 GtkWidget *statuslabel;
729 GtkWidget *ac_button;
731 GtkWidget *online_pixmap;
732 GtkWidget *offline_pixmap;
733 GtkWidget *online_switch;
734 GtkWidget *offline_switch;
735 GtkTooltips *offline_tip;
736 GtkTooltips *online_tip;
737 GtkTooltips *sel_ac_tip;
739 FolderView *folderview;
740 SummaryView *summaryview;
741 MessageView *messageview;
742 GdkColormap *colormap;
745 GtkItemFactory *ifactory;
749 guint n_menu_entries;
751 static GdkGeometry geometry;
753 debug_print("Creating main window...\n");
754 mainwin = g_new0(MainWindow, 1);
757 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
758 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
759 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
760 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
762 if (!geometry.min_height) {
763 geometry.min_width = 320;
764 geometry.min_height = 200;
766 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
769 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
770 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
771 MANAGE_WINDOW_SIGNALS_CONNECT(window);
772 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
773 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
775 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
776 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
778 gtk_widget_realize(window);
779 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
782 gtkut_widget_set_app_icon(window);
784 vbox = gtk_vbox_new(FALSE, 0);
785 gtk_widget_show(vbox);
786 gtk_container_add(GTK_CONTAINER(window), vbox);
789 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
790 menubar = menubar_create(window, mainwin_entries,
791 n_menu_entries, "<Main>", mainwin);
792 gtk_widget_show(menubar);
793 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
794 ifactory = gtk_item_factory_from_widget(menubar);
796 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
797 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
799 handlebox = gtk_handle_box_new();
800 gtk_widget_show(handlebox);
801 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
803 /* link window to mainwin->window to avoid gdk warnings */
804 mainwin->window = window;
807 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
811 /* vbox that contains body */
812 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
813 gtk_widget_show(vbox_body);
814 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
815 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
817 hbox_stat = gtk_hbox_new(FALSE, 2);
818 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
820 statusbar = statusbar_create();
821 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
823 progressbar = gtk_progress_bar_new();
824 gtk_widget_set_usize(progressbar, 120, 1);
825 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
827 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
828 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
829 online_tip = gtk_tooltips_new();
830 online_switch = gtk_button_new ();
831 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
832 online_switch, _("Go offline"), NULL);
833 offline_tip = gtk_tooltips_new();
834 offline_switch = gtk_button_new ();
835 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
836 offline_switch, _("Go online"), NULL);
837 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
838 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
839 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
840 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
841 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
842 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
843 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
844 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
846 statuslabel = gtk_label_new("");
847 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
849 sel_ac_tip = gtk_tooltips_new();
850 ac_button = gtk_button_new();
851 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
852 ac_button, _("Select account"), NULL);
853 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
854 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
855 gtk_widget_set_usize(ac_button, -1, 1);
856 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
857 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
858 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
860 ac_label = gtk_label_new("");
861 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
863 gtk_widget_show_all(hbox_stat);
865 gtk_widget_hide(offline_switch);
867 mainwin->folderview = folderview = folderview_create();
868 mainwin->summaryview = summaryview = summary_create();
869 mainwin->messageview = messageview = messageview_create(mainwin);
870 mainwin->logwin = log_window_create();
872 folderview->mainwin = mainwin;
873 folderview->summaryview = summaryview;
875 summaryview->mainwin = mainwin;
876 summaryview->folderview = folderview;
877 summaryview->messageview = messageview;
878 summaryview->window = window;
880 mainwin->vbox = vbox;
881 mainwin->menubar = menubar;
882 mainwin->menu_factory = ifactory;
883 mainwin->handlebox = handlebox;
884 mainwin->vbox_body = vbox_body;
885 mainwin->hbox_stat = hbox_stat;
886 mainwin->statusbar = statusbar;
887 mainwin->progressbar = progressbar;
888 mainwin->statuslabel = statuslabel;
889 mainwin->ac_button = ac_button;
890 mainwin->ac_label = ac_label;
892 mainwin->online_switch = online_switch;
893 mainwin->offline_switch = offline_switch;
894 mainwin->online_pixmap = online_pixmap;
895 mainwin->offline_pixmap = offline_pixmap;
897 /* set context IDs for status bar */
898 mainwin->mainwin_cid = gtk_statusbar_get_context_id
899 (GTK_STATUSBAR(statusbar), "Main Window");
900 mainwin->folderview_cid = gtk_statusbar_get_context_id
901 (GTK_STATUSBAR(statusbar), "Folder View");
902 mainwin->summaryview_cid = gtk_statusbar_get_context_id
903 (GTK_STATUSBAR(statusbar), "Summary View");
905 /* allocate colors for summary view and folder view */
906 summaryview->color_marked.red = summaryview->color_marked.green = 0;
907 summaryview->color_marked.blue = (guint16)65535;
909 summaryview->color_dim.red = summaryview->color_dim.green =
910 summaryview->color_dim.blue = COLOR_DIM;
912 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
913 &folderview->color_new);
915 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
916 &folderview->color_op);
918 summaryview->color_important.red = 0;
919 summaryview->color_important.green = 0;
920 summaryview->color_important.blue = (guint16)65535;
922 color[0] = summaryview->color_marked;
923 color[1] = summaryview->color_dim;
924 color[2] = folderview->color_new;
925 color[3] = folderview->color_op;
927 colormap = gdk_window_get_colormap(window->window);
928 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
929 for (i = 0; i < 4; i++) {
930 if (success[i] == FALSE)
931 g_warning("MainWindow: color allocation %d failed\n", i);
934 debug_print("done.\n");
936 messageview->visible = prefs_common.msgview_visible;
938 main_window_set_widgets(mainwin, type);
940 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
941 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
945 menuitem = gtk_item_factory_get_item
946 (ifactory, "/View/Code set/Auto detect");
947 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
949 switch (prefs_common.toolbar_style) {
951 menuitem = gtk_item_factory_get_item
952 (ifactory, "/View/Show or hide/Toolbar/None");
955 menuitem = gtk_item_factory_get_item
956 (ifactory, "/View/Show or hide/Toolbar/Icon");
959 menuitem = gtk_item_factory_get_item
960 (ifactory, "/View/Show or hide/Toolbar/Text");
963 menuitem = gtk_item_factory_get_item
964 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
966 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
968 gtk_widget_hide(mainwin->hbox_stat);
969 menuitem = gtk_item_factory_get_item
970 (ifactory, "/View/Show or hide/Status bar");
971 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
972 prefs_common.show_statusbar);
974 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
976 if (prefs_common.show_searchbar) {
977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
978 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
979 gtk_widget_hide(summaryview->search_description);
982 /* set account selection menu */
983 ac_menu = gtk_item_factory_get_widget
984 (ifactory, "/Configuration/Change current account");
985 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
986 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
987 mainwin->ac_menu = ac_menu;
989 toolbar_main_set_sensitive(mainwin);
991 /* create actions menu */
992 action_update_mainwin_menu(ifactory, mainwin);
994 /* attach accel groups to main window */
995 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
996 gtk_window_add_accel_group \
998 gtk_item_factory_from_widget(menu)->accel_group)
1000 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
1002 /* connect the accelerators for equivalent
1003 menu items in different menus */
1004 menu_connect_identical_items();
1008 /* show main window */
1009 gtk_widget_show(mainwin->window);
1011 /* initialize views */
1012 folderview_init(folderview);
1013 summary_init(summaryview);
1014 messageview_init(messageview);
1015 log_window_init(mainwin->logwin);
1016 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1017 prefs_common.loglength);
1019 sslcertwindow_register_hook();
1021 mainwin->lock_count = 0;
1022 mainwin->menu_lock_count = 0;
1023 mainwin->cursor_count = 0;
1025 mainwin->progressindicator_hook =
1026 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1029 watch_cursor = gdk_cursor_new(GDK_WATCH);
1031 mainwin_list = g_list_append(mainwin_list, mainwin);
1033 /* init work_offline */
1034 if (prefs_common.work_offline)
1035 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1040 void main_window_cursor_wait(MainWindow *mainwin)
1043 if (mainwin->cursor_count == 0)
1044 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1046 mainwin->cursor_count++;
1051 void main_window_cursor_normal(MainWindow *mainwin)
1053 if (mainwin->cursor_count)
1054 mainwin->cursor_count--;
1056 if (mainwin->cursor_count == 0)
1057 gdk_window_set_cursor(mainwin->window->window, NULL);
1062 /* lock / unlock the user-interface */
1063 void main_window_lock(MainWindow *mainwin)
1065 if (mainwin->lock_count == 0)
1066 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1068 mainwin->lock_count++;
1070 main_window_set_menu_sensitive(mainwin);
1071 toolbar_main_set_sensitive(mainwin);
1074 void main_window_unlock(MainWindow *mainwin)
1076 if (mainwin->lock_count)
1077 mainwin->lock_count--;
1079 main_window_set_menu_sensitive(mainwin);
1080 toolbar_main_set_sensitive(mainwin);
1082 if (mainwin->lock_count == 0)
1083 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1086 static void main_window_menu_callback_block(MainWindow *mainwin)
1088 mainwin->menu_lock_count++;
1091 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1093 if (mainwin->menu_lock_count)
1094 mainwin->menu_lock_count--;
1097 void main_window_reflect_prefs_all(void)
1099 main_window_reflect_prefs_all_real(FALSE);
1102 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1105 MainWindow *mainwin;
1108 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1109 mainwin = (MainWindow *)cur->data;
1111 main_window_show_cur_account(mainwin);
1112 main_window_set_menu_sensitive(mainwin);
1113 toolbar_main_set_sensitive(mainwin);
1116 if (pixmap_theme_changed) {
1117 toolbar_update(TOOLBAR_MAIN, mainwin);
1118 messageview_reflect_prefs_pixmap_theme();
1119 compose_reflect_prefs_pixmap_theme();
1120 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1121 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1123 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1124 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1125 mainwin->online_pixmap);
1126 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1127 gtk_widget_show(pixmap);
1128 mainwin->online_pixmap = pixmap;
1129 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1130 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1131 mainwin->offline_pixmap);
1132 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1133 gtk_widget_show(pixmap);
1134 mainwin->offline_pixmap = pixmap;
1137 summary_redisplay_msg(mainwin->summaryview);
1138 headerview_set_visibility(mainwin->messageview->headerview,
1139 prefs_common.display_header_pane);
1143 void main_window_set_summary_column(void)
1146 MainWindow *mainwin;
1148 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1149 mainwin = (MainWindow *)cur->data;
1150 summary_set_column_order(mainwin->summaryview);
1154 void main_window_set_account_menu(GList *account_list)
1156 GList *cur, *cur_ac, *cur_item;
1157 GtkWidget *menuitem;
1158 MainWindow *mainwin;
1159 PrefsAccount *ac_prefs;
1161 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1162 mainwin = (MainWindow *)cur->data;
1164 /* destroy all previous menu item */
1165 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1166 while (cur_item != NULL) {
1167 GList *next = cur_item->next;
1168 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1172 for (cur_ac = account_list; cur_ac != NULL;
1173 cur_ac = cur_ac->next) {
1174 ac_prefs = (PrefsAccount *)cur_ac->data;
1176 menuitem = gtk_menu_item_new_with_label
1177 (ac_prefs->account_name
1178 ? ac_prefs->account_name : _("Untitled"));
1179 gtk_widget_show(menuitem);
1180 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1181 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1182 GTK_SIGNAL_FUNC(account_menu_cb),
1188 static void main_window_show_cur_account(MainWindow *mainwin)
1193 ac_name = g_strdup(cur_account
1194 ? (cur_account->account_name
1195 ? cur_account->account_name : _("Untitled"))
1199 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1201 buf = g_strdup(PROG_VERSION);
1202 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1205 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1206 gtk_widget_queue_resize(mainwin->ac_button);
1211 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1213 switch (mainwin->type) {
1214 case SEPARATE_FOLDER:
1215 return mainwin->win.sep_folder.folderwin;
1217 return mainwin->win.sep_both.folderwin;
1223 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1225 switch (mainwin->type) {
1226 case SEPARATE_MESSAGE:
1227 return mainwin->win.sep_message.messagewin;
1229 return mainwin->win.sep_both.messagewin;
1235 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1237 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1238 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1239 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1240 GtkWidget *message_wid = mainwin->messageview->vbox;
1242 debug_print("Changing window separation type from %d to %d\n",
1243 mainwin->type, type);
1245 if (mainwin->type == type) return;
1247 /* remove widgets from those containers */
1248 gtk_widget_ref(folder_wid);
1249 gtk_widget_ref(summary_wid);
1250 gtk_widget_ref(message_wid);
1251 gtkut_container_remove
1252 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1253 gtkut_container_remove
1254 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1255 gtkut_container_remove
1256 (GTK_CONTAINER(message_wid->parent), message_wid);
1258 /* clean containers */
1259 switch (mainwin->type) {
1261 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1263 case SEPARATE_FOLDER:
1264 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1265 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1267 case SEPARATE_MESSAGE:
1268 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1269 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1272 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1273 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1277 gtk_widget_hide(mainwin->window);
1278 main_window_set_widgets(mainwin, type);
1279 gtk_widget_show(mainwin->window);
1281 gtk_widget_unref(folder_wid);
1282 gtk_widget_unref(summary_wid);
1283 gtk_widget_unref(message_wid);
1286 void main_window_toggle_message_view(MainWindow *mainwin)
1288 SummaryView *summaryview = mainwin->summaryview;
1289 union CompositeWin *cwin = &mainwin->win;
1290 GtkWidget *vpaned = NULL;
1291 GtkWidget *container = NULL;
1292 GtkWidget *msgwin = NULL;
1294 switch (mainwin->type) {
1296 vpaned = cwin->sep_none.vpaned;
1297 container = cwin->sep_none.hpaned;
1299 case SEPARATE_FOLDER:
1300 vpaned = cwin->sep_folder.vpaned;
1301 container = mainwin->vbox_body;
1303 case SEPARATE_MESSAGE:
1304 msgwin = mainwin->win.sep_message.messagewin;
1307 msgwin = mainwin->win.sep_both.messagewin;
1312 if (GTK_WIDGET_VISIBLE(msgwin)) {
1313 gtk_widget_hide(msgwin);
1314 mainwin->messageview->visible = FALSE;
1315 summaryview->displayed = NULL;
1317 gtk_widget_show(msgwin);
1318 mainwin->messageview->visible = TRUE;
1320 } else if (vpaned->parent != NULL) {
1321 mainwin->messageview->visible = FALSE;
1322 summaryview->displayed = NULL;
1323 gtk_widget_ref(vpaned);
1324 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1325 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1326 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1327 GTK_ARROW_UP, GTK_SHADOW_OUT);
1329 mainwin->messageview->visible = TRUE;
1330 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1331 gtk_container_add(GTK_CONTAINER(container), vpaned);
1332 gtk_widget_unref(vpaned);
1333 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1334 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1337 main_window_set_menu_sensitive(mainwin);
1339 prefs_common.msgview_visible = mainwin->messageview->visible;
1341 gtk_widget_grab_focus(summaryview->ctree);
1344 void main_window_get_size(MainWindow *mainwin)
1346 GtkAllocation *allocation;
1348 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1350 if (allocation->width > 1 && allocation->height > 1) {
1351 prefs_common.summaryview_width = allocation->width;
1353 if ((mainwin->type == SEPARATE_NONE ||
1354 mainwin->type == SEPARATE_FOLDER) &&
1355 messageview_is_visible(mainwin->messageview))
1356 prefs_common.summaryview_height = allocation->height;
1358 prefs_common.mainview_width = allocation->width;
1361 allocation = &mainwin->window->allocation;
1362 if (allocation->width > 1 && allocation->height > 1) {
1363 prefs_common.mainview_height = allocation->height;
1364 prefs_common.mainwin_width = allocation->width;
1365 prefs_common.mainwin_height = allocation->height;
1368 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1369 if (allocation->width > 1 && allocation->height > 1) {
1370 prefs_common.folderview_width = allocation->width;
1371 prefs_common.folderview_height = allocation->height;
1374 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1375 if (allocation->width > 1 && allocation->height > 1) {
1376 prefs_common.msgview_width = allocation->width;
1377 prefs_common.msgview_height = allocation->height;
1380 debug_print("summaryview size: %d x %d\n",
1381 prefs_common.summaryview_width,
1382 prefs_common.summaryview_height);
1383 debug_print("folderview size: %d x %d\n",
1384 prefs_common.folderview_width,
1385 prefs_common.folderview_height);
1386 debug_print("messageview size: %d x %d\n",
1387 prefs_common.msgview_width,
1388 prefs_common.msgview_height);
1391 void main_window_get_position(MainWindow *mainwin)
1396 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1398 prefs_common.mainview_x = x;
1399 prefs_common.mainview_y = y;
1400 prefs_common.mainwin_x = x;
1401 prefs_common.mainwin_y = y;
1403 debug_print("main window position: %d, %d\n", x, y);
1405 window = main_window_get_folder_window(mainwin);
1407 gtkut_widget_get_uposition(window, &x, &y);
1408 prefs_common.folderwin_x = x;
1409 prefs_common.folderwin_y = y;
1410 debug_print("folder window position: %d, %d\n", x, y);
1412 window = main_window_get_message_window(mainwin);
1414 gtkut_widget_get_uposition(window, &x, &y);
1415 prefs_common.main_msgwin_x = x;
1416 prefs_common.main_msgwin_y = y;
1417 debug_print("message window position: %d, %d\n", x, y);
1421 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1427 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1428 folder = FOLDER(list->data);
1429 if (folder && folder->trash && folder->trash->total_msgs > 0)
1433 if (!has_trash) return;
1436 if (alertpanel(_("Empty trash"),
1437 _("Empty all messages in trash?"),
1438 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1440 manage_window_focus_in(mainwin->window, NULL, NULL);
1443 procmsg_empty_trash();
1445 if (mainwin->summaryview->folder_item &&
1446 mainwin->summaryview->folder_item->stype == F_TRASH)
1447 gtk_widget_grab_focus(mainwin->folderview->ctree);
1450 void main_window_add_mailbox(MainWindow *mainwin)
1455 path = input_dialog(_("Add mailbox"),
1456 _("Input the location of mailbox.\n"
1457 "If the existing mailbox is specified, it will be\n"
1458 "scanned automatically."),
1461 if (folder_find_from_path(path)) {
1462 alertpanel_error(_("The mailbox `%s' already exists."), path);
1466 folder = folder_new(folder_get_class_from_string("mh"),
1467 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1471 if (folder->klass->create_tree(folder) < 0) {
1472 alertpanel_error(_("Creation of the mailbox failed.\n"
1473 "Maybe some files already exist, or you don't have the permission to write there."));
1474 folder_destroy(folder);
1479 folder_set_ui_func(folder, scan_tree_func, mainwin);
1480 folder_scan_tree(folder);
1481 folder_set_ui_func(folder, NULL, NULL);
1483 folderview_set(mainwin->folderview);
1486 void main_window_add_mbox(MainWindow *mainwin)
1491 path = input_dialog(_("Add mbox mailbox"),
1492 _("Input the location of mailbox."),
1497 if (folder_find_from_path(path)) {
1498 alertpanel_error(_("The mailbox `%s' already exists."), path);
1503 folder = folder_new(folder_get_class_from_string("mbox"),
1504 g_basename(path), path);
1507 if (folder->klass->create_tree(folder) < 0) {
1508 alertpanel_error(_("Creation of the mailbox failed."));
1509 folder_destroy(folder);
1515 folderview_set(mainwin->folderview);
1518 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1520 SensitiveCond state = 0;
1521 SummarySelection selection;
1522 FolderItem *item = mainwin->summaryview->folder_item;
1523 GList *account_list = account_get_list();
1525 selection = summary_get_selection_type(mainwin->summaryview);
1527 if (mainwin->lock_count == 0)
1528 state |= M_UNLOCKED;
1529 if (selection != SUMMARY_NONE)
1530 state |= M_MSG_EXIST;
1531 if (item && item->path && item->parent && !item->no_select) {
1533 /* if (item->folder->type != F_NEWS) */
1534 state |= M_ALLOW_DELETE;
1536 if (prefs_common.immediate_exec == 0
1537 && mainwin->lock_count == 0)
1538 state |= M_DELAY_EXEC;
1540 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1541 || selection != SUMMARY_NONE)
1542 state |= M_HIDE_READ_MSG;
1544 if (mainwin->summaryview->threaded)
1545 state |= M_THREADED;
1547 state |= M_UNTHREADED;
1548 if (selection == SUMMARY_SELECTED_SINGLE ||
1549 selection == SUMMARY_SELECTED_MULTIPLE)
1550 state |= M_TARGET_EXIST;
1551 if (selection == SUMMARY_SELECTED_SINGLE)
1552 state |= M_SINGLE_TARGET_EXIST;
1553 if (mainwin->summaryview->folder_item &&
1554 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1557 state |= M_NOT_NEWS;
1558 if (selection == SUMMARY_SELECTED_SINGLE &&
1560 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1561 item->stype == F_QUEUE)))
1562 state |= M_ALLOW_REEDIT;
1564 state |= M_HAVE_ACCOUNT;
1566 for ( ; account_list != NULL; account_list = account_list->next) {
1567 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1568 state |= M_HAVE_NEWS_ACCOUNT;
1573 if (inc_is_active())
1574 state |= M_INC_ACTIVE;
1581 void main_window_set_menu_sensitive(MainWindow *mainwin)
1583 GtkItemFactory *ifactory = mainwin->menu_factory;
1584 SensitiveCond state;
1586 GtkWidget *menuitem;
1587 SummaryView *summaryview;
1591 static const struct {
1595 {"/File/Folder" , M_UNLOCKED},
1596 {"/File/Add mailbox" , M_UNLOCKED},
1598 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1599 {"/File/Add mailbox/mbox..." , M_UNLOCKED},
1600 {"/File/Export to mbox file..." , M_UNLOCKED},
1601 {"/File/Empty trash" , M_UNLOCKED},
1602 {"/File/Work offline" , M_UNLOCKED},
1604 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1605 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1606 /* {"/File/Close" , M_UNLOCKED}, */
1607 {"/File/Exit" , M_UNLOCKED},
1609 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1611 {"/View/Sort" , M_EXEC},
1612 {"/View/Thread view" , M_EXEC},
1613 {"/View/Expand all threads" , M_MSG_EXIST},
1614 {"/View/Collapse all threads" , M_MSG_EXIST},
1615 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1616 {"/View/Go to/Prev message" , M_MSG_EXIST},
1617 {"/View/Go to/Next message" , M_MSG_EXIST},
1618 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1619 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1620 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1621 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1622 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1623 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1624 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1625 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1626 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1628 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1629 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1630 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1631 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1632 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1633 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1634 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1635 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1636 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1637 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1638 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1639 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1640 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1641 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1642 {"/Message/Mark" , M_TARGET_EXIST},
1644 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1645 {"/Tools/Harvest addresses" , M_UNLOCKED},
1646 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1647 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1648 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1649 {"/Tools/Execute" , M_DELAY_EXEC},
1650 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1652 {"/Configuration", M_UNLOCKED},
1657 state = main_window_get_current_state(mainwin);
1659 for (i = 0; entry[i].entry != NULL; i++) {
1660 sensitive = ((entry[i].cond & state) == entry[i].cond);
1661 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1664 main_window_menu_callback_block(mainwin);
1666 #define SET_CHECK_MENU_ACTIVE(path, active) \
1668 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1669 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1672 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1673 messageview_is_visible(mainwin->messageview));
1675 summaryview = mainwin->summaryview;
1676 menu_path = "/View/Sort/Don't sort";
1678 switch (summaryview->sort_key) {
1679 case SORT_BY_NUMBER:
1680 menu_path = "/View/Sort/by number"; break;
1682 menu_path = "/View/Sort/by size"; break;
1684 menu_path = "/View/Sort/by date"; break;
1686 menu_path = "/View/Sort/by from"; break;
1688 menu_path = "/View/Sort/by recipient"; break;
1689 case SORT_BY_SUBJECT:
1690 menu_path = "/View/Sort/by subject"; break;
1692 menu_path = "/View/Sort/by color label"; break;
1694 menu_path = "/View/Sort/by mark"; break;
1695 case SORT_BY_STATUS:
1696 menu_path = "/View/Sort/by status"; break;
1698 menu_path = "/View/Sort/by attachment"; break;
1700 menu_path = "/View/Sort/by score"; break;
1701 case SORT_BY_LOCKED:
1702 menu_path = "/View/Sort/by locked"; break;
1705 menu_path = "/View/Sort/Don't sort"; break;
1707 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1709 if (summaryview->sort_type == SORT_ASCENDING) {
1710 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1712 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1715 if (summaryview->sort_key != SORT_BY_NONE) {
1716 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1717 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1719 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1720 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1723 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1724 mainwin->messageview->mimeview->textview->show_all_headers);
1725 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1727 #undef SET_CHECK_MENU_ACTIVE
1729 main_window_menu_callback_unblock(mainwin);
1732 void main_window_popup(MainWindow *mainwin)
1734 gtkut_window_popup(mainwin->window);
1736 switch (mainwin->type) {
1737 case SEPARATE_FOLDER:
1738 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1740 case SEPARATE_MESSAGE:
1741 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1744 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1745 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1752 void main_window_show(MainWindow *mainwin)
1754 gtk_widget_show(mainwin->window);
1755 gtk_widget_show(mainwin->vbox_body);
1757 gtk_widget_set_uposition(mainwin->window,
1758 prefs_common.mainwin_x,
1759 prefs_common.mainwin_y);
1761 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1762 prefs_common.folderview_width,
1763 prefs_common.folderview_height);
1764 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1765 prefs_common.summaryview_width,
1766 prefs_common.summaryview_height);
1767 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1768 prefs_common.msgview_width,
1769 prefs_common.msgview_height);
1771 if (mainwin->type & SEPARATE_FOLDER) {
1772 GtkWidget *folderwin;
1774 folderwin = main_window_get_folder_window(mainwin);
1775 gtk_widget_show(folderwin);
1776 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1777 prefs_common.folderwin_y);
1780 if (mainwin->type & SEPARATE_MESSAGE) {
1781 GtkWidget *messagewin;
1783 messagewin = main_window_get_message_window(mainwin);
1784 gtk_widget_show(messagewin);
1785 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1786 prefs_common.main_msgwin_y);
1790 void main_window_hide(MainWindow *mainwin)
1792 main_window_get_size(mainwin);
1793 main_window_get_position(mainwin);
1795 gtk_widget_hide(mainwin->window);
1796 gtk_widget_hide(mainwin->vbox_body);
1798 if (mainwin->type & SEPARATE_FOLDER) {
1799 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1802 if (mainwin->type & SEPARATE_MESSAGE) {
1803 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1807 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1809 GtkWidget *folderwin = NULL;
1810 GtkWidget *messagewin = NULL;
1813 GtkWidget *vbox_body = mainwin->vbox_body;
1814 GtkItemFactory *ifactory = mainwin->menu_factory;
1815 GtkWidget *menuitem;
1816 GtkItemFactory *msgview_ifactory;
1818 debug_print("Setting widgets... ");
1820 /* create separated window(s) if needed */
1821 if (type & SEPARATE_FOLDER) {
1822 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1823 gtk_window_set_title(GTK_WINDOW(folderwin),
1824 _("Sylpheed - Folder View"));
1825 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1826 "folder_view", "Sylpheed");
1827 gtk_window_set_policy(GTK_WINDOW(folderwin),
1829 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1830 prefs_common.folderwin_y);
1831 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1833 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1834 GTK_SIGNAL_FUNC(folder_window_close_cb),
1836 gtk_container_add(GTK_CONTAINER(folderwin),
1837 GTK_WIDGET_PTR(mainwin->folderview));
1838 gtk_widget_realize(folderwin);
1839 if (prefs_common.folderview_visible)
1840 gtk_widget_show(folderwin);
1842 if (type & SEPARATE_MESSAGE) {
1843 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1844 gtk_window_set_title(GTK_WINDOW(messagewin),
1845 _("Sylpheed - Message View"));
1846 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1847 "message_view", "Sylpheed");
1848 gtk_window_set_policy(GTK_WINDOW(messagewin),
1850 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1851 prefs_common.main_msgwin_y);
1852 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1854 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1855 GTK_SIGNAL_FUNC(message_window_close_cb),
1857 if (messageview_is_visible(mainwin->messageview))
1858 gtk_widget_show(messagewin);
1861 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1862 prefs_common.folderview_width,
1863 prefs_common.folderview_height);
1864 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1865 prefs_common.summaryview_width,
1866 prefs_common.summaryview_height);
1867 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1868 prefs_common.msgview_width,
1869 prefs_common.msgview_height);
1873 hpaned = gtk_hpaned_new();
1874 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1875 gtk_paned_add1(GTK_PANED(hpaned),
1876 GTK_WIDGET_PTR(mainwin->folderview));
1877 gtk_widget_show(hpaned);
1878 gtk_widget_queue_resize(hpaned);
1880 vpaned = gtk_vpaned_new();
1881 if (messageview_is_visible(mainwin->messageview)) {
1882 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1883 gtk_paned_add1(GTK_PANED(vpaned),
1884 GTK_WIDGET_PTR(mainwin->summaryview));
1886 gtk_paned_add2(GTK_PANED(hpaned),
1887 GTK_WIDGET_PTR(mainwin->summaryview));
1888 gtk_widget_ref(vpaned);
1890 gtk_paned_add2(GTK_PANED(vpaned),
1891 GTK_WIDGET_PTR(mainwin->messageview));
1892 gtk_widget_show(vpaned);
1893 gtk_widget_queue_resize(vpaned);
1895 mainwin->win.sep_none.hpaned = hpaned;
1896 mainwin->win.sep_none.vpaned = vpaned;
1898 /* remove headerview if not in prefs */
1899 headerview_set_visibility(mainwin->messageview->headerview,
1900 prefs_common.display_header_pane);
1902 case SEPARATE_FOLDER:
1903 vpaned = gtk_vpaned_new();
1904 if (messageview_is_visible(mainwin->messageview)) {
1905 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1907 gtk_paned_add1(GTK_PANED(vpaned),
1908 GTK_WIDGET_PTR(mainwin->summaryview));
1910 gtk_box_pack_start(GTK_BOX(vbox_body),
1911 GTK_WIDGET_PTR(mainwin->summaryview),
1913 gtk_widget_ref(vpaned);
1915 gtk_paned_add2(GTK_PANED(vpaned),
1916 GTK_WIDGET_PTR(mainwin->messageview));
1917 gtk_widget_show(vpaned);
1918 gtk_widget_queue_resize(vpaned);
1920 mainwin->win.sep_folder.folderwin = folderwin;
1921 mainwin->win.sep_folder.vpaned = vpaned;
1923 /* remove headerview if not in prefs */
1924 headerview_set_visibility(mainwin->messageview->headerview,
1925 prefs_common.display_header_pane);
1928 case SEPARATE_MESSAGE:
1929 hpaned = gtk_hpaned_new();
1930 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1931 gtk_paned_add1(GTK_PANED(hpaned),
1932 GTK_WIDGET_PTR(mainwin->folderview));
1933 gtk_paned_add2(GTK_PANED(hpaned),
1934 GTK_WIDGET_PTR(mainwin->summaryview));
1935 gtk_widget_show(hpaned);
1936 gtk_widget_queue_resize(hpaned);
1937 messageview_add_toolbar(mainwin->messageview, messagewin);
1938 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1939 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1941 mainwin->win.sep_message.messagewin = messagewin;
1942 mainwin->win.sep_message.hpaned = hpaned;
1944 gtk_widget_realize(messagewin);
1945 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1946 gtk_widget_show_all(messagewin);
1947 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1948 mainwin->messageview->handlebox,
1949 prefs_common.toolbar_style);
1953 gtk_box_pack_start(GTK_BOX(vbox_body),
1954 GTK_WIDGET_PTR(mainwin->summaryview),
1957 mainwin->win.sep_both.folderwin = folderwin;
1958 mainwin->win.sep_both.messagewin = messagewin;
1963 gtk_widget_set_uposition(mainwin->window,
1964 prefs_common.mainwin_x,
1965 prefs_common.mainwin_y);
1967 gtk_widget_queue_resize(vbox_body);
1968 gtk_widget_queue_resize(mainwin->vbox);
1969 gtk_widget_queue_resize(mainwin->window);
1970 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1971 * and mimeview icon list/ctree lose track of their visibility states */
1972 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1973 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1974 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
1975 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
1977 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
1979 /* rehide quick search if necessary */
1980 if (!prefs_common.show_searchbar)
1981 gtk_widget_hide(mainwin->summaryview->hbox_search);
1983 mainwin->type = type;
1986 /* toggle menu state */
1987 menuitem = gtk_item_factory_get_item
1988 (ifactory, "/View/Show or hide/Folder tree");
1989 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1990 (type & SEPARATE_FOLDER) == 0 ? TRUE :
1991 prefs_common.folderview_visible);
1992 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
1993 menuitem = gtk_item_factory_get_item
1994 (ifactory, "/View/Show or hide/Message view");
1995 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1996 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
1997 prefs_common.msgview_visible);
1999 menuitem = gtk_item_factory_get_item
2000 (ifactory, "/View/Separate folder tree");
2001 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2002 ((type & SEPARATE_FOLDER) != 0));
2003 menuitem = gtk_item_factory_get_item
2004 (ifactory, "/View/Separate message view");
2005 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2006 ((type & SEPARATE_MESSAGE) != 0));
2010 (GTK_OBJECT(folderwin), "size_allocate",
2011 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
2016 (GTK_OBJECT(messagewin), "size_allocate",
2017 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
2021 debug_print("done.\n");
2024 void main_window_destroy_all(void)
2026 while (mainwin_list != NULL) {
2027 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2029 /* free toolbar stuff */
2030 toolbar_clear_list(TOOLBAR_MAIN);
2031 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2032 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2034 g_free(mainwin->toolbar);
2037 mainwin_list = g_list_remove(mainwin_list, mainwin);
2039 g_list_free(mainwin_list);
2043 static void toolbar_account_button_pressed(GtkWidget *widget,
2044 GdkEventButton *event,
2047 MainWindow *mainwin = (MainWindow *)data;
2050 if (event->button != 3) return;
2052 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2053 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2056 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2057 menu_button_position, widget,
2058 event->button, event->time);
2062 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2065 MainWindow *mainwin = (MainWindow *)data;
2069 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2070 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2073 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2074 menu_button_position, widget,
2075 event->button, event->time);
2078 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2080 MainWindow *mainwin = (MainWindow *)data;
2083 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2084 if (!button) return;
2085 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2086 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2087 manage_window_focus_in(mainwin->window, NULL, NULL);
2090 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2093 MainWindow *mainwin = (MainWindow *)data;
2095 if (mainwin->lock_count == 0)
2096 app_exit_cb(data, 0, widget);
2101 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2104 MainWindow *mainwin = (MainWindow *)data;
2105 GtkWidget *menuitem;
2107 menuitem = gtk_item_factory_get_item
2108 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2109 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2114 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2117 MainWindow *mainwin = (MainWindow *)data;
2118 GtkWidget *menuitem;
2120 menuitem = gtk_item_factory_get_item
2121 (mainwin->menu_factory, "/View/Show or hide/Message view");
2122 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2127 static void main_window_size_allocate_cb(GtkWidget *widget,
2128 GtkAllocation *allocation,
2131 MainWindow *mainwin = (MainWindow *)data;
2133 main_window_get_size(mainwin);
2136 static void folder_window_size_allocate_cb(GtkWidget *widget,
2137 GtkAllocation *allocation,
2140 MainWindow *mainwin = (MainWindow *)data;
2142 main_window_get_size(mainwin);
2145 static void message_window_size_allocate_cb(GtkWidget *widget,
2146 GtkAllocation *allocation,
2149 MainWindow *mainwin = (MainWindow *)data;
2151 main_window_get_size(mainwin);
2154 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2157 main_window_add_mailbox(mainwin);
2160 static void add_mbox_cb(MainWindow *mainwin, guint action,
2163 main_window_add_mbox(mainwin);
2166 static void update_folderview_cb(MainWindow *mainwin, guint action,
2169 summary_show(mainwin->summaryview, NULL);
2170 folderview_check_new_all();
2173 static void new_folder_cb(MainWindow *mainwin, guint action,
2176 folderview_new_folder(mainwin->folderview);
2179 static void rename_folder_cb(MainWindow *mainwin, guint action,
2182 folderview_rename_folder(mainwin->folderview);
2185 static void delete_folder_cb(MainWindow *mainwin, guint action,
2188 folderview_delete_folder(mainwin->folderview);
2191 static void import_mbox_cb(MainWindow *mainwin, guint action,
2194 import_mbox(mainwin->summaryview->folder_item);
2197 static void export_mbox_cb(MainWindow *mainwin, guint action,
2200 export_mbox(mainwin->summaryview->folder_item);
2203 static void empty_trash_cb(MainWindow *mainwin, guint action,
2206 main_window_empty_trash(mainwin, TRUE);
2209 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2211 summary_save_as(mainwin->summaryview);
2214 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2216 summary_print(mainwin->summaryview);
2219 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2221 if (prefs_common.confirm_on_exit) {
2222 if (alertpanel(_("Exit"), _("Exit this program?"),
2223 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2225 manage_window_focus_in(mainwin->window, NULL, NULL);
2228 app_will_exit(widget, mainwin);
2231 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2234 summary_search(mainwin->summaryview);
2236 message_search(mainwin->messageview);
2239 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2244 active = GTK_CHECK_MENU_ITEM(widget)->active;
2246 switch (mainwin->type) {
2248 case SEPARATE_MESSAGE:
2251 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2253 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2256 case SEPARATE_FOLDER:
2257 debug_print("separate folder\n");
2259 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2261 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2265 gtk_widget_show(mainwin->win.sep_both.folderwin);
2267 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2271 prefs_common.folderview_visible = active;
2274 static void toggle_message_cb(MainWindow *mainwin, guint action,
2279 active = GTK_CHECK_MENU_ITEM(widget)->active;
2281 if (active != messageview_is_visible(mainwin->messageview))
2282 summary_toggle_view(mainwin->summaryview);
2285 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2288 toolbar_toggle(action, mainwin);
2291 void main_window_reply_cb(MainWindow *mainwin, guint action,
2294 MessageView *msgview = (MessageView*)mainwin->messageview;
2295 GSList *msginfo_list = NULL;
2298 g_return_if_fail(msgview != NULL);
2300 msginfo_list = summary_get_selection(mainwin->summaryview);
2301 g_return_if_fail(msginfo_list != NULL);
2303 body = messageview_get_selection(msgview);
2304 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2306 g_slist_free(msginfo_list);
2310 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2313 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2314 gtk_widget_show(mainwin->hbox_stat);
2315 prefs_common.show_statusbar = TRUE;
2317 gtk_widget_hide(mainwin->hbox_stat);
2318 prefs_common.show_statusbar = FALSE;
2322 static void separate_widget_cb(MainWindow *mainwin, guint action,
2327 if (GTK_CHECK_MENU_ITEM(widget)->active)
2328 type = mainwin->type | action;
2330 type = mainwin->type & ~action;
2332 main_window_separation_change(mainwin, type);
2334 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2335 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2338 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2341 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2343 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2346 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2348 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2351 static void online_switch_clicked (GtkButton *btn, gpointer data)
2353 MainWindow *mainwin;
2354 GtkItemFactory *ifactory;
2355 GtkCheckMenuItem *menuitem;
2357 mainwin = (MainWindow *) data;
2359 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2360 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2362 g_return_if_fail(mainwin != NULL);
2363 g_return_if_fail(menuitem != NULL);
2365 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2367 gtk_widget_hide (mainwin->online_switch);
2368 gtk_widget_show (mainwin->offline_switch);
2369 menuitem->active = TRUE;
2370 prefs_common.work_offline = TRUE;
2371 inc_autocheck_timer_remove();
2374 gtk_widget_hide (mainwin->offline_switch);
2375 gtk_widget_show (mainwin->online_switch);
2376 menuitem->active = FALSE;
2377 prefs_common.work_offline = FALSE;
2378 inc_autocheck_timer_set();
2382 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2385 addressbook_open(NULL);
2388 static void log_window_show_cb(MainWindow *mainwin, guint action,
2391 log_window_show(mainwin->logwin);
2394 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2399 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2401 summary_move_to(mainwin->summaryview);
2404 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 summary_copy_to(mainwin->summaryview);
2409 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2411 summary_delete(mainwin->summaryview);
2414 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2416 summary_cancel(mainwin->summaryview);
2419 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2421 summary_open_msg(mainwin->summaryview);
2424 static void view_source_cb(MainWindow *mainwin, guint action,
2427 summary_view_source(mainwin->summaryview);
2430 static void show_all_header_cb(MainWindow *mainwin, guint action,
2433 if (mainwin->menu_lock_count) return;
2434 summary_display_msg_selected(mainwin->summaryview,
2435 GTK_CHECK_MENU_ITEM(widget)->active);
2438 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2440 summary_reedit(mainwin->summaryview);
2443 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2445 summary_mark(mainwin->summaryview);
2448 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2450 summary_unmark(mainwin->summaryview);
2453 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2456 summary_mark_as_unread(mainwin->summaryview);
2459 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2462 summary_mark_as_read(mainwin->summaryview);
2465 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2468 summary_mark_all_read(mainwin->summaryview);
2471 static void add_address_cb(MainWindow *mainwin, guint action,
2474 summary_add_address(mainwin->summaryview);
2477 static void set_charset_cb(MainWindow *mainwin, guint action,
2482 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2483 str = conv_get_charset_str((CharSet)action);
2484 g_free(prefs_common.force_charset);
2485 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2487 summary_redisplay_msg(mainwin->summaryview);
2489 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2493 static void hide_read_messages (MainWindow *mainwin, guint action,
2496 if (!mainwin->summaryview->folder_item
2497 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2499 summary_toggle_show_read_messages(mainwin->summaryview);
2502 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2504 if (mainwin->menu_lock_count) return;
2505 if (!mainwin->summaryview->folder_item) return;
2507 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2508 summary_thread_build(mainwin->summaryview);
2509 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2511 summary_unthread(mainwin->summaryview);
2512 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2516 static void expand_threads_cb(MainWindow *mainwin, guint action,
2519 summary_expand_threads(mainwin->summaryview);
2522 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2525 summary_collapse_threads(mainwin->summaryview);
2528 static void set_display_item_cb(MainWindow *mainwin, guint action,
2531 prefs_summary_column_open();
2534 static void sort_summary_cb(MainWindow *mainwin, guint action,
2537 FolderItem *item = mainwin->summaryview->folder_item;
2538 GtkWidget *menuitem;
2540 if (mainwin->menu_lock_count) return;
2542 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2543 menuitem = gtk_item_factory_get_item
2544 (mainwin->menu_factory, "/View/Sort/Ascending");
2545 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2546 GTK_CHECK_MENU_ITEM(menuitem)->active
2547 ? SORT_ASCENDING : SORT_DESCENDING);
2551 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2554 FolderItem *item = mainwin->summaryview->folder_item;
2556 if (mainwin->menu_lock_count) return;
2558 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2559 summary_sort(mainwin->summaryview,
2560 item->sort_key, (FolderSortType)action);
2563 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2566 summary_attract_by_subject(mainwin->summaryview);
2569 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2572 summary_delete_duplicated(mainwin->summaryview);
2575 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2577 summary_filter(mainwin->summaryview);
2580 static void execute_summary_cb(MainWindow *mainwin, guint action,
2583 summary_execute(mainwin->summaryview);
2586 static void update_summary_cb(MainWindow *mainwin, guint action,
2590 FolderView *folderview = mainwin->folderview;
2592 if (!mainwin->summaryview->folder_item) return;
2593 if (!folderview->opened) return;
2595 folder_update_op_count();
2597 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2598 folderview->opened);
2601 folder_item_scan(fitem);
2602 summary_show(mainwin->summaryview, fitem);
2605 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2607 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2610 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2615 static void prev_unread_cb(MainWindow *mainwin, guint action,
2618 summary_select_prev_unread(mainwin->summaryview);
2621 static void next_unread_cb(MainWindow *mainwin, guint action,
2624 summary_select_next_unread(mainwin->summaryview);
2627 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2629 summary_select_prev_new(mainwin->summaryview);
2632 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2634 summary_select_next_new(mainwin->summaryview);
2637 static void prev_marked_cb(MainWindow *mainwin, guint action,
2640 summary_select_prev_marked(mainwin->summaryview);
2643 static void next_marked_cb(MainWindow *mainwin, guint action,
2646 summary_select_next_marked(mainwin->summaryview);
2649 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2652 summary_select_prev_labeled(mainwin->summaryview);
2655 static void next_labeled_cb(MainWindow *mainwin, guint action,
2658 summary_select_next_labeled(mainwin->summaryview);
2661 static void goto_folder_cb(MainWindow *mainwin, guint action,
2664 FolderItem *to_folder;
2666 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2669 folderview_select(mainwin->folderview, to_folder);
2672 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2674 messageview_copy_clipboard(mainwin->messageview);
2677 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2679 MessageView *msgview = mainwin->messageview;
2681 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2682 summary_select_all(mainwin->summaryview);
2683 else if (messageview_is_visible(msgview) &&
2684 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2685 messageview_select_all(mainwin->messageview);
2688 static void select_thread_cb(MainWindow *mainwin, guint action,
2691 summary_select_thread(mainwin->summaryview);
2694 static void create_filter_cb(MainWindow *mainwin, guint action,
2697 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2700 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2703 prefs_common_open();
2706 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2709 prefs_scoring_open(NULL);
2712 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2715 prefs_filtering_open(NULL, NULL, NULL);
2718 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2721 prefs_template_open();
2724 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2727 prefs_actions_open(mainwin);
2730 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2733 ssl_manager_open(mainwin);
2736 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2740 new_account_cb(mainwin, 0, widget);
2742 account_open(cur_account);
2746 static void new_account_cb(MainWindow *mainwin, guint action,
2749 account_edit_open();
2750 if (!compose_get_compose_list()) account_add();
2753 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2755 cur_account = (PrefsAccount *)data;
2756 main_window_reflect_prefs_all();
2759 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2764 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2766 pluginwindow_create();
2769 static void manual_open_cb(MainWindow *mainwin, guint action,
2772 manual_open((ManualType)action);
2775 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2777 MainWindow *mainwin = (MainWindow *)data;
2781 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2782 LOCAL_FOLDER(folder)->rootpath,
2786 str = g_strdup_printf(_("Scanning folder %s ..."),
2787 LOCAL_FOLDER(folder)->rootpath);
2789 STATUSBAR_PUSH(mainwin, str);
2790 STATUSBAR_POP(mainwin);
2794 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2797 SummaryView *summary;
2799 g_return_val_if_fail(data, FALSE);
2800 summary = ((MainWindow *)data)->summaryview;
2801 g_return_val_if_fail(summary, FALSE);
2803 if (GTK_CLIST(summary->ctree)->selection &&
2804 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2807 if (summary->selected != summary->displayed)
2808 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2812 #define BREAK_ON_MODIFIER_KEY() \
2813 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2815 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2818 MainWindow *mainwin = (MainWindow*) data;
2820 if (!mainwin || !event) return;
2822 switch (event->keyval) {
2823 case GDK_Q: /* Quit */
2824 BREAK_ON_MODIFIER_KEY();
2826 app_exit_cb(mainwin, 0, NULL);
2829 if (mainwin->folderview && mainwin->summaryview
2830 && !mainwin->summaryview->displayed) {
2831 summary_lock(mainwin->summaryview);
2832 folderview_select_next_unread(mainwin->folderview);
2833 summary_unlock(mainwin->summaryview);
2841 #undef BREAK_ON_MODIFIER_KEY
2844 * Harvest addresses for selected folder.
2846 static void addr_harvest_cb( MainWindow *mainwin,
2850 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2854 * Harvest addresses for selected messages in summary view.
2856 static void addr_harvest_msg_cb( MainWindow *mainwin,
2860 summary_harvest_address( mainwin->summaryview );
2864 *\brief get a MainWindow
2866 *\return MainWindow * The first mainwindow in the mainwin_list
2868 MainWindow *mainwindow_get_mainwindow(void)
2870 if (mainwin_list && mainwin_list->data)
2871 return (MainWindow *)(mainwin_list->data);
2876 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2878 ProgressData *data = (ProgressData *) source;
2879 MainWindow *mainwin = (MainWindow *) userdata;
2881 switch (data->cmd) {
2882 case PROGRESS_COMMAND_START:
2883 case PROGRESS_COMMAND_STOP:
2884 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2886 case PROGRESS_COMMAND_SET_PERCENTAGE:
2887 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2890 while (gtk_events_pending()) gtk_main_iteration ();