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,
401 #define SEPARATE_ACTION 500
403 static GtkItemFactoryEntry mainwin_entries[] =
405 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
406 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
407 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
408 {N_("/_File/_Check for new messages in all folders"),
409 NULL, update_folderview_cb, 0, NULL},
410 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
411 {N_("/_File/_Folder/Create _new folder..."),
412 NULL, new_folder_cb, 0, NULL},
413 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
414 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
415 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
416 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
417 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
418 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
419 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
420 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
421 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
422 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
423 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
424 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
426 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
427 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
428 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
429 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
430 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
431 {N_("/_Edit/_Find in current message..."),
432 "<control>F", search_cb, 0, NULL},
433 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
434 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
435 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
436 {N_("/_View/Show or hi_de/_Folder tree"),
437 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
438 {N_("/_View/Show or hi_de/_Message view"),
439 "V", toggle_message_cb, 0, "<ToggleItem>"},
440 {N_("/_View/Show or hi_de/_Toolbar"),
441 NULL, NULL, 0, "<Branch>"},
442 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
443 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
444 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
445 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
446 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
447 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
448 {N_("/_View/Show or hi_de/_Toolbar/_None"),
449 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
450 {N_("/_View/Show or hi_de/Status _bar"),
451 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
452 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
453 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
454 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
455 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
456 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
457 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
458 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
459 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
460 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
461 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
462 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
463 {N_("/_View/_Sort/by _color label"),
464 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
465 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
466 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
467 {N_("/_View/_Sort/by a_ttachment"),
468 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
469 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
470 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
471 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
472 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
473 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
474 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
475 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
476 {N_("/_View/_Sort/_Attract by subject"),
477 NULL, attract_by_subject_cb, 0, NULL},
478 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
479 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
480 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
481 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
482 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
484 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
486 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
487 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
488 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_View/_Go to/P_rev unread message"),
490 "<shift>P", prev_unread_cb, 0, NULL},
491 {N_("/_View/_Go to/N_ext unread message"),
492 "<shift>N", next_unread_cb, 0, NULL},
493 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
495 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
496 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
497 {N_("/_View/_Go to/Prev _marked message"),
498 NULL, prev_marked_cb, 0, NULL},
499 {N_("/_View/_Go to/Next m_arked message"),
500 NULL, next_marked_cb, 0, NULL},
501 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_View/_Go to/Prev _labeled message"),
503 NULL, prev_labeled_cb, 0, NULL},
504 {N_("/_View/_Go to/Next la_beled message"),
505 NULL, next_labeled_cb, 0, NULL},
506 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
508 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
510 #define CODESET_SEPARATOR \
511 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
512 #define CODESET_ACTION(action) \
513 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
515 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
516 {N_("/_View/_Code set/_Auto detect"),
517 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
518 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
520 CODESET_ACTION(C_US_ASCII)},
523 {N_("/_View/_Code set/Unicode (_UTF-8)"),
524 CODESET_ACTION(C_UTF_8)},
527 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
528 CODESET_ACTION(C_ISO_8859_1)},
529 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
530 CODESET_ACTION(C_ISO_8859_15)},
533 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
534 CODESET_ACTION(C_ISO_8859_2)},
536 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
537 CODESET_ACTION(C_ISO_8859_13)},
538 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
539 CODESET_ACTION(C_ISO_8859_4)},
541 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
542 CODESET_ACTION(C_ISO_8859_7)},
544 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
545 CODESET_ACTION(C_ISO_8859_9)},
547 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
548 CODESET_ACTION(C_ISO_8859_5)},
549 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
550 CODESET_ACTION(C_KOI8_R)},
551 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
552 CODESET_ACTION(C_WINDOWS_1251)},
555 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
556 CODESET_ACTION(C_ISO_2022_JP)},
558 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
559 CODESET_ACTION(C_ISO_2022_JP_2)},
561 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
562 CODESET_ACTION(C_EUC_JP)},
563 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
564 CODESET_ACTION(C_SHIFT_JIS)},
567 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
568 CODESET_ACTION(C_GB2312)},
569 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
570 CODESET_ACTION(C_BIG5)},
571 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
572 CODESET_ACTION(C_EUC_TW)},
573 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
574 CODESET_ACTION(C_ISO_2022_CN)},
576 {N_("/_View/_Code set/Korean (EUC-_KR)"),
577 CODESET_ACTION(C_EUC_KR)},
578 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
579 CODESET_ACTION(C_ISO_2022_KR)},
581 {N_("/_View/_Code set/Thai (TIS-620)"),
582 CODESET_ACTION(C_TIS_620)},
583 {N_("/_View/_Code set/Thai (Windows-874)"),
584 CODESET_ACTION(C_WINDOWS_874)},
587 #undef CODESET_SEPARATOR
588 #undef CODESET_ACTION
590 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
591 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
592 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
593 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
594 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
597 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
598 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
599 {N_("/_Message/Get from _all accounts"),
600 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
601 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
602 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
604 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
606 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
607 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
608 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
609 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
610 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
611 {N_("/_Message/Repl_y to/mailing _list"),
612 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
613 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
614 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
616 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
617 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
619 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
621 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
622 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
623 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
624 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
626 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
627 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
628 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
629 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
630 {N_("/_Message/_Mark/Mark as rea_d"),
631 NULL, mark_as_read_cb, 0, NULL},
632 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
634 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
635 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
636 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
637 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
638 {N_("/_Tools/Add sender to address boo_k"),
639 NULL, add_address_cb, 0, NULL},
640 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
641 {N_("/_Tools/_Harvest addresses/from _Folder..."),
642 NULL, addr_harvest_cb, 0, NULL},
643 {N_("/_Tools/_Harvest addresses/from _Messages..."),
644 NULL, addr_harvest_msg_cb, 0, NULL},
645 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
646 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
647 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
648 {N_("/_Tools/_Create filter rule/_Automatically"),
649 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
650 {N_("/_Tools/_Create filter rule/by _From"),
651 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
652 {N_("/_Tools/_Create filter rule/by _To"),
653 NULL, create_filter_cb, FILTER_BY_TO, NULL},
654 {N_("/_Tools/_Create filter rule/by _Subject"),
655 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
656 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
658 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_Tools/Delete du_plicated messages"),
660 NULL, delete_duplicated_cb, 0, NULL},
661 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
664 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
665 {N_("/_Tools/SSL certi_ficates..."),
666 NULL, ssl_manager_open_cb, 0, NULL},
668 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
669 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
671 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
672 {N_("/_Configuration/_Common preferences..."),
673 NULL, prefs_common_open_cb, 0, NULL},
674 {N_("/_Configuration/_Scoring..."),
675 NULL, prefs_scoring_open_cb, 0, NULL},
676 {N_("/_Configuration/_Filtering..."),
677 NULL, prefs_filtering_open_cb, 0, NULL},
678 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
679 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
680 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Configuration/_Preferences for current account..."),
682 NULL, prefs_account_open_cb, 0, NULL},
683 {N_("/_Configuration/Create _new account..."),
684 NULL, new_account_cb, 0, NULL},
685 {N_("/_Configuration/_Edit accounts..."),
686 NULL, account_edit_open, 0, NULL},
687 {N_("/_Configuration/C_hange current account"),
688 NULL, NULL, 0, "<Branch>"},
689 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Configuration/Preferences..."), NULL, prefs_open_cb, 0, NULL},
691 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
693 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
694 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
695 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
696 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
697 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
698 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
699 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
700 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
701 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
704 MainWindow *main_window_create(SeparateType type)
710 GtkWidget *handlebox;
711 GtkWidget *vbox_body;
712 GtkWidget *hbox_stat;
713 GtkWidget *statusbar;
714 GtkWidget *progressbar;
715 GtkWidget *statuslabel;
716 GtkWidget *ac_button;
718 GtkWidget *online_pixmap;
719 GtkWidget *offline_pixmap;
720 GtkWidget *online_switch;
721 GtkWidget *offline_switch;
723 FolderView *folderview;
724 SummaryView *summaryview;
725 MessageView *messageview;
726 GdkColormap *colormap;
729 GtkItemFactory *ifactory;
733 guint n_menu_entries;
735 static GdkGeometry geometry;
737 debug_print("Creating main window...\n");
738 mainwin = g_new0(MainWindow, 1);
741 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
742 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
743 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
744 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
746 if (!geometry.min_height) {
747 geometry.min_width = 320;
748 geometry.min_height = 200;
750 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
753 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
754 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
755 MANAGE_WINDOW_SIGNALS_CONNECT(window);
756 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
757 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
759 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
760 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
762 gtk_widget_realize(window);
763 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
766 gtkut_widget_set_app_icon(window);
768 vbox = gtk_vbox_new(FALSE, 0);
769 gtk_widget_show(vbox);
770 gtk_container_add(GTK_CONTAINER(window), vbox);
773 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
774 menubar = menubar_create(window, mainwin_entries,
775 n_menu_entries, "<Main>", mainwin);
776 gtk_widget_show(menubar);
777 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
778 ifactory = gtk_item_factory_from_widget(menubar);
780 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
781 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
783 handlebox = gtk_handle_box_new();
784 gtk_widget_show(handlebox);
785 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
787 /* link window to mainwin->window to avoid gdk warnings */
788 mainwin->window = window;
791 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
795 /* vbox that contains body */
796 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
797 gtk_widget_show(vbox_body);
798 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
799 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
801 hbox_stat = gtk_hbox_new(FALSE, 2);
802 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
804 statusbar = statusbar_create();
805 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
807 progressbar = gtk_progress_bar_new();
808 gtk_widget_set_usize(progressbar, 120, 1);
809 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
811 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
812 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
813 online_switch = gtk_button_new ();
814 offline_switch = gtk_button_new ();
815 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
816 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
817 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
818 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
819 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
820 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
821 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
822 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
824 statuslabel = gtk_label_new("");
825 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
827 ac_button = gtk_button_new();
828 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
829 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
830 gtk_widget_set_usize(ac_button, -1, 1);
831 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
832 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
833 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
835 ac_label = gtk_label_new("");
836 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
838 gtk_widget_show_all(hbox_stat);
840 gtk_widget_hide(offline_switch);
842 mainwin->folderview = folderview = folderview_create();
843 mainwin->summaryview = summaryview = summary_create();
844 mainwin->messageview = messageview = messageview_create(mainwin);
845 mainwin->logwin = log_window_create();
847 folderview->mainwin = mainwin;
848 folderview->summaryview = summaryview;
850 summaryview->mainwin = mainwin;
851 summaryview->folderview = folderview;
852 summaryview->messageview = messageview;
853 summaryview->window = window;
855 mainwin->vbox = vbox;
856 mainwin->menubar = menubar;
857 mainwin->menu_factory = ifactory;
858 mainwin->handlebox = handlebox;
859 mainwin->vbox_body = vbox_body;
860 mainwin->hbox_stat = hbox_stat;
861 mainwin->statusbar = statusbar;
862 mainwin->progressbar = progressbar;
863 mainwin->statuslabel = statuslabel;
864 mainwin->ac_button = ac_button;
865 mainwin->ac_label = ac_label;
867 mainwin->online_switch = online_switch;
868 mainwin->offline_switch = offline_switch;
869 mainwin->online_pixmap = online_pixmap;
870 mainwin->offline_pixmap = offline_pixmap;
872 /* set context IDs for status bar */
873 mainwin->mainwin_cid = gtk_statusbar_get_context_id
874 (GTK_STATUSBAR(statusbar), "Main Window");
875 mainwin->folderview_cid = gtk_statusbar_get_context_id
876 (GTK_STATUSBAR(statusbar), "Folder View");
877 mainwin->summaryview_cid = gtk_statusbar_get_context_id
878 (GTK_STATUSBAR(statusbar), "Summary View");
880 /* allocate colors for summary view and folder view */
881 summaryview->color_marked.red = summaryview->color_marked.green = 0;
882 summaryview->color_marked.blue = (guint16)65535;
884 summaryview->color_dim.red = summaryview->color_dim.green =
885 summaryview->color_dim.blue = COLOR_DIM;
887 folderview->color_new.red = (guint16)55000;
888 folderview->color_new.green = folderview->color_new.blue = 15000;
890 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
891 &folderview->color_op);
893 summaryview->color_important.red = 0;
894 summaryview->color_important.green = 0;
895 summaryview->color_important.blue = (guint16)65535;
897 color[0] = summaryview->color_marked;
898 color[1] = summaryview->color_dim;
899 color[2] = folderview->color_new;
900 color[3] = folderview->color_op;
902 colormap = gdk_window_get_colormap(window->window);
903 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
904 for (i = 0; i < 4; i++) {
905 if (success[i] == FALSE)
906 g_warning("MainWindow: color allocation %d failed\n", i);
909 debug_print("done.\n");
911 messageview->visible = TRUE;
913 main_window_set_widgets(mainwin, type);
916 menuitem = gtk_item_factory_get_item
917 (ifactory, "/View/Code set/Auto detect");
918 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
920 switch (prefs_common.toolbar_style) {
922 menuitem = gtk_item_factory_get_item
923 (ifactory, "/View/Show or hide/Toolbar/None");
926 menuitem = gtk_item_factory_get_item
927 (ifactory, "/View/Show or hide/Toolbar/Icon");
930 menuitem = gtk_item_factory_get_item
931 (ifactory, "/View/Show or hide/Toolbar/Text");
934 menuitem = gtk_item_factory_get_item
935 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
937 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
939 gtk_widget_hide(mainwin->hbox_stat);
940 menuitem = gtk_item_factory_get_item
941 (ifactory, "/View/Show or hide/Status bar");
942 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
943 prefs_common.show_statusbar);
945 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
947 if (prefs_common.show_searchbar) {
948 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
949 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
950 gtk_widget_hide(summaryview->search_description);
953 /* set account selection menu */
954 ac_menu = gtk_item_factory_get_widget
955 (ifactory, "/Configuration/Change current account");
956 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
957 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
958 mainwin->ac_menu = ac_menu;
960 toolbar_main_set_sensitive(mainwin);
962 /* create actions menu */
963 update_mainwin_actions_menu(ifactory, mainwin);
965 /* attach accel groups to main window */
966 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
967 gtk_window_add_accel_group \
969 gtk_item_factory_from_widget(menu)->accel_group)
971 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
973 /* connect the accelerators for equivalent
974 menu items in different menus */
975 menu_connect_identical_items();
979 /* show main window */
980 gtk_widget_set_uposition(mainwin->window,
981 prefs_common.mainwin_x,
982 prefs_common.mainwin_y);
983 gtk_widget_set_usize(window, prefs_common.mainwin_width,
984 prefs_common.mainwin_height);
985 gtk_widget_show(mainwin->window);
987 /* initialize views */
988 folderview_init(folderview);
989 summary_init(summaryview);
990 messageview_init(messageview);
991 log_window_init(mainwin->logwin);
993 sslcertwindow_register_hook();
995 mainwin->lock_count = 0;
996 mainwin->menu_lock_count = 0;
997 mainwin->cursor_count = 0;
1000 watch_cursor = gdk_cursor_new(GDK_WATCH);
1002 mainwin_list = g_list_append(mainwin_list, mainwin);
1004 /* init work_offline */
1005 if (prefs_common.work_offline)
1006 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1011 void main_window_cursor_wait(MainWindow *mainwin)
1014 if (mainwin->cursor_count == 0)
1015 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1017 mainwin->cursor_count++;
1022 void main_window_cursor_normal(MainWindow *mainwin)
1024 if (mainwin->cursor_count)
1025 mainwin->cursor_count--;
1027 if (mainwin->cursor_count == 0)
1028 gdk_window_set_cursor(mainwin->window->window, NULL);
1033 /* lock / unlock the user-interface */
1034 void main_window_lock(MainWindow *mainwin)
1036 if (mainwin->lock_count == 0)
1037 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1039 mainwin->lock_count++;
1041 main_window_set_menu_sensitive(mainwin);
1042 toolbar_main_set_sensitive(mainwin);
1045 void main_window_unlock(MainWindow *mainwin)
1047 if (mainwin->lock_count)
1048 mainwin->lock_count--;
1050 main_window_set_menu_sensitive(mainwin);
1051 toolbar_main_set_sensitive(mainwin);
1053 if (mainwin->lock_count == 0)
1054 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1057 static void main_window_menu_callback_block(MainWindow *mainwin)
1059 mainwin->menu_lock_count++;
1062 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1064 if (mainwin->menu_lock_count)
1065 mainwin->menu_lock_count--;
1068 void main_window_reflect_prefs_all(void)
1070 main_window_reflect_prefs_all_real(FALSE);
1073 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1076 MainWindow *mainwin;
1079 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1080 mainwin = (MainWindow *)cur->data;
1082 main_window_show_cur_account(mainwin);
1083 main_window_set_menu_sensitive(mainwin);
1084 toolbar_main_set_sensitive(mainwin);
1087 if (pixmap_theme_changed) {
1088 toolbar_update(TOOLBAR_MAIN, mainwin);
1089 messageview_reflect_prefs_pixmap_theme();
1090 compose_reflect_prefs_pixmap_theme();
1091 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1092 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1094 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1095 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1096 mainwin->online_pixmap);
1097 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1098 gtk_widget_show(pixmap);
1099 mainwin->online_pixmap = pixmap;
1100 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1101 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1102 mainwin->offline_pixmap);
1103 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1104 gtk_widget_show(pixmap);
1105 mainwin->offline_pixmap = pixmap;
1108 summary_redisplay_msg(mainwin->summaryview);
1109 headerview_set_visibility(mainwin->messageview->headerview,
1110 prefs_common.display_header_pane);
1114 void main_window_set_summary_column(void)
1117 MainWindow *mainwin;
1119 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1120 mainwin = (MainWindow *)cur->data;
1121 summary_set_column_order(mainwin->summaryview);
1125 void main_window_set_account_menu(GList *account_list)
1127 GList *cur, *cur_ac, *cur_item;
1128 GtkWidget *menuitem;
1129 MainWindow *mainwin;
1130 PrefsAccount *ac_prefs;
1132 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1133 mainwin = (MainWindow *)cur->data;
1135 /* destroy all previous menu item */
1136 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1137 while (cur_item != NULL) {
1138 GList *next = cur_item->next;
1139 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1143 for (cur_ac = account_list; cur_ac != NULL;
1144 cur_ac = cur_ac->next) {
1145 ac_prefs = (PrefsAccount *)cur_ac->data;
1147 menuitem = gtk_menu_item_new_with_label
1148 (ac_prefs->account_name
1149 ? ac_prefs->account_name : _("Untitled"));
1150 gtk_widget_show(menuitem);
1151 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1152 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1153 GTK_SIGNAL_FUNC(account_menu_cb),
1159 static void main_window_show_cur_account(MainWindow *mainwin)
1164 ac_name = g_strdup(cur_account
1165 ? (cur_account->account_name
1166 ? cur_account->account_name : _("Untitled"))
1170 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1172 buf = g_strdup(PROG_VERSION);
1173 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1176 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1177 gtk_widget_queue_resize(mainwin->ac_button);
1182 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1184 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1185 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1186 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1187 GtkWidget *message_wid = mainwin->messageview->vbox;
1189 debug_print("Changing window separation type from %d to %d\n",
1190 mainwin->type, type);
1192 if (mainwin->type == type) return;
1194 /* remove widgets from those containers */
1195 gtk_widget_ref(folder_wid);
1196 gtk_widget_ref(summary_wid);
1197 gtk_widget_ref(message_wid);
1198 gtkut_container_remove
1199 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1200 gtkut_container_remove
1201 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1202 gtkut_container_remove
1203 (GTK_CONTAINER(message_wid->parent), message_wid);
1205 /* clean containers */
1206 switch (mainwin->type) {
1208 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1210 case SEPARATE_FOLDER:
1211 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1212 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1214 case SEPARATE_MESSAGE:
1215 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1216 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1219 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1220 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1224 gtk_widget_hide(mainwin->window);
1225 main_window_set_widgets(mainwin, type);
1226 gtk_widget_show(mainwin->window);
1228 gtk_widget_unref(folder_wid);
1229 gtk_widget_unref(summary_wid);
1230 gtk_widget_unref(message_wid);
1233 void main_window_toggle_message_view(MainWindow *mainwin)
1235 SummaryView *summaryview = mainwin->summaryview;
1236 union CompositeWin *cwin = &mainwin->win;
1237 GtkWidget *vpaned = NULL;
1238 GtkWidget *container = NULL;
1239 GtkWidget *msgwin = NULL;
1241 switch (mainwin->type) {
1243 vpaned = cwin->sep_none.vpaned;
1244 container = cwin->sep_none.hpaned;
1246 case SEPARATE_FOLDER:
1247 vpaned = cwin->sep_folder.vpaned;
1248 container = mainwin->vbox_body;
1250 case SEPARATE_MESSAGE:
1251 msgwin = mainwin->win.sep_message.messagewin;
1254 msgwin = mainwin->win.sep_both.messagewin;
1259 if (GTK_WIDGET_VISIBLE(msgwin)) {
1260 gtk_widget_hide(msgwin);
1261 mainwin->messageview->visible = FALSE;
1262 summaryview->displayed = NULL;
1264 gtk_widget_show(msgwin);
1265 mainwin->messageview->visible = TRUE;
1267 } else if (vpaned->parent != NULL) {
1268 mainwin->messageview->visible = FALSE;
1269 summaryview->displayed = NULL;
1270 gtk_widget_ref(vpaned);
1271 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1272 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1273 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1274 GTK_ARROW_UP, GTK_SHADOW_OUT);
1276 mainwin->messageview->visible = TRUE;
1277 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1278 gtk_container_add(GTK_CONTAINER(container), vpaned);
1279 gtk_widget_unref(vpaned);
1280 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1281 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1284 main_window_set_menu_sensitive(mainwin);
1286 gtk_widget_grab_focus(summaryview->ctree);
1289 void main_window_get_size(MainWindow *mainwin)
1291 GtkAllocation *allocation;
1293 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1295 prefs_common.summaryview_width = allocation->width;
1297 if ((mainwin->type == SEPARATE_NONE ||
1298 mainwin->type == SEPARATE_FOLDER) &&
1299 messageview_is_visible(mainwin->messageview))
1300 prefs_common.summaryview_height = allocation->height;
1302 prefs_common.mainview_width = allocation->width;
1304 allocation = &mainwin->window->allocation;
1306 prefs_common.mainview_height = allocation->height;
1307 prefs_common.mainwin_width = allocation->width;
1308 prefs_common.mainwin_height = allocation->height;
1310 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1312 prefs_common.folderview_width = allocation->width;
1313 prefs_common.folderview_height = allocation->height;
1316 void main_window_get_position(MainWindow *mainwin)
1320 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1322 prefs_common.mainview_x = x;
1323 prefs_common.mainview_y = y;
1324 prefs_common.mainwin_x = x;
1325 prefs_common.mainwin_y = y;
1327 debug_print("window position: x = %d, y = %d\n", x, y);
1330 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1336 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1337 folder = FOLDER(list->data);
1338 if (folder && folder->trash && folder->trash->total > 0)
1342 if (!has_trash) return;
1345 if (alertpanel(_("Empty trash"),
1346 _("Empty all messages in trash?"),
1347 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1349 manage_window_focus_in(mainwin->window, NULL, NULL);
1352 procmsg_empty_trash();
1354 if (mainwin->summaryview->folder_item &&
1355 mainwin->summaryview->folder_item->stype == F_TRASH)
1356 gtk_widget_grab_focus(mainwin->folderview->ctree);
1359 void main_window_add_mailbox(MainWindow *mainwin)
1364 path = input_dialog(_("Add mailbox"),
1365 _("Input the location of mailbox.\n"
1366 "If the existing mailbox is specified, it will be\n"
1367 "scanned automatically."),
1370 if (folder_find_from_path(path)) {
1371 alertpanel_error(_("The mailbox `%s' already exists."), path);
1375 if (!strcmp(path, "Mail"))
1376 folder = folder_new(F_MH, _("Mailbox"), path);
1378 folder = folder_new(F_MH, g_basename(path), path);
1381 if (folder->create_tree(folder) < 0) {
1382 alertpanel_error(_("Creation of the mailbox failed.\n"
1383 "Maybe some files already exist, or you don't have the permission to write there."));
1384 folder_destroy(folder);
1389 folder_set_ui_func(folder, scan_tree_func, mainwin);
1390 folder_scan_tree(folder);
1391 folder_set_ui_func(folder, NULL, NULL);
1393 folderview_set(mainwin->folderview);
1396 void main_window_add_mbox(MainWindow *mainwin)
1402 path = input_dialog(_("Add mbox mailbox"),
1403 _("Input the location of mailbox."),
1408 if (folder_find_from_path(path)) {
1409 alertpanel_error(_("The mailbox `%s' already exists."), path);
1415 if (!strcmp(path, "Mail"))
1416 folder = folder_new(F_MBOX, _("Mailbox"), path);
1420 folder = folder_new(F_MBOX, g_basename(path), path);
1423 if (folder->create_tree(folder) < 0) {
1424 alertpanel_error(_("Creation of the mailbox failed."));
1425 folder_destroy(folder);
1431 item = folder_item_new(folder, folder->name, NULL);
1432 item->folder = folder;
1433 folder->node = g_node_new(item);
1435 folder_create_folder(item, "inbox");
1436 folder_create_folder(item, "outbox");
1437 folder_create_folder(item, "queue");
1438 folder_create_folder(item, "draft");
1439 folder_create_folder(item, "trash");
1441 folderview_set(mainwin->folderview);
1444 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1446 SensitiveCond state = 0;
1447 SummarySelection selection;
1448 FolderItem *item = mainwin->summaryview->folder_item;
1449 GList *account_list = account_get_list();
1451 selection = summary_get_selection_type(mainwin->summaryview);
1453 if (mainwin->lock_count == 0)
1454 state |= M_UNLOCKED;
1455 if (selection != SUMMARY_NONE)
1456 state |= M_MSG_EXIST;
1457 if (item && item->path && item->parent && !item->no_select) {
1459 /* if (item->folder->type != F_NEWS) */
1460 state |= M_ALLOW_DELETE;
1462 if (prefs_common.immediate_exec == 0
1463 && mainwin->lock_count == 0)
1464 state |= M_DELAY_EXEC;
1466 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1467 || selection != SUMMARY_NONE)
1468 state |= M_HIDE_READ_MSG;
1470 if (mainwin->summaryview->threaded)
1471 state |= M_THREADED;
1473 state |= M_UNTHREADED;
1474 if (selection == SUMMARY_SELECTED_SINGLE ||
1475 selection == SUMMARY_SELECTED_MULTIPLE)
1476 state |= M_TARGET_EXIST;
1477 if (selection == SUMMARY_SELECTED_SINGLE)
1478 state |= M_SINGLE_TARGET_EXIST;
1479 if (mainwin->summaryview->folder_item &&
1480 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1483 state |= M_NOT_NEWS;
1484 if (selection == SUMMARY_SELECTED_SINGLE &&
1486 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1487 item->stype == F_QUEUE)))
1488 state |= M_ALLOW_REEDIT;
1490 state |= M_HAVE_ACCOUNT;
1492 for ( ; account_list != NULL; account_list = account_list->next) {
1493 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1494 state |= M_HAVE_NEWS_ACCOUNT;
1499 if (inc_is_active())
1500 state |= M_INC_ACTIVE;
1507 void main_window_set_menu_sensitive(MainWindow *mainwin)
1509 GtkItemFactory *ifactory = mainwin->menu_factory;
1510 SensitiveCond state;
1512 GtkWidget *menuitem;
1513 SummaryView *summaryview;
1517 static const struct {
1521 {"/File/Add mailbox..." , M_UNLOCKED},
1522 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1523 {"/File/Check for new messages in all folders", M_UNLOCKED},
1524 {"/File/Folder" , M_UNLOCKED},
1525 {"/File/Import mbox file..." , M_UNLOCKED},
1526 {"/File/Export to mbox file..." , M_UNLOCKED},
1527 {"/File/Empty trash" , M_UNLOCKED},
1528 {"/File/Work offline" , M_UNLOCKED},
1530 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1531 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1532 /* {"/File/Close" , M_UNLOCKED}, */
1533 {"/File/Exit" , M_UNLOCKED},
1535 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1537 {"/View/Sort" , M_EXEC},
1538 {"/View/Thread view" , M_EXEC},
1539 {"/View/Expand all threads" , M_MSG_EXIST},
1540 {"/View/Collapse all threads" , M_MSG_EXIST},
1541 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1542 {"/View/Go to/Prev message" , M_MSG_EXIST},
1543 {"/View/Go to/Next message" , M_MSG_EXIST},
1544 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1545 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1546 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1547 {"/View/Go to/Next new message" , M_MSG_EXIST},
1548 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1549 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1550 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1551 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1552 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1553 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1554 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1556 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1557 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1558 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1559 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1560 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1561 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1562 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1563 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1564 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1565 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1566 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1567 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1568 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1569 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1570 {"/Message/Mark" , M_TARGET_EXIST},
1572 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1573 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1574 {"/Tools/Harvest addresses" , M_UNLOCKED},
1575 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1576 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1577 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1578 {"/Tools/Execute" , M_DELAY_EXEC},
1579 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1581 {"/Configuration", M_UNLOCKED},
1586 state = main_window_get_current_state(mainwin);
1588 for (i = 0; entry[i].entry != NULL; i++) {
1589 sensitive = ((entry[i].cond & state) == entry[i].cond);
1590 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1593 main_window_menu_callback_block(mainwin);
1595 #define SET_CHECK_MENU_ACTIVE(path, active) \
1597 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1598 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1601 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1602 messageview_is_visible(mainwin->messageview));
1604 summaryview = mainwin->summaryview;
1605 menu_path = "/View/Sort/Don't sort";
1607 switch (summaryview->sort_key) {
1608 case SORT_BY_NUMBER:
1609 menu_path = "/View/Sort/by number"; break;
1611 menu_path = "/View/Sort/by size"; break;
1613 menu_path = "/View/Sort/by date"; break;
1615 menu_path = "/View/Sort/by from"; break;
1617 menu_path = "/View/Sort/by recipient"; break;
1618 case SORT_BY_SUBJECT:
1619 menu_path = "/View/Sort/by subject"; break;
1621 menu_path = "/View/Sort/by color label"; break;
1623 menu_path = "/View/Sort/by mark"; break;
1624 case SORT_BY_UNREAD:
1625 menu_path = "/View/Sort/by unread"; break;
1627 menu_path = "/View/Sort/by attachment"; break;
1629 menu_path = "/View/Sort/by score"; break;
1630 case SORT_BY_LOCKED:
1631 menu_path = "/View/Sort/by locked"; break;
1634 menu_path = "/View/Sort/Don't sort"; break;
1636 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1638 if (summaryview->sort_type == SORT_ASCENDING) {
1639 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1641 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1644 if (summaryview->sort_key != SORT_BY_NONE) {
1645 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1646 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1648 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1649 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1652 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1653 mainwin->messageview->textview->show_all_headers);
1654 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1656 #undef SET_CHECK_MENU_ACTIVE
1658 main_window_menu_callback_unblock(mainwin);
1661 void main_window_popup(MainWindow *mainwin)
1663 gtkut_window_popup(mainwin->window);
1665 switch (mainwin->type) {
1666 case SEPARATE_FOLDER:
1667 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1669 case SEPARATE_MESSAGE:
1670 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1673 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1674 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1681 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1683 GtkWidget *folderwin = NULL;
1684 GtkWidget *messagewin = NULL;
1687 GtkWidget *vbox_body = mainwin->vbox_body;
1688 GtkItemFactory *ifactory = mainwin->menu_factory;
1689 GtkWidget *menuitem;
1690 GtkItemFactory *msgview_ifactory;
1692 debug_print("Setting widgets...");
1694 /* create separated window(s) if needed */
1695 if (type & SEPARATE_FOLDER) {
1696 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1697 gtk_window_set_title(GTK_WINDOW(folderwin),
1698 _("Sylpheed - Folder View"));
1699 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1700 "folder_view", "Sylpheed");
1701 gtk_window_set_policy(GTK_WINDOW(folderwin),
1703 gtk_widget_set_usize(folderwin, -1,
1704 prefs_common.mainview_height);
1705 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1707 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1708 GTK_SIGNAL_FUNC(folder_window_close_cb),
1711 if (type & SEPARATE_MESSAGE) {
1712 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1713 gtk_window_set_title(GTK_WINDOW(messagewin),
1714 _("Sylpheed - Message View"));
1715 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1716 "message_view", "Sylpheed");
1717 gtk_window_set_policy(GTK_WINDOW(messagewin),
1719 gtk_widget_set_usize
1720 (messagewin, prefs_common.mainview_width,
1721 prefs_common.mainview_height
1722 - prefs_common.summaryview_height
1723 + DEFAULT_HEADERVIEW_HEIGHT);
1724 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1726 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1727 GTK_SIGNAL_FUNC(message_window_close_cb),
1733 hpaned = gtk_hpaned_new();
1734 gtk_widget_show(hpaned);
1735 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1736 gtk_paned_add1(GTK_PANED(hpaned),
1737 GTK_WIDGET_PTR(mainwin->folderview));
1739 vpaned = gtk_vpaned_new();
1740 if (messageview_is_visible(mainwin->messageview)) {
1741 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1742 gtk_paned_add1(GTK_PANED(vpaned),
1743 GTK_WIDGET_PTR(mainwin->summaryview));
1745 gtk_paned_add2(GTK_PANED(hpaned),
1746 GTK_WIDGET_PTR(mainwin->summaryview));
1747 gtk_widget_ref(vpaned);
1749 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1750 prefs_common.summaryview_width,
1751 prefs_common.summaryview_height);
1752 gtk_paned_add2(GTK_PANED(vpaned),
1753 GTK_WIDGET_PTR(mainwin->messageview));
1754 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1755 prefs_common.mainview_width, -1);
1756 gtk_widget_set_usize(mainwin->window,
1757 prefs_common.folderview_width +
1758 prefs_common.mainview_width,
1759 prefs_common.mainwin_height);
1760 gtk_widget_show_all(vpaned);
1762 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1763 * lose track of its visibility state */
1764 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1765 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1767 mainwin->win.sep_none.hpaned = hpaned;
1768 mainwin->win.sep_none.vpaned = vpaned;
1770 /* remove headerview if not in prefs */
1771 headerview_set_visibility(mainwin->messageview->headerview,
1772 prefs_common.display_header_pane);
1774 case SEPARATE_FOLDER:
1775 vpaned = gtk_vpaned_new();
1776 if (messageview_is_visible(mainwin->messageview)) {
1777 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1779 gtk_paned_add1(GTK_PANED(vpaned),
1780 GTK_WIDGET_PTR(mainwin->summaryview));
1782 gtk_box_pack_start(GTK_BOX(vbox_body),
1783 GTK_WIDGET_PTR(mainwin->summaryview),
1785 gtk_widget_ref(vpaned);
1787 gtk_paned_add2(GTK_PANED(vpaned),
1788 GTK_WIDGET_PTR(mainwin->messageview));
1789 gtk_widget_show_all(vpaned);
1790 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1791 prefs_common.summaryview_width,
1792 prefs_common.summaryview_height);
1793 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1794 prefs_common.mainview_width, -1);
1795 gtk_widget_set_usize(mainwin->window,
1796 prefs_common.mainview_width,
1797 prefs_common.mainview_height);
1799 gtk_container_add(GTK_CONTAINER(folderwin),
1800 GTK_WIDGET_PTR(mainwin->folderview));
1802 mainwin->win.sep_folder.folderwin = folderwin;
1803 mainwin->win.sep_folder.vpaned = vpaned;
1805 gtk_widget_show_all(folderwin);
1807 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1808 * lose track of its visibility state */
1809 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1810 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1812 /* remove headerview if not in prefs */
1813 headerview_set_visibility(mainwin->messageview->headerview,
1814 prefs_common.display_header_pane);
1817 case SEPARATE_MESSAGE:
1818 hpaned = gtk_hpaned_new();
1819 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1821 gtk_paned_add1(GTK_PANED(hpaned),
1822 GTK_WIDGET_PTR(mainwin->folderview));
1823 gtk_paned_add2(GTK_PANED(hpaned),
1824 GTK_WIDGET_PTR(mainwin->summaryview));
1825 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1826 prefs_common.summaryview_width,
1827 prefs_common.summaryview_height);
1828 gtk_widget_set_usize(mainwin->window,
1829 prefs_common.folderview_width +
1830 prefs_common.mainview_width,
1831 prefs_common.mainwin_height);
1832 gtk_widget_show_all(hpaned);
1834 messageview_add_toolbar(mainwin->messageview, messagewin);
1835 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1836 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1838 mainwin->win.sep_message.messagewin = messagewin;
1839 mainwin->win.sep_message.hpaned = hpaned;
1841 gtk_widget_show_all(messagewin);
1843 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1844 * lose track of its visibility state */
1845 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1846 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1849 gtk_box_pack_start(GTK_BOX(vbox_body),
1850 GTK_WIDGET_PTR(mainwin->summaryview),
1852 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1853 prefs_common.summaryview_width,
1854 prefs_common.summaryview_height);
1855 gtk_widget_set_usize(mainwin->window,
1856 prefs_common.mainview_width,
1857 prefs_common.mainwin_height);
1858 gtk_container_add(GTK_CONTAINER(folderwin),
1859 GTK_WIDGET_PTR(mainwin->folderview));
1860 gtk_container_add(GTK_CONTAINER(messagewin),
1861 GTK_WIDGET_PTR(mainwin->messageview));
1863 mainwin->win.sep_both.folderwin = folderwin;
1864 mainwin->win.sep_both.messagewin = messagewin;
1866 gtk_widget_show_all(folderwin);
1867 gtk_widget_show_all(messagewin);
1869 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1870 * lose track of its visibility state */
1871 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1872 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1876 /* rehide quick search if necessary */
1877 if (!prefs_common.show_searchbar)
1878 gtk_widget_hide(mainwin->summaryview->hbox_search);
1880 mainwin->type = type;
1882 mainwin->messageview->visible = TRUE;
1884 /* toggle menu state */
1885 menuitem = gtk_item_factory_get_item
1886 (ifactory, "/View/Show or hide/Folder tree");
1887 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1888 menuitem = gtk_item_factory_get_item
1889 (ifactory, "/View/Show or hide/Message view");
1890 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1892 menuitem = gtk_item_factory_get_item
1893 (ifactory, "/View/Separate folder tree");
1894 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1895 ((type & SEPARATE_FOLDER) != 0));
1896 menuitem = gtk_item_factory_get_item
1897 (ifactory, "/View/Separate message view");
1898 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1899 ((type & SEPARATE_MESSAGE) != 0));
1901 debug_print("done.\n");
1904 void main_window_destroy_all(void)
1906 while (mainwin_list != NULL) {
1907 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1909 /* free toolbar stuff */
1910 toolbar_clear_list(TOOLBAR_MAIN);
1911 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1912 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1914 g_free(mainwin->toolbar);
1917 mainwin_list = g_list_remove(mainwin_list, mainwin);
1919 g_list_free(mainwin_list);
1923 static void toolbar_account_button_pressed(GtkWidget *widget,
1924 GdkEventButton *event,
1927 MainWindow *mainwin = (MainWindow *)data;
1930 if (event->button != 3) return;
1932 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1933 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1936 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1937 menu_button_position, widget,
1938 event->button, event->time);
1942 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1945 MainWindow *mainwin = (MainWindow *)data;
1949 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1950 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1953 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1954 menu_button_position, widget,
1955 event->button, event->time);
1958 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
1960 MainWindow *mainwin = (MainWindow *)data;
1963 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
1964 if (!button) return;
1965 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1966 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
1967 manage_window_focus_in(mainwin->window, NULL, NULL);
1970 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1973 MainWindow *mainwin = (MainWindow *)data;
1975 if (mainwin->lock_count == 0)
1976 app_exit_cb(data, 0, widget);
1981 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1984 MainWindow *mainwin = (MainWindow *)data;
1985 GtkWidget *menuitem;
1987 menuitem = gtk_item_factory_get_item
1988 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
1989 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1994 static gint message_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/Message view");
2002 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2007 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2010 main_window_add_mailbox(mainwin);
2013 static void add_mbox_cb(MainWindow *mainwin, guint action,
2016 main_window_add_mbox(mainwin);
2019 static void update_folderview_cb(MainWindow *mainwin, guint action,
2022 summary_show(mainwin->summaryview, NULL);
2023 folderview_check_new_all();
2026 static void new_folder_cb(MainWindow *mainwin, guint action,
2029 folderview_new_folder(mainwin->folderview);
2032 static void rename_folder_cb(MainWindow *mainwin, guint action,
2035 folderview_rename_folder(mainwin->folderview);
2038 static void delete_folder_cb(MainWindow *mainwin, guint action,
2041 folderview_delete_folder(mainwin->folderview);
2044 static void import_mbox_cb(MainWindow *mainwin, guint action,
2047 import_mbox(mainwin->summaryview->folder_item);
2050 static void export_mbox_cb(MainWindow *mainwin, guint action,
2053 export_mbox(mainwin->summaryview->folder_item);
2056 static void empty_trash_cb(MainWindow *mainwin, guint action,
2059 main_window_empty_trash(mainwin, TRUE);
2062 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2064 summary_save_as(mainwin->summaryview);
2067 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2069 summary_print(mainwin->summaryview);
2072 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2074 if (prefs_common.confirm_on_exit) {
2075 if (alertpanel(_("Exit"), _("Exit this program?"),
2076 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2078 manage_window_focus_in(mainwin->window, NULL, NULL);
2081 app_will_exit(widget, mainwin);
2084 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2087 summary_search(mainwin->summaryview);
2089 message_search(mainwin->messageview);
2092 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2097 active = GTK_CHECK_MENU_ITEM(widget)->active;
2099 switch (mainwin->type) {
2101 case SEPARATE_MESSAGE:
2104 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2106 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2109 case SEPARATE_FOLDER:
2110 debug_print("separate folder\n");
2112 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2114 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2118 gtk_widget_show(mainwin->win.sep_both.folderwin);
2120 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2125 static void toggle_message_cb(MainWindow *mainwin, guint action,
2130 active = GTK_CHECK_MENU_ITEM(widget)->active;
2132 if (active != messageview_is_visible(mainwin->messageview))
2133 summary_toggle_view(mainwin->summaryview);
2136 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2139 toolbar_toggle(action, mainwin);
2142 /* END Toolbar Stuff */
2144 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2147 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2148 gtk_widget_show(mainwin->hbox_stat);
2149 prefs_common.show_statusbar = TRUE;
2151 gtk_widget_hide(mainwin->hbox_stat);
2152 prefs_common.show_statusbar = FALSE;
2156 static void separate_widget_cb(MainWindow *mainwin, guint action,
2161 if (GTK_CHECK_MENU_ITEM(widget)->active)
2162 type = mainwin->type | action;
2164 type = mainwin->type & ~action;
2166 main_window_separation_change(mainwin, type);
2168 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2169 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2172 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2175 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2177 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2180 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2182 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2185 static void online_switch_clicked (GtkButton *btn, gpointer data)
2187 MainWindow *mainwin;
2188 GtkItemFactory *ifactory;
2189 GtkCheckMenuItem *menuitem;
2191 mainwin = (MainWindow *) data;
2193 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2194 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2196 g_return_if_fail(mainwin != NULL);
2197 g_return_if_fail(menuitem != NULL);
2199 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2201 gtk_widget_hide (mainwin->online_switch);
2202 gtk_widget_show (mainwin->offline_switch);
2203 menuitem->active = TRUE;
2204 prefs_common.work_offline = TRUE;
2205 inc_autocheck_timer_remove();
2208 gtk_widget_hide (mainwin->offline_switch);
2209 gtk_widget_show (mainwin->online_switch);
2210 menuitem->active = FALSE;
2211 prefs_common.work_offline = FALSE;
2212 inc_autocheck_timer_set();
2216 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2219 addressbook_open(NULL);
2222 static void log_window_show_cb(MainWindow *mainwin, guint action,
2225 log_window_show(mainwin->logwin);
2228 static void sel_download_cb(MainWindow *mainwin, guint action,
2231 selective_download(mainwin);
2234 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2239 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2241 summary_move_to(mainwin->summaryview);
2244 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2246 summary_copy_to(mainwin->summaryview);
2249 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2251 summary_delete(mainwin->summaryview);
2254 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2256 summary_cancel(mainwin->summaryview);
2259 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2261 summary_open_msg(mainwin->summaryview);
2264 static void view_source_cb(MainWindow *mainwin, guint action,
2267 summary_view_source(mainwin->summaryview);
2270 static void show_all_header_cb(MainWindow *mainwin, guint action,
2273 if (mainwin->menu_lock_count) return;
2274 summary_display_msg_selected(mainwin->summaryview,
2275 GTK_CHECK_MENU_ITEM(widget)->active);
2278 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2280 summary_reedit(mainwin->summaryview);
2283 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2285 summary_mark(mainwin->summaryview);
2288 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2290 summary_unmark(mainwin->summaryview);
2293 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2296 summary_mark_as_unread(mainwin->summaryview);
2299 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2302 summary_mark_as_read(mainwin->summaryview);
2305 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2308 summary_mark_all_read(mainwin->summaryview);
2311 static void add_address_cb(MainWindow *mainwin, guint action,
2314 summary_add_address(mainwin->summaryview);
2317 static void set_charset_cb(MainWindow *mainwin, guint action,
2322 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2323 str = conv_get_charset_str((CharSet)action);
2324 g_free(prefs_common.force_charset);
2325 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2327 summary_redisplay_msg(mainwin->summaryview);
2329 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2333 static void hide_read_messages (MainWindow *mainwin, guint action,
2336 if (!mainwin->summaryview->folder_item
2337 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2339 summary_toggle_show_read_messages(mainwin->summaryview);
2342 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2344 if (mainwin->menu_lock_count) return;
2345 if (!mainwin->summaryview->folder_item) return;
2347 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2348 summary_thread_build(mainwin->summaryview);
2349 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2351 summary_unthread(mainwin->summaryview);
2352 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2356 static void expand_threads_cb(MainWindow *mainwin, guint action,
2359 summary_expand_threads(mainwin->summaryview);
2362 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2365 summary_collapse_threads(mainwin->summaryview);
2368 static void set_display_item_cb(MainWindow *mainwin, guint action,
2371 prefs_summary_column_open();
2374 static void sort_summary_cb(MainWindow *mainwin, guint action,
2377 FolderItem *item = mainwin->summaryview->folder_item;
2378 GtkWidget *menuitem;
2380 if (mainwin->menu_lock_count) return;
2382 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2383 menuitem = gtk_item_factory_get_item
2384 (mainwin->menu_factory, "/View/Sort/Ascending");
2385 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2386 GTK_CHECK_MENU_ITEM(menuitem)->active
2387 ? SORT_ASCENDING : SORT_DESCENDING);
2391 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2394 FolderItem *item = mainwin->summaryview->folder_item;
2396 if (mainwin->menu_lock_count) return;
2398 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2399 summary_sort(mainwin->summaryview,
2400 item->sort_key, (FolderSortType)action);
2403 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2406 summary_attract_by_subject(mainwin->summaryview);
2409 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2412 summary_delete_duplicated(mainwin->summaryview);
2415 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2417 summary_filter(mainwin->summaryview);
2420 static void execute_summary_cb(MainWindow *mainwin, guint action,
2423 summary_execute(mainwin->summaryview);
2426 static void update_summary_cb(MainWindow *mainwin, guint action,
2430 FolderView *folderview = mainwin->folderview;
2432 if (!mainwin->summaryview->folder_item) return;
2433 if (!folderview->opened) return;
2435 folder_update_op_count();
2437 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2438 folderview->opened);
2441 folder_item_scan(fitem);
2442 summary_show(mainwin->summaryview, fitem);
2445 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2447 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2450 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2452 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2455 static void prev_unread_cb(MainWindow *mainwin, guint action,
2458 summary_select_prev_unread(mainwin->summaryview);
2461 static void next_unread_cb(MainWindow *mainwin, guint action,
2464 summary_select_next_unread(mainwin->summaryview);
2467 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2469 summary_select_prev_new(mainwin->summaryview);
2472 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2474 summary_select_next_new(mainwin->summaryview);
2477 static void prev_marked_cb(MainWindow *mainwin, guint action,
2480 summary_select_prev_marked(mainwin->summaryview);
2483 static void next_marked_cb(MainWindow *mainwin, guint action,
2486 summary_select_next_marked(mainwin->summaryview);
2489 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2492 summary_select_prev_labeled(mainwin->summaryview);
2495 static void next_labeled_cb(MainWindow *mainwin, guint action,
2498 summary_select_next_labeled(mainwin->summaryview);
2501 static void goto_folder_cb(MainWindow *mainwin, guint action,
2504 FolderItem *to_folder;
2506 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2509 folderview_select(mainwin->folderview, to_folder);
2512 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2514 messageview_copy_clipboard(mainwin->messageview);
2517 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2519 MessageView *msgview = mainwin->messageview;
2521 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2522 summary_select_all(mainwin->summaryview);
2523 else if (messageview_is_visible(msgview) &&
2524 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2525 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2526 messageview_select_all(mainwin->messageview);
2529 static void select_thread_cb(MainWindow *mainwin, guint action,
2532 summary_select_thread(mainwin->summaryview);
2535 static void create_filter_cb(MainWindow *mainwin, guint action,
2538 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2541 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2544 prefs_common_open();
2547 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2550 prefs_scoring_open(NULL);
2553 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2556 prefs_filtering_open(NULL, NULL, NULL);
2559 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2562 prefs_template_open();
2565 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2568 prefs_actions_open(mainwin);
2571 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2574 ssl_manager_open(mainwin);
2577 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2581 new_account_cb(mainwin, 0, widget);
2583 account_open(cur_account);
2587 static void new_account_cb(MainWindow *mainwin, guint action,
2590 account_edit_open();
2591 if (!compose_get_compose_list()) account_add();
2594 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2596 cur_account = (PrefsAccount *)data;
2597 main_window_reflect_prefs_all();
2600 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2605 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2607 pluginwindow_create();
2610 static void manual_open_cb(MainWindow *mainwin, guint action,
2613 manual_open((ManualType)action);
2616 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2618 MainWindow *mainwin = (MainWindow *)data;
2622 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2623 LOCAL_FOLDER(folder)->rootpath,
2627 str = g_strdup_printf(_("Scanning folder %s ..."),
2628 LOCAL_FOLDER(folder)->rootpath);
2630 STATUSBAR_PUSH(mainwin, str);
2631 STATUSBAR_POP(mainwin);
2635 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2638 SummaryView *summary;
2640 g_return_val_if_fail(data, FALSE);
2641 summary = ((MainWindow *)data)->summaryview;
2642 g_return_val_if_fail(summary, FALSE);
2643 if (summary->selected != summary->displayed)
2644 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2648 #define BREAK_ON_MODIFIER_KEY() \
2649 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2651 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2654 MainWindow *mainwin = (MainWindow*) data;
2656 if (!mainwin || !event) return;
2658 switch (event->keyval) {
2659 case GDK_Q: /* Quit */
2660 BREAK_ON_MODIFIER_KEY();
2662 app_exit_cb(mainwin, 0, NULL);
2665 if (mainwin->folderview && mainwin->summaryview
2666 && !mainwin->summaryview->displayed) {
2667 summary_lock(mainwin->summaryview);
2668 folderview_select_next_unread(mainwin->folderview);
2669 summary_unlock(mainwin->summaryview);
2677 #undef BREAK_ON_MODIFIER_KEY
2680 * Harvest addresses for selected folder.
2682 static void addr_harvest_cb( MainWindow *mainwin,
2686 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2690 * Harvest addresses for selected messages in summary view.
2692 static void addr_harvest_msg_cb( MainWindow *mainwin,
2696 summary_harvest_address( mainwin->summaryview );
2700 *\brief get a MainWindow
2702 *\return MainWindow * The first mainwindow in the mainwin_list
2704 MainWindow *mainwindow_get_mainwindow(void)
2706 if (mainwin_list && mainwin_list->data)
2707 return (MainWindow *)(mainwin_list->data);