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"
89 #include "localfolder.h"
91 #define AC_LABEL_WIDTH 240
93 /* list of all instantiated MainWindow */
94 static GList *mainwin_list = NULL;
96 static GdkCursor *watch_cursor;
98 static void main_window_menu_callback_block (MainWindow *mainwin);
99 static void main_window_menu_callback_unblock (MainWindow *mainwin);
101 static void main_window_show_cur_account (MainWindow *mainwin);
103 static void main_window_set_widgets (MainWindow *mainwin,
107 static void toolbar_account_button_pressed (GtkWidget *widget,
108 GdkEventButton *event,
111 static void ac_label_button_pressed (GtkWidget *widget,
112 GdkEventButton *event,
114 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
117 static gint main_window_close_cb (GtkWidget *widget,
120 static gint folder_window_close_cb (GtkWidget *widget,
123 static gint message_window_close_cb (GtkWidget *widget,
127 static void main_window_size_allocate_cb (GtkWidget *widget,
128 GtkAllocation *allocation,
130 static void folder_window_size_allocate_cb (GtkWidget *widget,
131 GtkAllocation *allocation,
133 static void message_window_size_allocate_cb (GtkWidget *widget,
134 GtkAllocation *allocation,
137 static void new_folder_cb (MainWindow *mainwin,
140 static void rename_folder_cb (MainWindow *mainwin,
143 static void delete_folder_cb (MainWindow *mainwin,
146 static void update_folderview_cb (MainWindow *mainwin,
149 static void add_mailbox_cb (MainWindow *mainwin,
152 static void import_mbox_cb (MainWindow *mainwin,
155 static void export_mbox_cb (MainWindow *mainwin,
158 static void empty_trash_cb (MainWindow *mainwin,
162 static void save_as_cb (MainWindow *mainwin,
165 static void print_cb (MainWindow *mainwin,
168 static void app_exit_cb (MainWindow *mainwin,
172 static void search_cb (MainWindow *mainwin,
176 static void toggle_folder_cb (MainWindow *mainwin,
179 static void toggle_message_cb (MainWindow *mainwin,
182 static void toggle_toolbar_cb (MainWindow *mainwin,
185 static void toggle_statusbar_cb (MainWindow *mainwin,
188 static void separate_widget_cb (MainWindow *mainwin,
192 static void addressbook_open_cb (MainWindow *mainwin,
195 static void log_window_show_cb (MainWindow *mainwin,
199 static void inc_cancel_cb (MainWindow *mainwin,
203 static void open_msg_cb (MainWindow *mainwin,
207 static void view_source_cb (MainWindow *mainwin,
211 static void show_all_header_cb (MainWindow *mainwin,
215 static void reedit_cb (MainWindow *mainwin,
219 static void move_to_cb (MainWindow *mainwin,
222 static void copy_to_cb (MainWindow *mainwin,
225 static void delete_cb (MainWindow *mainwin,
229 static void cancel_cb (MainWindow *mainwin,
233 static void mark_cb (MainWindow *mainwin,
236 static void unmark_cb (MainWindow *mainwin,
240 static void mark_as_unread_cb (MainWindow *mainwin,
243 static void mark_as_read_cb (MainWindow *mainwin,
246 static void mark_all_read_cb (MainWindow *mainwin,
249 static void add_address_cb (MainWindow *mainwin,
253 static void set_charset_cb (MainWindow *mainwin,
257 static void hide_read_messages (MainWindow *mainwin,
261 static void thread_cb (MainWindow *mainwin,
264 static void expand_threads_cb (MainWindow *mainwin,
267 static void collapse_threads_cb (MainWindow *mainwin,
271 static void set_display_item_cb (MainWindow *mainwin,
274 static void sort_summary_cb (MainWindow *mainwin,
277 static void sort_summary_type_cb (MainWindow *mainwin,
280 static void attract_by_subject_cb(MainWindow *mainwin,
284 static void delete_duplicated_cb (MainWindow *mainwin,
287 static void filter_cb (MainWindow *mainwin,
290 static void execute_summary_cb (MainWindow *mainwin,
293 static void update_summary_cb (MainWindow *mainwin,
297 static void prev_cb (MainWindow *mainwin,
300 static void next_cb (MainWindow *mainwin,
303 static void next_unread_cb (MainWindow *mainwin,
306 static void prev_unread_cb (MainWindow *mainwin,
310 static void prev_new_cb (MainWindow *mainwin,
313 static void next_new_cb (MainWindow *mainwin,
316 static void prev_marked_cb (MainWindow *mainwin,
319 static void next_marked_cb (MainWindow *mainwin,
322 static void prev_labeled_cb (MainWindow *mainwin,
325 static void next_labeled_cb (MainWindow *mainwin,
329 static void goto_folder_cb (MainWindow *mainwin,
333 static void copy_cb (MainWindow *mainwin,
336 static void allsel_cb (MainWindow *mainwin,
339 static void select_thread_cb (MainWindow *mainwin,
343 static void create_filter_cb (MainWindow *mainwin,
347 static void prefs_common_open_cb (MainWindow *mainwin,
350 static void prefs_template_open_cb (MainWindow *mainwin,
353 static void prefs_actions_open_cb (MainWindow *mainwin,
356 static void prefs_account_open_cb (MainWindow *mainwin,
359 static void prefs_scoring_open_cb (MainWindow *mainwin,
362 static void prefs_filtering_open_cb (MainWindow *mainwin,
366 static void ssl_manager_open_cb (MainWindow *mainwin,
370 static void new_account_cb (MainWindow *mainwin,
374 static void account_menu_cb (GtkMenuItem *menuitem,
377 static void prefs_open_cb (GtkMenuItem *menuitem,
379 static void plugins_open_cb (GtkMenuItem *menuitem,
382 static void online_switch_clicked(GtkButton *btn,
385 static void manual_open_cb (MainWindow *mainwin,
389 static void scan_tree_func (Folder *folder,
393 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
395 static void addr_harvest_cb ( MainWindow *mainwin,
399 static void addr_harvest_msg_cb ( MainWindow *mainwin,
403 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
404 GdkEventFocus *focus,
406 void main_window_reply_cb (MainWindow *mainwin,
409 gboolean mainwindow_progressindicator_hook (gpointer source,
411 #define SEPARATE_ACTION 500
413 static GtkItemFactoryEntry mainwin_entries[] =
415 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
416 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
417 {N_("/_File/_Folder/Create _new folder..."),
418 NULL, new_folder_cb, 0, NULL},
419 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
420 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
421 {N_("/_File/_Folder/---"), NULL, NULL, 0, "<Separator>"},
422 {N_("/_File/_Folder/_Check for new messages in all folders"),
423 NULL, update_folderview_cb, 0, NULL},
424 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
425 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
426 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
427 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
428 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
429 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
430 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
431 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
432 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
433 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
434 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
435 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
437 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
438 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
439 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
440 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
441 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
442 {N_("/_Edit/_Find in current message..."),
443 "<control>F", search_cb, 0, NULL},
444 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
445 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
446 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
447 {N_("/_View/Show or hi_de/_Folder tree"),
448 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
449 {N_("/_View/Show or hi_de/_Message view"),
450 "V", toggle_message_cb, 0, "<ToggleItem>"},
451 {N_("/_View/Show or hi_de/_Toolbar"),
452 NULL, NULL, 0, "<Branch>"},
453 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
454 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
455 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
456 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
457 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
458 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
459 {N_("/_View/Show or hi_de/_Toolbar/_None"),
460 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
461 {N_("/_View/Show or hi_de/Status _bar"),
462 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
463 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
464 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
465 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
466 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
467 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
468 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
469 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
470 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
471 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
472 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
473 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
474 {N_("/_View/_Sort/by _color label"),
475 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
476 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
477 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
478 {N_("/_View/_Sort/by a_ttachment"),
479 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
480 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
481 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
482 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
483 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
484 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
485 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
486 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_View/_Sort/_Attract by subject"),
488 NULL, attract_by_subject_cb, 0, NULL},
489 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
490 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
491 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
492 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
493 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
495 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
498 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
499 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_View/_Go to/P_rev unread message"),
501 "<shift>P", prev_unread_cb, 0, NULL},
502 {N_("/_View/_Go to/N_ext unread message"),
503 "<shift>N", next_unread_cb, 0, NULL},
504 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
505 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
506 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
507 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_View/_Go to/Prev _marked message"),
509 NULL, prev_marked_cb, 0, NULL},
510 {N_("/_View/_Go to/Next m_arked message"),
511 NULL, next_marked_cb, 0, NULL},
512 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_View/_Go to/Prev _labeled message"),
514 NULL, prev_labeled_cb, 0, NULL},
515 {N_("/_View/_Go to/Next la_beled message"),
516 NULL, next_labeled_cb, 0, NULL},
517 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
519 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
521 #define CODESET_SEPARATOR \
522 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
523 #define CODESET_ACTION(action) \
524 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
526 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
527 {N_("/_View/_Code set/_Auto detect"),
528 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
529 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
531 CODESET_ACTION(C_US_ASCII)},
534 {N_("/_View/_Code set/Unicode (_UTF-8)"),
535 CODESET_ACTION(C_UTF_8)},
538 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
539 CODESET_ACTION(C_ISO_8859_1)},
540 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
541 CODESET_ACTION(C_ISO_8859_15)},
544 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
545 CODESET_ACTION(C_ISO_8859_2)},
547 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
548 CODESET_ACTION(C_ISO_8859_13)},
549 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
550 CODESET_ACTION(C_ISO_8859_4)},
552 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
553 CODESET_ACTION(C_ISO_8859_7)},
555 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
556 CODESET_ACTION(C_ISO_8859_9)},
558 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
559 CODESET_ACTION(C_ISO_8859_5)},
560 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
561 CODESET_ACTION(C_KOI8_R)},
562 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
563 CODESET_ACTION(C_WINDOWS_1251)},
566 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
567 CODESET_ACTION(C_ISO_2022_JP)},
569 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
570 CODESET_ACTION(C_ISO_2022_JP_2)},
572 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
573 CODESET_ACTION(C_EUC_JP)},
574 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
575 CODESET_ACTION(C_SHIFT_JIS)},
578 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
579 CODESET_ACTION(C_GB2312)},
580 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
581 CODESET_ACTION(C_BIG5)},
582 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
583 CODESET_ACTION(C_EUC_TW)},
584 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
585 CODESET_ACTION(C_ISO_2022_CN)},
587 {N_("/_View/_Code set/Korean (EUC-_KR)"),
588 CODESET_ACTION(C_EUC_KR)},
589 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
590 CODESET_ACTION(C_ISO_2022_KR)},
592 {N_("/_View/_Code set/Thai (TIS-620)"),
593 CODESET_ACTION(C_TIS_620)},
594 {N_("/_View/_Code set/Thai (Windows-874)"),
595 CODESET_ACTION(C_WINDOWS_874)},
598 #undef CODESET_SEPARATOR
599 #undef CODESET_ACTION
601 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
602 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
603 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
604 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
605 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
608 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
609 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
610 {N_("/_Message/Get from _all accounts"),
611 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
612 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
613 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
615 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
616 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
617 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
618 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
619 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
620 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
621 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
622 {N_("/_Message/Repl_y to/mailing _list"),
623 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
624 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
625 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
626 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
627 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
628 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
629 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
630 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
632 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
633 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
634 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
635 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
636 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
637 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
638 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
639 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
641 {N_("/_Message/_Mark/Mark as rea_d"),
642 NULL, mark_as_read_cb, 0, NULL},
643 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
645 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
646 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
647 {N_("/_Tools/Add sender to address boo_k"),
648 NULL, add_address_cb, 0, NULL},
649 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
650 {N_("/_Tools/_Harvest addresses/from _Folder..."),
651 NULL, addr_harvest_cb, 0, NULL},
652 {N_("/_Tools/_Harvest addresses/from _Messages..."),
653 NULL, addr_harvest_msg_cb, 0, NULL},
654 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
655 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
656 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
657 {N_("/_Tools/_Create filter rule/_Automatically"),
658 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
659 {N_("/_Tools/_Create filter rule/by _From"),
660 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
661 {N_("/_Tools/_Create filter rule/by _To"),
662 NULL, create_filter_cb, FILTER_BY_TO, NULL},
663 {N_("/_Tools/_Create filter rule/by _Subject"),
664 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
665 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
666 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
667 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Tools/Delete du_plicated messages"),
669 NULL, delete_duplicated_cb, 0, NULL},
670 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
673 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Tools/SSL certi_ficates..."),
675 NULL, ssl_manager_open_cb, 0, NULL},
677 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
678 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
680 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
681 {N_("/_Configuration/C_hange current account"),
682 NULL, NULL, 0, "<Branch>"},
683 {N_("/_Configuration/_Preferences for current account..."),
684 NULL, prefs_account_open_cb, 0, NULL},
685 {N_("/_Configuration/Create _new account..."),
686 NULL, new_account_cb, 0, NULL},
687 {N_("/_Configuration/_Edit accounts..."),
688 NULL, account_edit_open, 0, NULL},
689 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Configuration/_Common preferences..."),
691 NULL, prefs_common_open_cb, 0, NULL},
692 {N_("/_Configuration/_Scoring..."),
693 NULL, prefs_scoring_open_cb, 0, NULL},
694 {N_("/_Configuration/_Filtering..."),
695 NULL, prefs_filtering_open_cb, 0, NULL},
696 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
697 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
698 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
699 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
701 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
702 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
703 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
704 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
705 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
706 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
707 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
708 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
709 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
710 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
711 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
714 MainWindow *main_window_create(SeparateType type)
720 GtkWidget *handlebox;
721 GtkWidget *vbox_body;
722 GtkWidget *hbox_stat;
723 GtkWidget *statusbar;
724 GtkWidget *progressbar;
725 GtkWidget *statuslabel;
726 GtkWidget *ac_button;
728 GtkWidget *online_pixmap;
729 GtkWidget *offline_pixmap;
730 GtkWidget *online_switch;
731 GtkWidget *offline_switch;
732 GtkTooltips *offline_tip;
733 GtkTooltips *online_tip;
734 GtkTooltips *sel_ac_tip;
736 FolderView *folderview;
737 SummaryView *summaryview;
738 MessageView *messageview;
739 GdkColormap *colormap;
742 GtkItemFactory *ifactory;
746 guint n_menu_entries;
748 static GdkGeometry geometry;
750 debug_print("Creating main window...\n");
751 mainwin = g_new0(MainWindow, 1);
754 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
755 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
756 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
757 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
759 if (!geometry.min_height) {
760 geometry.min_width = 320;
761 geometry.min_height = 200;
763 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
766 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
767 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
768 MANAGE_WINDOW_SIGNALS_CONNECT(window);
769 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
770 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
772 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
773 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
775 gtk_widget_realize(window);
776 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
779 gtkut_widget_set_app_icon(window);
781 vbox = gtk_vbox_new(FALSE, 0);
782 gtk_widget_show(vbox);
783 gtk_container_add(GTK_CONTAINER(window), vbox);
786 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
787 menubar = menubar_create(window, mainwin_entries,
788 n_menu_entries, "<Main>", mainwin);
789 gtk_widget_show(menubar);
790 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
791 ifactory = gtk_item_factory_from_widget(menubar);
793 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
794 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
796 handlebox = gtk_handle_box_new();
797 gtk_widget_show(handlebox);
798 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
800 /* link window to mainwin->window to avoid gdk warnings */
801 mainwin->window = window;
804 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
808 /* vbox that contains body */
809 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
810 gtk_widget_show(vbox_body);
811 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
812 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
814 hbox_stat = gtk_hbox_new(FALSE, 2);
815 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
817 statusbar = statusbar_create();
818 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
820 progressbar = gtk_progress_bar_new();
821 gtk_widget_set_usize(progressbar, 120, 1);
822 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
824 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
825 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
826 online_tip = gtk_tooltips_new();
827 online_switch = gtk_button_new ();
828 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
829 online_switch, _("Go offline"), NULL);
830 offline_tip = gtk_tooltips_new();
831 offline_switch = gtk_button_new ();
832 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
833 offline_switch, _("Go online"), NULL);
834 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
835 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
836 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
837 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
838 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
839 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
840 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
841 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
843 statuslabel = gtk_label_new("");
844 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
846 sel_ac_tip = gtk_tooltips_new();
847 ac_button = gtk_button_new();
848 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
849 ac_button, _("Select account"), NULL);
850 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
851 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
852 gtk_widget_set_usize(ac_button, -1, 1);
853 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
854 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
855 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
857 ac_label = gtk_label_new("");
858 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
860 gtk_widget_show_all(hbox_stat);
862 gtk_widget_hide(offline_switch);
864 mainwin->folderview = folderview = folderview_create();
865 mainwin->summaryview = summaryview = summary_create();
866 mainwin->messageview = messageview = messageview_create(mainwin);
867 mainwin->logwin = log_window_create();
869 folderview->mainwin = mainwin;
870 folderview->summaryview = summaryview;
872 summaryview->mainwin = mainwin;
873 summaryview->folderview = folderview;
874 summaryview->messageview = messageview;
875 summaryview->window = window;
877 mainwin->vbox = vbox;
878 mainwin->menubar = menubar;
879 mainwin->menu_factory = ifactory;
880 mainwin->handlebox = handlebox;
881 mainwin->vbox_body = vbox_body;
882 mainwin->hbox_stat = hbox_stat;
883 mainwin->statusbar = statusbar;
884 mainwin->progressbar = progressbar;
885 mainwin->statuslabel = statuslabel;
886 mainwin->ac_button = ac_button;
887 mainwin->ac_label = ac_label;
889 mainwin->online_switch = online_switch;
890 mainwin->offline_switch = offline_switch;
891 mainwin->online_pixmap = online_pixmap;
892 mainwin->offline_pixmap = offline_pixmap;
894 /* set context IDs for status bar */
895 mainwin->mainwin_cid = gtk_statusbar_get_context_id
896 (GTK_STATUSBAR(statusbar), "Main Window");
897 mainwin->folderview_cid = gtk_statusbar_get_context_id
898 (GTK_STATUSBAR(statusbar), "Folder View");
899 mainwin->summaryview_cid = gtk_statusbar_get_context_id
900 (GTK_STATUSBAR(statusbar), "Summary View");
902 /* allocate colors for summary view and folder view */
903 summaryview->color_marked.red = summaryview->color_marked.green = 0;
904 summaryview->color_marked.blue = (guint16)65535;
906 summaryview->color_dim.red = summaryview->color_dim.green =
907 summaryview->color_dim.blue = COLOR_DIM;
909 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
910 &folderview->color_new);
912 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
913 &folderview->color_op);
915 summaryview->color_important.red = 0;
916 summaryview->color_important.green = 0;
917 summaryview->color_important.blue = (guint16)65535;
919 color[0] = summaryview->color_marked;
920 color[1] = summaryview->color_dim;
921 color[2] = folderview->color_new;
922 color[3] = folderview->color_op;
924 colormap = gdk_window_get_colormap(window->window);
925 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
926 for (i = 0; i < 4; i++) {
927 if (success[i] == FALSE)
928 g_warning("MainWindow: color allocation %d failed\n", i);
931 debug_print("done.\n");
933 messageview->visible = prefs_common.msgview_visible;
935 main_window_set_widgets(mainwin, type);
937 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
938 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
942 menuitem = gtk_item_factory_get_item
943 (ifactory, "/View/Code set/Auto detect");
944 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
946 switch (prefs_common.toolbar_style) {
948 menuitem = gtk_item_factory_get_item
949 (ifactory, "/View/Show or hide/Toolbar/None");
952 menuitem = gtk_item_factory_get_item
953 (ifactory, "/View/Show or hide/Toolbar/Icon");
956 menuitem = gtk_item_factory_get_item
957 (ifactory, "/View/Show or hide/Toolbar/Text");
960 menuitem = gtk_item_factory_get_item
961 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
963 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
965 gtk_widget_hide(mainwin->hbox_stat);
966 menuitem = gtk_item_factory_get_item
967 (ifactory, "/View/Show or hide/Status bar");
968 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
969 prefs_common.show_statusbar);
971 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
973 if (prefs_common.show_searchbar) {
974 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
975 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
976 gtk_widget_hide(summaryview->search_description);
979 /* set account selection menu */
980 ac_menu = gtk_item_factory_get_widget
981 (ifactory, "/Configuration/Change current account");
982 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
983 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
984 mainwin->ac_menu = ac_menu;
986 toolbar_main_set_sensitive(mainwin);
988 /* create actions menu */
989 action_update_mainwin_menu(ifactory, mainwin);
991 /* attach accel groups to main window */
992 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
993 gtk_window_add_accel_group \
995 gtk_item_factory_from_widget(menu)->accel_group)
997 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
999 /* connect the accelerators for equivalent
1000 menu items in different menus */
1001 menu_connect_identical_items();
1005 /* show main window */
1006 gtk_widget_show(mainwin->window);
1008 /* initialize views */
1009 folderview_init(folderview);
1010 summary_init(summaryview);
1011 messageview_init(messageview);
1012 log_window_init(mainwin->logwin);
1013 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1014 prefs_common.loglength);
1016 sslcertwindow_register_hook();
1018 mainwin->lock_count = 0;
1019 mainwin->menu_lock_count = 0;
1020 mainwin->cursor_count = 0;
1022 mainwin->progressindicator_hook =
1023 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1026 watch_cursor = gdk_cursor_new(GDK_WATCH);
1028 mainwin_list = g_list_append(mainwin_list, mainwin);
1030 /* init work_offline */
1031 if (prefs_common.work_offline)
1032 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1037 void main_window_cursor_wait(MainWindow *mainwin)
1040 if (mainwin->cursor_count == 0)
1041 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1043 mainwin->cursor_count++;
1048 void main_window_cursor_normal(MainWindow *mainwin)
1050 if (mainwin->cursor_count)
1051 mainwin->cursor_count--;
1053 if (mainwin->cursor_count == 0)
1054 gdk_window_set_cursor(mainwin->window->window, NULL);
1059 /* lock / unlock the user-interface */
1060 void main_window_lock(MainWindow *mainwin)
1062 if (mainwin->lock_count == 0)
1063 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1065 mainwin->lock_count++;
1067 main_window_set_menu_sensitive(mainwin);
1068 toolbar_main_set_sensitive(mainwin);
1071 void main_window_unlock(MainWindow *mainwin)
1073 if (mainwin->lock_count)
1074 mainwin->lock_count--;
1076 main_window_set_menu_sensitive(mainwin);
1077 toolbar_main_set_sensitive(mainwin);
1079 if (mainwin->lock_count == 0)
1080 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1083 static void main_window_menu_callback_block(MainWindow *mainwin)
1085 mainwin->menu_lock_count++;
1088 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1090 if (mainwin->menu_lock_count)
1091 mainwin->menu_lock_count--;
1094 void main_window_reflect_prefs_all(void)
1096 main_window_reflect_prefs_all_real(FALSE);
1099 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1102 MainWindow *mainwin;
1105 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1106 mainwin = (MainWindow *)cur->data;
1108 main_window_show_cur_account(mainwin);
1109 main_window_set_menu_sensitive(mainwin);
1110 toolbar_main_set_sensitive(mainwin);
1113 if (pixmap_theme_changed) {
1114 toolbar_update(TOOLBAR_MAIN, mainwin);
1115 messageview_reflect_prefs_pixmap_theme();
1116 compose_reflect_prefs_pixmap_theme();
1117 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1118 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1120 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1121 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1122 mainwin->online_pixmap);
1123 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1124 gtk_widget_show(pixmap);
1125 mainwin->online_pixmap = pixmap;
1126 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1127 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1128 mainwin->offline_pixmap);
1129 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1130 gtk_widget_show(pixmap);
1131 mainwin->offline_pixmap = pixmap;
1134 summary_redisplay_msg(mainwin->summaryview);
1135 headerview_set_visibility(mainwin->messageview->headerview,
1136 prefs_common.display_header_pane);
1140 void main_window_set_summary_column(void)
1143 MainWindow *mainwin;
1145 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1146 mainwin = (MainWindow *)cur->data;
1147 summary_set_column_order(mainwin->summaryview);
1151 void main_window_set_account_menu(GList *account_list)
1153 GList *cur, *cur_ac, *cur_item;
1154 GtkWidget *menuitem;
1155 MainWindow *mainwin;
1156 PrefsAccount *ac_prefs;
1158 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1159 mainwin = (MainWindow *)cur->data;
1161 /* destroy all previous menu item */
1162 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1163 while (cur_item != NULL) {
1164 GList *next = cur_item->next;
1165 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1169 for (cur_ac = account_list; cur_ac != NULL;
1170 cur_ac = cur_ac->next) {
1171 ac_prefs = (PrefsAccount *)cur_ac->data;
1173 menuitem = gtk_menu_item_new_with_label
1174 (ac_prefs->account_name
1175 ? ac_prefs->account_name : _("Untitled"));
1176 gtk_widget_show(menuitem);
1177 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1178 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1179 GTK_SIGNAL_FUNC(account_menu_cb),
1185 static void main_window_show_cur_account(MainWindow *mainwin)
1190 ac_name = g_strdup(cur_account
1191 ? (cur_account->account_name
1192 ? cur_account->account_name : _("Untitled"))
1196 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1198 buf = g_strdup(PROG_VERSION);
1199 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1202 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1203 gtk_widget_queue_resize(mainwin->ac_button);
1208 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1210 switch (mainwin->type) {
1211 case SEPARATE_FOLDER:
1212 return mainwin->win.sep_folder.folderwin;
1214 return mainwin->win.sep_both.folderwin;
1220 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1222 switch (mainwin->type) {
1223 case SEPARATE_MESSAGE:
1224 return mainwin->win.sep_message.messagewin;
1226 return mainwin->win.sep_both.messagewin;
1232 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1234 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1235 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1236 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1237 GtkWidget *message_wid = mainwin->messageview->vbox;
1239 debug_print("Changing window separation type from %d to %d\n",
1240 mainwin->type, type);
1242 if (mainwin->type == type) return;
1244 /* remove widgets from those containers */
1245 gtk_widget_ref(folder_wid);
1246 gtk_widget_ref(summary_wid);
1247 gtk_widget_ref(message_wid);
1248 gtkut_container_remove
1249 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1250 gtkut_container_remove
1251 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1252 gtkut_container_remove
1253 (GTK_CONTAINER(message_wid->parent), message_wid);
1255 /* clean containers */
1256 switch (mainwin->type) {
1258 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1260 case SEPARATE_FOLDER:
1261 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1262 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1264 case SEPARATE_MESSAGE:
1265 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1266 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1269 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1270 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1274 gtk_widget_hide(mainwin->window);
1275 main_window_set_widgets(mainwin, type);
1276 gtk_widget_show(mainwin->window);
1278 gtk_widget_unref(folder_wid);
1279 gtk_widget_unref(summary_wid);
1280 gtk_widget_unref(message_wid);
1283 void main_window_toggle_message_view(MainWindow *mainwin)
1285 SummaryView *summaryview = mainwin->summaryview;
1286 union CompositeWin *cwin = &mainwin->win;
1287 GtkWidget *vpaned = NULL;
1288 GtkWidget *container = NULL;
1289 GtkWidget *msgwin = NULL;
1291 switch (mainwin->type) {
1293 vpaned = cwin->sep_none.vpaned;
1294 container = cwin->sep_none.hpaned;
1296 case SEPARATE_FOLDER:
1297 vpaned = cwin->sep_folder.vpaned;
1298 container = mainwin->vbox_body;
1300 case SEPARATE_MESSAGE:
1301 msgwin = mainwin->win.sep_message.messagewin;
1304 msgwin = mainwin->win.sep_both.messagewin;
1309 if (GTK_WIDGET_VISIBLE(msgwin)) {
1310 gtk_widget_hide(msgwin);
1311 mainwin->messageview->visible = FALSE;
1312 summaryview->displayed = NULL;
1314 gtk_widget_show(msgwin);
1315 mainwin->messageview->visible = TRUE;
1317 } else if (vpaned->parent != NULL) {
1318 mainwin->messageview->visible = FALSE;
1319 summaryview->displayed = NULL;
1320 gtk_widget_ref(vpaned);
1321 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1322 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1323 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1324 GTK_ARROW_UP, GTK_SHADOW_OUT);
1326 mainwin->messageview->visible = TRUE;
1327 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1328 gtk_container_add(GTK_CONTAINER(container), vpaned);
1329 gtk_widget_unref(vpaned);
1330 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1331 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1334 main_window_set_menu_sensitive(mainwin);
1336 prefs_common.msgview_visible = mainwin->messageview->visible;
1338 gtk_widget_grab_focus(summaryview->ctree);
1341 void main_window_get_size(MainWindow *mainwin)
1343 GtkAllocation *allocation;
1345 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1347 if (allocation->width > 1 && allocation->height > 1) {
1348 prefs_common.summaryview_width = allocation->width;
1350 if ((mainwin->type == SEPARATE_NONE ||
1351 mainwin->type == SEPARATE_FOLDER) &&
1352 messageview_is_visible(mainwin->messageview))
1353 prefs_common.summaryview_height = allocation->height;
1355 prefs_common.mainview_width = allocation->width;
1358 allocation = &mainwin->window->allocation;
1359 if (allocation->width > 1 && allocation->height > 1) {
1360 prefs_common.mainview_height = allocation->height;
1361 prefs_common.mainwin_width = allocation->width;
1362 prefs_common.mainwin_height = allocation->height;
1365 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1366 if (allocation->width > 1 && allocation->height > 1) {
1367 prefs_common.folderview_width = allocation->width;
1368 prefs_common.folderview_height = allocation->height;
1371 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1372 if (allocation->width > 1 && allocation->height > 1) {
1373 prefs_common.msgview_width = allocation->width;
1374 prefs_common.msgview_height = allocation->height;
1377 debug_print("summaryview size: %d x %d\n",
1378 prefs_common.summaryview_width,
1379 prefs_common.summaryview_height);
1380 debug_print("folderview size: %d x %d\n",
1381 prefs_common.folderview_width,
1382 prefs_common.folderview_height);
1383 debug_print("messageview size: %d x %d\n",
1384 prefs_common.msgview_width,
1385 prefs_common.msgview_height);
1388 void main_window_get_position(MainWindow *mainwin)
1393 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1395 prefs_common.mainview_x = x;
1396 prefs_common.mainview_y = y;
1397 prefs_common.mainwin_x = x;
1398 prefs_common.mainwin_y = y;
1400 debug_print("main window position: %d, %d\n", x, y);
1402 window = main_window_get_folder_window(mainwin);
1404 gtkut_widget_get_uposition(window, &x, &y);
1405 prefs_common.folderwin_x = x;
1406 prefs_common.folderwin_y = y;
1407 debug_print("folder window position: %d, %d\n", x, y);
1409 window = main_window_get_message_window(mainwin);
1411 gtkut_widget_get_uposition(window, &x, &y);
1412 prefs_common.main_msgwin_x = x;
1413 prefs_common.main_msgwin_y = y;
1414 debug_print("message window position: %d, %d\n", x, y);
1418 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1424 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1425 folder = FOLDER(list->data);
1426 if (folder && folder->trash && folder->trash->total_msgs > 0)
1430 if (!has_trash) return;
1433 if (alertpanel(_("Empty trash"),
1434 _("Empty all messages in trash?"),
1435 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1437 manage_window_focus_in(mainwin->window, NULL, NULL);
1440 procmsg_empty_trash();
1442 if (mainwin->summaryview->folder_item &&
1443 mainwin->summaryview->folder_item->stype == F_TRASH)
1444 gtk_widget_grab_focus(mainwin->folderview->ctree);
1447 void main_window_add_mailbox(MainWindow *mainwin)
1452 path = input_dialog(_("Add mailbox"),
1453 _("Input the location of mailbox.\n"
1454 "If the existing mailbox is specified, it will be\n"
1455 "scanned automatically."),
1458 if (folder_find_from_path(path)) {
1459 alertpanel_error(_("The mailbox `%s' already exists."), path);
1463 folder = folder_new(folder_get_class_from_string("mh"),
1464 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1468 if (folder->klass->create_tree(folder) < 0) {
1469 alertpanel_error(_("Creation of the mailbox failed.\n"
1470 "Maybe some files already exist, or you don't have the permission to write there."));
1471 folder_destroy(folder);
1476 folder_set_ui_func(folder, scan_tree_func, mainwin);
1477 folder_scan_tree(folder);
1478 folder_set_ui_func(folder, NULL, NULL);
1480 folderview_set(mainwin->folderview);
1483 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1485 SensitiveCond state = 0;
1486 SummarySelection selection;
1487 FolderItem *item = mainwin->summaryview->folder_item;
1488 GList *account_list = account_get_list();
1490 selection = summary_get_selection_type(mainwin->summaryview);
1492 if (mainwin->lock_count == 0)
1493 state |= M_UNLOCKED;
1494 if (selection != SUMMARY_NONE)
1495 state |= M_MSG_EXIST;
1496 if (item && item->path && item->parent && !item->no_select) {
1498 /* if (item->folder->type != F_NEWS) */
1499 state |= M_ALLOW_DELETE;
1501 if (prefs_common.immediate_exec == 0
1502 && mainwin->lock_count == 0)
1503 state |= M_DELAY_EXEC;
1505 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1506 || selection != SUMMARY_NONE)
1507 state |= M_HIDE_READ_MSG;
1509 if (mainwin->summaryview->threaded)
1510 state |= M_THREADED;
1512 state |= M_UNTHREADED;
1513 if (selection == SUMMARY_SELECTED_SINGLE ||
1514 selection == SUMMARY_SELECTED_MULTIPLE)
1515 state |= M_TARGET_EXIST;
1516 if (selection == SUMMARY_SELECTED_SINGLE)
1517 state |= M_SINGLE_TARGET_EXIST;
1518 if (mainwin->summaryview->folder_item &&
1519 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1522 state |= M_NOT_NEWS;
1523 if (selection == SUMMARY_SELECTED_SINGLE &&
1525 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1526 item->stype == F_QUEUE)))
1527 state |= M_ALLOW_REEDIT;
1529 state |= M_HAVE_ACCOUNT;
1531 for ( ; account_list != NULL; account_list = account_list->next) {
1532 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1533 state |= M_HAVE_NEWS_ACCOUNT;
1538 if (inc_is_active())
1539 state |= M_INC_ACTIVE;
1546 void main_window_set_menu_sensitive(MainWindow *mainwin)
1548 GtkItemFactory *ifactory = mainwin->menu_factory;
1549 SensitiveCond state;
1551 GtkWidget *menuitem;
1552 SummaryView *summaryview;
1556 static const struct {
1560 {"/File/Folder" , M_UNLOCKED},
1561 {"/File/Add mailbox" , M_UNLOCKED},
1563 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1564 {"/File/Export to mbox file..." , M_UNLOCKED},
1565 {"/File/Empty trash" , M_UNLOCKED},
1566 {"/File/Work offline" , M_UNLOCKED},
1568 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1569 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1570 /* {"/File/Close" , M_UNLOCKED}, */
1571 {"/File/Exit" , M_UNLOCKED},
1573 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1575 {"/View/Sort" , M_EXEC},
1576 {"/View/Thread view" , M_EXEC},
1577 {"/View/Expand all threads" , M_MSG_EXIST},
1578 {"/View/Collapse all threads" , M_MSG_EXIST},
1579 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1580 {"/View/Go to/Prev message" , M_MSG_EXIST},
1581 {"/View/Go to/Next message" , M_MSG_EXIST},
1582 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1583 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1584 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1585 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1586 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1587 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1588 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1589 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1590 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1592 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1593 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1594 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1595 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1596 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1597 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1598 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1599 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1600 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1601 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1602 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1603 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1604 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1605 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1606 {"/Message/Mark" , M_TARGET_EXIST},
1608 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1609 {"/Tools/Harvest addresses" , M_UNLOCKED},
1610 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1611 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1612 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1613 {"/Tools/Execute" , M_DELAY_EXEC},
1614 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1616 {"/Configuration", M_UNLOCKED},
1621 state = main_window_get_current_state(mainwin);
1623 for (i = 0; entry[i].entry != NULL; i++) {
1624 sensitive = ((entry[i].cond & state) == entry[i].cond);
1625 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1628 main_window_menu_callback_block(mainwin);
1630 #define SET_CHECK_MENU_ACTIVE(path, active) \
1632 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1633 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1636 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1637 messageview_is_visible(mainwin->messageview));
1639 summaryview = mainwin->summaryview;
1640 menu_path = "/View/Sort/Don't sort";
1642 switch (summaryview->sort_key) {
1643 case SORT_BY_NUMBER:
1644 menu_path = "/View/Sort/by number"; break;
1646 menu_path = "/View/Sort/by size"; break;
1648 menu_path = "/View/Sort/by date"; break;
1650 menu_path = "/View/Sort/by from"; break;
1652 menu_path = "/View/Sort/by recipient"; break;
1653 case SORT_BY_SUBJECT:
1654 menu_path = "/View/Sort/by subject"; break;
1656 menu_path = "/View/Sort/by color label"; break;
1658 menu_path = "/View/Sort/by mark"; break;
1659 case SORT_BY_STATUS:
1660 menu_path = "/View/Sort/by status"; break;
1662 menu_path = "/View/Sort/by attachment"; break;
1664 menu_path = "/View/Sort/by score"; break;
1665 case SORT_BY_LOCKED:
1666 menu_path = "/View/Sort/by locked"; break;
1669 menu_path = "/View/Sort/Don't sort"; break;
1671 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1673 if (summaryview->sort_type == SORT_ASCENDING) {
1674 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1676 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1679 if (summaryview->sort_key != SORT_BY_NONE) {
1680 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1681 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1683 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1684 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1687 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1688 mainwin->messageview->mimeview->textview->show_all_headers);
1689 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1691 #undef SET_CHECK_MENU_ACTIVE
1693 main_window_menu_callback_unblock(mainwin);
1696 void main_window_popup(MainWindow *mainwin)
1698 gtkut_window_popup(mainwin->window);
1700 switch (mainwin->type) {
1701 case SEPARATE_FOLDER:
1702 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1704 case SEPARATE_MESSAGE:
1705 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1708 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1709 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1716 void main_window_show(MainWindow *mainwin)
1718 gtk_widget_show(mainwin->window);
1719 gtk_widget_show(mainwin->vbox_body);
1721 gtk_widget_set_uposition(mainwin->window,
1722 prefs_common.mainwin_x,
1723 prefs_common.mainwin_y);
1725 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1726 prefs_common.folderview_width,
1727 prefs_common.folderview_height);
1728 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1729 prefs_common.summaryview_width,
1730 prefs_common.summaryview_height);
1731 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1732 prefs_common.msgview_width,
1733 prefs_common.msgview_height);
1735 if (mainwin->type & SEPARATE_FOLDER) {
1736 GtkWidget *folderwin;
1738 folderwin = main_window_get_folder_window(mainwin);
1739 gtk_widget_show(folderwin);
1740 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1741 prefs_common.folderwin_y);
1744 if (mainwin->type & SEPARATE_MESSAGE) {
1745 GtkWidget *messagewin;
1747 messagewin = main_window_get_message_window(mainwin);
1748 gtk_widget_show(messagewin);
1749 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1750 prefs_common.main_msgwin_y);
1754 void main_window_hide(MainWindow *mainwin)
1756 main_window_get_size(mainwin);
1757 main_window_get_position(mainwin);
1759 gtk_widget_hide(mainwin->window);
1760 gtk_widget_hide(mainwin->vbox_body);
1762 if (mainwin->type & SEPARATE_FOLDER) {
1763 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1766 if (mainwin->type & SEPARATE_MESSAGE) {
1767 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1771 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1773 GtkWidget *folderwin = NULL;
1774 GtkWidget *messagewin = NULL;
1777 GtkWidget *vbox_body = mainwin->vbox_body;
1778 GtkItemFactory *ifactory = mainwin->menu_factory;
1779 GtkWidget *menuitem;
1780 GtkItemFactory *msgview_ifactory;
1782 debug_print("Setting widgets... ");
1784 /* create separated window(s) if needed */
1785 if (type & SEPARATE_FOLDER) {
1786 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1787 gtk_window_set_title(GTK_WINDOW(folderwin),
1788 _("Sylpheed - Folder View"));
1789 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1790 "folder_view", "Sylpheed");
1791 gtk_window_set_policy(GTK_WINDOW(folderwin),
1793 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1794 prefs_common.folderwin_y);
1795 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1797 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1798 GTK_SIGNAL_FUNC(folder_window_close_cb),
1800 gtk_container_add(GTK_CONTAINER(folderwin),
1801 GTK_WIDGET_PTR(mainwin->folderview));
1802 gtk_widget_realize(folderwin);
1803 if (prefs_common.folderview_visible)
1804 gtk_widget_show(folderwin);
1806 if (type & SEPARATE_MESSAGE) {
1807 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1808 gtk_window_set_title(GTK_WINDOW(messagewin),
1809 _("Sylpheed - Message View"));
1810 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1811 "message_view", "Sylpheed");
1812 gtk_window_set_policy(GTK_WINDOW(messagewin),
1814 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1815 prefs_common.main_msgwin_y);
1816 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1818 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1819 GTK_SIGNAL_FUNC(message_window_close_cb),
1821 if (messageview_is_visible(mainwin->messageview))
1822 gtk_widget_show(messagewin);
1825 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1826 prefs_common.folderview_width,
1827 prefs_common.folderview_height);
1828 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1829 prefs_common.summaryview_width,
1830 prefs_common.summaryview_height);
1831 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1832 prefs_common.msgview_width,
1833 prefs_common.msgview_height);
1837 hpaned = gtk_hpaned_new();
1838 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1839 gtk_paned_add1(GTK_PANED(hpaned),
1840 GTK_WIDGET_PTR(mainwin->folderview));
1841 gtk_widget_show(hpaned);
1842 gtk_widget_queue_resize(hpaned);
1844 vpaned = gtk_vpaned_new();
1845 if (messageview_is_visible(mainwin->messageview)) {
1846 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1847 gtk_paned_add1(GTK_PANED(vpaned),
1848 GTK_WIDGET_PTR(mainwin->summaryview));
1850 gtk_paned_add2(GTK_PANED(hpaned),
1851 GTK_WIDGET_PTR(mainwin->summaryview));
1852 gtk_widget_ref(vpaned);
1854 gtk_paned_add2(GTK_PANED(vpaned),
1855 GTK_WIDGET_PTR(mainwin->messageview));
1856 gtk_widget_show(vpaned);
1857 gtk_widget_queue_resize(vpaned);
1859 mainwin->win.sep_none.hpaned = hpaned;
1860 mainwin->win.sep_none.vpaned = vpaned;
1862 /* remove headerview if not in prefs */
1863 headerview_set_visibility(mainwin->messageview->headerview,
1864 prefs_common.display_header_pane);
1866 case SEPARATE_FOLDER:
1867 vpaned = gtk_vpaned_new();
1868 if (messageview_is_visible(mainwin->messageview)) {
1869 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1871 gtk_paned_add1(GTK_PANED(vpaned),
1872 GTK_WIDGET_PTR(mainwin->summaryview));
1874 gtk_box_pack_start(GTK_BOX(vbox_body),
1875 GTK_WIDGET_PTR(mainwin->summaryview),
1877 gtk_widget_ref(vpaned);
1879 gtk_paned_add2(GTK_PANED(vpaned),
1880 GTK_WIDGET_PTR(mainwin->messageview));
1881 gtk_widget_show(vpaned);
1882 gtk_widget_queue_resize(vpaned);
1884 mainwin->win.sep_folder.folderwin = folderwin;
1885 mainwin->win.sep_folder.vpaned = vpaned;
1887 /* remove headerview if not in prefs */
1888 headerview_set_visibility(mainwin->messageview->headerview,
1889 prefs_common.display_header_pane);
1892 case SEPARATE_MESSAGE:
1893 hpaned = gtk_hpaned_new();
1894 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1895 gtk_paned_add1(GTK_PANED(hpaned),
1896 GTK_WIDGET_PTR(mainwin->folderview));
1897 gtk_paned_add2(GTK_PANED(hpaned),
1898 GTK_WIDGET_PTR(mainwin->summaryview));
1899 gtk_widget_show(hpaned);
1900 gtk_widget_queue_resize(hpaned);
1901 messageview_add_toolbar(mainwin->messageview, messagewin);
1902 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1903 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1905 mainwin->win.sep_message.messagewin = messagewin;
1906 mainwin->win.sep_message.hpaned = hpaned;
1908 gtk_widget_realize(messagewin);
1909 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1910 gtk_widget_show_all(messagewin);
1911 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1912 mainwin->messageview->handlebox,
1913 prefs_common.toolbar_style);
1917 messageview_add_toolbar(mainwin->messageview, messagewin);
1918 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1919 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1921 gtk_box_pack_start(GTK_BOX(vbox_body),
1922 GTK_WIDGET_PTR(mainwin->summaryview),
1925 mainwin->win.sep_both.folderwin = folderwin;
1926 mainwin->win.sep_both.messagewin = messagewin;
1928 gtk_widget_realize(messagewin);
1929 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
1930 gtk_widget_show_all(messagewin);
1931 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
1932 mainwin->messageview->handlebox,
1933 prefs_common.toolbar_style);
1938 gtk_widget_set_uposition(mainwin->window,
1939 prefs_common.mainwin_x,
1940 prefs_common.mainwin_y);
1942 gtk_widget_queue_resize(vbox_body);
1943 gtk_widget_queue_resize(mainwin->vbox);
1944 gtk_widget_queue_resize(mainwin->window);
1945 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1946 * and mimeview icon list/ctree lose track of their visibility states */
1947 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1948 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1949 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
1950 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
1951 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
1952 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
1954 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
1956 /* rehide quick search if necessary */
1957 if (!prefs_common.show_searchbar)
1958 gtk_widget_hide(mainwin->summaryview->hbox_search);
1960 mainwin->type = type;
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),
1967 (type & SEPARATE_FOLDER) == 0 ? TRUE :
1968 prefs_common.folderview_visible);
1969 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
1970 menuitem = gtk_item_factory_get_item
1971 (ifactory, "/View/Show or hide/Message view");
1972 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1973 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
1974 prefs_common.msgview_visible);
1976 menuitem = gtk_item_factory_get_item
1977 (ifactory, "/View/Separate folder tree");
1978 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1979 ((type & SEPARATE_FOLDER) != 0));
1980 menuitem = gtk_item_factory_get_item
1981 (ifactory, "/View/Separate message view");
1982 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1983 ((type & SEPARATE_MESSAGE) != 0));
1987 (GTK_OBJECT(folderwin), "size_allocate",
1988 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
1993 (GTK_OBJECT(messagewin), "size_allocate",
1994 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
1998 debug_print("done.\n");
2001 void main_window_destroy_all(void)
2003 while (mainwin_list != NULL) {
2004 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2006 /* free toolbar stuff */
2007 toolbar_clear_list(TOOLBAR_MAIN);
2008 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2009 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2011 g_free(mainwin->toolbar);
2014 mainwin_list = g_list_remove(mainwin_list, mainwin);
2016 g_list_free(mainwin_list);
2020 static void toolbar_account_button_pressed(GtkWidget *widget,
2021 GdkEventButton *event,
2024 MainWindow *mainwin = (MainWindow *)data;
2027 if (event->button != 3) return;
2029 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2030 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2033 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2034 menu_button_position, widget,
2035 event->button, event->time);
2039 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2042 MainWindow *mainwin = (MainWindow *)data;
2046 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2047 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2050 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2051 menu_button_position, widget,
2052 event->button, event->time);
2055 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2057 MainWindow *mainwin = (MainWindow *)data;
2060 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2061 if (!button) return;
2062 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2063 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2064 manage_window_focus_in(mainwin->window, NULL, NULL);
2067 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2070 MainWindow *mainwin = (MainWindow *)data;
2072 if (mainwin->lock_count == 0)
2073 app_exit_cb(data, 0, widget);
2078 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2081 MainWindow *mainwin = (MainWindow *)data;
2082 GtkWidget *menuitem;
2084 menuitem = gtk_item_factory_get_item
2085 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2086 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2091 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2094 MainWindow *mainwin = (MainWindow *)data;
2095 GtkWidget *menuitem;
2097 menuitem = gtk_item_factory_get_item
2098 (mainwin->menu_factory, "/View/Show or hide/Message view");
2099 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2104 static void main_window_size_allocate_cb(GtkWidget *widget,
2105 GtkAllocation *allocation,
2108 MainWindow *mainwin = (MainWindow *)data;
2110 main_window_get_size(mainwin);
2113 static void folder_window_size_allocate_cb(GtkWidget *widget,
2114 GtkAllocation *allocation,
2117 MainWindow *mainwin = (MainWindow *)data;
2119 main_window_get_size(mainwin);
2122 static void message_window_size_allocate_cb(GtkWidget *widget,
2123 GtkAllocation *allocation,
2126 MainWindow *mainwin = (MainWindow *)data;
2128 main_window_get_size(mainwin);
2131 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2134 main_window_add_mailbox(mainwin);
2137 static void update_folderview_cb(MainWindow *mainwin, guint action,
2140 summary_show(mainwin->summaryview, NULL);
2141 folderview_check_new_all();
2144 static void new_folder_cb(MainWindow *mainwin, guint action,
2147 folderview_new_folder(mainwin->folderview);
2150 static void rename_folder_cb(MainWindow *mainwin, guint action,
2153 folderview_rename_folder(mainwin->folderview);
2156 static void delete_folder_cb(MainWindow *mainwin, guint action,
2159 folderview_delete_folder(mainwin->folderview);
2162 static void import_mbox_cb(MainWindow *mainwin, guint action,
2165 import_mbox(mainwin->summaryview->folder_item);
2168 static void export_mbox_cb(MainWindow *mainwin, guint action,
2171 export_mbox(mainwin->summaryview->folder_item);
2174 static void empty_trash_cb(MainWindow *mainwin, guint action,
2177 main_window_empty_trash(mainwin, TRUE);
2180 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2182 summary_save_as(mainwin->summaryview);
2185 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2187 summary_print(mainwin->summaryview);
2190 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2192 if (prefs_common.confirm_on_exit) {
2193 if (alertpanel(_("Exit"), _("Exit this program?"),
2194 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2196 manage_window_focus_in(mainwin->window, NULL, NULL);
2199 app_will_exit(widget, mainwin);
2202 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2205 summary_search(mainwin->summaryview);
2207 message_search(mainwin->messageview);
2210 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2215 active = GTK_CHECK_MENU_ITEM(widget)->active;
2217 switch (mainwin->type) {
2219 case SEPARATE_MESSAGE:
2222 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2224 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2227 case SEPARATE_FOLDER:
2228 debug_print("separate folder\n");
2230 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2232 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2236 gtk_widget_show(mainwin->win.sep_both.folderwin);
2238 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2242 prefs_common.folderview_visible = active;
2245 static void toggle_message_cb(MainWindow *mainwin, guint action,
2250 active = GTK_CHECK_MENU_ITEM(widget)->active;
2252 if (active != messageview_is_visible(mainwin->messageview))
2253 summary_toggle_view(mainwin->summaryview);
2256 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2259 toolbar_toggle(action, mainwin);
2262 void main_window_reply_cb(MainWindow *mainwin, guint action,
2265 MessageView *msgview = (MessageView*)mainwin->messageview;
2266 GSList *msginfo_list = NULL;
2269 g_return_if_fail(msgview != NULL);
2271 msginfo_list = summary_get_selection(mainwin->summaryview);
2272 g_return_if_fail(msginfo_list != NULL);
2274 body = messageview_get_selection(msgview);
2275 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2277 g_slist_free(msginfo_list);
2281 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2284 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2285 gtk_widget_show(mainwin->hbox_stat);
2286 prefs_common.show_statusbar = TRUE;
2288 gtk_widget_hide(mainwin->hbox_stat);
2289 prefs_common.show_statusbar = FALSE;
2293 static void separate_widget_cb(MainWindow *mainwin, guint action,
2298 if (GTK_CHECK_MENU_ITEM(widget)->active)
2299 type = mainwin->type | action;
2301 type = mainwin->type & ~action;
2303 main_window_separation_change(mainwin, type);
2305 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2306 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2309 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2312 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2314 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2317 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2319 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2322 static void online_switch_clicked (GtkButton *btn, gpointer data)
2324 MainWindow *mainwin;
2325 GtkItemFactory *ifactory;
2326 GtkCheckMenuItem *menuitem;
2328 mainwin = (MainWindow *) data;
2330 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2331 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2333 g_return_if_fail(mainwin != NULL);
2334 g_return_if_fail(menuitem != NULL);
2336 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2338 gtk_widget_hide (mainwin->online_switch);
2339 gtk_widget_show (mainwin->offline_switch);
2340 menuitem->active = TRUE;
2341 prefs_common.work_offline = TRUE;
2342 inc_autocheck_timer_remove();
2345 gtk_widget_hide (mainwin->offline_switch);
2346 gtk_widget_show (mainwin->online_switch);
2347 menuitem->active = FALSE;
2348 prefs_common.work_offline = FALSE;
2349 inc_autocheck_timer_set();
2353 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2356 addressbook_open(NULL);
2359 static void log_window_show_cb(MainWindow *mainwin, guint action,
2362 log_window_show(mainwin->logwin);
2365 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2370 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2372 summary_move_to(mainwin->summaryview);
2375 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2377 summary_copy_to(mainwin->summaryview);
2380 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2382 summary_delete(mainwin->summaryview);
2385 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2387 summary_cancel(mainwin->summaryview);
2390 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2392 summary_open_msg(mainwin->summaryview);
2395 static void view_source_cb(MainWindow *mainwin, guint action,
2398 summary_view_source(mainwin->summaryview);
2401 static void show_all_header_cb(MainWindow *mainwin, guint action,
2404 if (mainwin->menu_lock_count) return;
2405 summary_display_msg_selected(mainwin->summaryview,
2406 GTK_CHECK_MENU_ITEM(widget)->active);
2409 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2411 summary_reedit(mainwin->summaryview);
2414 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2416 summary_mark(mainwin->summaryview);
2419 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2421 summary_unmark(mainwin->summaryview);
2424 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2427 summary_mark_as_unread(mainwin->summaryview);
2430 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2433 summary_mark_as_read(mainwin->summaryview);
2436 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2439 summary_mark_all_read(mainwin->summaryview);
2442 static void add_address_cb(MainWindow *mainwin, guint action,
2445 summary_add_address(mainwin->summaryview);
2448 static void set_charset_cb(MainWindow *mainwin, guint action,
2453 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2454 str = conv_get_charset_str((CharSet)action);
2455 g_free(prefs_common.force_charset);
2456 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2458 summary_redisplay_msg(mainwin->summaryview);
2460 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2464 static void hide_read_messages (MainWindow *mainwin, guint action,
2467 if (!mainwin->summaryview->folder_item
2468 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2470 summary_toggle_show_read_messages(mainwin->summaryview);
2473 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2475 if (mainwin->menu_lock_count) return;
2476 if (!mainwin->summaryview->folder_item) return;
2478 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2479 summary_thread_build(mainwin->summaryview);
2480 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2482 summary_unthread(mainwin->summaryview);
2483 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2487 static void expand_threads_cb(MainWindow *mainwin, guint action,
2490 summary_expand_threads(mainwin->summaryview);
2493 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2496 summary_collapse_threads(mainwin->summaryview);
2499 static void set_display_item_cb(MainWindow *mainwin, guint action,
2502 prefs_summary_column_open();
2505 static void sort_summary_cb(MainWindow *mainwin, guint action,
2508 FolderItem *item = mainwin->summaryview->folder_item;
2509 GtkWidget *menuitem;
2511 if (mainwin->menu_lock_count) return;
2513 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2514 menuitem = gtk_item_factory_get_item
2515 (mainwin->menu_factory, "/View/Sort/Ascending");
2516 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2517 GTK_CHECK_MENU_ITEM(menuitem)->active
2518 ? SORT_ASCENDING : SORT_DESCENDING);
2522 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2525 FolderItem *item = mainwin->summaryview->folder_item;
2527 if (mainwin->menu_lock_count) return;
2529 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2530 summary_sort(mainwin->summaryview,
2531 item->sort_key, (FolderSortType)action);
2534 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2537 summary_attract_by_subject(mainwin->summaryview);
2540 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2543 summary_delete_duplicated(mainwin->summaryview);
2546 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2548 summary_filter(mainwin->summaryview);
2551 static void execute_summary_cb(MainWindow *mainwin, guint action,
2554 summary_execute(mainwin->summaryview);
2557 static void update_summary_cb(MainWindow *mainwin, guint action,
2561 FolderView *folderview = mainwin->folderview;
2563 if (!mainwin->summaryview->folder_item) return;
2564 if (!folderview->opened) return;
2566 folder_update_op_count();
2568 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2569 folderview->opened);
2572 folder_item_scan(fitem);
2573 summary_show(mainwin->summaryview, fitem);
2576 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2578 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2581 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2583 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2586 static void prev_unread_cb(MainWindow *mainwin, guint action,
2589 summary_select_prev_unread(mainwin->summaryview);
2592 static void next_unread_cb(MainWindow *mainwin, guint action,
2595 summary_select_next_unread(mainwin->summaryview);
2598 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2600 summary_select_prev_new(mainwin->summaryview);
2603 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2605 summary_select_next_new(mainwin->summaryview);
2608 static void prev_marked_cb(MainWindow *mainwin, guint action,
2611 summary_select_prev_marked(mainwin->summaryview);
2614 static void next_marked_cb(MainWindow *mainwin, guint action,
2617 summary_select_next_marked(mainwin->summaryview);
2620 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2623 summary_select_prev_labeled(mainwin->summaryview);
2626 static void next_labeled_cb(MainWindow *mainwin, guint action,
2629 summary_select_next_labeled(mainwin->summaryview);
2632 static void goto_folder_cb(MainWindow *mainwin, guint action,
2635 FolderItem *to_folder;
2637 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2640 folderview_select(mainwin->folderview, to_folder);
2643 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2645 messageview_copy_clipboard(mainwin->messageview);
2648 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2650 MessageView *msgview = mainwin->messageview;
2652 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2653 summary_select_all(mainwin->summaryview);
2654 else if (messageview_is_visible(msgview) &&
2655 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2656 messageview_select_all(mainwin->messageview);
2659 static void select_thread_cb(MainWindow *mainwin, guint action,
2662 summary_select_thread(mainwin->summaryview);
2665 static void create_filter_cb(MainWindow *mainwin, guint action,
2668 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2671 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2674 prefs_common_open();
2677 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2680 prefs_scoring_open(NULL);
2683 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2686 prefs_filtering_open(NULL, NULL, NULL);
2689 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2692 prefs_template_open();
2695 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2698 prefs_actions_open(mainwin);
2701 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2704 ssl_manager_open(mainwin);
2707 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2711 new_account_cb(mainwin, 0, widget);
2713 account_open(cur_account);
2717 static void new_account_cb(MainWindow *mainwin, guint action,
2720 account_edit_open();
2721 if (!compose_get_compose_list()) account_add();
2724 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2726 cur_account = (PrefsAccount *)data;
2727 main_window_reflect_prefs_all();
2730 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2735 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2737 pluginwindow_create();
2740 static void manual_open_cb(MainWindow *mainwin, guint action,
2743 manual_open((ManualType)action);
2746 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2748 MainWindow *mainwin = (MainWindow *)data;
2752 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2753 LOCAL_FOLDER(folder)->rootpath,
2757 str = g_strdup_printf(_("Scanning folder %s ..."),
2758 LOCAL_FOLDER(folder)->rootpath);
2760 STATUSBAR_PUSH(mainwin, str);
2761 STATUSBAR_POP(mainwin);
2765 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2768 SummaryView *summary;
2770 g_return_val_if_fail(data, FALSE);
2771 summary = ((MainWindow *)data)->summaryview;
2772 g_return_val_if_fail(summary, FALSE);
2774 if (GTK_CLIST(summary->ctree)->selection &&
2775 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
2778 if (summary->selected != summary->displayed)
2779 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2783 #define BREAK_ON_MODIFIER_KEY() \
2784 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2786 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2789 MainWindow *mainwin = (MainWindow*) data;
2791 if (!mainwin || !event) return;
2793 switch (event->keyval) {
2794 case GDK_Q: /* Quit */
2795 BREAK_ON_MODIFIER_KEY();
2797 app_exit_cb(mainwin, 0, NULL);
2800 if (mainwin->folderview && mainwin->summaryview
2801 && !mainwin->summaryview->displayed) {
2802 summary_lock(mainwin->summaryview);
2803 folderview_select_next_unread(mainwin->folderview);
2804 summary_unlock(mainwin->summaryview);
2812 #undef BREAK_ON_MODIFIER_KEY
2815 * Harvest addresses for selected folder.
2817 static void addr_harvest_cb( MainWindow *mainwin,
2821 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2825 * Harvest addresses for selected messages in summary view.
2827 static void addr_harvest_msg_cb( MainWindow *mainwin,
2831 summary_harvest_address( mainwin->summaryview );
2835 *\brief get a MainWindow
2837 *\return MainWindow * The first mainwindow in the mainwin_list
2839 MainWindow *mainwindow_get_mainwindow(void)
2841 if (mainwin_list && mainwin_list->data)
2842 return (MainWindow *)(mainwin_list->data);
2847 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
2849 ProgressData *data = (ProgressData *) source;
2850 MainWindow *mainwin = (MainWindow *) userdata;
2852 switch (data->cmd) {
2853 case PROGRESS_COMMAND_START:
2854 case PROGRESS_COMMAND_STOP:
2855 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
2857 case PROGRESS_COMMAND_SET_PERCENTAGE:
2858 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
2861 while (gtk_events_pending()) gtk_main_iteration ();