2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_actions.h"
64 #include "prefs_filtering.h"
65 #include "prefs_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_folder_item.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "selective_download.h"
84 #include "ssl_manager.h"
85 #include "sslcertwindow.h"
86 #include "prefs_gtk.h"
87 #include "pluginwindow.h"
89 #define AC_LABEL_WIDTH 240
91 /* list of all instantiated MainWindow */
92 static GList *mainwin_list = NULL;
94 static GdkCursor *watch_cursor;
96 static void main_window_menu_callback_block (MainWindow *mainwin);
97 static void main_window_menu_callback_unblock (MainWindow *mainwin);
99 static void main_window_show_cur_account (MainWindow *mainwin);
101 static void main_window_set_widgets (MainWindow *mainwin,
105 static void toolbar_account_button_pressed (GtkWidget *widget,
106 GdkEventButton *event,
109 static void ac_label_button_pressed (GtkWidget *widget,
110 GdkEventButton *event,
112 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
115 static gint main_window_close_cb (GtkWidget *widget,
118 static gint folder_window_close_cb (GtkWidget *widget,
121 static gint message_window_close_cb (GtkWidget *widget,
125 static void add_mailbox_cb (MainWindow *mainwin,
128 static void add_mbox_cb (MainWindow *mainwin,
131 static void update_folderview_cb (MainWindow *mainwin,
134 static void new_folder_cb (MainWindow *mainwin,
137 static void rename_folder_cb (MainWindow *mainwin,
140 static void delete_folder_cb (MainWindow *mainwin,
143 static void import_mbox_cb (MainWindow *mainwin,
146 static void export_mbox_cb (MainWindow *mainwin,
149 static void empty_trash_cb (MainWindow *mainwin,
153 static void save_as_cb (MainWindow *mainwin,
156 static void print_cb (MainWindow *mainwin,
159 static void app_exit_cb (MainWindow *mainwin,
163 static void search_cb (MainWindow *mainwin,
167 static void toggle_folder_cb (MainWindow *mainwin,
170 static void toggle_message_cb (MainWindow *mainwin,
173 static void toggle_toolbar_cb (MainWindow *mainwin,
176 static void toggle_statusbar_cb (MainWindow *mainwin,
179 static void separate_widget_cb (MainWindow *mainwin,
183 static void addressbook_open_cb (MainWindow *mainwin,
186 static void log_window_show_cb (MainWindow *mainwin,
189 static void sel_download_cb (MainWindow *mainwin,
193 static void inc_cancel_cb (MainWindow *mainwin,
197 static void open_msg_cb (MainWindow *mainwin,
201 static void view_source_cb (MainWindow *mainwin,
205 static void show_all_header_cb (MainWindow *mainwin,
209 static void reedit_cb (MainWindow *mainwin,
213 static void move_to_cb (MainWindow *mainwin,
216 static void copy_to_cb (MainWindow *mainwin,
219 static void delete_cb (MainWindow *mainwin,
223 static void cancel_cb (MainWindow *mainwin,
227 static void mark_cb (MainWindow *mainwin,
230 static void unmark_cb (MainWindow *mainwin,
234 static void mark_as_unread_cb (MainWindow *mainwin,
237 static void mark_as_read_cb (MainWindow *mainwin,
240 static void mark_all_read_cb (MainWindow *mainwin,
243 static void add_address_cb (MainWindow *mainwin,
247 static void set_charset_cb (MainWindow *mainwin,
251 static void hide_read_messages (MainWindow *mainwin,
255 static void thread_cb (MainWindow *mainwin,
258 static void expand_threads_cb (MainWindow *mainwin,
261 static void collapse_threads_cb (MainWindow *mainwin,
265 static void set_display_item_cb (MainWindow *mainwin,
268 static void sort_summary_cb (MainWindow *mainwin,
271 static void sort_summary_type_cb (MainWindow *mainwin,
274 static void attract_by_subject_cb(MainWindow *mainwin,
278 static void delete_duplicated_cb (MainWindow *mainwin,
281 static void filter_cb (MainWindow *mainwin,
284 static void execute_summary_cb (MainWindow *mainwin,
287 static void update_summary_cb (MainWindow *mainwin,
291 static void prev_cb (MainWindow *mainwin,
294 static void next_cb (MainWindow *mainwin,
297 static void next_unread_cb (MainWindow *mainwin,
300 static void prev_unread_cb (MainWindow *mainwin,
304 static void prev_new_cb (MainWindow *mainwin,
307 static void next_new_cb (MainWindow *mainwin,
310 static void prev_marked_cb (MainWindow *mainwin,
313 static void next_marked_cb (MainWindow *mainwin,
316 static void prev_labeled_cb (MainWindow *mainwin,
319 static void next_labeled_cb (MainWindow *mainwin,
323 static void goto_folder_cb (MainWindow *mainwin,
327 static void copy_cb (MainWindow *mainwin,
330 static void allsel_cb (MainWindow *mainwin,
333 static void select_thread_cb (MainWindow *mainwin,
337 static void create_filter_cb (MainWindow *mainwin,
341 static void prefs_common_open_cb (MainWindow *mainwin,
344 static void prefs_template_open_cb (MainWindow *mainwin,
347 static void prefs_actions_open_cb (MainWindow *mainwin,
350 static void prefs_account_open_cb (MainWindow *mainwin,
353 static void prefs_scoring_open_cb (MainWindow *mainwin,
356 static void prefs_filtering_open_cb (MainWindow *mainwin,
360 static void ssl_manager_open_cb (MainWindow *mainwin,
364 static void new_account_cb (MainWindow *mainwin,
368 static void account_menu_cb (GtkMenuItem *menuitem,
371 static void prefs_open_cb (GtkMenuItem *menuitem,
373 static void plugins_open_cb (GtkMenuItem *menuitem,
376 static void online_switch_clicked(GtkButton *btn,
379 static void manual_open_cb (MainWindow *mainwin,
383 static void scan_tree_func (Folder *folder,
387 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
389 static void addr_harvest_cb ( MainWindow *mainwin,
393 static void addr_harvest_msg_cb ( MainWindow *mainwin,
397 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
398 GdkEventFocus *focus,
400 void main_window_reply_cb (MainWindow *mainwin,
403 #define SEPARATE_ACTION 500
405 static GtkItemFactoryEntry mainwin_entries[] =
407 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
408 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
409 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
410 {N_("/_File/_Check for new messages in all folders"),
411 NULL, update_folderview_cb, 0, NULL},
412 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
413 {N_("/_File/_Folder/Create _new folder..."),
414 NULL, new_folder_cb, 0, NULL},
415 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
416 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
417 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
418 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
419 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
420 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
421 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
422 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
423 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
424 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
425 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
426 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
428 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
429 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
430 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
431 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
432 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
433 {N_("/_Edit/_Find in current message..."),
434 "<control>F", search_cb, 0, NULL},
435 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
436 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
437 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
438 {N_("/_View/Show or hi_de/_Folder tree"),
439 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
440 {N_("/_View/Show or hi_de/_Message view"),
441 "V", toggle_message_cb, 0, "<ToggleItem>"},
442 {N_("/_View/Show or hi_de/_Toolbar"),
443 NULL, NULL, 0, "<Branch>"},
444 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
445 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
446 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
447 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
448 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
449 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
450 {N_("/_View/Show or hi_de/_Toolbar/_None"),
451 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
452 {N_("/_View/Show or hi_de/Status _bar"),
453 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
454 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
455 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
456 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
457 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
459 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
460 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
461 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
462 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
463 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
464 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
465 {N_("/_View/_Sort/by _color label"),
466 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
467 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
468 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
469 {N_("/_View/_Sort/by a_ttachment"),
470 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
471 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
472 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
473 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
474 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
475 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
476 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
477 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_View/_Sort/_Attract by subject"),
479 NULL, attract_by_subject_cb, 0, NULL},
480 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
481 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
482 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
483 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
484 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
486 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
488 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
489 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
490 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
491 {N_("/_View/_Go to/P_rev unread message"),
492 "<shift>P", prev_unread_cb, 0, NULL},
493 {N_("/_View/_Go to/N_ext unread message"),
494 "<shift>N", next_unread_cb, 0, NULL},
495 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
497 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
498 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_View/_Go to/Prev _marked message"),
500 NULL, prev_marked_cb, 0, NULL},
501 {N_("/_View/_Go to/Next m_arked message"),
502 NULL, next_marked_cb, 0, NULL},
503 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_View/_Go to/Prev _labeled message"),
505 NULL, prev_labeled_cb, 0, NULL},
506 {N_("/_View/_Go to/Next la_beled message"),
507 NULL, next_labeled_cb, 0, NULL},
508 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
509 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
510 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
512 #define CODESET_SEPARATOR \
513 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
514 #define CODESET_ACTION(action) \
515 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
517 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
518 {N_("/_View/_Code set/_Auto detect"),
519 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
520 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
522 CODESET_ACTION(C_US_ASCII)},
525 {N_("/_View/_Code set/Unicode (_UTF-8)"),
526 CODESET_ACTION(C_UTF_8)},
529 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
530 CODESET_ACTION(C_ISO_8859_1)},
531 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
532 CODESET_ACTION(C_ISO_8859_15)},
535 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
536 CODESET_ACTION(C_ISO_8859_2)},
538 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
539 CODESET_ACTION(C_ISO_8859_13)},
540 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
541 CODESET_ACTION(C_ISO_8859_4)},
543 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
544 CODESET_ACTION(C_ISO_8859_7)},
546 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
547 CODESET_ACTION(C_ISO_8859_9)},
549 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
550 CODESET_ACTION(C_ISO_8859_5)},
551 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
552 CODESET_ACTION(C_KOI8_R)},
553 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
554 CODESET_ACTION(C_WINDOWS_1251)},
557 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
558 CODESET_ACTION(C_ISO_2022_JP)},
560 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
561 CODESET_ACTION(C_ISO_2022_JP_2)},
563 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
564 CODESET_ACTION(C_EUC_JP)},
565 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
566 CODESET_ACTION(C_SHIFT_JIS)},
569 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
570 CODESET_ACTION(C_GB2312)},
571 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
572 CODESET_ACTION(C_BIG5)},
573 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
574 CODESET_ACTION(C_EUC_TW)},
575 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
576 CODESET_ACTION(C_ISO_2022_CN)},
578 {N_("/_View/_Code set/Korean (EUC-_KR)"),
579 CODESET_ACTION(C_EUC_KR)},
580 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
581 CODESET_ACTION(C_ISO_2022_KR)},
583 {N_("/_View/_Code set/Thai (TIS-620)"),
584 CODESET_ACTION(C_TIS_620)},
585 {N_("/_View/_Code set/Thai (Windows-874)"),
586 CODESET_ACTION(C_WINDOWS_874)},
589 #undef CODESET_SEPARATOR
590 #undef CODESET_ACTION
592 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
593 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
594 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
595 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
596 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
597 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
599 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
600 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
601 {N_("/_Message/Get from _all accounts"),
602 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
603 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
604 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
606 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
608 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
609 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
610 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
611 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
612 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
613 {N_("/_Message/Repl_y to/mailing _list"),
614 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
615 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
616 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
617 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
618 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
619 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
621 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
623 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
624 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
625 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
626 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
628 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
629 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
630 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
632 {N_("/_Message/_Mark/Mark as rea_d"),
633 NULL, mark_as_read_cb, 0, NULL},
634 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
636 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
637 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
638 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
640 {N_("/_Tools/Add sender to address boo_k"),
641 NULL, add_address_cb, 0, NULL},
642 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
643 {N_("/_Tools/_Harvest addresses/from _Folder..."),
644 NULL, addr_harvest_cb, 0, NULL},
645 {N_("/_Tools/_Harvest addresses/from _Messages..."),
646 NULL, addr_harvest_msg_cb, 0, NULL},
647 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
649 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
650 {N_("/_Tools/_Create filter rule/_Automatically"),
651 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
652 {N_("/_Tools/_Create filter rule/by _From"),
653 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
654 {N_("/_Tools/_Create filter rule/by _To"),
655 NULL, create_filter_cb, FILTER_BY_TO, NULL},
656 {N_("/_Tools/_Create filter rule/by _Subject"),
657 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
658 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
660 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
661 {N_("/_Tools/Delete du_plicated messages"),
662 NULL, delete_duplicated_cb, 0, NULL},
663 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
666 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_Tools/SSL certi_ficates..."),
668 NULL, ssl_manager_open_cb, 0, NULL},
670 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
673 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
674 {N_("/_Configuration/C_hange current account"),
675 NULL, NULL, 0, "<Branch>"},
676 {N_("/_Configuration/_Preferences for current account..."),
677 NULL, prefs_account_open_cb, 0, NULL},
678 {N_("/_Configuration/Create _new account..."),
679 NULL, new_account_cb, 0, NULL},
680 {N_("/_Configuration/_Edit accounts..."),
681 NULL, account_edit_open, 0, NULL},
682 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
683 {N_("/_Configuration/_Common preferences..."),
684 NULL, prefs_common_open_cb, 0, NULL},
685 {N_("/_Configuration/_Scoring..."),
686 NULL, prefs_scoring_open_cb, 0, NULL},
687 {N_("/_Configuration/_Filtering..."),
688 NULL, prefs_filtering_open_cb, 0, NULL},
689 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
690 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
691 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
692 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
694 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
695 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
696 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
697 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
698 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
699 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
700 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
701 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
705 MainWindow *main_window_create(SeparateType type)
711 GtkWidget *handlebox;
712 GtkWidget *vbox_body;
713 GtkWidget *hbox_stat;
714 GtkWidget *statusbar;
715 GtkWidget *progressbar;
716 GtkWidget *statuslabel;
717 GtkWidget *ac_button;
719 GtkWidget *online_pixmap;
720 GtkWidget *offline_pixmap;
721 GtkWidget *online_switch;
722 GtkWidget *offline_switch;
723 GtkTooltips *offline_tip;
724 GtkTooltips *online_tip;
725 GtkTooltips *sel_ac_tip;
727 FolderView *folderview;
728 SummaryView *summaryview;
729 MessageView *messageview;
730 GdkColormap *colormap;
733 GtkItemFactory *ifactory;
737 guint n_menu_entries;
739 static GdkGeometry geometry;
741 debug_print("Creating main window...\n");
742 mainwin = g_new0(MainWindow, 1);
745 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
746 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
747 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
748 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
750 if (!geometry.min_height) {
751 geometry.min_width = 320;
752 geometry.min_height = 200;
754 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
757 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
758 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
759 MANAGE_WINDOW_SIGNALS_CONNECT(window);
760 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
761 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
763 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
764 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
766 gtk_widget_realize(window);
767 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
770 gtkut_widget_set_app_icon(window);
772 vbox = gtk_vbox_new(FALSE, 0);
773 gtk_widget_show(vbox);
774 gtk_container_add(GTK_CONTAINER(window), vbox);
777 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
778 menubar = menubar_create(window, mainwin_entries,
779 n_menu_entries, "<Main>", mainwin);
780 gtk_widget_show(menubar);
781 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
782 ifactory = gtk_item_factory_from_widget(menubar);
784 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
785 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
787 handlebox = gtk_handle_box_new();
788 gtk_widget_show(handlebox);
789 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
791 /* link window to mainwin->window to avoid gdk warnings */
792 mainwin->window = window;
795 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
799 /* vbox that contains body */
800 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
801 gtk_widget_show(vbox_body);
802 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
803 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
805 hbox_stat = gtk_hbox_new(FALSE, 2);
806 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
808 statusbar = statusbar_create();
809 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
811 progressbar = gtk_progress_bar_new();
812 gtk_widget_set_usize(progressbar, 120, 1);
813 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
815 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
816 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
817 online_tip = gtk_tooltips_new();
818 online_switch = gtk_button_new ();
819 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),
820 online_switch, _("Go offline"), NULL);
821 offline_tip = gtk_tooltips_new();
822 offline_switch = gtk_button_new ();
823 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),
824 offline_switch, _("Go online"), NULL);
825 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
826 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
827 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
828 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
829 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
830 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
831 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
832 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
834 statuslabel = gtk_label_new("");
835 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
837 sel_ac_tip = gtk_tooltips_new();
838 ac_button = gtk_button_new();
839 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
840 ac_button, _("Select account"), NULL);
841 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
842 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
843 gtk_widget_set_usize(ac_button, -1, 1);
844 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
845 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
846 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
848 ac_label = gtk_label_new("");
849 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
851 gtk_widget_show_all(hbox_stat);
853 gtk_widget_hide(offline_switch);
855 mainwin->folderview = folderview = folderview_create();
856 mainwin->summaryview = summaryview = summary_create();
857 mainwin->messageview = messageview = messageview_create(mainwin);
858 mainwin->logwin = log_window_create();
860 folderview->mainwin = mainwin;
861 folderview->summaryview = summaryview;
863 summaryview->mainwin = mainwin;
864 summaryview->folderview = folderview;
865 summaryview->messageview = messageview;
866 summaryview->window = window;
868 mainwin->vbox = vbox;
869 mainwin->menubar = menubar;
870 mainwin->menu_factory = ifactory;
871 mainwin->handlebox = handlebox;
872 mainwin->vbox_body = vbox_body;
873 mainwin->hbox_stat = hbox_stat;
874 mainwin->statusbar = statusbar;
875 mainwin->progressbar = progressbar;
876 mainwin->statuslabel = statuslabel;
877 mainwin->ac_button = ac_button;
878 mainwin->ac_label = ac_label;
880 mainwin->online_switch = online_switch;
881 mainwin->offline_switch = offline_switch;
882 mainwin->online_pixmap = online_pixmap;
883 mainwin->offline_pixmap = offline_pixmap;
885 /* set context IDs for status bar */
886 mainwin->mainwin_cid = gtk_statusbar_get_context_id
887 (GTK_STATUSBAR(statusbar), "Main Window");
888 mainwin->folderview_cid = gtk_statusbar_get_context_id
889 (GTK_STATUSBAR(statusbar), "Folder View");
890 mainwin->summaryview_cid = gtk_statusbar_get_context_id
891 (GTK_STATUSBAR(statusbar), "Summary View");
893 /* allocate colors for summary view and folder view */
894 summaryview->color_marked.red = summaryview->color_marked.green = 0;
895 summaryview->color_marked.blue = (guint16)65535;
897 summaryview->color_dim.red = summaryview->color_dim.green =
898 summaryview->color_dim.blue = COLOR_DIM;
900 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
901 &folderview->color_new);
903 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
904 &folderview->color_op);
906 summaryview->color_important.red = 0;
907 summaryview->color_important.green = 0;
908 summaryview->color_important.blue = (guint16)65535;
910 color[0] = summaryview->color_marked;
911 color[1] = summaryview->color_dim;
912 color[2] = folderview->color_new;
913 color[3] = folderview->color_op;
915 colormap = gdk_window_get_colormap(window->window);
916 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
917 for (i = 0; i < 4; i++) {
918 if (success[i] == FALSE)
919 g_warning("MainWindow: color allocation %d failed\n", i);
922 debug_print("done.\n");
924 messageview->visible = TRUE;
926 main_window_set_widgets(mainwin, type);
929 menuitem = gtk_item_factory_get_item
930 (ifactory, "/View/Code set/Auto detect");
931 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
933 switch (prefs_common.toolbar_style) {
935 menuitem = gtk_item_factory_get_item
936 (ifactory, "/View/Show or hide/Toolbar/None");
939 menuitem = gtk_item_factory_get_item
940 (ifactory, "/View/Show or hide/Toolbar/Icon");
943 menuitem = gtk_item_factory_get_item
944 (ifactory, "/View/Show or hide/Toolbar/Text");
947 menuitem = gtk_item_factory_get_item
948 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
950 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
952 gtk_widget_hide(mainwin->hbox_stat);
953 menuitem = gtk_item_factory_get_item
954 (ifactory, "/View/Show or hide/Status bar");
955 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
956 prefs_common.show_statusbar);
958 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
960 if (prefs_common.show_searchbar) {
961 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
962 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
963 gtk_widget_hide(summaryview->search_description);
966 /* set account selection menu */
967 ac_menu = gtk_item_factory_get_widget
968 (ifactory, "/Configuration/Change current account");
969 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
970 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
971 mainwin->ac_menu = ac_menu;
973 toolbar_main_set_sensitive(mainwin);
975 /* create actions menu */
976 update_mainwin_actions_menu(ifactory, mainwin);
978 /* attach accel groups to main window */
979 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
980 gtk_window_add_accel_group \
982 gtk_item_factory_from_widget(menu)->accel_group)
984 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
986 /* connect the accelerators for equivalent
987 menu items in different menus */
988 menu_connect_identical_items();
992 /* show main window */
993 gtk_widget_set_uposition(mainwin->window,
994 prefs_common.mainwin_x,
995 prefs_common.mainwin_y);
996 gtk_widget_set_usize(window, prefs_common.mainwin_width,
997 prefs_common.mainwin_height);
998 gtk_widget_show(mainwin->window);
1000 /* initialize views */
1001 folderview_init(folderview);
1002 summary_init(summaryview);
1003 messageview_init(messageview);
1004 log_window_init(mainwin->logwin);
1006 sslcertwindow_register_hook();
1008 mainwin->lock_count = 0;
1009 mainwin->menu_lock_count = 0;
1010 mainwin->cursor_count = 0;
1013 watch_cursor = gdk_cursor_new(GDK_WATCH);
1015 mainwin_list = g_list_append(mainwin_list, mainwin);
1017 /* init work_offline */
1018 if (prefs_common.work_offline)
1019 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1024 void main_window_cursor_wait(MainWindow *mainwin)
1027 if (mainwin->cursor_count == 0)
1028 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1030 mainwin->cursor_count++;
1035 void main_window_cursor_normal(MainWindow *mainwin)
1037 if (mainwin->cursor_count)
1038 mainwin->cursor_count--;
1040 if (mainwin->cursor_count == 0)
1041 gdk_window_set_cursor(mainwin->window->window, NULL);
1046 /* lock / unlock the user-interface */
1047 void main_window_lock(MainWindow *mainwin)
1049 if (mainwin->lock_count == 0)
1050 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1052 mainwin->lock_count++;
1054 main_window_set_menu_sensitive(mainwin);
1055 toolbar_main_set_sensitive(mainwin);
1058 void main_window_unlock(MainWindow *mainwin)
1060 if (mainwin->lock_count)
1061 mainwin->lock_count--;
1063 main_window_set_menu_sensitive(mainwin);
1064 toolbar_main_set_sensitive(mainwin);
1066 if (mainwin->lock_count == 0)
1067 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1070 static void main_window_menu_callback_block(MainWindow *mainwin)
1072 mainwin->menu_lock_count++;
1075 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1077 if (mainwin->menu_lock_count)
1078 mainwin->menu_lock_count--;
1081 void main_window_reflect_prefs_all(void)
1083 main_window_reflect_prefs_all_real(FALSE);
1086 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1089 MainWindow *mainwin;
1092 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1093 mainwin = (MainWindow *)cur->data;
1095 main_window_show_cur_account(mainwin);
1096 main_window_set_menu_sensitive(mainwin);
1097 toolbar_main_set_sensitive(mainwin);
1100 if (pixmap_theme_changed) {
1101 toolbar_update(TOOLBAR_MAIN, mainwin);
1102 messageview_reflect_prefs_pixmap_theme();
1103 compose_reflect_prefs_pixmap_theme();
1104 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1105 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1107 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1108 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1109 mainwin->online_pixmap);
1110 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1111 gtk_widget_show(pixmap);
1112 mainwin->online_pixmap = pixmap;
1113 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1114 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1115 mainwin->offline_pixmap);
1116 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1117 gtk_widget_show(pixmap);
1118 mainwin->offline_pixmap = pixmap;
1121 summary_redisplay_msg(mainwin->summaryview);
1122 headerview_set_visibility(mainwin->messageview->headerview,
1123 prefs_common.display_header_pane);
1127 void main_window_set_summary_column(void)
1130 MainWindow *mainwin;
1132 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1133 mainwin = (MainWindow *)cur->data;
1134 summary_set_column_order(mainwin->summaryview);
1138 void main_window_set_account_menu(GList *account_list)
1140 GList *cur, *cur_ac, *cur_item;
1141 GtkWidget *menuitem;
1142 MainWindow *mainwin;
1143 PrefsAccount *ac_prefs;
1145 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1146 mainwin = (MainWindow *)cur->data;
1148 /* destroy all previous menu item */
1149 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1150 while (cur_item != NULL) {
1151 GList *next = cur_item->next;
1152 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1156 for (cur_ac = account_list; cur_ac != NULL;
1157 cur_ac = cur_ac->next) {
1158 ac_prefs = (PrefsAccount *)cur_ac->data;
1160 menuitem = gtk_menu_item_new_with_label
1161 (ac_prefs->account_name
1162 ? ac_prefs->account_name : _("Untitled"));
1163 gtk_widget_show(menuitem);
1164 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1165 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1166 GTK_SIGNAL_FUNC(account_menu_cb),
1172 static void main_window_show_cur_account(MainWindow *mainwin)
1177 ac_name = g_strdup(cur_account
1178 ? (cur_account->account_name
1179 ? cur_account->account_name : _("Untitled"))
1183 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1185 buf = g_strdup(PROG_VERSION);
1186 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1189 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1190 gtk_widget_queue_resize(mainwin->ac_button);
1195 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1197 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1198 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1199 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1200 GtkWidget *message_wid = mainwin->messageview->vbox;
1202 debug_print("Changing window separation type from %d to %d\n",
1203 mainwin->type, type);
1205 if (mainwin->type == type) return;
1207 /* remove widgets from those containers */
1208 gtk_widget_ref(folder_wid);
1209 gtk_widget_ref(summary_wid);
1210 gtk_widget_ref(message_wid);
1211 gtkut_container_remove
1212 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1213 gtkut_container_remove
1214 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1215 gtkut_container_remove
1216 (GTK_CONTAINER(message_wid->parent), message_wid);
1218 /* clean containers */
1219 switch (mainwin->type) {
1221 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1223 case SEPARATE_FOLDER:
1224 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1225 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1227 case SEPARATE_MESSAGE:
1228 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1229 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1232 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1233 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1237 gtk_widget_hide(mainwin->window);
1238 main_window_set_widgets(mainwin, type);
1239 gtk_widget_show(mainwin->window);
1241 gtk_widget_unref(folder_wid);
1242 gtk_widget_unref(summary_wid);
1243 gtk_widget_unref(message_wid);
1246 void main_window_toggle_message_view(MainWindow *mainwin)
1248 SummaryView *summaryview = mainwin->summaryview;
1249 union CompositeWin *cwin = &mainwin->win;
1250 GtkWidget *vpaned = NULL;
1251 GtkWidget *container = NULL;
1252 GtkWidget *msgwin = NULL;
1254 switch (mainwin->type) {
1256 vpaned = cwin->sep_none.vpaned;
1257 container = cwin->sep_none.hpaned;
1259 case SEPARATE_FOLDER:
1260 vpaned = cwin->sep_folder.vpaned;
1261 container = mainwin->vbox_body;
1263 case SEPARATE_MESSAGE:
1264 msgwin = mainwin->win.sep_message.messagewin;
1267 msgwin = mainwin->win.sep_both.messagewin;
1272 if (GTK_WIDGET_VISIBLE(msgwin)) {
1273 gtk_widget_hide(msgwin);
1274 mainwin->messageview->visible = FALSE;
1275 summaryview->displayed = NULL;
1277 gtk_widget_show(msgwin);
1278 mainwin->messageview->visible = TRUE;
1280 } else if (vpaned->parent != NULL) {
1281 mainwin->messageview->visible = FALSE;
1282 summaryview->displayed = NULL;
1283 gtk_widget_ref(vpaned);
1284 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1285 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1286 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1287 GTK_ARROW_UP, GTK_SHADOW_OUT);
1289 mainwin->messageview->visible = TRUE;
1290 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1291 gtk_container_add(GTK_CONTAINER(container), vpaned);
1292 gtk_widget_unref(vpaned);
1293 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1294 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1297 main_window_set_menu_sensitive(mainwin);
1299 gtk_widget_grab_focus(summaryview->ctree);
1302 void main_window_get_size(MainWindow *mainwin)
1304 GtkAllocation *allocation;
1306 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1308 prefs_common.summaryview_width = allocation->width;
1310 if ((mainwin->type == SEPARATE_NONE ||
1311 mainwin->type == SEPARATE_FOLDER) &&
1312 messageview_is_visible(mainwin->messageview))
1313 prefs_common.summaryview_height = allocation->height;
1315 prefs_common.mainview_width = allocation->width;
1317 allocation = &mainwin->window->allocation;
1319 prefs_common.mainview_height = allocation->height;
1320 prefs_common.mainwin_width = allocation->width;
1321 prefs_common.mainwin_height = allocation->height;
1323 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1325 prefs_common.folderview_width = allocation->width;
1326 prefs_common.folderview_height = allocation->height;
1329 void main_window_get_position(MainWindow *mainwin)
1333 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1335 prefs_common.mainview_x = x;
1336 prefs_common.mainview_y = y;
1337 prefs_common.mainwin_x = x;
1338 prefs_common.mainwin_y = y;
1340 debug_print("window position: x = %d, y = %d\n", x, y);
1343 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1349 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1350 folder = FOLDER(list->data);
1351 if (folder && folder->trash && folder->trash->total > 0)
1355 if (!has_trash) return;
1358 if (alertpanel(_("Empty trash"),
1359 _("Empty all messages in trash?"),
1360 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1362 manage_window_focus_in(mainwin->window, NULL, NULL);
1365 procmsg_empty_trash();
1367 if (mainwin->summaryview->folder_item &&
1368 mainwin->summaryview->folder_item->stype == F_TRASH)
1369 gtk_widget_grab_focus(mainwin->folderview->ctree);
1372 void main_window_add_mailbox(MainWindow *mainwin)
1377 path = input_dialog(_("Add mailbox"),
1378 _("Input the location of mailbox.\n"
1379 "If the existing mailbox is specified, it will be\n"
1380 "scanned automatically."),
1383 if (folder_find_from_path(path)) {
1384 alertpanel_error(_("The mailbox `%s' already exists."), path);
1388 if (!strcmp(path, "Mail"))
1389 folder = folder_new(F_MH, _("Mailbox"), path);
1391 folder = folder_new(F_MH, g_basename(path), path);
1394 if (folder->create_tree(folder) < 0) {
1395 alertpanel_error(_("Creation of the mailbox failed.\n"
1396 "Maybe some files already exist, or you don't have the permission to write there."));
1397 folder_destroy(folder);
1402 folder_set_ui_func(folder, scan_tree_func, mainwin);
1403 folder_scan_tree(folder);
1404 folder_set_ui_func(folder, NULL, NULL);
1406 folderview_set(mainwin->folderview);
1409 void main_window_add_mbox(MainWindow *mainwin)
1415 path = input_dialog(_("Add mbox mailbox"),
1416 _("Input the location of mailbox."),
1421 if (folder_find_from_path(path)) {
1422 alertpanel_error(_("The mailbox `%s' already exists."), path);
1428 if (!strcmp(path, "Mail"))
1429 folder = folder_new(F_MBOX, _("Mailbox"), path);
1433 folder = folder_new(F_MBOX, g_basename(path), path);
1436 if (folder->create_tree(folder) < 0) {
1437 alertpanel_error(_("Creation of the mailbox failed."));
1438 folder_destroy(folder);
1444 item = folder_item_new(folder, folder->name, NULL);
1445 item->folder = folder;
1446 folder->node = g_node_new(item);
1448 folder_create_folder(item, "inbox");
1449 folder_create_folder(item, "outbox");
1450 folder_create_folder(item, "queue");
1451 folder_create_folder(item, "draft");
1452 folder_create_folder(item, "trash");
1454 folderview_set(mainwin->folderview);
1457 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1459 SensitiveCond state = 0;
1460 SummarySelection selection;
1461 FolderItem *item = mainwin->summaryview->folder_item;
1462 GList *account_list = account_get_list();
1464 selection = summary_get_selection_type(mainwin->summaryview);
1466 if (mainwin->lock_count == 0)
1467 state |= M_UNLOCKED;
1468 if (selection != SUMMARY_NONE)
1469 state |= M_MSG_EXIST;
1470 if (item && item->path && item->parent && !item->no_select) {
1472 /* if (item->folder->type != F_NEWS) */
1473 state |= M_ALLOW_DELETE;
1475 if (prefs_common.immediate_exec == 0
1476 && mainwin->lock_count == 0)
1477 state |= M_DELAY_EXEC;
1479 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1480 || selection != SUMMARY_NONE)
1481 state |= M_HIDE_READ_MSG;
1483 if (mainwin->summaryview->threaded)
1484 state |= M_THREADED;
1486 state |= M_UNTHREADED;
1487 if (selection == SUMMARY_SELECTED_SINGLE ||
1488 selection == SUMMARY_SELECTED_MULTIPLE)
1489 state |= M_TARGET_EXIST;
1490 if (selection == SUMMARY_SELECTED_SINGLE)
1491 state |= M_SINGLE_TARGET_EXIST;
1492 if (mainwin->summaryview->folder_item &&
1493 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1496 state |= M_NOT_NEWS;
1497 if (selection == SUMMARY_SELECTED_SINGLE &&
1499 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1500 item->stype == F_QUEUE)))
1501 state |= M_ALLOW_REEDIT;
1503 state |= M_HAVE_ACCOUNT;
1505 for ( ; account_list != NULL; account_list = account_list->next) {
1506 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1507 state |= M_HAVE_NEWS_ACCOUNT;
1512 if (inc_is_active())
1513 state |= M_INC_ACTIVE;
1520 void main_window_set_menu_sensitive(MainWindow *mainwin)
1522 GtkItemFactory *ifactory = mainwin->menu_factory;
1523 SensitiveCond state;
1525 GtkWidget *menuitem;
1526 SummaryView *summaryview;
1530 static const struct {
1534 {"/File/Add mailbox..." , M_UNLOCKED},
1535 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1536 {"/File/Check for new messages in all folders", M_UNLOCKED},
1537 {"/File/Folder" , M_UNLOCKED},
1538 {"/File/Import mbox file..." , M_UNLOCKED},
1539 {"/File/Export to mbox file..." , M_UNLOCKED},
1540 {"/File/Empty trash" , M_UNLOCKED},
1541 {"/File/Work offline" , M_UNLOCKED},
1543 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1544 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1545 /* {"/File/Close" , M_UNLOCKED}, */
1546 {"/File/Exit" , M_UNLOCKED},
1548 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1550 {"/View/Sort" , M_EXEC},
1551 {"/View/Thread view" , M_EXEC},
1552 {"/View/Expand all threads" , M_MSG_EXIST},
1553 {"/View/Collapse all threads" , M_MSG_EXIST},
1554 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1555 {"/View/Go to/Prev message" , M_MSG_EXIST},
1556 {"/View/Go to/Next message" , M_MSG_EXIST},
1557 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1558 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1559 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1560 {"/View/Go to/Next new message" , M_MSG_EXIST},
1561 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1562 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1563 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1564 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1565 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1566 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1567 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1569 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1570 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1571 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1572 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1573 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1574 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1575 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1576 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1577 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1578 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1579 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1580 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1581 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1582 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1583 {"/Message/Mark" , M_TARGET_EXIST},
1585 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1586 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1587 {"/Tools/Harvest addresses" , M_UNLOCKED},
1588 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1589 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1590 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1591 {"/Tools/Execute" , M_DELAY_EXEC},
1592 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1594 {"/Configuration", M_UNLOCKED},
1599 state = main_window_get_current_state(mainwin);
1601 for (i = 0; entry[i].entry != NULL; i++) {
1602 sensitive = ((entry[i].cond & state) == entry[i].cond);
1603 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1606 main_window_menu_callback_block(mainwin);
1608 #define SET_CHECK_MENU_ACTIVE(path, active) \
1610 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1611 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1614 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1615 messageview_is_visible(mainwin->messageview));
1617 summaryview = mainwin->summaryview;
1618 menu_path = "/View/Sort/Don't sort";
1620 switch (summaryview->sort_key) {
1621 case SORT_BY_NUMBER:
1622 menu_path = "/View/Sort/by number"; break;
1624 menu_path = "/View/Sort/by size"; break;
1626 menu_path = "/View/Sort/by date"; break;
1628 menu_path = "/View/Sort/by from"; break;
1630 menu_path = "/View/Sort/by recipient"; break;
1631 case SORT_BY_SUBJECT:
1632 menu_path = "/View/Sort/by subject"; break;
1634 menu_path = "/View/Sort/by color label"; break;
1636 menu_path = "/View/Sort/by mark"; break;
1637 case SORT_BY_STATUS:
1638 menu_path = "/View/Sort/by status"; break;
1640 menu_path = "/View/Sort/by attachment"; break;
1642 menu_path = "/View/Sort/by score"; break;
1643 case SORT_BY_LOCKED:
1644 menu_path = "/View/Sort/by locked"; break;
1647 menu_path = "/View/Sort/Don't sort"; break;
1649 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1651 if (summaryview->sort_type == SORT_ASCENDING) {
1652 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1654 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1657 if (summaryview->sort_key != SORT_BY_NONE) {
1658 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1659 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1661 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1662 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1665 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1666 mainwin->messageview->textview->show_all_headers);
1667 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1669 #undef SET_CHECK_MENU_ACTIVE
1671 main_window_menu_callback_unblock(mainwin);
1674 void main_window_popup(MainWindow *mainwin)
1676 gtkut_window_popup(mainwin->window);
1678 switch (mainwin->type) {
1679 case SEPARATE_FOLDER:
1680 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1682 case SEPARATE_MESSAGE:
1683 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1686 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1687 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1694 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1696 GtkWidget *folderwin = NULL;
1697 GtkWidget *messagewin = NULL;
1700 GtkWidget *vbox_body = mainwin->vbox_body;
1701 GtkItemFactory *ifactory = mainwin->menu_factory;
1702 GtkWidget *menuitem;
1703 GtkItemFactory *msgview_ifactory;
1705 debug_print("Setting widgets...");
1707 /* create separated window(s) if needed */
1708 if (type & SEPARATE_FOLDER) {
1709 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1710 gtk_window_set_title(GTK_WINDOW(folderwin),
1711 _("Sylpheed - Folder View"));
1712 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1713 "folder_view", "Sylpheed");
1714 gtk_window_set_policy(GTK_WINDOW(folderwin),
1716 gtk_widget_set_usize(folderwin, -1,
1717 prefs_common.mainview_height);
1718 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1720 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1721 GTK_SIGNAL_FUNC(folder_window_close_cb),
1724 if (type & SEPARATE_MESSAGE) {
1725 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1726 gtk_window_set_title(GTK_WINDOW(messagewin),
1727 _("Sylpheed - Message View"));
1728 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1729 "message_view", "Sylpheed");
1730 gtk_window_set_policy(GTK_WINDOW(messagewin),
1732 gtk_widget_set_usize
1733 (messagewin, prefs_common.mainview_width,
1734 prefs_common.mainview_height
1735 - prefs_common.summaryview_height
1736 + DEFAULT_HEADERVIEW_HEIGHT);
1737 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1739 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1740 GTK_SIGNAL_FUNC(message_window_close_cb),
1746 hpaned = gtk_hpaned_new();
1747 gtk_widget_show(hpaned);
1748 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1749 gtk_paned_add1(GTK_PANED(hpaned),
1750 GTK_WIDGET_PTR(mainwin->folderview));
1752 vpaned = gtk_vpaned_new();
1753 if (messageview_is_visible(mainwin->messageview)) {
1754 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1755 gtk_paned_add1(GTK_PANED(vpaned),
1756 GTK_WIDGET_PTR(mainwin->summaryview));
1758 gtk_paned_add2(GTK_PANED(hpaned),
1759 GTK_WIDGET_PTR(mainwin->summaryview));
1760 gtk_widget_ref(vpaned);
1762 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1763 prefs_common.summaryview_width,
1764 prefs_common.summaryview_height);
1765 gtk_paned_add2(GTK_PANED(vpaned),
1766 GTK_WIDGET_PTR(mainwin->messageview));
1767 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1768 prefs_common.mainview_width, -1);
1769 gtk_widget_set_usize(mainwin->window,
1770 prefs_common.folderview_width +
1771 prefs_common.mainview_width,
1772 prefs_common.mainwin_height);
1773 gtk_widget_show_all(vpaned);
1775 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1776 * lose track of its visibility state */
1777 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1778 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1780 mainwin->win.sep_none.hpaned = hpaned;
1781 mainwin->win.sep_none.vpaned = vpaned;
1783 /* remove headerview if not in prefs */
1784 headerview_set_visibility(mainwin->messageview->headerview,
1785 prefs_common.display_header_pane);
1787 case SEPARATE_FOLDER:
1788 vpaned = gtk_vpaned_new();
1789 if (messageview_is_visible(mainwin->messageview)) {
1790 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1792 gtk_paned_add1(GTK_PANED(vpaned),
1793 GTK_WIDGET_PTR(mainwin->summaryview));
1795 gtk_box_pack_start(GTK_BOX(vbox_body),
1796 GTK_WIDGET_PTR(mainwin->summaryview),
1798 gtk_widget_ref(vpaned);
1800 gtk_paned_add2(GTK_PANED(vpaned),
1801 GTK_WIDGET_PTR(mainwin->messageview));
1802 gtk_widget_show_all(vpaned);
1803 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1804 prefs_common.summaryview_width,
1805 prefs_common.summaryview_height);
1806 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1807 prefs_common.mainview_width, -1);
1808 gtk_widget_set_usize(mainwin->window,
1809 prefs_common.mainview_width,
1810 prefs_common.mainview_height);
1812 gtk_container_add(GTK_CONTAINER(folderwin),
1813 GTK_WIDGET_PTR(mainwin->folderview));
1815 mainwin->win.sep_folder.folderwin = folderwin;
1816 mainwin->win.sep_folder.vpaned = vpaned;
1818 gtk_widget_show_all(folderwin);
1820 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1821 * lose track of its visibility state */
1822 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1823 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1825 /* remove headerview if not in prefs */
1826 headerview_set_visibility(mainwin->messageview->headerview,
1827 prefs_common.display_header_pane);
1830 case SEPARATE_MESSAGE:
1831 hpaned = gtk_hpaned_new();
1832 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1834 gtk_paned_add1(GTK_PANED(hpaned),
1835 GTK_WIDGET_PTR(mainwin->folderview));
1836 gtk_paned_add2(GTK_PANED(hpaned),
1837 GTK_WIDGET_PTR(mainwin->summaryview));
1838 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1839 prefs_common.summaryview_width,
1840 prefs_common.summaryview_height);
1841 gtk_widget_set_usize(mainwin->window,
1842 prefs_common.folderview_width +
1843 prefs_common.mainview_width,
1844 prefs_common.mainwin_height);
1845 gtk_widget_show_all(hpaned);
1847 messageview_add_toolbar(mainwin->messageview, messagewin);
1848 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1849 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1851 mainwin->win.sep_message.messagewin = messagewin;
1852 mainwin->win.sep_message.hpaned = hpaned;
1854 gtk_widget_show_all(messagewin);
1856 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1857 * lose track of its visibility state */
1858 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1859 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1862 gtk_box_pack_start(GTK_BOX(vbox_body),
1863 GTK_WIDGET_PTR(mainwin->summaryview),
1865 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1866 prefs_common.summaryview_width,
1867 prefs_common.summaryview_height);
1868 gtk_widget_set_usize(mainwin->window,
1869 prefs_common.mainview_width,
1870 prefs_common.mainwin_height);
1871 gtk_container_add(GTK_CONTAINER(folderwin),
1872 GTK_WIDGET_PTR(mainwin->folderview));
1873 gtk_container_add(GTK_CONTAINER(messagewin),
1874 GTK_WIDGET_PTR(mainwin->messageview));
1876 mainwin->win.sep_both.folderwin = folderwin;
1877 mainwin->win.sep_both.messagewin = messagewin;
1879 gtk_widget_show_all(folderwin);
1880 gtk_widget_show_all(messagewin);
1882 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1883 * lose track of its visibility state */
1884 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1885 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1889 /* rehide quick search if necessary */
1890 if (!prefs_common.show_searchbar)
1891 gtk_widget_hide(mainwin->summaryview->hbox_search);
1893 mainwin->type = type;
1895 mainwin->messageview->visible = TRUE;
1897 /* toggle menu state */
1898 menuitem = gtk_item_factory_get_item
1899 (ifactory, "/View/Show or hide/Folder tree");
1900 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1901 menuitem = gtk_item_factory_get_item
1902 (ifactory, "/View/Show or hide/Message view");
1903 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1905 menuitem = gtk_item_factory_get_item
1906 (ifactory, "/View/Separate folder tree");
1907 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1908 ((type & SEPARATE_FOLDER) != 0));
1909 menuitem = gtk_item_factory_get_item
1910 (ifactory, "/View/Separate message view");
1911 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1912 ((type & SEPARATE_MESSAGE) != 0));
1914 debug_print("done.\n");
1917 void main_window_destroy_all(void)
1919 while (mainwin_list != NULL) {
1920 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1922 /* free toolbar stuff */
1923 toolbar_clear_list(TOOLBAR_MAIN);
1924 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1925 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1927 g_free(mainwin->toolbar);
1930 mainwin_list = g_list_remove(mainwin_list, mainwin);
1932 g_list_free(mainwin_list);
1936 static void toolbar_account_button_pressed(GtkWidget *widget,
1937 GdkEventButton *event,
1940 MainWindow *mainwin = (MainWindow *)data;
1943 if (event->button != 3) return;
1945 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1946 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1949 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1950 menu_button_position, widget,
1951 event->button, event->time);
1955 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1958 MainWindow *mainwin = (MainWindow *)data;
1962 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1963 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1966 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1967 menu_button_position, widget,
1968 event->button, event->time);
1971 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
1973 MainWindow *mainwin = (MainWindow *)data;
1976 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
1977 if (!button) return;
1978 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1979 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
1980 manage_window_focus_in(mainwin->window, NULL, NULL);
1983 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1986 MainWindow *mainwin = (MainWindow *)data;
1988 if (mainwin->lock_count == 0)
1989 app_exit_cb(data, 0, widget);
1994 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1997 MainWindow *mainwin = (MainWindow *)data;
1998 GtkWidget *menuitem;
2000 menuitem = gtk_item_factory_get_item
2001 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2002 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2007 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2010 MainWindow *mainwin = (MainWindow *)data;
2011 GtkWidget *menuitem;
2013 menuitem = gtk_item_factory_get_item
2014 (mainwin->menu_factory, "/View/Show or hide/Message view");
2015 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2020 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2023 main_window_add_mailbox(mainwin);
2026 static void add_mbox_cb(MainWindow *mainwin, guint action,
2029 main_window_add_mbox(mainwin);
2032 static void update_folderview_cb(MainWindow *mainwin, guint action,
2035 summary_show(mainwin->summaryview, NULL);
2036 folderview_check_new_all();
2039 static void new_folder_cb(MainWindow *mainwin, guint action,
2042 folderview_new_folder(mainwin->folderview);
2045 static void rename_folder_cb(MainWindow *mainwin, guint action,
2048 folderview_rename_folder(mainwin->folderview);
2051 static void delete_folder_cb(MainWindow *mainwin, guint action,
2054 folderview_delete_folder(mainwin->folderview);
2057 static void import_mbox_cb(MainWindow *mainwin, guint action,
2060 import_mbox(mainwin->summaryview->folder_item);
2063 static void export_mbox_cb(MainWindow *mainwin, guint action,
2066 export_mbox(mainwin->summaryview->folder_item);
2069 static void empty_trash_cb(MainWindow *mainwin, guint action,
2072 main_window_empty_trash(mainwin, TRUE);
2075 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2077 summary_save_as(mainwin->summaryview);
2080 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2082 summary_print(mainwin->summaryview);
2085 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2087 if (prefs_common.confirm_on_exit) {
2088 if (alertpanel(_("Exit"), _("Exit this program?"),
2089 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2091 manage_window_focus_in(mainwin->window, NULL, NULL);
2094 app_will_exit(widget, mainwin);
2097 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2100 summary_search(mainwin->summaryview);
2102 message_search(mainwin->messageview);
2105 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2110 active = GTK_CHECK_MENU_ITEM(widget)->active;
2112 switch (mainwin->type) {
2114 case SEPARATE_MESSAGE:
2117 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2119 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2122 case SEPARATE_FOLDER:
2123 debug_print("separate folder\n");
2125 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2127 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2131 gtk_widget_show(mainwin->win.sep_both.folderwin);
2133 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2138 static void toggle_message_cb(MainWindow *mainwin, guint action,
2143 active = GTK_CHECK_MENU_ITEM(widget)->active;
2145 if (active != messageview_is_visible(mainwin->messageview))
2146 summary_toggle_view(mainwin->summaryview);
2149 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2152 toolbar_toggle(action, mainwin);
2155 void main_window_reply_cb(MainWindow *mainwin, guint action,
2158 MessageView *msgview = (MessageView*)mainwin->messageview;
2159 GSList *msginfo_list = NULL;
2162 g_return_if_fail(msgview != NULL);
2164 msginfo_list = summary_get_selection(mainwin->summaryview);
2165 g_return_if_fail(msginfo_list != NULL);
2167 body = messageview_get_selection(msgview);
2168 compose_reply_mode((ComposeMode)action, msginfo_list, body);
2170 g_slist_free(msginfo_list);
2174 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2177 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2178 gtk_widget_show(mainwin->hbox_stat);
2179 prefs_common.show_statusbar = TRUE;
2181 gtk_widget_hide(mainwin->hbox_stat);
2182 prefs_common.show_statusbar = FALSE;
2186 static void separate_widget_cb(MainWindow *mainwin, guint action,
2191 if (GTK_CHECK_MENU_ITEM(widget)->active)
2192 type = mainwin->type | action;
2194 type = mainwin->type & ~action;
2196 main_window_separation_change(mainwin, type);
2198 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2199 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2202 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2205 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2207 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2210 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2212 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2215 static void online_switch_clicked (GtkButton *btn, gpointer data)
2217 MainWindow *mainwin;
2218 GtkItemFactory *ifactory;
2219 GtkCheckMenuItem *menuitem;
2221 mainwin = (MainWindow *) data;
2223 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2224 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2226 g_return_if_fail(mainwin != NULL);
2227 g_return_if_fail(menuitem != NULL);
2229 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2231 gtk_widget_hide (mainwin->online_switch);
2232 gtk_widget_show (mainwin->offline_switch);
2233 menuitem->active = TRUE;
2234 prefs_common.work_offline = TRUE;
2235 inc_autocheck_timer_remove();
2238 gtk_widget_hide (mainwin->offline_switch);
2239 gtk_widget_show (mainwin->online_switch);
2240 menuitem->active = FALSE;
2241 prefs_common.work_offline = FALSE;
2242 inc_autocheck_timer_set();
2246 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2249 addressbook_open(NULL);
2252 static void log_window_show_cb(MainWindow *mainwin, guint action,
2255 log_window_show(mainwin->logwin);
2258 static void sel_download_cb(MainWindow *mainwin, guint action,
2261 selective_download(mainwin);
2264 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2269 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2271 summary_move_to(mainwin->summaryview);
2274 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2276 summary_copy_to(mainwin->summaryview);
2279 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2281 summary_delete(mainwin->summaryview);
2284 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2286 summary_cancel(mainwin->summaryview);
2289 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2291 summary_open_msg(mainwin->summaryview);
2294 static void view_source_cb(MainWindow *mainwin, guint action,
2297 summary_view_source(mainwin->summaryview);
2300 static void show_all_header_cb(MainWindow *mainwin, guint action,
2303 if (mainwin->menu_lock_count) return;
2304 summary_display_msg_selected(mainwin->summaryview,
2305 GTK_CHECK_MENU_ITEM(widget)->active);
2308 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2310 summary_reedit(mainwin->summaryview);
2313 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2315 summary_mark(mainwin->summaryview);
2318 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2320 summary_unmark(mainwin->summaryview);
2323 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2326 summary_mark_as_unread(mainwin->summaryview);
2329 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2332 summary_mark_as_read(mainwin->summaryview);
2335 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2338 summary_mark_all_read(mainwin->summaryview);
2341 static void add_address_cb(MainWindow *mainwin, guint action,
2344 summary_add_address(mainwin->summaryview);
2347 static void set_charset_cb(MainWindow *mainwin, guint action,
2352 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2353 str = conv_get_charset_str((CharSet)action);
2354 g_free(prefs_common.force_charset);
2355 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2357 summary_redisplay_msg(mainwin->summaryview);
2359 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2363 static void hide_read_messages (MainWindow *mainwin, guint action,
2366 if (!mainwin->summaryview->folder_item
2367 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2369 summary_toggle_show_read_messages(mainwin->summaryview);
2372 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2374 if (mainwin->menu_lock_count) return;
2375 if (!mainwin->summaryview->folder_item) return;
2377 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2378 summary_thread_build(mainwin->summaryview);
2379 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2381 summary_unthread(mainwin->summaryview);
2382 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2386 static void expand_threads_cb(MainWindow *mainwin, guint action,
2389 summary_expand_threads(mainwin->summaryview);
2392 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2395 summary_collapse_threads(mainwin->summaryview);
2398 static void set_display_item_cb(MainWindow *mainwin, guint action,
2401 prefs_summary_column_open();
2404 static void sort_summary_cb(MainWindow *mainwin, guint action,
2407 FolderItem *item = mainwin->summaryview->folder_item;
2408 GtkWidget *menuitem;
2410 if (mainwin->menu_lock_count) return;
2412 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2413 menuitem = gtk_item_factory_get_item
2414 (mainwin->menu_factory, "/View/Sort/Ascending");
2415 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2416 GTK_CHECK_MENU_ITEM(menuitem)->active
2417 ? SORT_ASCENDING : SORT_DESCENDING);
2421 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2424 FolderItem *item = mainwin->summaryview->folder_item;
2426 if (mainwin->menu_lock_count) return;
2428 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2429 summary_sort(mainwin->summaryview,
2430 item->sort_key, (FolderSortType)action);
2433 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2436 summary_attract_by_subject(mainwin->summaryview);
2439 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2442 summary_delete_duplicated(mainwin->summaryview);
2445 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2447 summary_filter(mainwin->summaryview);
2450 static void execute_summary_cb(MainWindow *mainwin, guint action,
2453 summary_execute(mainwin->summaryview);
2456 static void update_summary_cb(MainWindow *mainwin, guint action,
2460 FolderView *folderview = mainwin->folderview;
2462 if (!mainwin->summaryview->folder_item) return;
2463 if (!folderview->opened) return;
2465 folder_update_op_count();
2467 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2468 folderview->opened);
2471 folder_item_scan(fitem);
2472 summary_show(mainwin->summaryview, fitem);
2475 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2477 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2480 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2482 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2485 static void prev_unread_cb(MainWindow *mainwin, guint action,
2488 summary_select_prev_unread(mainwin->summaryview);
2491 static void next_unread_cb(MainWindow *mainwin, guint action,
2494 summary_select_next_unread(mainwin->summaryview);
2497 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2499 summary_select_prev_new(mainwin->summaryview);
2502 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2504 summary_select_next_new(mainwin->summaryview);
2507 static void prev_marked_cb(MainWindow *mainwin, guint action,
2510 summary_select_prev_marked(mainwin->summaryview);
2513 static void next_marked_cb(MainWindow *mainwin, guint action,
2516 summary_select_next_marked(mainwin->summaryview);
2519 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2522 summary_select_prev_labeled(mainwin->summaryview);
2525 static void next_labeled_cb(MainWindow *mainwin, guint action,
2528 summary_select_next_labeled(mainwin->summaryview);
2531 static void goto_folder_cb(MainWindow *mainwin, guint action,
2534 FolderItem *to_folder;
2536 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2539 folderview_select(mainwin->folderview, to_folder);
2542 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2544 messageview_copy_clipboard(mainwin->messageview);
2547 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2549 MessageView *msgview = mainwin->messageview;
2551 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2552 summary_select_all(mainwin->summaryview);
2553 else if (messageview_is_visible(msgview) &&
2554 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2555 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2556 messageview_select_all(mainwin->messageview);
2559 static void select_thread_cb(MainWindow *mainwin, guint action,
2562 summary_select_thread(mainwin->summaryview);
2565 static void create_filter_cb(MainWindow *mainwin, guint action,
2568 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2571 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2574 prefs_common_open();
2577 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2580 prefs_scoring_open(NULL);
2583 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2586 prefs_filtering_open(NULL, NULL, NULL);
2589 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2592 prefs_template_open();
2595 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2598 prefs_actions_open(mainwin);
2601 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2604 ssl_manager_open(mainwin);
2607 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2611 new_account_cb(mainwin, 0, widget);
2613 account_open(cur_account);
2617 static void new_account_cb(MainWindow *mainwin, guint action,
2620 account_edit_open();
2621 if (!compose_get_compose_list()) account_add();
2624 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2626 cur_account = (PrefsAccount *)data;
2627 main_window_reflect_prefs_all();
2630 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2635 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2637 pluginwindow_create();
2640 static void manual_open_cb(MainWindow *mainwin, guint action,
2643 manual_open((ManualType)action);
2646 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2648 MainWindow *mainwin = (MainWindow *)data;
2652 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2653 LOCAL_FOLDER(folder)->rootpath,
2657 str = g_strdup_printf(_("Scanning folder %s ..."),
2658 LOCAL_FOLDER(folder)->rootpath);
2660 STATUSBAR_PUSH(mainwin, str);
2661 STATUSBAR_POP(mainwin);
2665 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2668 SummaryView *summary;
2670 g_return_val_if_fail(data, FALSE);
2671 summary = ((MainWindow *)data)->summaryview;
2672 g_return_val_if_fail(summary, FALSE);
2673 if (summary->selected != summary->displayed)
2674 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2678 #define BREAK_ON_MODIFIER_KEY() \
2679 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2681 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2684 MainWindow *mainwin = (MainWindow*) data;
2686 if (!mainwin || !event) return;
2688 switch (event->keyval) {
2689 case GDK_Q: /* Quit */
2690 BREAK_ON_MODIFIER_KEY();
2692 app_exit_cb(mainwin, 0, NULL);
2695 if (mainwin->folderview && mainwin->summaryview
2696 && !mainwin->summaryview->displayed) {
2697 summary_lock(mainwin->summaryview);
2698 folderview_select_next_unread(mainwin->folderview);
2699 summary_unlock(mainwin->summaryview);
2707 #undef BREAK_ON_MODIFIER_KEY
2710 * Harvest addresses for selected folder.
2712 static void addr_harvest_cb( MainWindow *mainwin,
2716 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2720 * Harvest addresses for selected messages in summary view.
2722 static void addr_harvest_msg_cb( MainWindow *mainwin,
2726 summary_harvest_address( mainwin->summaryview );
2730 *\brief get a MainWindow
2732 *\return MainWindow * The first mainwindow in the mainwin_list
2734 MainWindow *mainwindow_get_mainwindow(void)
2736 if (mainwin_list && mainwin_list->data)
2737 return (MainWindow *)(mainwin_list->data);