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 _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/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/C_hange current account"),
673 NULL, NULL, 0, "<Branch>"},
674 {N_("/_Configuration/_Preferences for current account..."),
675 NULL, prefs_account_open_cb, 0, NULL},
676 {N_("/_Configuration/Create _new account..."),
677 NULL, new_account_cb, 0, NULL},
678 {N_("/_Configuration/_Edit accounts..."),
679 NULL, account_edit_open, 0, NULL},
680 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Configuration/_Common preferences..."),
682 NULL, prefs_common_open_cb, 0, NULL},
683 {N_("/_Configuration/_Scoring..."),
684 NULL, prefs_scoring_open_cb, 0, NULL},
685 {N_("/_Configuration/_Filtering..."),
686 NULL, prefs_filtering_open_cb, 0, NULL},
687 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
688 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
689 {N_("/_Configuration/_Other Preferences..."), NULL, prefs_open_cb, 0, NULL},
690 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
692 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
693 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
694 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
695 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
696 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
697 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
698 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
699 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
703 MainWindow *main_window_create(SeparateType type)
709 GtkWidget *handlebox;
710 GtkWidget *vbox_body;
711 GtkWidget *hbox_stat;
712 GtkWidget *statusbar;
713 GtkWidget *progressbar;
714 GtkWidget *statuslabel;
715 GtkWidget *ac_button;
717 GtkWidget *online_pixmap;
718 GtkWidget *offline_pixmap;
719 GtkWidget *online_switch;
720 GtkWidget *offline_switch;
722 FolderView *folderview;
723 SummaryView *summaryview;
724 MessageView *messageview;
725 GdkColormap *colormap;
728 GtkItemFactory *ifactory;
732 guint n_menu_entries;
734 static GdkGeometry geometry;
736 debug_print("Creating main window...\n");
737 mainwin = g_new0(MainWindow, 1);
740 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
741 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
742 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
743 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
745 if (!geometry.min_height) {
746 geometry.min_width = 320;
747 geometry.min_height = 200;
749 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
752 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
753 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
754 MANAGE_WINDOW_SIGNALS_CONNECT(window);
755 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
756 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
758 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
759 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
761 gtk_widget_realize(window);
762 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
765 gtkut_widget_set_app_icon(window);
767 vbox = gtk_vbox_new(FALSE, 0);
768 gtk_widget_show(vbox);
769 gtk_container_add(GTK_CONTAINER(window), vbox);
772 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
773 menubar = menubar_create(window, mainwin_entries,
774 n_menu_entries, "<Main>", mainwin);
775 gtk_widget_show(menubar);
776 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
777 ifactory = gtk_item_factory_from_widget(menubar);
779 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
780 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
782 handlebox = gtk_handle_box_new();
783 gtk_widget_show(handlebox);
784 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
786 /* link window to mainwin->window to avoid gdk warnings */
787 mainwin->window = window;
790 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
794 /* vbox that contains body */
795 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
796 gtk_widget_show(vbox_body);
797 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
798 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
800 hbox_stat = gtk_hbox_new(FALSE, 2);
801 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
803 statusbar = statusbar_create();
804 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
806 progressbar = gtk_progress_bar_new();
807 gtk_widget_set_usize(progressbar, 120, 1);
808 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
810 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
811 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
812 online_switch = gtk_button_new ();
813 offline_switch = gtk_button_new ();
814 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
815 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
816 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
817 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
818 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
819 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
820 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
821 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
823 statuslabel = gtk_label_new("");
824 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
826 ac_button = gtk_button_new();
827 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
828 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
829 gtk_widget_set_usize(ac_button, -1, 1);
830 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
831 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
832 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
834 ac_label = gtk_label_new("");
835 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
837 gtk_widget_show_all(hbox_stat);
839 gtk_widget_hide(offline_switch);
841 mainwin->folderview = folderview = folderview_create();
842 mainwin->summaryview = summaryview = summary_create();
843 mainwin->messageview = messageview = messageview_create(mainwin);
844 mainwin->logwin = log_window_create();
846 folderview->mainwin = mainwin;
847 folderview->summaryview = summaryview;
849 summaryview->mainwin = mainwin;
850 summaryview->folderview = folderview;
851 summaryview->messageview = messageview;
852 summaryview->window = window;
854 mainwin->vbox = vbox;
855 mainwin->menubar = menubar;
856 mainwin->menu_factory = ifactory;
857 mainwin->handlebox = handlebox;
858 mainwin->vbox_body = vbox_body;
859 mainwin->hbox_stat = hbox_stat;
860 mainwin->statusbar = statusbar;
861 mainwin->progressbar = progressbar;
862 mainwin->statuslabel = statuslabel;
863 mainwin->ac_button = ac_button;
864 mainwin->ac_label = ac_label;
866 mainwin->online_switch = online_switch;
867 mainwin->offline_switch = offline_switch;
868 mainwin->online_pixmap = online_pixmap;
869 mainwin->offline_pixmap = offline_pixmap;
871 /* set context IDs for status bar */
872 mainwin->mainwin_cid = gtk_statusbar_get_context_id
873 (GTK_STATUSBAR(statusbar), "Main Window");
874 mainwin->folderview_cid = gtk_statusbar_get_context_id
875 (GTK_STATUSBAR(statusbar), "Folder View");
876 mainwin->summaryview_cid = gtk_statusbar_get_context_id
877 (GTK_STATUSBAR(statusbar), "Summary View");
879 /* allocate colors for summary view and folder view */
880 summaryview->color_marked.red = summaryview->color_marked.green = 0;
881 summaryview->color_marked.blue = (guint16)65535;
883 summaryview->color_dim.red = summaryview->color_dim.green =
884 summaryview->color_dim.blue = COLOR_DIM;
886 folderview->color_new.red = (guint16)55000;
887 folderview->color_new.green = folderview->color_new.blue = 15000;
889 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
890 &folderview->color_op);
892 summaryview->color_important.red = 0;
893 summaryview->color_important.green = 0;
894 summaryview->color_important.blue = (guint16)65535;
896 color[0] = summaryview->color_marked;
897 color[1] = summaryview->color_dim;
898 color[2] = folderview->color_new;
899 color[3] = folderview->color_op;
901 colormap = gdk_window_get_colormap(window->window);
902 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
903 for (i = 0; i < 4; i++) {
904 if (success[i] == FALSE)
905 g_warning("MainWindow: color allocation %d failed\n", i);
908 debug_print("done.\n");
910 messageview->visible = TRUE;
912 main_window_set_widgets(mainwin, type);
915 menuitem = gtk_item_factory_get_item
916 (ifactory, "/View/Code set/Auto detect");
917 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
919 switch (prefs_common.toolbar_style) {
921 menuitem = gtk_item_factory_get_item
922 (ifactory, "/View/Show or hide/Toolbar/None");
925 menuitem = gtk_item_factory_get_item
926 (ifactory, "/View/Show or hide/Toolbar/Icon");
929 menuitem = gtk_item_factory_get_item
930 (ifactory, "/View/Show or hide/Toolbar/Text");
933 menuitem = gtk_item_factory_get_item
934 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
936 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
938 gtk_widget_hide(mainwin->hbox_stat);
939 menuitem = gtk_item_factory_get_item
940 (ifactory, "/View/Show or hide/Status bar");
941 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
942 prefs_common.show_statusbar);
944 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
946 if (prefs_common.show_searchbar) {
947 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
948 if (prefs_common.summary_quicksearch_type != S_SEARCH_EXTENDED)
949 gtk_widget_hide(summaryview->search_description);
952 /* set account selection menu */
953 ac_menu = gtk_item_factory_get_widget
954 (ifactory, "/Configuration/Change current account");
955 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
956 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
957 mainwin->ac_menu = ac_menu;
959 toolbar_main_set_sensitive(mainwin);
961 /* create actions menu */
962 update_mainwin_actions_menu(ifactory, mainwin);
964 /* attach accel groups to main window */
965 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
966 gtk_window_add_accel_group \
968 gtk_item_factory_from_widget(menu)->accel_group)
970 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu,mainwin->window);
972 /* connect the accelerators for equivalent
973 menu items in different menus */
974 menu_connect_identical_items();
978 /* show main window */
979 gtk_widget_set_uposition(mainwin->window,
980 prefs_common.mainwin_x,
981 prefs_common.mainwin_y);
982 gtk_widget_set_usize(window, prefs_common.mainwin_width,
983 prefs_common.mainwin_height);
984 gtk_widget_show(mainwin->window);
986 /* initialize views */
987 folderview_init(folderview);
988 summary_init(summaryview);
989 messageview_init(messageview);
990 log_window_init(mainwin->logwin);
992 sslcertwindow_register_hook();
994 mainwin->lock_count = 0;
995 mainwin->menu_lock_count = 0;
996 mainwin->cursor_count = 0;
999 watch_cursor = gdk_cursor_new(GDK_WATCH);
1001 mainwin_list = g_list_append(mainwin_list, mainwin);
1003 /* init work_offline */
1004 if (prefs_common.work_offline)
1005 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1010 void main_window_cursor_wait(MainWindow *mainwin)
1013 if (mainwin->cursor_count == 0)
1014 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1016 mainwin->cursor_count++;
1021 void main_window_cursor_normal(MainWindow *mainwin)
1023 if (mainwin->cursor_count)
1024 mainwin->cursor_count--;
1026 if (mainwin->cursor_count == 0)
1027 gdk_window_set_cursor(mainwin->window->window, NULL);
1032 /* lock / unlock the user-interface */
1033 void main_window_lock(MainWindow *mainwin)
1035 if (mainwin->lock_count == 0)
1036 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1038 mainwin->lock_count++;
1040 main_window_set_menu_sensitive(mainwin);
1041 toolbar_main_set_sensitive(mainwin);
1044 void main_window_unlock(MainWindow *mainwin)
1046 if (mainwin->lock_count)
1047 mainwin->lock_count--;
1049 main_window_set_menu_sensitive(mainwin);
1050 toolbar_main_set_sensitive(mainwin);
1052 if (mainwin->lock_count == 0)
1053 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1056 static void main_window_menu_callback_block(MainWindow *mainwin)
1058 mainwin->menu_lock_count++;
1061 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1063 if (mainwin->menu_lock_count)
1064 mainwin->menu_lock_count--;
1067 void main_window_reflect_prefs_all(void)
1069 main_window_reflect_prefs_all_real(FALSE);
1072 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1075 MainWindow *mainwin;
1078 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1079 mainwin = (MainWindow *)cur->data;
1081 main_window_show_cur_account(mainwin);
1082 main_window_set_menu_sensitive(mainwin);
1083 toolbar_main_set_sensitive(mainwin);
1086 if (pixmap_theme_changed) {
1087 toolbar_update(TOOLBAR_MAIN, mainwin);
1088 messageview_reflect_prefs_pixmap_theme();
1089 compose_reflect_prefs_pixmap_theme();
1090 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1091 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1093 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1094 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1095 mainwin->online_pixmap);
1096 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1097 gtk_widget_show(pixmap);
1098 mainwin->online_pixmap = pixmap;
1099 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1100 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1101 mainwin->offline_pixmap);
1102 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1103 gtk_widget_show(pixmap);
1104 mainwin->offline_pixmap = pixmap;
1107 summary_redisplay_msg(mainwin->summaryview);
1108 headerview_set_visibility(mainwin->messageview->headerview,
1109 prefs_common.display_header_pane);
1113 void main_window_set_summary_column(void)
1116 MainWindow *mainwin;
1118 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1119 mainwin = (MainWindow *)cur->data;
1120 summary_set_column_order(mainwin->summaryview);
1124 void main_window_set_account_menu(GList *account_list)
1126 GList *cur, *cur_ac, *cur_item;
1127 GtkWidget *menuitem;
1128 MainWindow *mainwin;
1129 PrefsAccount *ac_prefs;
1131 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1132 mainwin = (MainWindow *)cur->data;
1134 /* destroy all previous menu item */
1135 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1136 while (cur_item != NULL) {
1137 GList *next = cur_item->next;
1138 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1142 for (cur_ac = account_list; cur_ac != NULL;
1143 cur_ac = cur_ac->next) {
1144 ac_prefs = (PrefsAccount *)cur_ac->data;
1146 menuitem = gtk_menu_item_new_with_label
1147 (ac_prefs->account_name
1148 ? ac_prefs->account_name : _("Untitled"));
1149 gtk_widget_show(menuitem);
1150 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1151 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1152 GTK_SIGNAL_FUNC(account_menu_cb),
1158 static void main_window_show_cur_account(MainWindow *mainwin)
1163 ac_name = g_strdup(cur_account
1164 ? (cur_account->account_name
1165 ? cur_account->account_name : _("Untitled"))
1169 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1171 buf = g_strdup(PROG_VERSION);
1172 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1175 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1176 gtk_widget_queue_resize(mainwin->ac_button);
1181 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1183 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1184 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1185 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1186 GtkWidget *message_wid = mainwin->messageview->vbox;
1188 debug_print("Changing window separation type from %d to %d\n",
1189 mainwin->type, type);
1191 if (mainwin->type == type) return;
1193 /* remove widgets from those containers */
1194 gtk_widget_ref(folder_wid);
1195 gtk_widget_ref(summary_wid);
1196 gtk_widget_ref(message_wid);
1197 gtkut_container_remove
1198 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1199 gtkut_container_remove
1200 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1201 gtkut_container_remove
1202 (GTK_CONTAINER(message_wid->parent), message_wid);
1204 /* clean containers */
1205 switch (mainwin->type) {
1207 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1209 case SEPARATE_FOLDER:
1210 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1211 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1213 case SEPARATE_MESSAGE:
1214 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1215 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1218 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1219 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1223 gtk_widget_hide(mainwin->window);
1224 main_window_set_widgets(mainwin, type);
1225 gtk_widget_show(mainwin->window);
1227 gtk_widget_unref(folder_wid);
1228 gtk_widget_unref(summary_wid);
1229 gtk_widget_unref(message_wid);
1232 void main_window_toggle_message_view(MainWindow *mainwin)
1234 SummaryView *summaryview = mainwin->summaryview;
1235 union CompositeWin *cwin = &mainwin->win;
1236 GtkWidget *vpaned = NULL;
1237 GtkWidget *container = NULL;
1238 GtkWidget *msgwin = NULL;
1240 switch (mainwin->type) {
1242 vpaned = cwin->sep_none.vpaned;
1243 container = cwin->sep_none.hpaned;
1245 case SEPARATE_FOLDER:
1246 vpaned = cwin->sep_folder.vpaned;
1247 container = mainwin->vbox_body;
1249 case SEPARATE_MESSAGE:
1250 msgwin = mainwin->win.sep_message.messagewin;
1253 msgwin = mainwin->win.sep_both.messagewin;
1258 if (GTK_WIDGET_VISIBLE(msgwin)) {
1259 gtk_widget_hide(msgwin);
1260 mainwin->messageview->visible = FALSE;
1261 summaryview->displayed = NULL;
1263 gtk_widget_show(msgwin);
1264 mainwin->messageview->visible = TRUE;
1266 } else if (vpaned->parent != NULL) {
1267 mainwin->messageview->visible = FALSE;
1268 summaryview->displayed = NULL;
1269 gtk_widget_ref(vpaned);
1270 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1271 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1272 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1273 GTK_ARROW_UP, GTK_SHADOW_OUT);
1275 mainwin->messageview->visible = TRUE;
1276 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1277 gtk_container_add(GTK_CONTAINER(container), vpaned);
1278 gtk_widget_unref(vpaned);
1279 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1280 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1283 main_window_set_menu_sensitive(mainwin);
1285 gtk_widget_grab_focus(summaryview->ctree);
1288 void main_window_get_size(MainWindow *mainwin)
1290 GtkAllocation *allocation;
1292 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1294 prefs_common.summaryview_width = allocation->width;
1296 if ((mainwin->type == SEPARATE_NONE ||
1297 mainwin->type == SEPARATE_FOLDER) &&
1298 messageview_is_visible(mainwin->messageview))
1299 prefs_common.summaryview_height = allocation->height;
1301 prefs_common.mainview_width = allocation->width;
1303 allocation = &mainwin->window->allocation;
1305 prefs_common.mainview_height = allocation->height;
1306 prefs_common.mainwin_width = allocation->width;
1307 prefs_common.mainwin_height = allocation->height;
1309 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1311 prefs_common.folderview_width = allocation->width;
1312 prefs_common.folderview_height = allocation->height;
1315 void main_window_get_position(MainWindow *mainwin)
1319 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1321 prefs_common.mainview_x = x;
1322 prefs_common.mainview_y = y;
1323 prefs_common.mainwin_x = x;
1324 prefs_common.mainwin_y = y;
1326 debug_print("window position: x = %d, y = %d\n", x, y);
1329 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1335 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1336 folder = FOLDER(list->data);
1337 if (folder && folder->trash && folder->trash->total > 0)
1341 if (!has_trash) return;
1344 if (alertpanel(_("Empty trash"),
1345 _("Empty all messages in trash?"),
1346 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1348 manage_window_focus_in(mainwin->window, NULL, NULL);
1351 procmsg_empty_trash();
1353 if (mainwin->summaryview->folder_item &&
1354 mainwin->summaryview->folder_item->stype == F_TRASH)
1355 gtk_widget_grab_focus(mainwin->folderview->ctree);
1358 void main_window_add_mailbox(MainWindow *mainwin)
1363 path = input_dialog(_("Add mailbox"),
1364 _("Input the location of mailbox.\n"
1365 "If the existing mailbox is specified, it will be\n"
1366 "scanned automatically."),
1369 if (folder_find_from_path(path)) {
1370 alertpanel_error(_("The mailbox `%s' already exists."), path);
1374 if (!strcmp(path, "Mail"))
1375 folder = folder_new(F_MH, _("Mailbox"), path);
1377 folder = folder_new(F_MH, g_basename(path), path);
1380 if (folder->create_tree(folder) < 0) {
1381 alertpanel_error(_("Creation of the mailbox failed.\n"
1382 "Maybe some files already exist, or you don't have the permission to write there."));
1383 folder_destroy(folder);
1388 folder_set_ui_func(folder, scan_tree_func, mainwin);
1389 folder_scan_tree(folder);
1390 folder_set_ui_func(folder, NULL, NULL);
1392 folderview_set(mainwin->folderview);
1395 void main_window_add_mbox(MainWindow *mainwin)
1401 path = input_dialog(_("Add mbox mailbox"),
1402 _("Input the location of mailbox."),
1407 if (folder_find_from_path(path)) {
1408 alertpanel_error(_("The mailbox `%s' already exists."), path);
1414 if (!strcmp(path, "Mail"))
1415 folder = folder_new(F_MBOX, _("Mailbox"), path);
1419 folder = folder_new(F_MBOX, g_basename(path), path);
1422 if (folder->create_tree(folder) < 0) {
1423 alertpanel_error(_("Creation of the mailbox failed."));
1424 folder_destroy(folder);
1430 item = folder_item_new(folder, folder->name, NULL);
1431 item->folder = folder;
1432 folder->node = g_node_new(item);
1434 folder_create_folder(item, "inbox");
1435 folder_create_folder(item, "outbox");
1436 folder_create_folder(item, "queue");
1437 folder_create_folder(item, "draft");
1438 folder_create_folder(item, "trash");
1440 folderview_set(mainwin->folderview);
1443 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1445 SensitiveCond state = 0;
1446 SummarySelection selection;
1447 FolderItem *item = mainwin->summaryview->folder_item;
1448 GList *account_list = account_get_list();
1450 selection = summary_get_selection_type(mainwin->summaryview);
1452 if (mainwin->lock_count == 0)
1453 state |= M_UNLOCKED;
1454 if (selection != SUMMARY_NONE)
1455 state |= M_MSG_EXIST;
1456 if (item && item->path && item->parent && !item->no_select) {
1458 /* if (item->folder->type != F_NEWS) */
1459 state |= M_ALLOW_DELETE;
1461 if (prefs_common.immediate_exec == 0
1462 && mainwin->lock_count == 0)
1463 state |= M_DELAY_EXEC;
1465 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1466 || selection != SUMMARY_NONE)
1467 state |= M_HIDE_READ_MSG;
1469 if (mainwin->summaryview->threaded)
1470 state |= M_THREADED;
1472 state |= M_UNTHREADED;
1473 if (selection == SUMMARY_SELECTED_SINGLE ||
1474 selection == SUMMARY_SELECTED_MULTIPLE)
1475 state |= M_TARGET_EXIST;
1476 if (selection == SUMMARY_SELECTED_SINGLE)
1477 state |= M_SINGLE_TARGET_EXIST;
1478 if (mainwin->summaryview->folder_item &&
1479 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1482 state |= M_NOT_NEWS;
1483 if (selection == SUMMARY_SELECTED_SINGLE &&
1485 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1486 item->stype == F_QUEUE)))
1487 state |= M_ALLOW_REEDIT;
1489 state |= M_HAVE_ACCOUNT;
1491 for ( ; account_list != NULL; account_list = account_list->next) {
1492 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1493 state |= M_HAVE_NEWS_ACCOUNT;
1498 if (inc_is_active())
1499 state |= M_INC_ACTIVE;
1506 void main_window_set_menu_sensitive(MainWindow *mainwin)
1508 GtkItemFactory *ifactory = mainwin->menu_factory;
1509 SensitiveCond state;
1511 GtkWidget *menuitem;
1512 SummaryView *summaryview;
1516 static const struct {
1520 {"/File/Add mailbox..." , M_UNLOCKED},
1521 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1522 {"/File/Check for new messages in all folders", M_UNLOCKED},
1523 {"/File/Folder" , M_UNLOCKED},
1524 {"/File/Import mbox file..." , M_UNLOCKED},
1525 {"/File/Export to mbox file..." , M_UNLOCKED},
1526 {"/File/Empty trash" , M_UNLOCKED},
1527 {"/File/Work offline" , M_UNLOCKED},
1529 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1530 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1531 /* {"/File/Close" , M_UNLOCKED}, */
1532 {"/File/Exit" , M_UNLOCKED},
1534 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1536 {"/View/Sort" , M_EXEC},
1537 {"/View/Thread view" , M_EXEC},
1538 {"/View/Expand all threads" , M_MSG_EXIST},
1539 {"/View/Collapse all threads" , M_MSG_EXIST},
1540 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1541 {"/View/Go to/Prev message" , M_MSG_EXIST},
1542 {"/View/Go to/Next message" , M_MSG_EXIST},
1543 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1544 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1545 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1546 {"/View/Go to/Next new message" , M_MSG_EXIST},
1547 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1548 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1549 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1550 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1551 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1552 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1553 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1555 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1556 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1557 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1558 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1559 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1560 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1561 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1562 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1563 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1564 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1565 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1566 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1567 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1568 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1569 {"/Message/Mark" , M_TARGET_EXIST},
1571 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1572 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1573 {"/Tools/Harvest addresses" , M_UNLOCKED},
1574 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1575 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1576 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1577 {"/Tools/Execute" , M_DELAY_EXEC},
1578 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1580 {"/Configuration", M_UNLOCKED},
1585 state = main_window_get_current_state(mainwin);
1587 for (i = 0; entry[i].entry != NULL; i++) {
1588 sensitive = ((entry[i].cond & state) == entry[i].cond);
1589 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1592 main_window_menu_callback_block(mainwin);
1594 #define SET_CHECK_MENU_ACTIVE(path, active) \
1596 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1597 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1600 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1601 messageview_is_visible(mainwin->messageview));
1603 summaryview = mainwin->summaryview;
1604 menu_path = "/View/Sort/Don't sort";
1606 switch (summaryview->sort_key) {
1607 case SORT_BY_NUMBER:
1608 menu_path = "/View/Sort/by number"; break;
1610 menu_path = "/View/Sort/by size"; break;
1612 menu_path = "/View/Sort/by date"; break;
1614 menu_path = "/View/Sort/by from"; break;
1616 menu_path = "/View/Sort/by recipient"; break;
1617 case SORT_BY_SUBJECT:
1618 menu_path = "/View/Sort/by subject"; break;
1620 menu_path = "/View/Sort/by color label"; break;
1622 menu_path = "/View/Sort/by mark"; break;
1623 case SORT_BY_STATUS:
1624 menu_path = "/View/Sort/by status"; break;
1626 menu_path = "/View/Sort/by attachment"; break;
1628 menu_path = "/View/Sort/by score"; break;
1629 case SORT_BY_LOCKED:
1630 menu_path = "/View/Sort/by locked"; break;
1633 menu_path = "/View/Sort/Don't sort"; break;
1635 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1637 if (summaryview->sort_type == SORT_ASCENDING) {
1638 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1640 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1643 if (summaryview->sort_key != SORT_BY_NONE) {
1644 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1645 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1647 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1648 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1651 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1652 mainwin->messageview->textview->show_all_headers);
1653 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1655 #undef SET_CHECK_MENU_ACTIVE
1657 main_window_menu_callback_unblock(mainwin);
1660 void main_window_popup(MainWindow *mainwin)
1662 gtkut_window_popup(mainwin->window);
1664 switch (mainwin->type) {
1665 case SEPARATE_FOLDER:
1666 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1668 case SEPARATE_MESSAGE:
1669 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1672 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1673 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1680 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1682 GtkWidget *folderwin = NULL;
1683 GtkWidget *messagewin = NULL;
1686 GtkWidget *vbox_body = mainwin->vbox_body;
1687 GtkItemFactory *ifactory = mainwin->menu_factory;
1688 GtkWidget *menuitem;
1689 GtkItemFactory *msgview_ifactory;
1691 debug_print("Setting widgets...");
1693 /* create separated window(s) if needed */
1694 if (type & SEPARATE_FOLDER) {
1695 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1696 gtk_window_set_title(GTK_WINDOW(folderwin),
1697 _("Sylpheed - Folder View"));
1698 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1699 "folder_view", "Sylpheed");
1700 gtk_window_set_policy(GTK_WINDOW(folderwin),
1702 gtk_widget_set_usize(folderwin, -1,
1703 prefs_common.mainview_height);
1704 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1706 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1707 GTK_SIGNAL_FUNC(folder_window_close_cb),
1710 if (type & SEPARATE_MESSAGE) {
1711 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1712 gtk_window_set_title(GTK_WINDOW(messagewin),
1713 _("Sylpheed - Message View"));
1714 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1715 "message_view", "Sylpheed");
1716 gtk_window_set_policy(GTK_WINDOW(messagewin),
1718 gtk_widget_set_usize
1719 (messagewin, prefs_common.mainview_width,
1720 prefs_common.mainview_height
1721 - prefs_common.summaryview_height
1722 + DEFAULT_HEADERVIEW_HEIGHT);
1723 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1725 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1726 GTK_SIGNAL_FUNC(message_window_close_cb),
1732 hpaned = gtk_hpaned_new();
1733 gtk_widget_show(hpaned);
1734 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1735 gtk_paned_add1(GTK_PANED(hpaned),
1736 GTK_WIDGET_PTR(mainwin->folderview));
1738 vpaned = gtk_vpaned_new();
1739 if (messageview_is_visible(mainwin->messageview)) {
1740 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1741 gtk_paned_add1(GTK_PANED(vpaned),
1742 GTK_WIDGET_PTR(mainwin->summaryview));
1744 gtk_paned_add2(GTK_PANED(hpaned),
1745 GTK_WIDGET_PTR(mainwin->summaryview));
1746 gtk_widget_ref(vpaned);
1748 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1749 prefs_common.summaryview_width,
1750 prefs_common.summaryview_height);
1751 gtk_paned_add2(GTK_PANED(vpaned),
1752 GTK_WIDGET_PTR(mainwin->messageview));
1753 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1754 prefs_common.mainview_width, -1);
1755 gtk_widget_set_usize(mainwin->window,
1756 prefs_common.folderview_width +
1757 prefs_common.mainview_width,
1758 prefs_common.mainwin_height);
1759 gtk_widget_show_all(vpaned);
1761 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1762 * lose track of its visibility state */
1763 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1764 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1766 mainwin->win.sep_none.hpaned = hpaned;
1767 mainwin->win.sep_none.vpaned = vpaned;
1769 /* remove headerview if not in prefs */
1770 headerview_set_visibility(mainwin->messageview->headerview,
1771 prefs_common.display_header_pane);
1773 case SEPARATE_FOLDER:
1774 vpaned = gtk_vpaned_new();
1775 if (messageview_is_visible(mainwin->messageview)) {
1776 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1778 gtk_paned_add1(GTK_PANED(vpaned),
1779 GTK_WIDGET_PTR(mainwin->summaryview));
1781 gtk_box_pack_start(GTK_BOX(vbox_body),
1782 GTK_WIDGET_PTR(mainwin->summaryview),
1784 gtk_widget_ref(vpaned);
1786 gtk_paned_add2(GTK_PANED(vpaned),
1787 GTK_WIDGET_PTR(mainwin->messageview));
1788 gtk_widget_show_all(vpaned);
1789 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1790 prefs_common.summaryview_width,
1791 prefs_common.summaryview_height);
1792 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1793 prefs_common.mainview_width, -1);
1794 gtk_widget_set_usize(mainwin->window,
1795 prefs_common.mainview_width,
1796 prefs_common.mainview_height);
1798 gtk_container_add(GTK_CONTAINER(folderwin),
1799 GTK_WIDGET_PTR(mainwin->folderview));
1801 mainwin->win.sep_folder.folderwin = folderwin;
1802 mainwin->win.sep_folder.vpaned = vpaned;
1804 gtk_widget_show_all(folderwin);
1806 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1807 * lose track of its visibility state */
1808 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1809 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1811 /* remove headerview if not in prefs */
1812 headerview_set_visibility(mainwin->messageview->headerview,
1813 prefs_common.display_header_pane);
1816 case SEPARATE_MESSAGE:
1817 hpaned = gtk_hpaned_new();
1818 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1820 gtk_paned_add1(GTK_PANED(hpaned),
1821 GTK_WIDGET_PTR(mainwin->folderview));
1822 gtk_paned_add2(GTK_PANED(hpaned),
1823 GTK_WIDGET_PTR(mainwin->summaryview));
1824 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1825 prefs_common.summaryview_width,
1826 prefs_common.summaryview_height);
1827 gtk_widget_set_usize(mainwin->window,
1828 prefs_common.folderview_width +
1829 prefs_common.mainview_width,
1830 prefs_common.mainwin_height);
1831 gtk_widget_show_all(hpaned);
1833 messageview_add_toolbar(mainwin->messageview, messagewin);
1834 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
1835 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
1837 mainwin->win.sep_message.messagewin = messagewin;
1838 mainwin->win.sep_message.hpaned = hpaned;
1840 gtk_widget_show_all(messagewin);
1842 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1843 * lose track of its visibility state */
1844 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1845 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1848 gtk_box_pack_start(GTK_BOX(vbox_body),
1849 GTK_WIDGET_PTR(mainwin->summaryview),
1851 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1852 prefs_common.summaryview_width,
1853 prefs_common.summaryview_height);
1854 gtk_widget_set_usize(mainwin->window,
1855 prefs_common.mainview_width,
1856 prefs_common.mainwin_height);
1857 gtk_container_add(GTK_CONTAINER(folderwin),
1858 GTK_WIDGET_PTR(mainwin->folderview));
1859 gtk_container_add(GTK_CONTAINER(messagewin),
1860 GTK_WIDGET_PTR(mainwin->messageview));
1862 mainwin->win.sep_both.folderwin = folderwin;
1863 mainwin->win.sep_both.messagewin = messagewin;
1865 gtk_widget_show_all(folderwin);
1866 gtk_widget_show_all(messagewin);
1868 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1869 * lose track of its visibility state */
1870 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1871 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1875 /* rehide quick search if necessary */
1876 if (!prefs_common.show_searchbar)
1877 gtk_widget_hide(mainwin->summaryview->hbox_search);
1879 mainwin->type = type;
1881 mainwin->messageview->visible = TRUE;
1883 /* toggle menu state */
1884 menuitem = gtk_item_factory_get_item
1885 (ifactory, "/View/Show or hide/Folder tree");
1886 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1887 menuitem = gtk_item_factory_get_item
1888 (ifactory, "/View/Show or hide/Message view");
1889 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1891 menuitem = gtk_item_factory_get_item
1892 (ifactory, "/View/Separate folder tree");
1893 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1894 ((type & SEPARATE_FOLDER) != 0));
1895 menuitem = gtk_item_factory_get_item
1896 (ifactory, "/View/Separate message view");
1897 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1898 ((type & SEPARATE_MESSAGE) != 0));
1900 debug_print("done.\n");
1903 void main_window_destroy_all(void)
1905 while (mainwin_list != NULL) {
1906 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
1908 /* free toolbar stuff */
1909 toolbar_clear_list(TOOLBAR_MAIN);
1910 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
1911 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
1913 g_free(mainwin->toolbar);
1916 mainwin_list = g_list_remove(mainwin_list, mainwin);
1918 g_list_free(mainwin_list);
1922 static void toolbar_account_button_pressed(GtkWidget *widget,
1923 GdkEventButton *event,
1926 MainWindow *mainwin = (MainWindow *)data;
1929 if (event->button != 3) return;
1931 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1932 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1935 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1936 menu_button_position, widget,
1937 event->button, event->time);
1941 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1944 MainWindow *mainwin = (MainWindow *)data;
1948 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1949 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1952 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1953 menu_button_position, widget,
1954 event->button, event->time);
1957 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
1959 MainWindow *mainwin = (MainWindow *)data;
1962 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
1963 if (!button) return;
1964 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1965 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
1966 manage_window_focus_in(mainwin->window, NULL, NULL);
1969 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1972 MainWindow *mainwin = (MainWindow *)data;
1974 if (mainwin->lock_count == 0)
1975 app_exit_cb(data, 0, widget);
1980 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1983 MainWindow *mainwin = (MainWindow *)data;
1984 GtkWidget *menuitem;
1986 menuitem = gtk_item_factory_get_item
1987 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
1988 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1993 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1996 MainWindow *mainwin = (MainWindow *)data;
1997 GtkWidget *menuitem;
1999 menuitem = gtk_item_factory_get_item
2000 (mainwin->menu_factory, "/View/Show or hide/Message view");
2001 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2006 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2009 main_window_add_mailbox(mainwin);
2012 static void add_mbox_cb(MainWindow *mainwin, guint action,
2015 main_window_add_mbox(mainwin);
2018 static void update_folderview_cb(MainWindow *mainwin, guint action,
2021 summary_show(mainwin->summaryview, NULL);
2022 folderview_check_new_all();
2025 static void new_folder_cb(MainWindow *mainwin, guint action,
2028 folderview_new_folder(mainwin->folderview);
2031 static void rename_folder_cb(MainWindow *mainwin, guint action,
2034 folderview_rename_folder(mainwin->folderview);
2037 static void delete_folder_cb(MainWindow *mainwin, guint action,
2040 folderview_delete_folder(mainwin->folderview);
2043 static void import_mbox_cb(MainWindow *mainwin, guint action,
2046 import_mbox(mainwin->summaryview->folder_item);
2049 static void export_mbox_cb(MainWindow *mainwin, guint action,
2052 export_mbox(mainwin->summaryview->folder_item);
2055 static void empty_trash_cb(MainWindow *mainwin, guint action,
2058 main_window_empty_trash(mainwin, TRUE);
2061 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2063 summary_save_as(mainwin->summaryview);
2066 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2068 summary_print(mainwin->summaryview);
2071 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2073 if (prefs_common.confirm_on_exit) {
2074 if (alertpanel(_("Exit"), _("Exit this program?"),
2075 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2077 manage_window_focus_in(mainwin->window, NULL, NULL);
2080 app_will_exit(widget, mainwin);
2083 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2086 summary_search(mainwin->summaryview);
2088 message_search(mainwin->messageview);
2091 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2096 active = GTK_CHECK_MENU_ITEM(widget)->active;
2098 switch (mainwin->type) {
2100 case SEPARATE_MESSAGE:
2103 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2105 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2108 case SEPARATE_FOLDER:
2109 debug_print("separate folder\n");
2111 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2113 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2117 gtk_widget_show(mainwin->win.sep_both.folderwin);
2119 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2124 static void toggle_message_cb(MainWindow *mainwin, guint action,
2129 active = GTK_CHECK_MENU_ITEM(widget)->active;
2131 if (active != messageview_is_visible(mainwin->messageview))
2132 summary_toggle_view(mainwin->summaryview);
2135 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2138 toolbar_toggle(action, mainwin);
2141 /* END Toolbar Stuff */
2143 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2146 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2147 gtk_widget_show(mainwin->hbox_stat);
2148 prefs_common.show_statusbar = TRUE;
2150 gtk_widget_hide(mainwin->hbox_stat);
2151 prefs_common.show_statusbar = FALSE;
2155 static void separate_widget_cb(MainWindow *mainwin, guint action,
2160 if (GTK_CHECK_MENU_ITEM(widget)->active)
2161 type = mainwin->type | action;
2163 type = mainwin->type & ~action;
2165 main_window_separation_change(mainwin, type);
2167 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2168 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2171 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2174 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2176 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2179 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2181 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2184 static void online_switch_clicked (GtkButton *btn, gpointer data)
2186 MainWindow *mainwin;
2187 GtkItemFactory *ifactory;
2188 GtkCheckMenuItem *menuitem;
2190 mainwin = (MainWindow *) data;
2192 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2193 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2195 g_return_if_fail(mainwin != NULL);
2196 g_return_if_fail(menuitem != NULL);
2198 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2200 gtk_widget_hide (mainwin->online_switch);
2201 gtk_widget_show (mainwin->offline_switch);
2202 menuitem->active = TRUE;
2203 prefs_common.work_offline = TRUE;
2204 inc_autocheck_timer_remove();
2207 gtk_widget_hide (mainwin->offline_switch);
2208 gtk_widget_show (mainwin->online_switch);
2209 menuitem->active = FALSE;
2210 prefs_common.work_offline = FALSE;
2211 inc_autocheck_timer_set();
2215 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2218 addressbook_open(NULL);
2221 static void log_window_show_cb(MainWindow *mainwin, guint action,
2224 log_window_show(mainwin->logwin);
2227 static void sel_download_cb(MainWindow *mainwin, guint action,
2230 selective_download(mainwin);
2233 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2238 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2240 summary_move_to(mainwin->summaryview);
2243 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2245 summary_copy_to(mainwin->summaryview);
2248 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2250 summary_delete(mainwin->summaryview);
2253 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2255 summary_cancel(mainwin->summaryview);
2258 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2260 summary_open_msg(mainwin->summaryview);
2263 static void view_source_cb(MainWindow *mainwin, guint action,
2266 summary_view_source(mainwin->summaryview);
2269 static void show_all_header_cb(MainWindow *mainwin, guint action,
2272 if (mainwin->menu_lock_count) return;
2273 summary_display_msg_selected(mainwin->summaryview,
2274 GTK_CHECK_MENU_ITEM(widget)->active);
2277 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2279 summary_reedit(mainwin->summaryview);
2282 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2284 summary_mark(mainwin->summaryview);
2287 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2289 summary_unmark(mainwin->summaryview);
2292 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2295 summary_mark_as_unread(mainwin->summaryview);
2298 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2301 summary_mark_as_read(mainwin->summaryview);
2304 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2307 summary_mark_all_read(mainwin->summaryview);
2310 static void add_address_cb(MainWindow *mainwin, guint action,
2313 summary_add_address(mainwin->summaryview);
2316 static void set_charset_cb(MainWindow *mainwin, guint action,
2321 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2322 str = conv_get_charset_str((CharSet)action);
2323 g_free(prefs_common.force_charset);
2324 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2326 summary_redisplay_msg(mainwin->summaryview);
2328 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2332 static void hide_read_messages (MainWindow *mainwin, guint action,
2335 if (!mainwin->summaryview->folder_item
2336 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2338 summary_toggle_show_read_messages(mainwin->summaryview);
2341 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2343 if (mainwin->menu_lock_count) return;
2344 if (!mainwin->summaryview->folder_item) return;
2346 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2347 summary_thread_build(mainwin->summaryview);
2348 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2350 summary_unthread(mainwin->summaryview);
2351 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2355 static void expand_threads_cb(MainWindow *mainwin, guint action,
2358 summary_expand_threads(mainwin->summaryview);
2361 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2364 summary_collapse_threads(mainwin->summaryview);
2367 static void set_display_item_cb(MainWindow *mainwin, guint action,
2370 prefs_summary_column_open();
2373 static void sort_summary_cb(MainWindow *mainwin, guint action,
2376 FolderItem *item = mainwin->summaryview->folder_item;
2377 GtkWidget *menuitem;
2379 if (mainwin->menu_lock_count) return;
2381 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2382 menuitem = gtk_item_factory_get_item
2383 (mainwin->menu_factory, "/View/Sort/Ascending");
2384 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2385 GTK_CHECK_MENU_ITEM(menuitem)->active
2386 ? SORT_ASCENDING : SORT_DESCENDING);
2390 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2393 FolderItem *item = mainwin->summaryview->folder_item;
2395 if (mainwin->menu_lock_count) return;
2397 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2398 summary_sort(mainwin->summaryview,
2399 item->sort_key, (FolderSortType)action);
2402 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2405 summary_attract_by_subject(mainwin->summaryview);
2408 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2411 summary_delete_duplicated(mainwin->summaryview);
2414 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2416 summary_filter(mainwin->summaryview);
2419 static void execute_summary_cb(MainWindow *mainwin, guint action,
2422 summary_execute(mainwin->summaryview);
2425 static void update_summary_cb(MainWindow *mainwin, guint action,
2429 FolderView *folderview = mainwin->folderview;
2431 if (!mainwin->summaryview->folder_item) return;
2432 if (!folderview->opened) return;
2434 folder_update_op_count();
2436 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2437 folderview->opened);
2440 folder_item_scan(fitem);
2441 summary_show(mainwin->summaryview, fitem);
2444 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2446 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2449 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2451 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2454 static void prev_unread_cb(MainWindow *mainwin, guint action,
2457 summary_select_prev_unread(mainwin->summaryview);
2460 static void next_unread_cb(MainWindow *mainwin, guint action,
2463 summary_select_next_unread(mainwin->summaryview);
2466 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2468 summary_select_prev_new(mainwin->summaryview);
2471 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2473 summary_select_next_new(mainwin->summaryview);
2476 static void prev_marked_cb(MainWindow *mainwin, guint action,
2479 summary_select_prev_marked(mainwin->summaryview);
2482 static void next_marked_cb(MainWindow *mainwin, guint action,
2485 summary_select_next_marked(mainwin->summaryview);
2488 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2491 summary_select_prev_labeled(mainwin->summaryview);
2494 static void next_labeled_cb(MainWindow *mainwin, guint action,
2497 summary_select_next_labeled(mainwin->summaryview);
2500 static void goto_folder_cb(MainWindow *mainwin, guint action,
2503 FolderItem *to_folder;
2505 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2508 folderview_select(mainwin->folderview, to_folder);
2511 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2513 messageview_copy_clipboard(mainwin->messageview);
2516 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2518 MessageView *msgview = mainwin->messageview;
2520 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2521 summary_select_all(mainwin->summaryview);
2522 else if (messageview_is_visible(msgview) &&
2523 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
2524 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2525 messageview_select_all(mainwin->messageview);
2528 static void select_thread_cb(MainWindow *mainwin, guint action,
2531 summary_select_thread(mainwin->summaryview);
2534 static void create_filter_cb(MainWindow *mainwin, guint action,
2537 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2540 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2543 prefs_common_open();
2546 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2549 prefs_scoring_open(NULL);
2552 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2555 prefs_filtering_open(NULL, NULL, NULL);
2558 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2561 prefs_template_open();
2564 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2567 prefs_actions_open(mainwin);
2570 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2573 ssl_manager_open(mainwin);
2576 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2580 new_account_cb(mainwin, 0, widget);
2582 account_open(cur_account);
2586 static void new_account_cb(MainWindow *mainwin, guint action,
2589 account_edit_open();
2590 if (!compose_get_compose_list()) account_add();
2593 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2595 cur_account = (PrefsAccount *)data;
2596 main_window_reflect_prefs_all();
2599 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
2604 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
2606 pluginwindow_create();
2609 static void manual_open_cb(MainWindow *mainwin, guint action,
2612 manual_open((ManualType)action);
2615 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2617 MainWindow *mainwin = (MainWindow *)data;
2621 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2622 LOCAL_FOLDER(folder)->rootpath,
2626 str = g_strdup_printf(_("Scanning folder %s ..."),
2627 LOCAL_FOLDER(folder)->rootpath);
2629 STATUSBAR_PUSH(mainwin, str);
2630 STATUSBAR_POP(mainwin);
2634 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
2637 SummaryView *summary;
2639 g_return_val_if_fail(data, FALSE);
2640 summary = ((MainWindow *)data)->summaryview;
2641 g_return_val_if_fail(summary, FALSE);
2642 if (summary->selected != summary->displayed)
2643 summary_select_node(summary, summary->displayed, FALSE, TRUE);
2647 #define BREAK_ON_MODIFIER_KEY() \
2648 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2650 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
2653 MainWindow *mainwin = (MainWindow*) data;
2655 if (!mainwin || !event) return;
2657 switch (event->keyval) {
2658 case GDK_Q: /* Quit */
2659 BREAK_ON_MODIFIER_KEY();
2661 app_exit_cb(mainwin, 0, NULL);
2664 if (mainwin->folderview && mainwin->summaryview
2665 && !mainwin->summaryview->displayed) {
2666 summary_lock(mainwin->summaryview);
2667 folderview_select_next_unread(mainwin->folderview);
2668 summary_unlock(mainwin->summaryview);
2676 #undef BREAK_ON_MODIFIER_KEY
2679 * Harvest addresses for selected folder.
2681 static void addr_harvest_cb( MainWindow *mainwin,
2685 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
2689 * Harvest addresses for selected messages in summary view.
2691 static void addr_harvest_msg_cb( MainWindow *mainwin,
2695 summary_harvest_address( mainwin->summaryview );
2699 *\brief get a MainWindow
2701 *\return MainWindow * The first mainwindow in the mainwin_list
2703 MainWindow *mainwindow_get_mainwindow(void)
2705 if (mainwin_list && mainwin_list->data)
2706 return (MainWindow *)(mainwin_list->data);