2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2005 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 <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkwindow.h>
27 #include <gtk/gtkwidget.h>
28 #include <gtk/gtksignal.h>
29 #include <gtk/gtkvbox.h>
30 #include <gtk/gtkcontainer.h>
31 #include <gtk/gtkstatusbar.h>
32 #include <gtk/gtkprogressbar.h>
33 #include <gtk/gtkhpaned.h>
34 #include <gtk/gtkvpaned.h>
35 #include <gtk/gtkcheckmenuitem.h>
36 #include <gtk/gtkitemfactory.h>
37 #include <gtk/gtkeditable.h>
38 #include <gtk/gtkmenu.h>
39 #include <gtk/gtkmenuitem.h>
40 #include <gtk/gtkhandlebox.h>
41 #include <gtk/gtktoolbar.h>
42 #include <gtk/gtkbutton.h>
43 #include <gtk/gtktooltips.h>
47 #include "mainwindow.h"
48 #include "folderview.h"
49 #include "foldersel.h"
50 #include "summaryview.h"
51 #include "summary_search.h"
52 #include "messageview.h"
53 #include "message_search.h"
54 #include "headerview.h"
56 #include "stock_pixmap.h"
63 #include "prefs_common.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "ssl_manager.h"
84 #include "sslcertwindow.h"
85 #include "prefs_gtk.h"
86 #include "pluginwindow.h"
88 #include "progressindicator.h"
89 #include "localfolder.h"
90 #include "filtering.h"
91 #include "folderutils.h"
92 #include "foldersort.h"
94 #define AC_LABEL_WIDTH 240
96 /* list of all instantiated MainWindow */
97 static GList *mainwin_list = NULL;
99 static GdkCursor *watch_cursor;
101 static void main_window_menu_callback_block (MainWindow *mainwin);
102 static void main_window_menu_callback_unblock (MainWindow *mainwin);
104 static void main_window_show_cur_account (MainWindow *mainwin);
106 static void main_window_set_widgets (MainWindow *mainwin,
110 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
111 GdkEventButton *event,
115 static void toolbar_child_attached (GtkWidget *widget,
118 static void toolbar_child_detached (GtkWidget *widget,
122 static gboolean ac_label_button_pressed (GtkWidget *widget,
123 GdkEventButton *event,
125 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
128 static gint main_window_close_cb (GtkWidget *widget,
131 static gint folder_window_close_cb (GtkWidget *widget,
134 static gint message_window_close_cb (GtkWidget *widget,
138 static void main_window_size_allocate_cb (GtkWidget *widget,
139 GtkAllocation *allocation,
141 static void folder_window_size_allocate_cb (GtkWidget *widget,
142 GtkAllocation *allocation,
144 static void message_window_size_allocate_cb (GtkWidget *widget,
145 GtkAllocation *allocation,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void foldersort_cb (MainWindow *mainwin,
157 static void import_mbox_cb (MainWindow *mainwin,
160 static void export_mbox_cb (MainWindow *mainwin,
163 static void export_list_mbox_cb (MainWindow *mainwin,
166 static void empty_trash_cb (MainWindow *mainwin,
170 static void save_as_cb (MainWindow *mainwin,
173 static void print_cb (MainWindow *mainwin,
176 static void app_exit_cb (MainWindow *mainwin,
180 static void search_cb (MainWindow *mainwin,
184 static void toggle_folder_cb (MainWindow *mainwin,
187 static void toggle_message_cb (MainWindow *mainwin,
190 static void toggle_toolbar_cb (MainWindow *mainwin,
193 static void toggle_statusbar_cb (MainWindow *mainwin,
196 static void separate_widget_cb (MainWindow *mainwin,
200 static void addressbook_open_cb (MainWindow *mainwin,
203 static void log_window_show_cb (MainWindow *mainwin,
207 static void inc_cancel_cb (MainWindow *mainwin,
211 static void open_msg_cb (MainWindow *mainwin,
215 static void view_source_cb (MainWindow *mainwin,
219 static void show_all_header_cb (MainWindow *mainwin,
223 static void move_to_cb (MainWindow *mainwin,
226 static void copy_to_cb (MainWindow *mainwin,
229 static void delete_cb (MainWindow *mainwin,
233 static void cancel_cb (MainWindow *mainwin,
237 static void mark_cb (MainWindow *mainwin,
240 static void unmark_cb (MainWindow *mainwin,
244 static void mark_as_unread_cb (MainWindow *mainwin,
247 static void mark_as_read_cb (MainWindow *mainwin,
250 static void mark_all_read_cb (MainWindow *mainwin,
254 static void reedit_cb (MainWindow *mainwin,
258 static void add_address_cb (MainWindow *mainwin,
262 static void set_charset_cb (MainWindow *mainwin,
266 static void set_decode_cb (MainWindow *mainwin,
270 static void hide_read_messages (MainWindow *mainwin,
274 static void thread_cb (MainWindow *mainwin,
277 static void expand_threads_cb (MainWindow *mainwin,
280 static void collapse_threads_cb (MainWindow *mainwin,
284 static void set_display_item_cb (MainWindow *mainwin,
287 static void sort_summary_cb (MainWindow *mainwin,
290 static void sort_summary_type_cb (MainWindow *mainwin,
293 static void attract_by_subject_cb(MainWindow *mainwin,
297 static void delete_duplicated_cb (MainWindow *mainwin,
300 static void delete_duplicated_all_cb (MainWindow *mainwin,
303 static void filter_cb (MainWindow *mainwin,
306 static void execute_summary_cb (MainWindow *mainwin,
309 static void update_summary_cb (MainWindow *mainwin,
313 static void prev_cb (MainWindow *mainwin,
316 static void next_cb (MainWindow *mainwin,
319 static void next_unread_cb (MainWindow *mainwin,
322 static void prev_unread_cb (MainWindow *mainwin,
326 static void prev_new_cb (MainWindow *mainwin,
329 static void next_new_cb (MainWindow *mainwin,
332 static void prev_marked_cb (MainWindow *mainwin,
335 static void next_marked_cb (MainWindow *mainwin,
338 static void prev_labeled_cb (MainWindow *mainwin,
341 static void next_labeled_cb (MainWindow *mainwin,
345 static void goto_folder_cb (MainWindow *mainwin,
349 static void copy_cb (MainWindow *mainwin,
352 static void allsel_cb (MainWindow *mainwin,
355 static void select_thread_cb (MainWindow *mainwin,
359 static void create_filter_cb (MainWindow *mainwin,
362 static void create_processing_cb (MainWindow *mainwin,
366 static void prefs_template_open_cb (MainWindow *mainwin,
369 static void prefs_actions_open_cb (MainWindow *mainwin,
372 static void prefs_account_open_cb (MainWindow *mainwin,
376 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
380 static void prefs_post_processing_open_cb (MainWindow *mainwin,
384 static void prefs_filtering_open_cb (MainWindow *mainwin,
388 static void ssl_manager_open_cb (MainWindow *mainwin,
392 static void new_account_cb (MainWindow *mainwin,
396 static void account_selector_menu_cb (GtkMenuItem *menuitem,
398 static void account_receive_menu_cb (GtkMenuItem *menuitem,
401 static void prefs_open_cb (GtkMenuItem *menuitem,
403 static void plugins_open_cb (GtkMenuItem *menuitem,
406 static void online_switch_clicked(GtkButton *btn,
409 static void manual_open_cb (MainWindow *mainwin,
413 static void scan_tree_func (Folder *folder,
417 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
419 static void addr_harvest_cb ( MainWindow *mainwin,
423 static void addr_harvest_msg_cb ( MainWindow *mainwin,
427 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
428 GdkEventFocus *focus,
430 void main_window_reply_cb (MainWindow *mainwin,
433 gboolean mainwindow_progressindicator_hook (gpointer source,
435 #define SEPARATE_ACTION 500
437 static GtkItemFactoryEntry mainwin_entries[] =
439 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
440 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
441 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
442 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
443 {N_("/_File/Change folder order"), NULL, foldersort_cb, 0, NULL},
444 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
445 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
446 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
447 {N_("/_File/Exp_ort selected to mbox file..."),
448 NULL, export_list_mbox_cb, 0, NULL},
449 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
450 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
451 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
452 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
453 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
454 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
455 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
456 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
457 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
458 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
460 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
461 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
462 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
463 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
464 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
465 {N_("/_Edit/_Find in current message..."),
466 "<control>F", search_cb, 0, NULL},
467 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
468 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
469 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
470 {N_("/_View/Show or hi_de/_Folder tree"),
471 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
472 {N_("/_View/Show or hi_de/_Message view"),
473 "V", toggle_message_cb, 0, "<ToggleItem>"},
474 {N_("/_View/Show or hi_de/_Toolbar"),
475 NULL, NULL, 0, "<Branch>"},
476 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
477 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
478 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
479 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
480 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
481 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
482 {N_("/_View/Show or hi_de/_Toolbar/_None"),
483 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
484 {N_("/_View/Show or hi_de/Status _bar"),
485 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
486 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
488 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
489 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
492 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
493 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
494 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
495 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
496 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
497 {N_("/_View/_Sort/by _color label"),
498 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
499 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
500 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
501 {N_("/_View/_Sort/by a_ttachment"),
502 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
503 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
504 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
505 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
506 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
508 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
509 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_View/_Sort/_Attract by subject"),
511 NULL, attract_by_subject_cb, 0, NULL},
512 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
513 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
514 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
515 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
516 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
518 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
520 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
521 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
522 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_View/_Go to/P_rev unread message"),
524 "<shift>P", prev_unread_cb, 0, NULL},
525 {N_("/_View/_Go to/N_ext unread message"),
526 "<shift>N", next_unread_cb, 0, NULL},
527 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
529 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
530 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_View/_Go to/Prev _marked message"),
532 NULL, prev_marked_cb, 0, NULL},
533 {N_("/_View/_Go to/Next m_arked message"),
534 NULL, next_marked_cb, 0, NULL},
535 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_View/_Go to/Prev _labeled message"),
537 NULL, prev_labeled_cb, 0, NULL},
538 {N_("/_View/_Go to/Next la_beled message"),
539 NULL, next_labeled_cb, 0, NULL},
540 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
542 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
544 #define ENC_SEPARATOR \
545 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
546 #define ENC_ACTION(action) \
547 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
549 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
550 {N_("/_View/Character _encoding/_Auto detect"),
551 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
552 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
553 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
554 ENC_ACTION(C_US_ASCII)},
555 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
556 ENC_ACTION(C_UTF_8)},
559 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
560 ENC_ACTION(C_ISO_8859_1)},
561 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
562 ENC_ACTION(C_ISO_8859_15)},
565 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
566 ENC_ACTION(C_ISO_8859_2)},
569 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
570 ENC_ACTION(C_ISO_8859_13)},
571 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
572 ENC_ACTION(C_ISO_8859_4)},
575 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
576 ENC_ACTION(C_ISO_8859_7)},
579 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
580 ENC_ACTION(C_ISO_8859_8)},
581 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
582 ENC_ACTION(C_CP1255)},
585 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
586 ENC_ACTION(C_ISO_8859_9)},
589 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
590 ENC_ACTION(C_ISO_8859_5)},
591 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
592 ENC_ACTION(C_KOI8_R)},
593 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
594 ENC_ACTION(C_KOI8_U)},
595 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
596 ENC_ACTION(C_CP1251)},
599 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
600 ENC_ACTION(C_ISO_2022_JP)},
601 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
602 ENC_ACTION(C_ISO_2022_JP_2)},
603 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
604 ENC_ACTION(C_EUC_JP)},
605 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
606 ENC_ACTION(C_SHIFT_JIS)},
609 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
610 ENC_ACTION(C_GB2312)},
611 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
613 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
615 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
616 ENC_ACTION(C_EUC_TW)},
617 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
618 ENC_ACTION(C_ISO_2022_CN)},
621 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
622 ENC_ACTION(C_EUC_KR)},
623 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
624 ENC_ACTION(C_ISO_2022_KR)},
627 {N_("/_View/Character _encoding/Thai (TIS-620)"),
628 ENC_ACTION(C_TIS_620)},
629 {N_("/_View/Character _encoding/Thai (Windows-874)"),
630 ENC_ACTION(C_WINDOWS_874)},
635 #define DEC_SEPARATOR \
636 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
637 #define DEC_ACTION(action) \
638 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
639 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
640 {N_("/_View/Decode/_Auto detect"),
641 NULL, set_decode_cb, 0, "<RadioItem>"},
642 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
643 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
644 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
645 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
646 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
651 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
653 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
654 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
655 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
656 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
658 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
659 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
660 {N_("/_Message/Recei_ve/Get from _current account"),
661 "<control>I", inc_mail_cb, 0, NULL},
662 {N_("/_Message/Recei_ve/Get from _all accounts"),
663 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
664 {N_("/_Message/Recei_ve/Cancel receivin_g"),
665 NULL, inc_cancel_cb, 0, NULL},
666 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
668 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
669 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
670 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
671 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
672 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
673 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
674 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
675 {N_("/_Message/Repl_y to/mailing _list"),
676 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
677 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
678 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
680 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
681 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
682 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
683 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
684 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
685 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
686 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
687 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
688 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
689 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
690 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
691 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
692 {N_("/_Message/_Mark/Mark as rea_d"),
693 NULL, mark_as_read_cb, 0, NULL},
694 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
695 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
698 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
699 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
700 {N_("/_Tools/Add sender to address boo_k"),
701 NULL, add_address_cb, 0, NULL},
702 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
703 {N_("/_Tools/_Harvest addresses/from _Folder..."),
704 NULL, addr_harvest_cb, 0, NULL},
705 {N_("/_Tools/_Harvest addresses/from _Messages..."),
706 NULL, addr_harvest_msg_cb, 0, NULL},
707 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Tools/_Filter all messages in folder"),
709 NULL, filter_cb, 0, NULL},
710 {N_("/_Tools/Filter _selected messages"),
711 NULL, filter_cb, 1, NULL},
712 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
713 {N_("/_Tools/_Create filter rule/_Automatically"),
714 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
715 {N_("/_Tools/_Create filter rule/by _From"),
716 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
717 {N_("/_Tools/_Create filter rule/by _To"),
718 NULL, create_filter_cb, FILTER_BY_TO, NULL},
719 {N_("/_Tools/_Create filter rule/by _Subject"),
720 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
721 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
722 {N_("/_Tools/C_reate processing rule/_Automatically"),
723 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
724 {N_("/_Tools/C_reate processing rule/by _From"),
725 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
726 {N_("/_Tools/C_reate processing rule/by _To"),
727 NULL, create_processing_cb, FILTER_BY_TO, NULL},
728 {N_("/_Tools/C_reate processing rule/by _Subject"),
729 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
730 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
731 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
732 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
733 {N_("/_Tools/Ch_eck for new messages in all folders"),
734 NULL, update_folderview_cb, 0, NULL},
735 {N_("/_Tools/Delete du_plicated messages"),
736 NULL, NULL, 0, "<Branch>"},
737 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
738 NULL, delete_duplicated_cb, 0, NULL},
739 {N_("/_Tools/Delete du_plicated messages/In all folders"),
740 NULL, delete_duplicated_all_cb, 0, NULL},
741 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
742 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
744 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
745 {N_("/_Tools/SSL cer_tificates..."),
746 NULL, ssl_manager_open_cb, 0, NULL},
748 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
749 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
751 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
752 {N_("/_Configuration/C_hange current account"),
753 NULL, NULL, 0, "<Branch>"},
754 {N_("/_Configuration/_Preferences for current account..."),
755 NULL, prefs_account_open_cb, 0, NULL},
756 {N_("/_Configuration/Create _new account..."),
757 NULL, new_account_cb, 0, NULL},
758 {N_("/_Configuration/_Edit accounts..."),
759 NULL, account_edit_open, 0, NULL},
760 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Configuration/P_references..."),
762 NULL, prefs_open_cb, 0, NULL},
763 {N_("/_Configuration/Pre-pr_ocessing..."),
764 NULL, prefs_pre_processing_open_cb, 0, NULL},
765 {N_("/_Configuration/Post-pro_cessing..."),
766 NULL, prefs_post_processing_open_cb, 0, NULL},
767 {N_("/_Configuration/_Filtering..."),
768 NULL, prefs_filtering_open_cb, 0, NULL},
769 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
770 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
771 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
773 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
774 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
775 {N_("/_Help/Ma_nual (Sylpheed Doc Homepage)"),
776 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
777 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
778 {N_("/_Help/FA_Q (Sylpheed Doc Homepage)"),
779 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
780 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
781 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
782 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
783 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
786 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
792 MainWindow *mainwin = (MainWindow *)user_data;
794 if (mainwin->summaryview &&
795 mainwin->summaryview->quicksearch &&
796 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
797 (mod == 0 || mod == GDK_SHIFT_MASK)) {
798 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
804 MainWindow *main_window_create(SeparateType type)
810 GtkWidget *handlebox;
811 GtkWidget *vbox_body;
812 GtkWidget *hbox_stat;
813 GtkWidget *statusbar;
814 GtkWidget *progressbar;
815 GtkWidget *statuslabel;
816 GtkWidget *ac_button;
818 GtkWidget *online_pixmap;
819 GtkWidget *offline_pixmap;
820 GtkWidget *online_switch;
821 GtkWidget *offline_switch;
822 GtkTooltips *offline_tip;
823 GtkTooltips *online_tip;
824 GtkTooltips *sel_ac_tip;
826 FolderView *folderview;
827 SummaryView *summaryview;
828 MessageView *messageview;
829 GdkColormap *colormap;
832 GtkItemFactory *ifactory;
836 guint n_menu_entries;
837 gboolean hide_messageview = FALSE;
839 static GdkGeometry geometry;
841 debug_print("Creating main window...\n");
842 mainwin = g_new0(MainWindow, 1);
845 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
846 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
847 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
849 if (!geometry.min_height) {
850 geometry.min_width = 320;
851 geometry.min_height = 200;
853 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
856 g_signal_connect(G_OBJECT(window), "delete_event",
857 G_CALLBACK(main_window_close_cb), mainwin);
858 MANAGE_WINDOW_SIGNALS_CONNECT(window);
859 g_signal_connect(G_OBJECT(window), "focus_in_event",
860 G_CALLBACK(mainwindow_focus_in_event),
862 g_signal_connect(G_OBJECT(window), "key_press_event",
863 G_CALLBACK(mainwindow_key_pressed), mainwin);
865 gtk_widget_realize(window);
866 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
869 gtkut_widget_set_app_icon(window);
871 vbox = gtk_vbox_new(FALSE, 0);
872 gtk_widget_show(vbox);
873 gtk_container_add(GTK_CONTAINER(window), vbox);
876 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
877 menubar = menubar_create(window, mainwin_entries,
878 n_menu_entries, "<Main>", mainwin);
879 gtk_widget_show(menubar);
880 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
881 ifactory = gtk_item_factory_from_widget(menubar);
883 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
884 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
886 handlebox = gtk_handle_box_new();
887 gtk_widget_show(handlebox);
888 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
889 g_signal_connect(G_OBJECT(handlebox), "child_attached",
890 G_CALLBACK(toolbar_child_attached), mainwin);
891 g_signal_connect(G_OBJECT(handlebox), "child_detached",
892 G_CALLBACK(toolbar_child_detached), mainwin);
894 /* link window to mainwin->window to avoid gdk warnings */
895 mainwin->window = window;
898 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
902 /* vbox that contains body */
903 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
904 gtk_widget_show(vbox_body);
905 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
906 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
908 hbox_stat = gtk_hbox_new(FALSE, 2);
909 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
911 statusbar = statusbar_create();
912 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
914 progressbar = gtk_progress_bar_new();
915 gtk_widget_set_size_request(progressbar, 120, 1);
916 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
918 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
919 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
920 online_tip = gtk_tooltips_new();
921 online_switch = gtk_button_new ();
922 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
923 _("You are online. Click the icon to go offline"), NULL);
924 offline_tip = gtk_tooltips_new();
925 offline_switch = gtk_button_new ();
926 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
927 _("You are offline. Click the icon to go online"),
929 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
930 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
931 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
932 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
933 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
934 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
935 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
936 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
938 statuslabel = gtk_label_new("");
939 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
941 sel_ac_tip = gtk_tooltips_new();
942 ac_button = gtk_button_new();
943 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
944 ac_button, _("Select account"), NULL);
945 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
946 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
947 gtk_widget_set_size_request(ac_button, -1, 0);
948 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
949 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
950 G_CALLBACK(ac_label_button_pressed), mainwin);
952 ac_label = gtk_label_new("");
953 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
955 gtk_widget_show_all(hbox_stat);
957 gtk_widget_hide(offline_switch);
959 mainwin->folderview = folderview = folderview_create();
960 mainwin->summaryview = summaryview = summary_create();
961 mainwin->messageview = messageview = messageview_create(mainwin);
962 mainwin->logwin = log_window_create();
964 folderview->mainwin = mainwin;
965 folderview->summaryview = summaryview;
967 summaryview->mainwin = mainwin;
968 summaryview->folderview = folderview;
969 summaryview->messageview = messageview;
970 summaryview->window = window;
972 messageview->statusbar = statusbar;
973 mainwin->vbox = vbox;
974 mainwin->menubar = menubar;
975 mainwin->menu_factory = ifactory;
976 mainwin->handlebox = handlebox;
977 mainwin->vbox_body = vbox_body;
978 mainwin->hbox_stat = hbox_stat;
979 mainwin->statusbar = statusbar;
980 mainwin->progressbar = progressbar;
981 mainwin->statuslabel = statuslabel;
982 mainwin->online_switch = online_switch;
983 mainwin->online_pixmap = online_pixmap;
984 mainwin->offline_pixmap = offline_pixmap;
985 mainwin->ac_button = ac_button;
986 mainwin->ac_label = ac_label;
987 mainwin->offline_switch = offline_switch;
989 /* set context IDs for status bar */
990 mainwin->mainwin_cid = gtk_statusbar_get_context_id
991 (GTK_STATUSBAR(statusbar), "Main Window");
992 mainwin->folderview_cid = gtk_statusbar_get_context_id
993 (GTK_STATUSBAR(statusbar), "Folder View");
994 mainwin->summaryview_cid = gtk_statusbar_get_context_id
995 (GTK_STATUSBAR(statusbar), "Summary View");
996 mainwin->messageview_cid = gtk_statusbar_get_context_id
997 (GTK_STATUSBAR(statusbar), "Message View");
999 messageview->statusbar_cid = mainwin->messageview_cid;
1001 /* allocate colors for summary view and folder view */
1002 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1003 summaryview->color_marked.blue = (guint16)65535;
1005 summaryview->color_dim.red = summaryview->color_dim.green =
1006 summaryview->color_dim.blue = COLOR_DIM;
1008 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1009 &folderview->color_new);
1011 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1012 &folderview->color_op);
1014 summaryview->color_important.red = 0;
1015 summaryview->color_important.green = 0;
1016 summaryview->color_important.blue = (guint16)65535;
1018 color[0] = summaryview->color_marked;
1019 color[1] = summaryview->color_dim;
1020 color[2] = folderview->color_new;
1021 color[3] = folderview->color_op;
1023 colormap = gdk_window_get_colormap(window->window);
1024 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1025 for (i = 0; i < 4; i++) {
1026 if (success[i] == FALSE)
1027 g_warning("MainWindow: color allocation %d failed\n", i);
1030 debug_print("done.\n");
1032 messageview->visible = prefs_common.msgview_visible;
1033 hide_messageview = !messageview->visible;
1035 main_window_set_widgets(mainwin, type);
1037 g_signal_connect(G_OBJECT(window), "size_allocate",
1038 G_CALLBACK(main_window_size_allocate_cb),
1041 /* set menu items */
1042 menuitem = gtk_item_factory_get_item
1043 (ifactory, "/View/Character encoding/Auto detect");
1044 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1046 switch (prefs_common.toolbar_style) {
1048 menuitem = gtk_item_factory_get_item
1049 (ifactory, "/View/Show or hide/Toolbar/None");
1052 menuitem = gtk_item_factory_get_item
1053 (ifactory, "/View/Show or hide/Toolbar/Icon");
1056 menuitem = gtk_item_factory_get_item
1057 (ifactory, "/View/Show or hide/Toolbar/Text");
1060 menuitem = gtk_item_factory_get_item
1061 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1063 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1065 gtk_widget_hide(mainwin->hbox_stat);
1066 menuitem = gtk_item_factory_get_item
1067 (ifactory, "/View/Show or hide/Status bar");
1068 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1069 prefs_common.show_statusbar);
1071 /* set account selection menu */
1072 ac_menu = gtk_item_factory_get_widget
1073 (ifactory, "/Configuration/Change current account");
1074 g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1075 G_CALLBACK(ac_menu_popup_closed), mainwin);
1076 mainwin->ac_menu = ac_menu;
1078 toolbar_main_set_sensitive(mainwin);
1080 /* create actions menu */
1081 main_window_update_actions_menu(mainwin);
1083 /* attach accel groups to main window */
1084 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1085 gtk_window_add_accel_group \
1087 gtk_item_factory_from_widget(menu)->accel_group); \
1088 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1090 G_CALLBACK(main_window_accel_activate), mainwin);
1093 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1095 /* connect the accelerators for equivalent
1096 menu items in different menus */
1097 menu_connect_identical_items();
1101 /* show main window */
1102 gtk_widget_show(mainwin->window);
1104 /* initialize views */
1105 folderview_init(folderview);
1106 summary_init(summaryview);
1107 messageview_init(messageview);
1108 log_window_init(mainwin->logwin);
1109 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1110 prefs_common.loglength);
1112 sslcertwindow_register_hook();
1114 mainwin->lock_count = 0;
1115 mainwin->menu_lock_count = 0;
1116 mainwin->cursor_count = 0;
1118 mainwin->progressindicator_hook =
1119 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1122 watch_cursor = gdk_cursor_new(GDK_WATCH);
1124 mainwin_list = g_list_append(mainwin_list, mainwin);
1126 /* init work_offline */
1127 if (prefs_common.work_offline)
1128 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1130 if (mainwin->type == SEPARATE_NONE && hide_messageview)
1131 main_window_toggle_message_view(mainwin);
1136 void main_window_destroy(MainWindow *mainwin)
1138 /* TODO : destroy other component */
1139 messageview_destroy(mainwin->messageview);
1140 mainwin->messageview = NULL;
1143 void main_window_update_actions_menu(MainWindow *mainwin)
1145 GtkItemFactory *ifactory;
1147 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1148 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1151 void main_window_cursor_wait(MainWindow *mainwin)
1154 if (mainwin->cursor_count == 0)
1155 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1157 mainwin->cursor_count++;
1162 void main_window_cursor_normal(MainWindow *mainwin)
1164 if (mainwin->cursor_count)
1165 mainwin->cursor_count--;
1167 if (mainwin->cursor_count == 0)
1168 gdk_window_set_cursor(mainwin->window->window, NULL);
1173 /* lock / unlock the user-interface */
1174 void main_window_lock(MainWindow *mainwin)
1176 if (mainwin->lock_count == 0)
1177 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1179 mainwin->lock_count++;
1181 main_window_set_menu_sensitive(mainwin);
1182 toolbar_main_set_sensitive(mainwin);
1185 void main_window_unlock(MainWindow *mainwin)
1187 if (mainwin->lock_count)
1188 mainwin->lock_count--;
1190 main_window_set_menu_sensitive(mainwin);
1191 toolbar_main_set_sensitive(mainwin);
1193 if (mainwin->lock_count == 0)
1194 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1197 static void main_window_menu_callback_block(MainWindow *mainwin)
1199 mainwin->menu_lock_count++;
1202 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1204 if (mainwin->menu_lock_count)
1205 mainwin->menu_lock_count--;
1208 void main_window_reflect_prefs_all(void)
1210 main_window_reflect_prefs_all_real(FALSE);
1213 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1216 MainWindow *mainwin;
1219 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1220 mainwin = (MainWindow *)cur->data;
1222 main_window_show_cur_account(mainwin);
1223 main_window_set_menu_sensitive(mainwin);
1224 toolbar_main_set_sensitive(mainwin);
1227 if (pixmap_theme_changed) {
1228 toolbar_update(TOOLBAR_MAIN, mainwin);
1229 messageview_reflect_prefs_pixmap_theme();
1230 compose_reflect_prefs_pixmap_theme();
1231 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1232 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1234 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1235 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1236 mainwin->online_pixmap);
1237 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1238 gtk_widget_show(pixmap);
1239 mainwin->online_pixmap = pixmap;
1240 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1241 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1242 mainwin->offline_pixmap);
1243 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1244 gtk_widget_show(pixmap);
1245 mainwin->offline_pixmap = pixmap;
1248 headerview_set_visibility(mainwin->messageview->headerview,
1249 prefs_common.display_header_pane);
1251 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1253 summary_redisplay_msg(mainwin->summaryview);
1257 void main_window_set_summary_column(void)
1260 MainWindow *mainwin;
1262 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1263 mainwin = (MainWindow *)cur->data;
1264 summary_set_column_order(mainwin->summaryview);
1268 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1269 GList *account_list)
1271 GList *cur_ac, *cur_item;
1272 GtkWidget *menuitem;
1273 PrefsAccount *ac_prefs;
1275 /* destroy all previous menu item */
1276 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1277 while (cur_item != NULL) {
1278 GList *next = cur_item->next;
1279 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1283 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1284 ac_prefs = (PrefsAccount *)cur_ac->data;
1286 menuitem = gtk_menu_item_new_with_label
1287 (ac_prefs->account_name
1288 ? ac_prefs->account_name : _("Untitled"));
1289 gtk_widget_show(menuitem);
1290 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1291 g_signal_connect(G_OBJECT(menuitem), "activate",
1292 G_CALLBACK(account_selector_menu_cb),
1297 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1298 GList *account_list)
1300 GList *cur_ac, *cur_item;
1302 GtkWidget *menuitem;
1303 PrefsAccount *ac_prefs;
1305 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1306 "/Message/Receive");
1308 /* search for separator */
1309 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1310 cur_item = cur_item->next) {
1311 if (GTK_BIN(cur_item->data)->child == NULL) {
1312 cur_item = cur_item->next;
1317 /* destroy all previous menu item */
1318 while (cur_item != NULL) {
1319 GList *next = cur_item->next;
1320 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1324 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1325 ac_prefs = (PrefsAccount *)cur_ac->data;
1327 menuitem = gtk_menu_item_new_with_label
1328 (ac_prefs->account_name ? ac_prefs->account_name
1330 gtk_widget_show(menuitem);
1331 gtk_menu_append(GTK_MENU(menu), menuitem);
1332 g_signal_connect(G_OBJECT(menuitem), "activate",
1333 G_CALLBACK(account_receive_menu_cb),
1338 void main_window_set_account_menu(GList *account_list)
1341 MainWindow *mainwin;
1343 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1344 mainwin = (MainWindow *)cur->data;
1345 main_window_set_account_selector_menu(mainwin, account_list);
1346 main_window_set_account_receive_menu(mainwin, account_list);
1350 static void main_window_show_cur_account(MainWindow *mainwin)
1355 ac_name = g_strdup(cur_account
1356 ? (cur_account->account_name
1357 ? cur_account->account_name : _("Untitled"))
1361 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1363 buf = g_strdup(PROG_VERSION);
1364 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1367 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1368 gtk_widget_queue_resize(mainwin->ac_button);
1373 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1375 switch (mainwin->type) {
1376 case SEPARATE_FOLDER:
1377 return mainwin->win.sep_folder.folderwin;
1379 return mainwin->win.sep_both.folderwin;
1385 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1387 switch (mainwin->type) {
1388 case SEPARATE_MESSAGE:
1389 return mainwin->win.sep_message.messagewin;
1391 return mainwin->win.sep_both.messagewin;
1397 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1399 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1400 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1401 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1402 GtkWidget *message_wid = mainwin->messageview->vbox;
1404 debug_print("Changing window separation type from %d to %d\n",
1405 mainwin->type, type);
1407 if (mainwin->type == type) return;
1409 /* remove widgets from those containers */
1410 gtk_widget_ref(folder_wid);
1411 gtk_widget_ref(summary_wid);
1412 gtk_widget_ref(message_wid);
1413 gtkut_container_remove
1414 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1415 gtkut_container_remove
1416 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1417 gtkut_container_remove
1418 (GTK_CONTAINER(message_wid->parent), message_wid);
1420 /* clean containers */
1421 switch (mainwin->type) {
1423 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1425 case SEPARATE_FOLDER:
1426 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1427 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1429 case SEPARATE_MESSAGE:
1430 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1431 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1434 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1435 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1439 gtk_widget_hide(mainwin->window);
1440 main_window_set_widgets(mainwin, type);
1441 gtk_widget_show(mainwin->window);
1443 gtk_widget_unref(folder_wid);
1444 gtk_widget_unref(summary_wid);
1445 gtk_widget_unref(message_wid);
1448 void main_window_toggle_message_view(MainWindow *mainwin)
1450 SummaryView *summaryview = mainwin->summaryview;
1451 union CompositeWin *cwin = &mainwin->win;
1452 GtkWidget *vpaned = NULL;
1453 GtkWidget *container = NULL;
1454 GtkWidget *msgwin = NULL;
1456 switch (mainwin->type) {
1458 vpaned = cwin->sep_none.vpaned;
1459 container = cwin->sep_none.hpaned;
1461 case SEPARATE_FOLDER:
1462 vpaned = cwin->sep_folder.vpaned;
1463 container = mainwin->vbox_body;
1465 case SEPARATE_MESSAGE:
1466 msgwin = mainwin->win.sep_message.messagewin;
1469 msgwin = mainwin->win.sep_both.messagewin;
1474 if (GTK_WIDGET_VISIBLE(msgwin)) {
1475 gtk_widget_hide(msgwin);
1476 mainwin->messageview->visible = FALSE;
1477 summaryview->displayed = NULL;
1479 gtk_widget_show(msgwin);
1480 mainwin->messageview->visible = TRUE;
1482 } else if (vpaned->parent != NULL) {
1483 mainwin->messageview->visible = FALSE;
1484 summaryview->displayed = NULL;
1485 gtk_widget_ref(vpaned);
1486 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1487 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1489 mainwin->messageview->visible = TRUE;
1490 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1491 gtk_container_add(GTK_CONTAINER(container), vpaned);
1492 gtk_widget_unref(vpaned);
1495 if (messageview_is_visible(mainwin->messageview))
1496 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1497 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1499 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1500 GTK_ARROW_UP, GTK_SHADOW_OUT);
1502 if (mainwin->messageview->visible == FALSE)
1503 messageview_clear(mainwin->messageview);
1505 main_window_set_menu_sensitive(mainwin);
1507 prefs_common.msgview_visible = mainwin->messageview->visible;
1509 gtk_widget_grab_focus(summaryview->ctree);
1512 void main_window_get_size(MainWindow *mainwin)
1514 GtkAllocation *allocation;
1516 if (mainwin->messageview == NULL) {
1517 debug_print("called after messageview "
1518 "has been deallocated!\n");
1522 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1524 if (allocation->width > 1 && allocation->height > 1) {
1525 prefs_common.summaryview_width = allocation->width;
1527 if ((mainwin->type == SEPARATE_NONE ||
1528 mainwin->type == SEPARATE_FOLDER) &&
1529 messageview_is_visible(mainwin->messageview))
1530 prefs_common.summaryview_height = allocation->height;
1532 prefs_common.mainview_width = allocation->width;
1535 allocation = &mainwin->window->allocation;
1536 if (allocation->width > 1 && allocation->height > 1) {
1537 prefs_common.mainview_height = allocation->height;
1538 prefs_common.mainwin_width = allocation->width;
1539 prefs_common.mainwin_height = allocation->height;
1542 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1543 if (allocation->width > 1 && allocation->height > 1) {
1544 prefs_common.folderview_width = allocation->width;
1545 prefs_common.folderview_height = allocation->height;
1548 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1549 if (allocation->width > 1 && allocation->height > 1) {
1550 prefs_common.msgview_width = allocation->width;
1551 prefs_common.msgview_height = allocation->height;
1554 /* debug_print("summaryview size: %d x %d\n",
1555 prefs_common.summaryview_width,
1556 prefs_common.summaryview_height);
1557 debug_print("folderview size: %d x %d\n",
1558 prefs_common.folderview_width,
1559 prefs_common.folderview_height);
1560 debug_print("messageview size: %d x %d\n",
1561 prefs_common.msgview_width,
1562 prefs_common.msgview_height); */
1565 void main_window_get_position(MainWindow *mainwin)
1570 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1572 prefs_common.mainview_x = x;
1573 prefs_common.mainview_y = y;
1574 prefs_common.mainwin_x = x;
1575 prefs_common.mainwin_y = y;
1577 debug_print("main window position: %d, %d\n", x, y);
1579 window = main_window_get_folder_window(mainwin);
1581 gtkut_widget_get_uposition(window, &x, &y);
1582 prefs_common.folderwin_x = x;
1583 prefs_common.folderwin_y = y;
1584 debug_print("folder window position: %d, %d\n", x, y);
1586 window = main_window_get_message_window(mainwin);
1588 gtkut_widget_get_uposition(window, &x, &y);
1589 prefs_common.main_msgwin_x = x;
1590 prefs_common.main_msgwin_y = y;
1591 debug_print("message window position: %d, %d\n", x, y);
1595 void main_window_progress_on(MainWindow *mainwin)
1597 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1600 void main_window_progress_off(MainWindow *mainwin)
1602 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1603 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1606 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1610 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1611 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1612 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1613 (cur == 0 && total == 0) ? 0 :
1614 (gfloat)cur / (gfloat)total);
1617 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1623 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1624 folder = FOLDER(list->data);
1625 if (folder && folder->trash && folder->trash->total_msgs > 0)
1629 if (!has_trash) return;
1632 if (alertpanel(_("Empty trash"),
1633 _("Empty all messages in trash?"),
1634 GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1637 manage_window_focus_in(mainwin->window, NULL, NULL);
1640 procmsg_empty_all_trash();
1642 if (mainwin->summaryview->folder_item &&
1643 mainwin->summaryview->folder_item->stype == F_TRASH)
1644 gtk_widget_grab_focus(mainwin->folderview->ctree);
1647 void main_window_add_mailbox(MainWindow *mainwin)
1652 path = input_dialog(_("Add mailbox"),
1653 _("Input the location of mailbox.\n"
1654 "If the existing mailbox is specified, it will be\n"
1655 "scanned automatically."),
1658 if (folder_find_from_path(path)) {
1659 alertpanel_error(_("The mailbox `%s' already exists."), path);
1663 folder = folder_new(folder_get_class_from_string("mh"),
1664 !strcmp(path, "Mail") ? _("Mailbox") :
1665 g_path_get_basename(path), path);
1668 if (folder->klass->create_tree(folder) < 0) {
1669 alertpanel_error(_("Creation of the mailbox failed.\n"
1670 "Maybe some files already exist, or you don't have the permission to write there."));
1671 folder_destroy(folder);
1676 folder_set_ui_func(folder, scan_tree_func, mainwin);
1677 folder_scan_tree(folder);
1678 folder_set_ui_func(folder, NULL, NULL);
1681 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1683 SensitiveCond state = 0;
1684 SummarySelection selection;
1685 FolderItem *item = mainwin->summaryview->folder_item;
1686 GList *account_list = account_get_list();
1688 selection = summary_get_selection_type(mainwin->summaryview);
1690 if (mainwin->lock_count == 0)
1691 state |= M_UNLOCKED;
1692 if (selection != SUMMARY_NONE)
1693 state |= M_MSG_EXIST;
1694 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1696 /* if (item->folder->type != F_NEWS) */
1697 state |= M_ALLOW_DELETE;
1699 if (prefs_common.immediate_exec == 0
1700 && mainwin->lock_count == 0)
1701 state |= M_DELAY_EXEC;
1703 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1704 || selection != SUMMARY_NONE)
1705 state |= M_HIDE_READ_MSG;
1707 if (mainwin->summaryview->threaded)
1708 state |= M_THREADED;
1710 state |= M_UNTHREADED;
1711 if (selection == SUMMARY_SELECTED_SINGLE ||
1712 selection == SUMMARY_SELECTED_MULTIPLE)
1713 state |= M_TARGET_EXIST;
1714 if (selection == SUMMARY_SELECTED_SINGLE)
1715 state |= M_SINGLE_TARGET_EXIST;
1716 if (mainwin->summaryview->folder_item &&
1717 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1720 state |= M_NOT_NEWS;
1721 if (selection == SUMMARY_SELECTED_SINGLE &&
1723 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1724 item->stype == F_QUEUE)))
1725 state |= M_ALLOW_REEDIT;
1727 state |= M_HAVE_ACCOUNT;
1729 for ( ; account_list != NULL; account_list = account_list->next) {
1730 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1731 state |= M_HAVE_NEWS_ACCOUNT;
1736 if (inc_is_active())
1737 state |= M_INC_ACTIVE;
1744 void main_window_set_menu_sensitive(MainWindow *mainwin)
1746 GtkItemFactory *ifactory = mainwin->menu_factory;
1747 SensitiveCond state;
1750 GtkWidget *menuitem;
1751 SummaryView *summaryview;
1756 static const struct {
1760 {"/File/Add mailbox" , M_UNLOCKED},
1762 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1763 {"/File/Change folder order" , M_UNLOCKED},
1764 {"/File/Export to mbox file..." , M_UNLOCKED},
1765 {"/File/Empty all Trash folders" , M_UNLOCKED},
1766 {"/File/Work offline" , M_UNLOCKED},
1768 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1769 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1770 /* {"/File/Close" , M_UNLOCKED}, */
1771 {"/File/Exit" , M_UNLOCKED},
1773 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1775 {"/View/Sort" , M_EXEC},
1776 {"/View/Thread view" , M_EXEC},
1777 {"/View/Expand all threads" , M_MSG_EXIST},
1778 {"/View/Collapse all threads" , M_MSG_EXIST},
1779 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1780 {"/View/Go to/Prev message" , M_MSG_EXIST},
1781 {"/View/Go to/Next message" , M_MSG_EXIST},
1782 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1783 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1784 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1785 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1786 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1787 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1788 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1789 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1790 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1792 {"/Message/Receive/Get from current account"
1793 , M_HAVE_ACCOUNT|M_UNLOCKED},
1794 {"/Message/Receive/Get from all accounts"
1795 , M_HAVE_ACCOUNT|M_UNLOCKED},
1796 {"/Message/Receive/Cancel receiving"
1799 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1800 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1801 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1802 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1803 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1804 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1805 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1806 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1807 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1808 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1809 {"/Message/Mark" , M_TARGET_EXIST},
1810 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1812 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1813 {"/Tools/Harvest addresses" , M_UNLOCKED},
1814 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1815 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1816 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1817 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1818 {"/Tools/Execute" , M_DELAY_EXEC},
1819 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1821 {"/Configuration", M_UNLOCKED},
1826 state = main_window_get_current_state(mainwin);
1828 for (i = 0; entry[i].entry != NULL; i++) {
1829 sensitive = ((entry[i].cond & state) == entry[i].cond);
1830 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1833 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1835 /* search for separator */
1836 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1837 cur_item = cur_item->next) {
1838 if (GTK_BIN(cur_item->data)->child == NULL) {
1839 cur_item = cur_item->next;
1844 for (; cur_item != NULL; cur_item = cur_item->next) {
1845 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1846 (M_UNLOCKED & state) != 0);
1849 main_window_menu_callback_block(mainwin);
1851 #define SET_CHECK_MENU_ACTIVE(path, active) \
1853 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1854 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1857 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1858 messageview_is_visible(mainwin->messageview));
1860 summaryview = mainwin->summaryview;
1861 menu_path = "/View/Sort/Don't sort";
1863 switch (summaryview->sort_key) {
1864 case SORT_BY_NUMBER:
1865 menu_path = "/View/Sort/by number"; break;
1867 menu_path = "/View/Sort/by size"; break;
1869 menu_path = "/View/Sort/by date"; break;
1871 menu_path = "/View/Sort/by from"; break;
1873 menu_path = "/View/Sort/by recipient"; break;
1874 case SORT_BY_SUBJECT:
1875 menu_path = "/View/Sort/by subject"; break;
1877 menu_path = "/View/Sort/by color label"; break;
1879 menu_path = "/View/Sort/by mark"; break;
1880 case SORT_BY_STATUS:
1881 menu_path = "/View/Sort/by status"; break;
1883 menu_path = "/View/Sort/by attachment"; break;
1885 menu_path = "/View/Sort/by score"; break;
1886 case SORT_BY_LOCKED:
1887 menu_path = "/View/Sort/by locked"; break;
1890 menu_path = "/View/Sort/Don't sort"; break;
1892 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1894 if (summaryview->sort_type == SORT_ASCENDING) {
1895 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1897 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1900 if (summaryview->sort_key != SORT_BY_NONE) {
1901 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1902 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1904 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1905 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1908 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1909 mainwin->messageview->mimeview->textview->show_all_headers);
1910 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1912 #undef SET_CHECK_MENU_ACTIVE
1914 main_window_menu_callback_unblock(mainwin);
1917 void main_window_popup(MainWindow *mainwin)
1919 gtkut_window_popup(mainwin->window);
1921 switch (mainwin->type) {
1922 case SEPARATE_FOLDER:
1923 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1925 case SEPARATE_MESSAGE:
1926 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1929 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1930 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1937 void main_window_show(MainWindow *mainwin)
1939 gtk_widget_show(mainwin->window);
1940 gtk_widget_show(mainwin->vbox_body);
1942 gtk_widget_set_uposition(mainwin->window,
1943 prefs_common.mainwin_x,
1944 prefs_common.mainwin_y);
1946 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1947 prefs_common.folderview_width,
1948 prefs_common.folderview_height);
1949 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1950 prefs_common.summaryview_width,
1951 prefs_common.summaryview_height);
1952 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1953 prefs_common.msgview_width,
1954 prefs_common.msgview_height);
1956 if (mainwin->type & SEPARATE_FOLDER) {
1957 GtkWidget *folderwin;
1959 folderwin = main_window_get_folder_window(mainwin);
1960 gtk_widget_show(folderwin);
1961 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1962 prefs_common.folderwin_y);
1965 if (mainwin->type & SEPARATE_MESSAGE) {
1966 GtkWidget *messagewin;
1968 messagewin = main_window_get_message_window(mainwin);
1969 gtk_widget_show(messagewin);
1970 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1971 prefs_common.main_msgwin_y);
1975 void main_window_hide(MainWindow *mainwin)
1977 main_window_get_size(mainwin);
1978 main_window_get_position(mainwin);
1980 gtk_widget_hide(mainwin->window);
1981 gtk_widget_hide(mainwin->vbox_body);
1983 if (mainwin->type & SEPARATE_FOLDER) {
1984 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1987 if (mainwin->type & SEPARATE_MESSAGE) {
1988 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1992 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1994 GtkWidget *folderwin = NULL;
1995 GtkWidget *messagewin = NULL;
1998 GtkWidget *vbox_body = mainwin->vbox_body;
1999 GtkItemFactory *ifactory = mainwin->menu_factory;
2000 GtkWidget *menuitem;
2001 GtkItemFactory *msgview_ifactory;
2003 debug_print("Setting widgets... ");
2005 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2006 prefs_common.folderview_width,
2007 prefs_common.folderview_height);
2008 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2009 prefs_common.summaryview_width,
2010 prefs_common.summaryview_height);
2011 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2012 prefs_common.msgview_width,
2013 prefs_common.msgview_height);
2015 /* create separated window(s) if needed */
2016 if (type & SEPARATE_FOLDER) {
2017 static GdkGeometry folderwin_geometry;
2019 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2020 gtk_window_set_title(GTK_WINDOW(folderwin),
2021 _("Sylpheed - Folder View"));
2023 gtk_window_move(GTK_WINDOW(folderwin),
2024 prefs_common.folderwin_x,
2025 prefs_common.folderwin_y);
2027 if (!folderwin_geometry.min_height) {
2028 folderwin_geometry.min_width = 320;
2029 folderwin_geometry.min_height = 200;
2031 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2032 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2034 gtk_widget_set_size_request(folderwin,
2035 prefs_common.folderview_width,
2036 prefs_common.folderview_height);
2038 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2041 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2042 G_CALLBACK(folder_window_close_cb),
2044 gtk_container_add(GTK_CONTAINER(folderwin),
2045 GTK_WIDGET_PTR(mainwin->folderview));
2046 gtk_widget_realize(folderwin);
2048 if (prefs_common.folderview_visible)
2049 gtk_widget_show(folderwin);
2052 if (type & SEPARATE_MESSAGE) {
2053 static GdkGeometry msgwin_geometry;
2055 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2056 gtk_window_set_title(GTK_WINDOW(messagewin),
2057 _("Sylpheed - Message View"));
2059 gtk_window_move(GTK_WINDOW(messagewin),
2060 prefs_common.main_msgwin_x,
2061 prefs_common.main_msgwin_y);
2063 if (!msgwin_geometry.min_height) {
2064 msgwin_geometry.min_width = 320;
2065 msgwin_geometry.min_height = 200;
2067 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2068 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2070 gtk_widget_set_size_request(messagewin,
2071 prefs_common.msgwin_width,
2072 prefs_common.msgwin_height);
2074 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2076 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2077 G_CALLBACK(message_window_close_cb),
2079 if (messageview_is_visible(mainwin->messageview))
2080 gtk_widget_show(messagewin);
2082 mainwin->messageview->statusbar = mainwin->statusbar;
2083 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2088 hpaned = gtk_hpaned_new();
2089 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2090 gtk_paned_add1(GTK_PANED(hpaned),
2091 GTK_WIDGET_PTR(mainwin->folderview));
2092 gtk_widget_show(hpaned);
2093 gtk_widget_queue_resize(hpaned);
2095 vpaned = gtk_vpaned_new();
2096 if (messageview_is_visible(mainwin->messageview)) {
2097 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2098 gtk_paned_add1(GTK_PANED(vpaned),
2099 GTK_WIDGET_PTR(mainwin->summaryview));
2101 gtk_paned_add2(GTK_PANED(hpaned),
2102 GTK_WIDGET_PTR(mainwin->summaryview));
2103 gtk_widget_ref(vpaned);
2105 gtk_paned_add2(GTK_PANED(vpaned),
2106 GTK_WIDGET_PTR(mainwin->messageview));
2107 gtk_widget_show(vpaned);
2108 gtk_widget_queue_resize(vpaned);
2110 mainwin->win.sep_none.hpaned = hpaned;
2111 mainwin->win.sep_none.vpaned = vpaned;
2113 /* remove headerview if not in prefs */
2114 headerview_set_visibility(mainwin->messageview->headerview,
2115 prefs_common.display_header_pane);
2117 case SEPARATE_FOLDER:
2118 vpaned = gtk_vpaned_new();
2119 if (messageview_is_visible(mainwin->messageview)) {
2120 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2122 gtk_paned_add1(GTK_PANED(vpaned),
2123 GTK_WIDGET_PTR(mainwin->summaryview));
2125 gtk_box_pack_start(GTK_BOX(vbox_body),
2126 GTK_WIDGET_PTR(mainwin->summaryview),
2128 gtk_widget_ref(vpaned);
2130 gtk_paned_add2(GTK_PANED(vpaned),
2131 GTK_WIDGET_PTR(mainwin->messageview));
2132 gtk_widget_show(vpaned);
2133 gtk_widget_queue_resize(vpaned);
2135 mainwin->win.sep_folder.folderwin = folderwin;
2136 mainwin->win.sep_folder.vpaned = vpaned;
2138 /* remove headerview if not in prefs */
2139 headerview_set_visibility(mainwin->messageview->headerview,
2140 prefs_common.display_header_pane);
2143 case SEPARATE_MESSAGE:
2144 hpaned = gtk_hpaned_new();
2145 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2146 gtk_paned_add1(GTK_PANED(hpaned),
2147 GTK_WIDGET_PTR(mainwin->folderview));
2148 gtk_paned_add2(GTK_PANED(hpaned),
2149 GTK_WIDGET_PTR(mainwin->summaryview));
2150 gtk_widget_show(hpaned);
2151 gtk_widget_queue_resize(hpaned);
2152 messageview_add_toolbar(mainwin->messageview, messagewin);
2153 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2154 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2156 mainwin->win.sep_message.messagewin = messagewin;
2157 mainwin->win.sep_message.hpaned = hpaned;
2159 gtk_widget_realize(messagewin);
2160 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2161 gtk_widget_show_all(messagewin);
2162 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2163 mainwin->messageview->handlebox,
2164 prefs_common.toolbar_style);
2168 messageview_add_toolbar(mainwin->messageview, messagewin);
2169 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2170 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2172 gtk_box_pack_start(GTK_BOX(vbox_body),
2173 GTK_WIDGET_PTR(mainwin->summaryview),
2176 mainwin->win.sep_both.folderwin = folderwin;
2177 mainwin->win.sep_both.messagewin = messagewin;
2179 gtk_widget_realize(messagewin);
2180 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2181 gtk_widget_show_all(messagewin);
2182 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2183 mainwin->messageview->handlebox,
2184 prefs_common.toolbar_style);
2189 if (messageview_is_visible(mainwin->messageview))
2190 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2191 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2193 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2194 GTK_ARROW_UP, GTK_SHADOW_OUT);
2196 gtk_window_move(GTK_WINDOW(mainwin->window),
2197 prefs_common.mainwin_x,
2198 prefs_common.mainwin_y);
2200 gtk_widget_queue_resize(vbox_body);
2201 gtk_widget_queue_resize(mainwin->vbox);
2202 gtk_widget_queue_resize(mainwin->window);
2203 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2204 * and mimeview icon list/ctree lose track of their visibility states */
2205 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2206 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2207 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2208 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2209 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2210 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2212 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2214 mainwin->type = type;
2217 /* toggle menu state */
2218 menuitem = gtk_item_factory_get_item
2219 (ifactory, "/View/Show or hide/Folder tree");
2220 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2221 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2222 prefs_common.folderview_visible);
2223 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2224 menuitem = gtk_item_factory_get_item
2225 (ifactory, "/View/Show or hide/Message view");
2226 gtk_check_menu_item_set_active
2227 (GTK_CHECK_MENU_ITEM(menuitem),
2228 messageview_is_visible(mainwin->messageview));
2230 menuitem = gtk_item_factory_get_item
2231 (ifactory, "/View/Separate folder tree");
2232 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2233 ((type & SEPARATE_FOLDER) != 0));
2234 menuitem = gtk_item_factory_get_item
2235 (ifactory, "/View/Separate message view");
2236 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2237 ((type & SEPARATE_MESSAGE) != 0));
2241 (G_OBJECT(folderwin), "size_allocate",
2242 G_CALLBACK(folder_window_size_allocate_cb),
2247 (G_OBJECT(messagewin), "size_allocate",
2248 G_CALLBACK(message_window_size_allocate_cb),
2252 debug_print("done.\n");
2255 void main_window_destroy_all(void)
2257 while (mainwin_list != NULL) {
2258 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2260 /* free toolbar stuff */
2261 toolbar_clear_list(TOOLBAR_MAIN);
2262 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2263 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2265 g_free(mainwin->toolbar);
2268 mainwin_list = g_list_remove(mainwin_list, mainwin);
2270 g_list_free(mainwin_list);
2274 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2275 GdkEventButton *event,
2278 MainWindow *mainwin = (MainWindow *)data;
2280 if (!event) return FALSE;
2281 if (event->button != 3) return FALSE;
2283 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2284 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2287 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2288 menu_button_position, widget,
2289 event->button, event->time);
2295 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2298 gtk_widget_set_size_request(child, 1, -1);
2301 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2304 gtk_widget_set_size_request(child, -1, -1);
2307 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2310 MainWindow *mainwin = (MainWindow *)data;
2312 if (!event) return FALSE;
2314 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2315 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2318 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2319 menu_button_position, widget,
2320 event->button, event->time);
2325 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2327 MainWindow *mainwin = (MainWindow *)data;
2330 button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2331 if (!button) return;
2332 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2333 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2334 manage_window_focus_in(mainwin->window, NULL, NULL);
2337 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2340 MainWindow *mainwin = (MainWindow *)data;
2342 if (mainwin->lock_count == 0)
2343 app_exit_cb(data, 0, widget);
2348 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2351 MainWindow *mainwin = (MainWindow *)data;
2352 GtkWidget *menuitem;
2354 menuitem = gtk_item_factory_get_item
2355 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2356 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2361 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2364 MainWindow *mainwin = (MainWindow *)data;
2365 GtkWidget *menuitem;
2367 menuitem = gtk_item_factory_get_item
2368 (mainwin->menu_factory, "/View/Show or hide/Message view");
2369 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2371 mainwin->messageview->statusbar = mainwin->statusbar;
2372 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2377 static void main_window_size_allocate_cb(GtkWidget *widget,
2378 GtkAllocation *allocation,
2381 MainWindow *mainwin = (MainWindow *)data;
2383 main_window_get_size(mainwin);
2386 static void folder_window_size_allocate_cb(GtkWidget *widget,
2387 GtkAllocation *allocation,
2390 MainWindow *mainwin = (MainWindow *)data;
2392 main_window_get_size(mainwin);
2395 static void message_window_size_allocate_cb(GtkWidget *widget,
2396 GtkAllocation *allocation,
2399 MainWindow *mainwin = (MainWindow *)data;
2401 main_window_get_size(mainwin);
2404 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2407 main_window_add_mailbox(mainwin);
2410 static void update_folderview_cb(MainWindow *mainwin, guint action,
2413 summary_show(mainwin->summaryview, NULL);
2414 folderview_check_new_all();
2417 static void foldersort_cb(MainWindow *mainwin, guint action,
2423 static void import_mbox_cb(MainWindow *mainwin, guint action,
2426 import_mbox(mainwin->summaryview->folder_item);
2429 static void export_mbox_cb(MainWindow *mainwin, guint action,
2432 export_mbox(mainwin->summaryview->folder_item);
2435 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2438 summaryview_export_mbox_list(mainwin->summaryview);
2441 static void empty_trash_cb(MainWindow *mainwin, guint action,
2444 main_window_empty_trash(mainwin, TRUE);
2447 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2449 summary_save_as(mainwin->summaryview);
2452 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2454 summary_print(mainwin->summaryview);
2457 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2459 if (prefs_common.confirm_on_exit) {
2460 if (alertpanel(_("Exit"), _("Exit this program?"),
2461 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
2464 manage_window_focus_in(mainwin->window, NULL, NULL);
2467 app_will_exit(widget, mainwin);
2470 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2473 summary_search(mainwin->summaryview);
2475 message_search(mainwin->messageview);
2478 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2483 active = GTK_CHECK_MENU_ITEM(widget)->active;
2485 switch (mainwin->type) {
2487 case SEPARATE_MESSAGE:
2490 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2492 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2495 case SEPARATE_FOLDER:
2496 debug_print("separate folder\n");
2498 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2500 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2504 gtk_widget_show(mainwin->win.sep_both.folderwin);
2506 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2510 prefs_common.folderview_visible = active;
2513 static void toggle_message_cb(MainWindow *mainwin, guint action,
2518 active = GTK_CHECK_MENU_ITEM(widget)->active;
2520 if (active != messageview_is_visible(mainwin->messageview))
2521 summary_toggle_view(mainwin->summaryview);
2524 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2527 toolbar_toggle(action, mainwin);
2530 void main_window_reply_cb(MainWindow *mainwin, guint action,
2533 MessageView *msgview = (MessageView*)mainwin->messageview;
2534 GSList *msginfo_list = NULL;
2536 g_return_if_fail(msgview != NULL);
2538 msginfo_list = summary_get_selection(mainwin->summaryview);
2539 g_return_if_fail(msginfo_list != NULL);
2540 compose_reply_from_messageview(msgview, msginfo_list, action);
2541 g_slist_free(msginfo_list);
2545 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2548 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2549 gtk_widget_show(mainwin->hbox_stat);
2550 prefs_common.show_statusbar = TRUE;
2552 gtk_widget_hide(mainwin->hbox_stat);
2553 prefs_common.show_statusbar = FALSE;
2557 static void separate_widget_cb(MainWindow *mainwin, guint action,
2562 if (GTK_CHECK_MENU_ITEM(widget)->active)
2563 type = mainwin->type | action;
2565 type = mainwin->type & ~action;
2567 main_window_separation_change(mainwin, type);
2569 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2570 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2573 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2576 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2578 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2581 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2583 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2586 static void online_switch_clicked (GtkButton *btn, gpointer data)
2588 MainWindow *mainwin;
2589 GtkItemFactory *ifactory;
2590 GtkCheckMenuItem *menuitem;
2592 mainwin = (MainWindow *) data;
2594 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2595 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2597 g_return_if_fail(mainwin != NULL);
2598 g_return_if_fail(menuitem != NULL);
2600 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2602 gtk_widget_hide (mainwin->online_switch);
2603 gtk_widget_show (mainwin->offline_switch);
2604 menuitem->active = TRUE;
2605 prefs_common.work_offline = TRUE;
2606 inc_autocheck_timer_remove();
2609 gtk_widget_hide (mainwin->offline_switch);
2610 gtk_widget_show (mainwin->online_switch);
2611 menuitem->active = FALSE;
2612 prefs_common.work_offline = FALSE;
2613 inc_autocheck_timer_set();
2617 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2620 addressbook_open(NULL);
2623 static void log_window_show_cb(MainWindow *mainwin, guint action,
2626 log_window_show(mainwin->logwin);
2629 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2634 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2636 summary_move_to(mainwin->summaryview);
2639 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2641 summary_copy_to(mainwin->summaryview);
2644 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2646 summary_delete(mainwin->summaryview);
2649 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2651 summary_cancel(mainwin->summaryview);
2654 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2656 summary_open_msg(mainwin->summaryview);
2659 static void view_source_cb(MainWindow *mainwin, guint action,
2662 summary_view_source(mainwin->summaryview);
2665 static void show_all_header_cb(MainWindow *mainwin, guint action,
2668 if (mainwin->menu_lock_count) return;
2669 mainwin->summaryview->messageview->all_headers =
2670 GTK_CHECK_MENU_ITEM(widget)->active;
2671 summary_display_msg_selected(mainwin->summaryview,
2672 GTK_CHECK_MENU_ITEM(widget)->active);
2675 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2677 summary_mark(mainwin->summaryview);
2680 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2682 summary_unmark(mainwin->summaryview);
2685 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2688 summary_mark_as_unread(mainwin->summaryview);
2691 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2694 summary_mark_as_read(mainwin->summaryview);
2697 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2700 summary_mark_all_read(mainwin->summaryview);
2703 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2705 summary_reedit(mainwin->summaryview);
2708 static void add_address_cb(MainWindow *mainwin, guint action,
2711 summary_add_address(mainwin->summaryview);
2714 static void set_charset_cb(MainWindow *mainwin, guint action,
2719 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2720 str = conv_get_charset_str((CharSet)action);
2722 g_free(mainwin->messageview->forced_charset);
2723 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2724 procmime_force_charset(str);
2726 summary_redisplay_msg(mainwin->summaryview);
2728 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2732 static void set_decode_cb(MainWindow *mainwin, guint action,
2735 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2736 mainwin->messageview->forced_encoding = (EncodingType)action;
2738 summary_redisplay_msg(mainwin->summaryview);
2740 debug_print("forced encoding: %d\n", action);
2744 static void hide_read_messages (MainWindow *mainwin, guint action,
2747 if (!mainwin->summaryview->folder_item
2748 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2750 summary_toggle_show_read_messages(mainwin->summaryview);
2753 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2755 if (mainwin->menu_lock_count) return;
2756 if (!mainwin->summaryview->folder_item) return;
2758 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2759 summary_thread_build(mainwin->summaryview);
2760 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2762 summary_unthread(mainwin->summaryview);
2763 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2767 static void expand_threads_cb(MainWindow *mainwin, guint action,
2770 summary_expand_threads(mainwin->summaryview);
2773 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2776 summary_collapse_threads(mainwin->summaryview);
2779 static void set_display_item_cb(MainWindow *mainwin, guint action,
2782 prefs_summary_column_open();
2785 static void sort_summary_cb(MainWindow *mainwin, guint action,
2788 FolderItem *item = mainwin->summaryview->folder_item;
2789 GtkWidget *menuitem;
2791 if (mainwin->menu_lock_count) return;
2793 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2794 menuitem = gtk_item_factory_get_item
2795 (mainwin->menu_factory, "/View/Sort/Ascending");
2796 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2797 GTK_CHECK_MENU_ITEM(menuitem)->active
2798 ? SORT_ASCENDING : SORT_DESCENDING);
2799 item->sort_key = action;
2803 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2806 FolderItem *item = mainwin->summaryview->folder_item;
2808 if (mainwin->menu_lock_count) return;
2810 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2811 summary_sort(mainwin->summaryview,
2812 item->sort_key, (FolderSortType)action);
2815 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2818 summary_attract_by_subject(mainwin->summaryview);
2821 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2826 item = folderview_get_selected_item(mainwin->folderview);
2828 main_window_cursor_wait(mainwin);
2829 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2831 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2832 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2834 STATUSBAR_POP(mainwin);
2835 main_window_cursor_normal(mainwin);
2845 static void deldup_all(FolderItem *item, gpointer _data)
2847 struct DelDupsData *data = _data;
2850 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2852 data->dups += result;
2857 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2860 struct DelDupsData data = {0, 0};
2862 folder_func_to_all_folders(deldup_all, &data);
2863 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
2864 "Deleted %d duplicate messages in %d folders.\n",
2866 data.dups, data.folders);
2869 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2871 summary_filter(mainwin->summaryview, (gboolean)action);
2874 static void execute_summary_cb(MainWindow *mainwin, guint action,
2877 summary_execute(mainwin->summaryview);
2880 static void update_summary_cb(MainWindow *mainwin, guint action,
2884 FolderView *folderview = mainwin->folderview;
2886 if (!mainwin->summaryview->folder_item) return;
2887 if (!folderview->opened) return;
2889 folder_update_op_count();
2891 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2892 folderview->opened);
2895 folder_item_scan(fitem);
2896 summary_show(mainwin->summaryview, fitem);
2899 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2901 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2904 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2906 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2909 static void prev_unread_cb(MainWindow *mainwin, guint action,
2912 summary_select_prev_unread(mainwin->summaryview);
2915 static void next_unread_cb(MainWindow *mainwin, guint action,
2918 summary_select_next_unread(mainwin->summaryview);
2921 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2923 summary_select_prev_new(mainwin->summaryview);
2926 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2928 summary_select_next_new(mainwin->summaryview);
2931 static void prev_marked_cb(MainWindow *mainwin, guint action,
2934 summary_select_prev_marked(mainwin->summaryview);
2937 static void next_marked_cb(MainWindow *mainwin, guint action,
2940 summary_select_next_marked(mainwin->summaryview);
2943 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2946 summary_select_prev_labeled(mainwin->summaryview);
2949 static void next_labeled_cb(MainWindow *mainwin, guint action,
2952 summary_select_next_labeled(mainwin->summaryview);
2955 static void goto_folder_cb(MainWindow *mainwin, guint action,
2958 FolderItem *to_folder;
2960 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2963 folderview_select(mainwin->folderview, to_folder);
2966 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2968 messageview_copy_clipboard(mainwin->messageview);
2971 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2973 MessageView *msgview = mainwin->messageview;
2975 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2976 summary_select_all(mainwin->summaryview);
2977 else if (messageview_is_visible(msgview) &&
2978 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2979 messageview_select_all(mainwin->messageview);
2982 static void select_thread_cb(MainWindow *mainwin, guint action,
2985 summary_select_thread(mainwin->summaryview);
2988 static void create_filter_cb(MainWindow *mainwin, guint action,
2991 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2994 static void create_processing_cb(MainWindow *mainwin, guint action,
2997 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3000 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3003 prefs_filtering_open(&pre_global_processing,
3004 _("Processing rules to apply before folder rules"),
3008 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3011 prefs_filtering_open(&post_global_processing,
3012 _("Processing rules to apply after folder rules"),
3016 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3019 prefs_filtering_open(&filtering_rules,
3020 _("Filtering configuration"),
3024 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3027 prefs_template_open();
3030 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3033 prefs_actions_open(mainwin);
3036 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3039 ssl_manager_open(mainwin);
3042 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3046 new_account_cb(mainwin, 0, widget);
3048 account_open(cur_account);
3052 static void new_account_cb(MainWindow *mainwin, guint action,
3055 account_edit_open();
3056 if (!compose_get_compose_list()) account_add();
3059 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3061 cur_account = (PrefsAccount *)data;
3062 main_window_reflect_prefs_all();
3065 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3067 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3068 PrefsAccount *account = (PrefsAccount *)data;
3070 inc_account_mail(mainwin, account);
3073 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3078 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3080 pluginwindow_create();
3083 static void manual_open_cb(MainWindow *mainwin, guint action,
3086 manual_open((ManualType)action);
3089 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3091 MainWindow *mainwin = (MainWindow *)data;
3095 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3096 LOCAL_FOLDER(folder)->rootpath,
3100 str = g_strdup_printf(_("Scanning folder %s ..."),
3101 LOCAL_FOLDER(folder)->rootpath);
3103 STATUSBAR_PUSH(mainwin, str);
3104 STATUSBAR_POP(mainwin);
3108 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3111 SummaryView *summary;
3113 g_return_val_if_fail(data, FALSE);
3114 summary = ((MainWindow *)data)->summaryview;
3115 g_return_val_if_fail(summary, FALSE);
3117 if (GTK_CLIST(summary->ctree)->selection &&
3118 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3121 if (summary->selected != summary->displayed)
3122 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3126 #define BREAK_ON_MODIFIER_KEY() \
3127 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3129 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3132 MainWindow *mainwin = (MainWindow*) data;
3134 if (!mainwin || !event)
3137 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3140 switch (event->keyval) {
3141 case GDK_Q: /* Quit */
3142 BREAK_ON_MODIFIER_KEY();
3144 app_exit_cb(mainwin, 0, NULL);
3147 if (mainwin->folderview && mainwin->summaryview
3148 && !mainwin->summaryview->displayed) {
3149 summary_lock(mainwin->summaryview);
3150 folderview_select_next_unread(mainwin->folderview);
3151 summary_unlock(mainwin->summaryview);
3160 #undef BREAK_ON_MODIFIER_KEY
3163 * Harvest addresses for selected folder.
3165 static void addr_harvest_cb( MainWindow *mainwin,
3169 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3173 * Harvest addresses for selected messages in summary view.
3175 static void addr_harvest_msg_cb( MainWindow *mainwin,
3179 summary_harvest_address( mainwin->summaryview );
3183 *\brief get a MainWindow
3185 *\return MainWindow * The first mainwindow in the mainwin_list
3187 MainWindow *mainwindow_get_mainwindow(void)
3189 if (mainwin_list && mainwin_list->data)
3190 return (MainWindow *)(mainwin_list->data);
3195 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3197 ProgressData *data = (ProgressData *) source;
3198 MainWindow *mainwin = (MainWindow *) userdata;
3200 switch (data->cmd) {
3201 case PROGRESS_COMMAND_START:
3202 case PROGRESS_COMMAND_STOP:
3203 gtk_progress_bar_set_fraction
3204 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3206 case PROGRESS_COMMAND_SET_PERCENTAGE:
3207 gtk_progress_bar_set_fraction
3208 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3211 while (gtk_events_pending()) gtk_main_iteration ();