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_folder_column.h"
69 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "ssl_manager.h"
85 #include "sslcertwindow.h"
86 #include "prefs_gtk.h"
87 #include "pluginwindow.h"
89 #include "progressindicator.h"
90 #include "localfolder.h"
91 #include "filtering.h"
92 #include "folderutils.h"
93 #include "foldersort.h"
95 #define AC_LABEL_WIDTH 240
97 /* list of all instantiated MainWindow */
98 static GList *mainwin_list = NULL;
100 static GdkCursor *watch_cursor;
102 static void main_window_menu_callback_block (MainWindow *mainwin);
103 static void main_window_menu_callback_unblock (MainWindow *mainwin);
105 static void main_window_show_cur_account (MainWindow *mainwin);
107 static void main_window_set_widgets (MainWindow *mainwin,
111 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
112 GdkEventButton *event,
116 static void toolbar_child_attached (GtkWidget *widget,
119 static void toolbar_child_detached (GtkWidget *widget,
123 static gboolean ac_label_button_pressed (GtkWidget *widget,
124 GdkEventButton *event,
127 static gint main_window_close_cb (GtkWidget *widget,
130 static gint folder_window_close_cb (GtkWidget *widget,
133 static gint message_window_close_cb (GtkWidget *widget,
137 static void main_window_size_allocate_cb (GtkWidget *widget,
138 GtkAllocation *allocation,
140 static void folder_window_size_allocate_cb (GtkWidget *widget,
141 GtkAllocation *allocation,
143 static void message_window_size_allocate_cb (GtkWidget *widget,
144 GtkAllocation *allocation,
147 static void update_folderview_cb (MainWindow *mainwin,
150 static void add_mailbox_cb (MainWindow *mainwin,
153 static void foldersort_cb (MainWindow *mainwin,
156 static void import_mbox_cb (MainWindow *mainwin,
159 static void export_mbox_cb (MainWindow *mainwin,
162 static void export_list_mbox_cb (MainWindow *mainwin,
165 static void empty_trash_cb (MainWindow *mainwin,
169 static void save_as_cb (MainWindow *mainwin,
172 static void print_cb (MainWindow *mainwin,
175 static void app_exit_cb (MainWindow *mainwin,
179 static void search_cb (MainWindow *mainwin,
183 static void toggle_folder_cb (MainWindow *mainwin,
186 static void toggle_message_cb (MainWindow *mainwin,
189 static void toggle_toolbar_cb (MainWindow *mainwin,
192 static void toggle_statusbar_cb (MainWindow *mainwin,
195 static void separate_widget_cb (MainWindow *mainwin,
199 static void addressbook_open_cb (MainWindow *mainwin,
202 static void log_window_show_cb (MainWindow *mainwin,
206 static void inc_cancel_cb (MainWindow *mainwin,
210 static void open_msg_cb (MainWindow *mainwin,
214 static void view_source_cb (MainWindow *mainwin,
218 static void show_all_header_cb (MainWindow *mainwin,
222 static void move_to_cb (MainWindow *mainwin,
225 static void copy_to_cb (MainWindow *mainwin,
228 static void delete_cb (MainWindow *mainwin,
231 static void delete_trash_cb (MainWindow *mainwin,
235 static void cancel_cb (MainWindow *mainwin,
239 static void mark_cb (MainWindow *mainwin,
242 static void unmark_cb (MainWindow *mainwin,
246 static void mark_as_unread_cb (MainWindow *mainwin,
249 static void mark_as_read_cb (MainWindow *mainwin,
252 static void mark_all_read_cb (MainWindow *mainwin,
256 static void reedit_cb (MainWindow *mainwin,
260 static void add_address_cb (MainWindow *mainwin,
264 static void set_charset_cb (MainWindow *mainwin,
268 static void set_decode_cb (MainWindow *mainwin,
272 static void hide_read_messages (MainWindow *mainwin,
276 static void thread_cb (MainWindow *mainwin,
279 static void expand_threads_cb (MainWindow *mainwin,
282 static void collapse_threads_cb (MainWindow *mainwin,
286 static void set_summary_display_item_cb (MainWindow *mainwin,
289 static void set_folder_display_item_cb (MainWindow *mainwin,
292 static void sort_summary_cb (MainWindow *mainwin,
295 static void sort_summary_type_cb (MainWindow *mainwin,
298 static void attract_by_subject_cb(MainWindow *mainwin,
302 static void delete_duplicated_cb (MainWindow *mainwin,
305 static void delete_duplicated_all_cb (MainWindow *mainwin,
308 static void filter_cb (MainWindow *mainwin,
311 static void execute_summary_cb (MainWindow *mainwin,
314 static void update_summary_cb (MainWindow *mainwin,
318 static void prev_cb (MainWindow *mainwin,
321 static void next_cb (MainWindow *mainwin,
324 static void next_unread_cb (MainWindow *mainwin,
327 static void prev_unread_cb (MainWindow *mainwin,
331 static void prev_new_cb (MainWindow *mainwin,
334 static void next_new_cb (MainWindow *mainwin,
337 static void prev_marked_cb (MainWindow *mainwin,
340 static void next_marked_cb (MainWindow *mainwin,
343 static void prev_labeled_cb (MainWindow *mainwin,
346 static void next_labeled_cb (MainWindow *mainwin,
350 static void goto_folder_cb (MainWindow *mainwin,
354 static void copy_cb (MainWindow *mainwin,
357 static void allsel_cb (MainWindow *mainwin,
360 static void select_thread_cb (MainWindow *mainwin,
364 static void create_filter_cb (MainWindow *mainwin,
367 static void create_processing_cb (MainWindow *mainwin,
371 static void prefs_template_open_cb (MainWindow *mainwin,
374 static void prefs_actions_open_cb (MainWindow *mainwin,
377 static void prefs_account_open_cb (MainWindow *mainwin,
381 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
385 static void prefs_post_processing_open_cb (MainWindow *mainwin,
389 static void prefs_filtering_open_cb (MainWindow *mainwin,
393 static void ssl_manager_open_cb (MainWindow *mainwin,
397 static void new_account_cb (MainWindow *mainwin,
401 static void account_selector_menu_cb (GtkMenuItem *menuitem,
403 static void account_receive_menu_cb (GtkMenuItem *menuitem,
406 static void prefs_open_cb (GtkMenuItem *menuitem,
408 static void plugins_open_cb (GtkMenuItem *menuitem,
411 static void online_switch_clicked(GtkButton *btn,
414 static void manual_open_cb (MainWindow *mainwin,
418 static void scan_tree_func (Folder *folder,
422 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
424 static void addr_harvest_cb ( MainWindow *mainwin,
428 static void addr_harvest_msg_cb ( MainWindow *mainwin,
432 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
433 GdkEventFocus *focus,
435 void main_window_reply_cb (MainWindow *mainwin,
438 gboolean mainwindow_progressindicator_hook (gpointer source,
440 #define SEPARATE_ACTION 500
441 static void mainwindow_quicksearch (MainWindow *mainwin,
445 static GtkItemFactoryEntry mainwin_entries[] =
447 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
448 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
449 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
450 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
451 {N_("/_File/Change folder order"), NULL, foldersort_cb, 0, NULL},
452 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
453 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
454 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
455 {N_("/_File/Exp_ort selected to mbox file..."),
456 NULL, export_list_mbox_cb, 0, NULL},
457 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
459 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
460 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
461 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
462 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
463 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
464 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
465 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
466 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
468 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
469 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
470 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
471 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
472 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
473 {N_("/_Edit/_Find in current message..."),
474 "<control>F", search_cb, 0, NULL},
475 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
476 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
477 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
478 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
479 {N_("/_View/Show or hi_de/_Folder tree"),
480 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
481 {N_("/_View/Show or hi_de/_Message view"),
482 "V", toggle_message_cb, 0, "<ToggleItem>"},
483 {N_("/_View/Show or hi_de/_Toolbar"),
484 NULL, NULL, 0, "<Branch>"},
485 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
486 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
487 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
488 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
489 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
490 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
491 {N_("/_View/Show or hi_de/_Toolbar/_None"),
492 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
493 {N_("/_View/Show or hi_de/Status _bar"),
494 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
495 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
497 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
498 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
501 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
502 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
503 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
504 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
505 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
506 {N_("/_View/_Sort/by _color label"),
507 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
508 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
509 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
510 {N_("/_View/_Sort/by a_ttachment"),
511 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
512 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
513 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
514 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
515 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
517 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
518 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_View/_Sort/_Attract by subject"),
520 NULL, attract_by_subject_cb, 0, NULL},
521 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
522 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
523 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
524 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
525 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
526 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
527 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
529 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
531 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
532 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
533 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_View/_Go to/P_rev unread message"),
535 "<shift>P", prev_unread_cb, 0, NULL},
536 {N_("/_View/_Go to/N_ext unread message"),
537 "<shift>N", next_unread_cb, 0, NULL},
538 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
540 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
541 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
542 {N_("/_View/_Go to/Prev _marked message"),
543 NULL, prev_marked_cb, 0, NULL},
544 {N_("/_View/_Go to/Next m_arked message"),
545 NULL, next_marked_cb, 0, NULL},
546 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
547 {N_("/_View/_Go to/Prev _labeled message"),
548 NULL, prev_labeled_cb, 0, NULL},
549 {N_("/_View/_Go to/Next la_beled message"),
550 NULL, next_labeled_cb, 0, NULL},
551 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
553 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
555 #define ENC_SEPARATOR \
556 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
557 #define ENC_ACTION(action) \
558 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
560 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
561 {N_("/_View/Character _encoding/_Auto detect"),
562 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
563 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
564 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
565 ENC_ACTION(C_US_ASCII)},
566 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
567 ENC_ACTION(C_UTF_8)},
570 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
571 ENC_ACTION(C_ISO_8859_1)},
572 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
573 ENC_ACTION(C_ISO_8859_15)},
576 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
577 ENC_ACTION(C_ISO_8859_2)},
580 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
581 ENC_ACTION(C_ISO_8859_13)},
582 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
583 ENC_ACTION(C_ISO_8859_4)},
586 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
587 ENC_ACTION(C_ISO_8859_7)},
590 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
591 ENC_ACTION(C_ISO_8859_8)},
592 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
593 ENC_ACTION(C_CP1255)},
596 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
597 ENC_ACTION(C_ISO_8859_9)},
600 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
601 ENC_ACTION(C_ISO_8859_5)},
602 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
603 ENC_ACTION(C_KOI8_R)},
604 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
605 ENC_ACTION(C_KOI8_U)},
606 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
607 ENC_ACTION(C_CP1251)},
610 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
611 ENC_ACTION(C_ISO_2022_JP)},
612 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
613 ENC_ACTION(C_ISO_2022_JP_2)},
614 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
615 ENC_ACTION(C_EUC_JP)},
616 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
617 ENC_ACTION(C_SHIFT_JIS)},
620 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
621 ENC_ACTION(C_GB2312)},
622 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
624 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
626 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
627 ENC_ACTION(C_EUC_TW)},
628 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
629 ENC_ACTION(C_ISO_2022_CN)},
632 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
633 ENC_ACTION(C_EUC_KR)},
634 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
635 ENC_ACTION(C_ISO_2022_KR)},
638 {N_("/_View/Character _encoding/Thai (TIS-620)"),
639 ENC_ACTION(C_TIS_620)},
640 {N_("/_View/Character _encoding/Thai (Windows-874)"),
641 ENC_ACTION(C_WINDOWS_874)},
646 #define DEC_SEPARATOR \
647 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
648 #define DEC_ACTION(action) \
649 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
650 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
651 {N_("/_View/Decode/_Auto detect"),
652 NULL, set_decode_cb, 0, "<RadioItem>"},
653 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
655 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
656 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
657 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
662 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
663 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
664 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
665 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
666 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
669 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
671 {N_("/_Message/Recei_ve/Get from _current account"),
672 "<control>I", inc_mail_cb, 0, NULL},
673 {N_("/_Message/Recei_ve/Get from _all accounts"),
674 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
675 {N_("/_Message/Recei_ve/Cancel receivin_g"),
676 NULL, inc_cancel_cb, 0, NULL},
677 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
678 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
679 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
680 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
681 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
682 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
683 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
684 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
685 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
686 {N_("/_Message/Repl_y to/mailing _list"),
687 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
688 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
689 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
691 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
692 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
693 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
694 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
695 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
696 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
697 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
698 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
701 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
702 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
703 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
704 {N_("/_Message/_Mark/Mark as rea_d"),
705 NULL, mark_as_read_cb, 0, NULL},
706 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
707 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
710 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
711 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
712 {N_("/_Tools/Add sender to address boo_k"),
713 NULL, add_address_cb, 0, NULL},
714 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
715 {N_("/_Tools/_Harvest addresses/from _Folder..."),
716 NULL, addr_harvest_cb, 0, NULL},
717 {N_("/_Tools/_Harvest addresses/from _Messages..."),
718 NULL, addr_harvest_msg_cb, 0, NULL},
719 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
720 {N_("/_Tools/_Filter all messages in folder"),
721 NULL, filter_cb, 0, NULL},
722 {N_("/_Tools/Filter _selected messages"),
723 NULL, filter_cb, 1, NULL},
724 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
725 {N_("/_Tools/_Create filter rule/_Automatically"),
726 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
727 {N_("/_Tools/_Create filter rule/by _From"),
728 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
729 {N_("/_Tools/_Create filter rule/by _To"),
730 NULL, create_filter_cb, FILTER_BY_TO, NULL},
731 {N_("/_Tools/_Create filter rule/by _Subject"),
732 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
733 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
734 {N_("/_Tools/C_reate processing rule/_Automatically"),
735 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
736 {N_("/_Tools/C_reate processing rule/by _From"),
737 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
738 {N_("/_Tools/C_reate processing rule/by _To"),
739 NULL, create_processing_cb, FILTER_BY_TO, NULL},
740 {N_("/_Tools/C_reate processing rule/by _Subject"),
741 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
742 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
743 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
744 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
745 {N_("/_Tools/Ch_eck for new messages in all folders"),
746 NULL, update_folderview_cb, 0, NULL},
747 {N_("/_Tools/Delete du_plicated messages"),
748 NULL, NULL, 0, "<Branch>"},
749 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
750 NULL, delete_duplicated_cb, 0, NULL},
751 {N_("/_Tools/Delete du_plicated messages/In all folders"),
752 NULL, delete_duplicated_all_cb, 0, NULL},
753 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
754 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
756 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
757 {N_("/_Tools/SSL cer_tificates..."),
758 NULL, ssl_manager_open_cb, 0, NULL},
760 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
763 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
764 {N_("/_Configuration/C_hange current account"),
765 NULL, NULL, 0, "<Branch>"},
766 {N_("/_Configuration/_Preferences for current account..."),
767 NULL, prefs_account_open_cb, 0, NULL},
768 {N_("/_Configuration/Create _new account..."),
769 NULL, new_account_cb, 0, NULL},
770 {N_("/_Configuration/_Edit accounts..."),
771 NULL, account_edit_open, 0, NULL},
772 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
773 {N_("/_Configuration/P_references..."),
774 NULL, prefs_open_cb, 0, NULL},
775 {N_("/_Configuration/Pre-pr_ocessing..."),
776 NULL, prefs_pre_processing_open_cb, 0, NULL},
777 {N_("/_Configuration/Post-pro_cessing..."),
778 NULL, prefs_post_processing_open_cb, 0, NULL},
779 {N_("/_Configuration/_Filtering..."),
780 NULL, prefs_filtering_open_cb, 0, NULL},
781 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
782 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
783 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
785 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
786 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
787 {N_("/_Help/_FAQ"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
788 {N_("/_Help/_Online User-contributed FAQ"),
789 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
790 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
791 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
794 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
800 MainWindow *mainwin = (MainWindow *)user_data;
802 if (mainwin->summaryview &&
803 mainwin->summaryview->quicksearch &&
804 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
805 (mod == 0 || mod == GDK_SHIFT_MASK)) {
806 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
812 MainWindow *main_window_create(SeparateType type)
818 GtkWidget *handlebox;
819 GtkWidget *vbox_body;
820 GtkWidget *hbox_stat;
821 GtkWidget *statusbar;
822 GtkWidget *progressbar;
823 GtkWidget *statuslabel;
824 GtkWidget *ac_button;
826 GtkWidget *online_pixmap;
827 GtkWidget *offline_pixmap;
828 GtkWidget *online_switch;
829 GtkWidget *offline_switch;
830 GtkTooltips *offline_tip;
831 GtkTooltips *online_tip;
832 GtkTooltips *sel_ac_tip;
834 FolderView *folderview;
835 SummaryView *summaryview;
836 MessageView *messageview;
837 GdkColormap *colormap;
840 GtkItemFactory *ifactory;
844 guint n_menu_entries;
846 static GdkGeometry geometry;
848 debug_print("Creating main window...\n");
849 mainwin = g_new0(MainWindow, 1);
852 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
853 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
854 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
856 if (!geometry.min_height) {
857 geometry.min_width = 320;
858 geometry.min_height = 200;
860 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
863 g_signal_connect(G_OBJECT(window), "delete_event",
864 G_CALLBACK(main_window_close_cb), mainwin);
865 MANAGE_WINDOW_SIGNALS_CONNECT(window);
866 g_signal_connect(G_OBJECT(window), "focus_in_event",
867 G_CALLBACK(mainwindow_focus_in_event),
869 g_signal_connect(G_OBJECT(window), "key_press_event",
870 G_CALLBACK(mainwindow_key_pressed), mainwin);
872 gtk_widget_realize(window);
873 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
876 gtkut_widget_set_app_icon(window);
878 vbox = gtk_vbox_new(FALSE, 0);
879 gtk_widget_show(vbox);
880 gtk_container_add(GTK_CONTAINER(window), vbox);
883 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
884 menubar = menubar_create(window, mainwin_entries,
885 n_menu_entries, "<Main>", mainwin);
886 gtk_widget_show(menubar);
887 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
888 ifactory = gtk_item_factory_from_widget(menubar);
890 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
891 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
893 if (prefs_common.toolbar_detachable) {
894 handlebox = gtk_handle_box_new();
895 gtk_widget_show(handlebox);
896 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
897 g_signal_connect(G_OBJECT(handlebox), "child_attached",
898 G_CALLBACK(toolbar_child_attached), mainwin);
899 g_signal_connect(G_OBJECT(handlebox), "child_detached",
900 G_CALLBACK(toolbar_child_detached), mainwin);
902 handlebox = gtk_hbox_new(FALSE, 0);
903 gtk_widget_show(handlebox);
904 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
906 /* link window to mainwin->window to avoid gdk warnings */
907 mainwin->window = window;
910 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
914 /* vbox that contains body */
915 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
916 gtk_widget_show(vbox_body);
917 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
918 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
920 hbox_stat = gtk_hbox_new(FALSE, 2);
921 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
923 statusbar = statusbar_create();
924 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
926 progressbar = gtk_progress_bar_new();
927 gtk_widget_set_size_request(progressbar, 120, 1);
928 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
930 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
931 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
932 online_tip = gtk_tooltips_new();
933 online_switch = gtk_button_new ();
934 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
935 _("You are online. Click the icon to go offline"), NULL);
936 offline_tip = gtk_tooltips_new();
937 offline_switch = gtk_button_new ();
938 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
939 _("You are offline. Click the icon to go online"),
941 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
942 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
943 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
944 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
945 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
946 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
947 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
948 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
950 statuslabel = gtk_label_new("");
951 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
953 sel_ac_tip = gtk_tooltips_new();
954 ac_button = gtk_button_new();
955 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
956 ac_button, _("Select account"), NULL);
957 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
958 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
959 gtk_widget_set_size_request(ac_button, -1, 0);
960 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
961 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
962 G_CALLBACK(ac_label_button_pressed), mainwin);
964 ac_label = gtk_label_new("");
965 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
967 gtk_widget_show_all(hbox_stat);
969 gtk_widget_hide(offline_switch);
971 mainwin->folderview = folderview = folderview_create();
972 mainwin->summaryview = summaryview = summary_create();
973 mainwin->messageview = messageview = messageview_create(mainwin);
974 mainwin->logwin = log_window_create();
976 folderview->mainwin = mainwin;
977 folderview->summaryview = summaryview;
979 summaryview->mainwin = mainwin;
980 summaryview->folderview = folderview;
981 summaryview->messageview = messageview;
982 summaryview->window = window;
984 messageview->statusbar = statusbar;
985 mainwin->vbox = vbox;
986 mainwin->menubar = menubar;
987 mainwin->menu_factory = ifactory;
988 mainwin->handlebox = handlebox;
989 mainwin->vbox_body = vbox_body;
990 mainwin->hbox_stat = hbox_stat;
991 mainwin->statusbar = statusbar;
992 mainwin->progressbar = progressbar;
993 mainwin->statuslabel = statuslabel;
994 mainwin->online_switch = online_switch;
995 mainwin->online_pixmap = online_pixmap;
996 mainwin->offline_pixmap = offline_pixmap;
997 mainwin->ac_button = ac_button;
998 mainwin->ac_label = ac_label;
999 mainwin->offline_switch = offline_switch;
1001 /* set context IDs for status bar */
1002 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1003 (GTK_STATUSBAR(statusbar), "Main Window");
1004 mainwin->folderview_cid = gtk_statusbar_get_context_id
1005 (GTK_STATUSBAR(statusbar), "Folder View");
1006 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1007 (GTK_STATUSBAR(statusbar), "Summary View");
1008 mainwin->messageview_cid = gtk_statusbar_get_context_id
1009 (GTK_STATUSBAR(statusbar), "Message View");
1011 messageview->statusbar_cid = mainwin->messageview_cid;
1013 /* allocate colors for summary view and folder view */
1014 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1015 summaryview->color_marked.blue = (guint16)65535;
1017 summaryview->color_dim.red = summaryview->color_dim.green =
1018 summaryview->color_dim.blue = COLOR_DIM;
1020 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1021 &folderview->color_new);
1023 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1024 &folderview->color_op);
1026 summaryview->color_important.red = 0;
1027 summaryview->color_important.green = 0;
1028 summaryview->color_important.blue = (guint16)65535;
1030 color[0] = summaryview->color_marked;
1031 color[1] = summaryview->color_dim;
1032 color[2] = folderview->color_new;
1033 color[3] = folderview->color_op;
1035 colormap = gdk_drawable_get_colormap(window->window);
1036 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1037 for (i = 0; i < 4; i++) {
1038 if (success[i] == FALSE)
1039 g_warning("MainWindow: color allocation %d failed\n", i);
1042 debug_print("done.\n");
1044 messageview->visible = prefs_common.msgview_visible;
1046 main_window_set_widgets(mainwin, type);
1048 g_signal_connect(G_OBJECT(window), "size_allocate",
1049 G_CALLBACK(main_window_size_allocate_cb),
1052 /* set menu items */
1053 menuitem = gtk_item_factory_get_item
1054 (ifactory, "/View/Character encoding/Auto detect");
1055 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1057 switch (prefs_common.toolbar_style) {
1059 menuitem = gtk_item_factory_get_item
1060 (ifactory, "/View/Show or hide/Toolbar/None");
1063 menuitem = gtk_item_factory_get_item
1064 (ifactory, "/View/Show or hide/Toolbar/Icon");
1067 menuitem = gtk_item_factory_get_item
1068 (ifactory, "/View/Show or hide/Toolbar/Text");
1071 menuitem = gtk_item_factory_get_item
1072 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1074 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1076 gtk_widget_hide(mainwin->hbox_stat);
1077 menuitem = gtk_item_factory_get_item
1078 (ifactory, "/View/Show or hide/Status bar");
1079 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1080 prefs_common.show_statusbar);
1082 /* set account selection menu */
1083 ac_menu = gtk_item_factory_get_widget
1084 (ifactory, "/Configuration/Change current account");
1085 mainwin->ac_menu = ac_menu;
1087 toolbar_main_set_sensitive(mainwin);
1089 /* create actions menu */
1090 main_window_update_actions_menu(mainwin);
1092 /* attach accel groups to main window */
1093 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1094 gtk_window_add_accel_group \
1096 gtk_item_factory_from_widget(menu)->accel_group); \
1097 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1099 G_CALLBACK(main_window_accel_activate), mainwin);
1102 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1104 /* connect the accelerators for equivalent
1105 menu items in different menus */
1106 menu_connect_identical_items();
1110 /* show main window */
1111 gtk_widget_show(mainwin->window);
1113 /* initialize views */
1114 folderview_init(folderview);
1115 summary_init(summaryview);
1116 messageview_init(messageview);
1117 log_window_init(mainwin->logwin);
1118 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1119 prefs_common.loglength);
1121 sslcertwindow_register_hook();
1123 mainwin->lock_count = 0;
1124 mainwin->menu_lock_count = 0;
1125 mainwin->cursor_count = 0;
1127 mainwin->progressindicator_hook =
1128 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1131 watch_cursor = gdk_cursor_new(GDK_WATCH);
1133 mainwin_list = g_list_append(mainwin_list, mainwin);
1135 /* init work_offline */
1136 if (prefs_common.work_offline)
1137 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1142 void main_window_destroy(MainWindow *mainwin)
1144 /* TODO : destroy other component */
1145 messageview_destroy(mainwin->messageview);
1146 mainwin->messageview = NULL;
1149 void main_window_update_actions_menu(MainWindow *mainwin)
1151 GtkItemFactory *ifactory;
1153 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1154 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1157 void main_window_cursor_wait(MainWindow *mainwin)
1160 if (mainwin->cursor_count == 0)
1161 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1163 mainwin->cursor_count++;
1168 void main_window_cursor_normal(MainWindow *mainwin)
1170 if (mainwin->cursor_count)
1171 mainwin->cursor_count--;
1173 if (mainwin->cursor_count == 0)
1174 gdk_window_set_cursor(mainwin->window->window, NULL);
1179 /* lock / unlock the user-interface */
1180 void main_window_lock(MainWindow *mainwin)
1182 if (mainwin->lock_count == 0)
1183 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1185 mainwin->lock_count++;
1187 main_window_set_menu_sensitive(mainwin);
1188 toolbar_main_set_sensitive(mainwin);
1191 void main_window_unlock(MainWindow *mainwin)
1193 if (mainwin->lock_count)
1194 mainwin->lock_count--;
1196 main_window_set_menu_sensitive(mainwin);
1197 toolbar_main_set_sensitive(mainwin);
1199 if (mainwin->lock_count == 0)
1200 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1203 static void main_window_menu_callback_block(MainWindow *mainwin)
1205 mainwin->menu_lock_count++;
1208 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1210 if (mainwin->menu_lock_count)
1211 mainwin->menu_lock_count--;
1214 static guint prefs_tag = 0;
1216 void main_window_reflect_prefs_all(void)
1218 main_window_reflect_prefs_all_real(FALSE);
1221 static gboolean reflect_prefs_timeout_cb(gpointer data)
1223 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1225 MainWindow *mainwin;
1228 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1229 mainwin = (MainWindow *)cur->data;
1231 main_window_show_cur_account(mainwin);
1232 main_window_set_menu_sensitive(mainwin);
1233 toolbar_main_set_sensitive(mainwin);
1236 if (pixmap_theme_changed) {
1237 toolbar_update(TOOLBAR_MAIN, mainwin);
1238 messageview_reflect_prefs_pixmap_theme();
1239 compose_reflect_prefs_pixmap_theme();
1240 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1241 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1243 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1244 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1245 mainwin->online_pixmap);
1246 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1247 gtk_widget_show(pixmap);
1248 mainwin->online_pixmap = pixmap;
1249 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1250 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1251 mainwin->offline_pixmap);
1252 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1253 gtk_widget_show(pixmap);
1254 mainwin->offline_pixmap = pixmap;
1257 headerview_set_font(mainwin->messageview->headerview);
1258 headerview_set_visibility(mainwin->messageview->headerview,
1259 prefs_common.display_header_pane);
1260 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1261 folderview_reflect_prefs();
1262 summary_reflect_prefs();
1263 summary_redisplay_msg(mainwin->summaryview);
1269 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1271 if (prefs_tag == 0 || pixmap_theme_changed) {
1272 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1273 GINT_TO_POINTER(pixmap_theme_changed));
1277 void main_window_set_summary_column(void)
1280 MainWindow *mainwin;
1282 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1283 mainwin = (MainWindow *)cur->data;
1284 summary_set_column_order(mainwin->summaryview);
1288 void main_window_set_folder_column(void)
1291 MainWindow *mainwin;
1293 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1294 mainwin = (MainWindow *)cur->data;
1295 folderview_set_column_order(mainwin->folderview);
1299 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1300 GList *account_list)
1302 GList *cur_ac, *cur_item;
1303 GtkWidget *menuitem;
1304 PrefsAccount *ac_prefs;
1306 /* destroy all previous menu item */
1307 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1308 while (cur_item != NULL) {
1309 GList *next = cur_item->next;
1310 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1314 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1315 ac_prefs = (PrefsAccount *)cur_ac->data;
1317 menuitem = gtk_menu_item_new_with_label
1318 (ac_prefs->account_name
1319 ? ac_prefs->account_name : _("Untitled"));
1320 gtk_widget_show(menuitem);
1321 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1322 g_signal_connect(G_OBJECT(menuitem), "activate",
1323 G_CALLBACK(account_selector_menu_cb),
1328 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1329 GList *account_list)
1331 GList *cur_ac, *cur_item;
1333 GtkWidget *menuitem;
1334 PrefsAccount *ac_prefs;
1336 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1337 "/Message/Receive");
1339 /* search for separator */
1340 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1341 cur_item = cur_item->next) {
1342 if (GTK_BIN(cur_item->data)->child == NULL) {
1343 cur_item = cur_item->next;
1348 /* destroy all previous menu item */
1349 while (cur_item != NULL) {
1350 GList *next = cur_item->next;
1351 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1355 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1356 ac_prefs = (PrefsAccount *)cur_ac->data;
1358 menuitem = gtk_menu_item_new_with_label
1359 (ac_prefs->account_name ? ac_prefs->account_name
1361 gtk_widget_show(menuitem);
1362 gtk_menu_append(GTK_MENU(menu), menuitem);
1363 g_signal_connect(G_OBJECT(menuitem), "activate",
1364 G_CALLBACK(account_receive_menu_cb),
1369 void main_window_set_account_menu(GList *account_list)
1372 MainWindow *mainwin;
1374 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1375 mainwin = (MainWindow *)cur->data;
1376 main_window_set_account_selector_menu(mainwin, account_list);
1377 main_window_set_account_receive_menu(mainwin, account_list);
1381 static void main_window_show_cur_account(MainWindow *mainwin)
1386 ac_name = g_strdup(cur_account
1387 ? (cur_account->account_name
1388 ? cur_account->account_name : _("Untitled"))
1392 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1394 buf = g_strdup(PROG_VERSION);
1395 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1398 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1399 gtk_widget_queue_resize(mainwin->ac_button);
1404 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1406 switch (mainwin->type) {
1407 case SEPARATE_FOLDER:
1408 return mainwin->win.sep_folder.folderwin;
1410 return mainwin->win.sep_both.folderwin;
1416 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1418 switch (mainwin->type) {
1419 case SEPARATE_MESSAGE:
1420 return mainwin->win.sep_message.messagewin;
1422 return mainwin->win.sep_both.messagewin;
1428 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1430 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1431 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1432 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1433 GtkWidget *message_wid = mainwin->messageview->vbox;
1435 debug_print("Changing window separation type from %d to %d\n",
1436 mainwin->type, type);
1438 if (mainwin->type == type) return;
1440 /* remove widgets from those containers */
1441 gtk_widget_ref(folder_wid);
1442 gtk_widget_ref(summary_wid);
1443 gtk_widget_ref(message_wid);
1444 gtkut_container_remove
1445 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1446 gtkut_container_remove
1447 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1448 gtkut_container_remove
1449 (GTK_CONTAINER(message_wid->parent), message_wid);
1451 /* clean containers */
1452 switch (mainwin->type) {
1454 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1456 case SEPARATE_FOLDER:
1457 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1458 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1460 case SEPARATE_MESSAGE:
1461 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1462 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1465 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1466 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1470 gtk_widget_hide(mainwin->window);
1471 main_window_set_widgets(mainwin, type);
1472 gtk_widget_show(mainwin->window);
1474 gtk_widget_unref(folder_wid);
1475 gtk_widget_unref(summary_wid);
1476 gtk_widget_unref(message_wid);
1479 void main_window_toggle_message_view(MainWindow *mainwin)
1481 SummaryView *summaryview = mainwin->summaryview;
1482 union CompositeWin *cwin = &mainwin->win;
1483 GtkWidget *vpaned = NULL;
1484 GtkWidget *container = NULL;
1485 GtkWidget *msgwin = NULL;
1487 switch (mainwin->type) {
1489 vpaned = cwin->sep_none.vpaned;
1490 container = cwin->sep_none.hpaned;
1492 case SEPARATE_FOLDER:
1493 vpaned = cwin->sep_folder.vpaned;
1494 container = mainwin->vbox_body;
1496 case SEPARATE_MESSAGE:
1497 msgwin = mainwin->win.sep_message.messagewin;
1500 msgwin = mainwin->win.sep_both.messagewin;
1505 if (GTK_WIDGET_VISIBLE(msgwin)) {
1506 gtk_widget_hide(msgwin);
1507 mainwin->messageview->visible = FALSE;
1508 summaryview->displayed = NULL;
1510 gtk_widget_show(msgwin);
1511 mainwin->messageview->visible = TRUE;
1513 } else if (vpaned->parent != NULL) {
1514 mainwin->messageview->visible = FALSE;
1515 summaryview->displayed = NULL;
1516 gtk_widget_ref(vpaned);
1517 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1518 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1520 mainwin->messageview->visible = TRUE;
1521 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1522 gtk_container_add(GTK_CONTAINER(container), vpaned);
1523 gtk_widget_unref(vpaned);
1526 if (messageview_is_visible(mainwin->messageview))
1527 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1528 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1530 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1531 GTK_ARROW_UP, GTK_SHADOW_OUT);
1533 if (mainwin->messageview->visible == FALSE)
1534 messageview_clear(mainwin->messageview);
1536 main_window_set_menu_sensitive(mainwin);
1538 prefs_common.msgview_visible = mainwin->messageview->visible;
1540 gtk_widget_grab_focus(summaryview->ctree);
1543 void main_window_get_size(MainWindow *mainwin)
1545 GtkAllocation *allocation;
1547 if (mainwin->messageview == NULL) {
1548 debug_print("called after messageview "
1549 "has been deallocated!\n");
1553 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1555 if (allocation->width > 1 && allocation->height > 1) {
1556 prefs_common.summaryview_width = allocation->width;
1558 if ((mainwin->type == SEPARATE_NONE ||
1559 mainwin->type == SEPARATE_FOLDER) &&
1560 messageview_is_visible(mainwin->messageview))
1561 prefs_common.summaryview_height = allocation->height;
1563 prefs_common.mainview_width = allocation->width;
1566 allocation = &mainwin->window->allocation;
1567 if (allocation->width > 1 && allocation->height > 1) {
1568 prefs_common.mainview_height = allocation->height;
1569 prefs_common.mainwin_width = allocation->width;
1570 prefs_common.mainwin_height = allocation->height;
1573 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1574 if (allocation->width > 1 && allocation->height > 1) {
1575 prefs_common.folderview_width = allocation->width;
1576 prefs_common.folderview_height = allocation->height;
1579 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1580 if (allocation->width > 1 && allocation->height > 1) {
1581 prefs_common.msgview_width = allocation->width;
1582 prefs_common.msgview_height = allocation->height;
1585 /* debug_print("summaryview size: %d x %d\n",
1586 prefs_common.summaryview_width,
1587 prefs_common.summaryview_height);
1588 debug_print("folderview size: %d x %d\n",
1589 prefs_common.folderview_width,
1590 prefs_common.folderview_height);
1591 debug_print("messageview size: %d x %d\n",
1592 prefs_common.msgview_width,
1593 prefs_common.msgview_height); */
1596 void main_window_get_position(MainWindow *mainwin)
1601 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1603 prefs_common.mainview_x = x;
1604 prefs_common.mainview_y = y;
1605 prefs_common.mainwin_x = x;
1606 prefs_common.mainwin_y = y;
1608 debug_print("main window position: %d, %d\n", x, y);
1610 window = main_window_get_folder_window(mainwin);
1612 gtkut_widget_get_uposition(window, &x, &y);
1613 prefs_common.folderwin_x = x;
1614 prefs_common.folderwin_y = y;
1615 debug_print("folder window position: %d, %d\n", x, y);
1617 window = main_window_get_message_window(mainwin);
1619 gtkut_widget_get_uposition(window, &x, &y);
1620 prefs_common.main_msgwin_x = x;
1621 prefs_common.main_msgwin_y = y;
1622 debug_print("message window position: %d, %d\n", x, y);
1626 void main_window_progress_on(MainWindow *mainwin)
1628 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1631 void main_window_progress_off(MainWindow *mainwin)
1633 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1634 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1637 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1641 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1642 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1643 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1644 (cur == 0 && total == 0) ? 0 :
1645 (gfloat)cur / (gfloat)total);
1648 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1651 if (alertpanel(_("Empty trash"),
1652 _("Delete all messages in trash folders?"),
1653 GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1656 manage_window_focus_in(mainwin->window, NULL, NULL);
1659 procmsg_empty_all_trash();
1661 if (mainwin->summaryview->folder_item &&
1662 mainwin->summaryview->folder_item->stype == F_TRASH)
1663 gtk_widget_grab_focus(mainwin->folderview->ctree);
1666 void main_window_add_mailbox(MainWindow *mainwin)
1671 path = input_dialog(_("Add mailbox"),
1672 _("Input the location of mailbox.\n"
1673 "If the existing mailbox is specified, it will be\n"
1674 "scanned automatically."),
1677 if (folder_find_from_path(path)) {
1678 alertpanel_error(_("The mailbox '%s' already exists."), path);
1682 folder = folder_new(folder_get_class_from_string("mh"),
1683 !strcmp(path, "Mail") ? _("Mailbox") :
1684 g_path_get_basename(path), path);
1687 if (folder->klass->create_tree(folder) < 0) {
1688 alertpanel_error(_("Creation of the mailbox failed.\n"
1689 "Maybe some files already exist, or you don't have the permission to write there."));
1690 folder_destroy(folder);
1695 folder_set_ui_func(folder, scan_tree_func, mainwin);
1696 folder_scan_tree(folder);
1697 folder_set_ui_func(folder, NULL, NULL);
1700 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1702 SensitiveCond state = 0;
1703 SummarySelection selection;
1704 FolderItem *item = mainwin->summaryview->folder_item;
1705 GList *account_list = account_get_list();
1707 selection = summary_get_selection_type(mainwin->summaryview);
1709 if (mainwin->lock_count == 0)
1710 state |= M_UNLOCKED;
1711 if (selection != SUMMARY_NONE)
1712 state |= M_MSG_EXIST;
1713 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1715 /* if (item->folder->type != F_NEWS) */
1716 state |= M_ALLOW_DELETE;
1718 if (prefs_common.immediate_exec == 0
1719 && mainwin->lock_count == 0)
1720 state |= M_DELAY_EXEC;
1722 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1723 || selection != SUMMARY_NONE)
1724 state |= M_HIDE_READ_MSG;
1726 if (mainwin->summaryview->threaded)
1727 state |= M_THREADED;
1729 state |= M_UNTHREADED;
1730 if (selection == SUMMARY_SELECTED_SINGLE ||
1731 selection == SUMMARY_SELECTED_MULTIPLE)
1732 state |= M_TARGET_EXIST;
1733 if (selection == SUMMARY_SELECTED_SINGLE)
1734 state |= M_SINGLE_TARGET_EXIST;
1735 if (mainwin->summaryview->folder_item &&
1736 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1739 state |= M_NOT_NEWS;
1740 if (selection == SUMMARY_SELECTED_SINGLE &&
1742 (folder_has_parent_of_type(item, F_DRAFT) ||
1743 folder_has_parent_of_type(item, F_OUTBOX) ||
1744 folder_has_parent_of_type(item, F_QUEUE))))
1745 state |= M_ALLOW_REEDIT;
1747 state |= M_HAVE_ACCOUNT;
1749 for ( ; account_list != NULL; account_list = account_list->next) {
1750 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1751 state |= M_HAVE_NEWS_ACCOUNT;
1756 if (inc_is_active())
1757 state |= M_INC_ACTIVE;
1764 void main_window_set_menu_sensitive(MainWindow *mainwin)
1766 GtkItemFactory *ifactory = mainwin->menu_factory;
1767 SensitiveCond state;
1770 GtkWidget *menuitem;
1771 SummaryView *summaryview;
1776 static const struct {
1780 {"/File/Add mailbox" , M_UNLOCKED},
1782 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1783 {"/File/Change folder order" , M_UNLOCKED},
1784 {"/File/Export to mbox file..." , M_UNLOCKED},
1785 {"/File/Empty all Trash folders" , M_UNLOCKED},
1786 {"/File/Work offline" , M_UNLOCKED},
1788 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1789 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1790 /* {"/File/Close" , M_UNLOCKED}, */
1791 {"/File/Exit" , M_UNLOCKED},
1793 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1795 {"/View/Sort" , M_EXEC},
1796 {"/View/Thread view" , M_EXEC},
1797 {"/View/Expand all threads" , M_MSG_EXIST},
1798 {"/View/Collapse all threads" , M_MSG_EXIST},
1799 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1800 {"/View/Go to/Prev message" , M_MSG_EXIST},
1801 {"/View/Go to/Next message" , M_MSG_EXIST},
1802 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1803 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1804 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1805 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1806 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1807 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1808 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1809 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1810 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1812 {"/Message/Receive/Get from current account"
1813 , M_HAVE_ACCOUNT|M_UNLOCKED},
1814 {"/Message/Receive/Get from all accounts"
1815 , M_HAVE_ACCOUNT|M_UNLOCKED},
1816 {"/Message/Receive/Cancel receiving"
1819 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1820 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1821 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1822 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1823 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1824 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1825 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1826 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1827 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1828 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1829 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1830 {"/Message/Mark" , M_TARGET_EXIST},
1831 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1833 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1834 {"/Tools/Harvest addresses" , M_UNLOCKED},
1835 {"/Tools/Harvest addresses/from Folder..."
1836 , M_UNLOCKED|M_MSG_EXIST},
1837 {"/Tools/Harvest addresses/from Messages..."
1838 , M_UNLOCKED|M_MSG_EXIST|M_TARGET_EXIST},
1839 {"/Tools/Harvest addresses" , M_UNLOCKED},
1840 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1841 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1842 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1843 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1844 {"/Tools/Execute" , M_DELAY_EXEC},
1845 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1847 {"/Configuration", M_UNLOCKED},
1852 state = main_window_get_current_state(mainwin);
1854 for (i = 0; entry[i].entry != NULL; i++) {
1855 sensitive = ((entry[i].cond & state) == entry[i].cond);
1856 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1859 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1861 /* search for separator */
1862 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1863 cur_item = cur_item->next) {
1864 if (GTK_BIN(cur_item->data)->child == NULL) {
1865 cur_item = cur_item->next;
1870 for (; cur_item != NULL; cur_item = cur_item->next) {
1871 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1872 (M_UNLOCKED & state) != 0);
1875 main_window_menu_callback_block(mainwin);
1877 #define SET_CHECK_MENU_ACTIVE(path, active) \
1879 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1880 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1883 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1884 messageview_is_visible(mainwin->messageview));
1886 summaryview = mainwin->summaryview;
1887 menu_path = "/View/Sort/Don't sort";
1889 switch (summaryview->sort_key) {
1890 case SORT_BY_NUMBER:
1891 menu_path = "/View/Sort/by number"; break;
1893 menu_path = "/View/Sort/by size"; break;
1895 menu_path = "/View/Sort/by date"; break;
1897 menu_path = "/View/Sort/by from"; break;
1899 menu_path = "/View/Sort/by recipient"; break;
1900 case SORT_BY_SUBJECT:
1901 menu_path = "/View/Sort/by subject"; break;
1903 menu_path = "/View/Sort/by color label"; break;
1905 menu_path = "/View/Sort/by mark"; break;
1906 case SORT_BY_STATUS:
1907 menu_path = "/View/Sort/by status"; break;
1909 menu_path = "/View/Sort/by attachment"; break;
1911 menu_path = "/View/Sort/by score"; break;
1912 case SORT_BY_LOCKED:
1913 menu_path = "/View/Sort/by locked"; break;
1916 menu_path = "/View/Sort/Don't sort"; break;
1918 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1920 if (summaryview->sort_type == SORT_ASCENDING) {
1921 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1923 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1926 if (summaryview->sort_key != SORT_BY_NONE) {
1927 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1928 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1930 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1931 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1934 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1935 mainwin->messageview->mimeview->textview->show_all_headers);
1936 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1938 #undef SET_CHECK_MENU_ACTIVE
1940 main_window_menu_callback_unblock(mainwin);
1943 void main_window_popup(MainWindow *mainwin)
1945 gtkut_window_popup(mainwin->window);
1947 switch (mainwin->type) {
1948 case SEPARATE_FOLDER:
1949 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1951 case SEPARATE_MESSAGE:
1952 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1955 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1956 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1963 void main_window_show(MainWindow *mainwin)
1965 gtk_widget_show(mainwin->window);
1966 gtk_widget_show(mainwin->vbox_body);
1968 gtk_widget_set_uposition(mainwin->window,
1969 prefs_common.mainwin_x,
1970 prefs_common.mainwin_y);
1972 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1973 prefs_common.folderview_width,
1974 prefs_common.folderview_height);
1975 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1976 prefs_common.summaryview_width,
1977 prefs_common.summaryview_height);
1978 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1979 prefs_common.msgview_width,
1980 prefs_common.msgview_height);
1982 if (mainwin->type & SEPARATE_FOLDER) {
1983 GtkWidget *folderwin;
1985 folderwin = main_window_get_folder_window(mainwin);
1986 gtk_widget_show(folderwin);
1987 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1988 prefs_common.folderwin_y);
1991 if (mainwin->type & SEPARATE_MESSAGE) {
1992 GtkWidget *messagewin;
1994 messagewin = main_window_get_message_window(mainwin);
1995 gtk_widget_show(messagewin);
1996 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1997 prefs_common.main_msgwin_y);
2001 void main_window_hide(MainWindow *mainwin)
2003 main_window_get_size(mainwin);
2004 main_window_get_position(mainwin);
2006 gtk_widget_hide(mainwin->window);
2007 gtk_widget_hide(mainwin->vbox_body);
2009 if (mainwin->type & SEPARATE_FOLDER) {
2010 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2013 if (mainwin->type & SEPARATE_MESSAGE) {
2014 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2018 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2020 GtkWidget *folderwin = NULL;
2021 GtkWidget *messagewin = NULL;
2024 GtkWidget *vbox_body = mainwin->vbox_body;
2025 GtkItemFactory *ifactory = mainwin->menu_factory;
2026 GtkWidget *menuitem;
2027 GtkItemFactory *msgview_ifactory;
2029 debug_print("Setting widgets... ");
2031 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2032 prefs_common.folderview_width,
2033 prefs_common.folderview_height);
2034 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2035 prefs_common.summaryview_width,
2036 prefs_common.summaryview_height);
2037 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2038 prefs_common.msgview_width,
2039 prefs_common.msgview_height);
2041 /* create separated window(s) if needed */
2042 if (type & SEPARATE_FOLDER) {
2043 static GdkGeometry folderwin_geometry;
2045 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2046 gtk_window_set_title(GTK_WINDOW(folderwin),
2047 _("Sylpheed - Folder View"));
2049 gtk_window_move(GTK_WINDOW(folderwin),
2050 prefs_common.folderwin_x,
2051 prefs_common.folderwin_y);
2053 if (!folderwin_geometry.min_height) {
2054 folderwin_geometry.min_width = 320;
2055 folderwin_geometry.min_height = 200;
2057 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2058 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2060 gtk_widget_set_size_request(folderwin,
2061 prefs_common.folderview_width,
2062 prefs_common.folderview_height);
2064 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2067 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2068 G_CALLBACK(folder_window_close_cb),
2070 gtk_container_add(GTK_CONTAINER(folderwin),
2071 GTK_WIDGET_PTR(mainwin->folderview));
2072 gtk_widget_realize(folderwin);
2074 if (prefs_common.folderview_visible)
2075 gtk_widget_show(folderwin);
2078 if (type & SEPARATE_MESSAGE) {
2079 static GdkGeometry msgwin_geometry;
2081 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2082 gtk_window_set_title(GTK_WINDOW(messagewin),
2083 _("Sylpheed - Message View"));
2085 gtk_window_move(GTK_WINDOW(messagewin),
2086 prefs_common.main_msgwin_x,
2087 prefs_common.main_msgwin_y);
2089 if (!msgwin_geometry.min_height) {
2090 msgwin_geometry.min_width = 320;
2091 msgwin_geometry.min_height = 200;
2093 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2094 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2096 gtk_widget_set_size_request(messagewin,
2097 prefs_common.msgwin_width,
2098 prefs_common.msgwin_height);
2100 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2102 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2103 G_CALLBACK(message_window_close_cb),
2105 if (messageview_is_visible(mainwin->messageview))
2106 gtk_widget_show(messagewin);
2108 mainwin->messageview->statusbar = mainwin->statusbar;
2109 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2114 hpaned = gtk_hpaned_new();
2115 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2116 gtk_paned_add1(GTK_PANED(hpaned),
2117 GTK_WIDGET_PTR(mainwin->folderview));
2118 gtk_widget_show(hpaned);
2119 gtk_widget_queue_resize(hpaned);
2121 vpaned = gtk_vpaned_new();
2122 if (messageview_is_visible(mainwin->messageview)) {
2123 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2124 gtk_paned_add1(GTK_PANED(vpaned),
2125 GTK_WIDGET_PTR(mainwin->summaryview));
2127 gtk_paned_add2(GTK_PANED(hpaned),
2128 GTK_WIDGET_PTR(mainwin->summaryview));
2129 gtk_widget_ref(vpaned);
2131 gtk_paned_add2(GTK_PANED(vpaned),
2132 GTK_WIDGET_PTR(mainwin->messageview));
2133 gtk_widget_show(vpaned);
2134 gtk_widget_queue_resize(vpaned);
2136 mainwin->win.sep_none.hpaned = hpaned;
2137 mainwin->win.sep_none.vpaned = vpaned;
2139 /* remove headerview if not in prefs */
2140 headerview_set_visibility(mainwin->messageview->headerview,
2141 prefs_common.display_header_pane);
2143 case SEPARATE_FOLDER:
2144 vpaned = gtk_vpaned_new();
2145 if (messageview_is_visible(mainwin->messageview)) {
2146 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2148 gtk_paned_add1(GTK_PANED(vpaned),
2149 GTK_WIDGET_PTR(mainwin->summaryview));
2151 gtk_box_pack_start(GTK_BOX(vbox_body),
2152 GTK_WIDGET_PTR(mainwin->summaryview),
2154 gtk_widget_ref(vpaned);
2156 gtk_paned_add2(GTK_PANED(vpaned),
2157 GTK_WIDGET_PTR(mainwin->messageview));
2158 gtk_widget_show(vpaned);
2159 gtk_widget_queue_resize(vpaned);
2161 mainwin->win.sep_folder.folderwin = folderwin;
2162 mainwin->win.sep_folder.vpaned = vpaned;
2164 /* remove headerview if not in prefs */
2165 headerview_set_visibility(mainwin->messageview->headerview,
2166 prefs_common.display_header_pane);
2169 case SEPARATE_MESSAGE:
2170 hpaned = gtk_hpaned_new();
2171 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2172 gtk_paned_add1(GTK_PANED(hpaned),
2173 GTK_WIDGET_PTR(mainwin->folderview));
2174 gtk_paned_add2(GTK_PANED(hpaned),
2175 GTK_WIDGET_PTR(mainwin->summaryview));
2176 gtk_widget_show(hpaned);
2177 gtk_widget_queue_resize(hpaned);
2178 messageview_add_toolbar(mainwin->messageview, messagewin);
2179 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2180 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2182 mainwin->win.sep_message.messagewin = messagewin;
2183 mainwin->win.sep_message.hpaned = hpaned;
2185 gtk_widget_realize(messagewin);
2186 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2187 gtk_widget_show_all(messagewin);
2188 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2189 mainwin->messageview->handlebox,
2190 prefs_common.toolbar_style);
2194 messageview_add_toolbar(mainwin->messageview, messagewin);
2195 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2196 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2198 gtk_box_pack_start(GTK_BOX(vbox_body),
2199 GTK_WIDGET_PTR(mainwin->summaryview),
2202 mainwin->win.sep_both.folderwin = folderwin;
2203 mainwin->win.sep_both.messagewin = messagewin;
2205 gtk_widget_realize(messagewin);
2206 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2207 gtk_widget_show_all(messagewin);
2208 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2209 mainwin->messageview->handlebox,
2210 prefs_common.toolbar_style);
2215 if (messageview_is_visible(mainwin->messageview))
2216 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2217 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2219 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2220 GTK_ARROW_UP, GTK_SHADOW_OUT);
2222 gtk_window_move(GTK_WINDOW(mainwin->window),
2223 prefs_common.mainwin_x,
2224 prefs_common.mainwin_y);
2226 gtk_widget_queue_resize(vbox_body);
2227 gtk_widget_queue_resize(mainwin->vbox);
2228 gtk_widget_queue_resize(mainwin->window);
2229 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2230 * and mimeview icon list/ctree lose track of their visibility states */
2231 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2232 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2233 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2234 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2235 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2236 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2238 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2240 mainwin->type = type;
2243 /* toggle menu state */
2244 menuitem = gtk_item_factory_get_item
2245 (ifactory, "/View/Show or hide/Folder tree");
2246 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2247 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2248 prefs_common.folderview_visible);
2249 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2250 menuitem = gtk_item_factory_get_item
2251 (ifactory, "/View/Show or hide/Message view");
2252 gtk_check_menu_item_set_active
2253 (GTK_CHECK_MENU_ITEM(menuitem),
2254 messageview_is_visible(mainwin->messageview));
2256 menuitem = gtk_item_factory_get_item
2257 (ifactory, "/View/Separate folder tree");
2258 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2259 ((type & SEPARATE_FOLDER) != 0));
2260 menuitem = gtk_item_factory_get_item
2261 (ifactory, "/View/Separate message view");
2262 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2263 ((type & SEPARATE_MESSAGE) != 0));
2267 (G_OBJECT(folderwin), "size_allocate",
2268 G_CALLBACK(folder_window_size_allocate_cb),
2273 (G_OBJECT(messagewin), "size_allocate",
2274 G_CALLBACK(message_window_size_allocate_cb),
2278 debug_print("done.\n");
2281 void main_window_destroy_all(void)
2283 while (mainwin_list != NULL) {
2284 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2286 /* free toolbar stuff */
2287 toolbar_clear_list(TOOLBAR_MAIN);
2288 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2289 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2291 g_free(mainwin->toolbar);
2294 mainwin_list = g_list_remove(mainwin_list, mainwin);
2296 g_list_free(mainwin_list);
2300 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2301 GdkEventButton *event,
2304 MainWindow *mainwin = (MainWindow *)data;
2306 if (!event) return FALSE;
2307 if (event->button != 3) return FALSE;
2309 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2310 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2313 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2314 menu_button_position, widget,
2315 event->button, event->time);
2321 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2324 gtk_widget_set_size_request(child, 1, -1);
2327 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2330 gtk_widget_set_size_request(child, -1, -1);
2333 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2336 MainWindow *mainwin = (MainWindow *)data;
2338 if (!event) return FALSE;
2340 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2341 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2344 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2345 menu_button_position, widget,
2346 event->button, event->time);
2351 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2354 MainWindow *mainwin = (MainWindow *)data;
2356 if (mainwin->lock_count == 0)
2357 app_exit_cb(data, 0, widget);
2362 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2365 MainWindow *mainwin = (MainWindow *)data;
2366 GtkWidget *menuitem;
2368 menuitem = gtk_item_factory_get_item
2369 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2370 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2375 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2378 MainWindow *mainwin = (MainWindow *)data;
2379 GtkWidget *menuitem;
2381 menuitem = gtk_item_factory_get_item
2382 (mainwin->menu_factory, "/View/Show or hide/Message view");
2383 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2385 mainwin->messageview->statusbar = mainwin->statusbar;
2386 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2391 static void main_window_size_allocate_cb(GtkWidget *widget,
2392 GtkAllocation *allocation,
2395 MainWindow *mainwin = (MainWindow *)data;
2397 main_window_get_size(mainwin);
2400 static void folder_window_size_allocate_cb(GtkWidget *widget,
2401 GtkAllocation *allocation,
2404 MainWindow *mainwin = (MainWindow *)data;
2406 main_window_get_size(mainwin);
2409 static void message_window_size_allocate_cb(GtkWidget *widget,
2410 GtkAllocation *allocation,
2413 MainWindow *mainwin = (MainWindow *)data;
2415 main_window_get_size(mainwin);
2418 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2421 main_window_add_mailbox(mainwin);
2424 static void update_folderview_cb(MainWindow *mainwin, guint action,
2427 summary_show(mainwin->summaryview, NULL);
2428 folderview_check_new_all();
2431 static void foldersort_cb(MainWindow *mainwin, guint action,
2437 static void import_mbox_cb(MainWindow *mainwin, guint action,
2440 import_mbox(mainwin->summaryview->folder_item);
2443 static void export_mbox_cb(MainWindow *mainwin, guint action,
2446 export_mbox(mainwin->summaryview->folder_item);
2449 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2452 summaryview_export_mbox_list(mainwin->summaryview);
2455 static void empty_trash_cb(MainWindow *mainwin, guint action,
2458 main_window_empty_trash(mainwin, TRUE);
2461 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2463 summary_save_as(mainwin->summaryview);
2466 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2468 summary_print(mainwin->summaryview);
2471 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2473 if (prefs_common.confirm_on_exit) {
2474 if (alertpanel(_("Exit"), _("Exit this program?"),
2475 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
2478 manage_window_focus_in(mainwin->window, NULL, NULL);
2481 app_will_exit(widget, mainwin);
2484 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2487 summary_search(mainwin->summaryview);
2489 message_search(mainwin->messageview);
2492 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
2494 prefs_common.show_searchbar = TRUE;
2495 quicksearch_show(mainwin->summaryview->quicksearch);
2498 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2503 active = GTK_CHECK_MENU_ITEM(widget)->active;
2505 switch (mainwin->type) {
2507 case SEPARATE_MESSAGE:
2510 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2512 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2515 case SEPARATE_FOLDER:
2516 debug_print("separate folder\n");
2518 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2520 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2524 gtk_widget_show(mainwin->win.sep_both.folderwin);
2526 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2530 prefs_common.folderview_visible = active;
2533 static void toggle_message_cb(MainWindow *mainwin, guint action,
2538 active = GTK_CHECK_MENU_ITEM(widget)->active;
2540 if (active != messageview_is_visible(mainwin->messageview))
2541 summary_toggle_view(mainwin->summaryview);
2544 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2547 toolbar_toggle(action, mainwin);
2550 void main_window_reply_cb(MainWindow *mainwin, guint action,
2553 MessageView *msgview = (MessageView*)mainwin->messageview;
2554 GSList *msginfo_list = NULL;
2556 g_return_if_fail(msgview != NULL);
2558 msginfo_list = summary_get_selection(mainwin->summaryview);
2559 g_return_if_fail(msginfo_list != NULL);
2560 compose_reply_from_messageview(msgview, msginfo_list, action);
2561 g_slist_free(msginfo_list);
2565 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2568 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2569 gtk_widget_show(mainwin->hbox_stat);
2570 prefs_common.show_statusbar = TRUE;
2572 gtk_widget_hide(mainwin->hbox_stat);
2573 prefs_common.show_statusbar = FALSE;
2577 static void separate_widget_cb(MainWindow *mainwin, guint action,
2582 if (GTK_CHECK_MENU_ITEM(widget)->active)
2583 type = mainwin->type | action;
2585 type = mainwin->type & ~action;
2587 main_window_separation_change(mainwin, type);
2589 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2590 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2593 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2596 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2598 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2601 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2603 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2606 static void online_switch_clicked (GtkButton *btn, gpointer data)
2608 MainWindow *mainwin;
2609 GtkItemFactory *ifactory;
2610 GtkCheckMenuItem *menuitem;
2612 mainwin = (MainWindow *) data;
2614 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2615 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2617 g_return_if_fail(mainwin != NULL);
2618 g_return_if_fail(menuitem != NULL);
2620 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2622 gtk_widget_hide (mainwin->online_switch);
2623 gtk_widget_show (mainwin->offline_switch);
2624 menuitem->active = TRUE;
2625 prefs_common.work_offline = TRUE;
2626 inc_autocheck_timer_remove();
2629 gtk_widget_hide (mainwin->offline_switch);
2630 gtk_widget_show (mainwin->online_switch);
2631 menuitem->active = FALSE;
2632 prefs_common.work_offline = FALSE;
2633 inc_autocheck_timer_set();
2637 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2640 addressbook_open(NULL);
2643 static void log_window_show_cb(MainWindow *mainwin, guint action,
2646 log_window_show(mainwin->logwin);
2649 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2654 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2656 summary_move_to(mainwin->summaryview);
2659 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2661 summary_copy_to(mainwin->summaryview);
2664 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2666 summary_delete(mainwin->summaryview);
2669 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2671 summary_delete_trash(mainwin->summaryview);
2674 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2676 summary_cancel(mainwin->summaryview);
2679 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2681 summary_open_msg(mainwin->summaryview);
2684 static void view_source_cb(MainWindow *mainwin, guint action,
2687 summary_view_source(mainwin->summaryview);
2690 static void show_all_header_cb(MainWindow *mainwin, guint action,
2693 if (mainwin->menu_lock_count) return;
2694 mainwin->summaryview->messageview->all_headers =
2695 GTK_CHECK_MENU_ITEM(widget)->active;
2696 summary_display_msg_selected(mainwin->summaryview,
2697 GTK_CHECK_MENU_ITEM(widget)->active);
2700 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2702 summary_mark(mainwin->summaryview);
2705 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2707 summary_unmark(mainwin->summaryview);
2710 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2713 summary_mark_as_unread(mainwin->summaryview);
2716 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2719 summary_mark_as_read(mainwin->summaryview);
2722 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2725 summary_mark_all_read(mainwin->summaryview);
2728 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2730 summary_reedit(mainwin->summaryview);
2733 static void add_address_cb(MainWindow *mainwin, guint action,
2736 summary_add_address(mainwin->summaryview);
2739 static void set_charset_cb(MainWindow *mainwin, guint action,
2744 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2745 str = conv_get_charset_str((CharSet)action);
2747 g_free(mainwin->messageview->forced_charset);
2748 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2749 procmime_force_charset(str);
2751 summary_redisplay_msg(mainwin->summaryview);
2753 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2757 static void set_decode_cb(MainWindow *mainwin, guint action,
2760 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2761 mainwin->messageview->forced_encoding = (EncodingType)action;
2763 summary_redisplay_msg(mainwin->summaryview);
2765 debug_print("forced encoding: %d\n", action);
2769 static void hide_read_messages (MainWindow *mainwin, guint action,
2772 if (!mainwin->summaryview->folder_item
2773 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2775 summary_toggle_show_read_messages(mainwin->summaryview);
2778 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2780 if (mainwin->menu_lock_count) return;
2781 if (!mainwin->summaryview->folder_item) return;
2783 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2784 summary_thread_build(mainwin->summaryview);
2785 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2787 summary_unthread(mainwin->summaryview);
2788 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2792 static void expand_threads_cb(MainWindow *mainwin, guint action,
2795 summary_expand_threads(mainwin->summaryview);
2798 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2801 summary_collapse_threads(mainwin->summaryview);
2804 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
2807 prefs_summary_column_open();
2810 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
2813 prefs_folder_column_open();
2816 static void sort_summary_cb(MainWindow *mainwin, guint action,
2819 FolderItem *item = mainwin->summaryview->folder_item;
2820 GtkWidget *menuitem;
2822 if (mainwin->menu_lock_count) return;
2824 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2825 menuitem = gtk_item_factory_get_item
2826 (mainwin->menu_factory, "/View/Sort/Ascending");
2827 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2828 GTK_CHECK_MENU_ITEM(menuitem)->active
2829 ? SORT_ASCENDING : SORT_DESCENDING);
2830 item->sort_key = action;
2834 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2837 FolderItem *item = mainwin->summaryview->folder_item;
2839 if (mainwin->menu_lock_count) return;
2841 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2842 summary_sort(mainwin->summaryview,
2843 item->sort_key, (FolderSortType)action);
2846 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2849 summary_attract_by_subject(mainwin->summaryview);
2852 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2857 item = folderview_get_selected_item(mainwin->folderview);
2859 main_window_cursor_wait(mainwin);
2860 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2862 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2863 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2865 STATUSBAR_POP(mainwin);
2866 main_window_cursor_normal(mainwin);
2876 static void deldup_all(FolderItem *item, gpointer _data)
2878 struct DelDupsData *data = _data;
2881 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2883 data->dups += result;
2888 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2891 struct DelDupsData data = {0, 0};
2893 folder_func_to_all_folders(deldup_all, &data);
2894 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
2895 "Deleted %d duplicate messages in %d folders.\n",
2897 data.dups, data.folders);
2900 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2902 summary_filter(mainwin->summaryview, (gboolean)action);
2905 static void execute_summary_cb(MainWindow *mainwin, guint action,
2908 summary_execute(mainwin->summaryview);
2911 static void update_summary_cb(MainWindow *mainwin, guint action,
2915 FolderView *folderview = mainwin->folderview;
2917 if (!mainwin->summaryview->folder_item) return;
2918 if (!folderview->opened) return;
2920 folder_update_op_count();
2922 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2923 folderview->opened);
2926 folder_item_scan(fitem);
2927 summary_show(mainwin->summaryview, fitem);
2930 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2932 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2935 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2937 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2940 static void prev_unread_cb(MainWindow *mainwin, guint action,
2943 summary_select_prev_unread(mainwin->summaryview);
2946 static void next_unread_cb(MainWindow *mainwin, guint action,
2949 summary_select_next_unread(mainwin->summaryview);
2952 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2954 summary_select_prev_new(mainwin->summaryview);
2957 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2959 summary_select_next_new(mainwin->summaryview);
2962 static void prev_marked_cb(MainWindow *mainwin, guint action,
2965 summary_select_prev_marked(mainwin->summaryview);
2968 static void next_marked_cb(MainWindow *mainwin, guint action,
2971 summary_select_next_marked(mainwin->summaryview);
2974 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2977 summary_select_prev_labeled(mainwin->summaryview);
2980 static void next_labeled_cb(MainWindow *mainwin, guint action,
2983 summary_select_next_labeled(mainwin->summaryview);
2986 static void goto_folder_cb(MainWindow *mainwin, guint action,
2989 FolderItem *to_folder;
2991 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2994 folderview_select(mainwin->folderview, to_folder);
2997 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2999 messageview_copy_clipboard(mainwin->messageview);
3002 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3004 MessageView *msgview = mainwin->messageview;
3006 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3007 summary_select_all(mainwin->summaryview);
3008 else if (messageview_is_visible(msgview) &&
3009 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3010 messageview_select_all(mainwin->messageview);
3013 static void select_thread_cb(MainWindow *mainwin, guint action,
3016 summary_select_thread(mainwin->summaryview);
3019 static void create_filter_cb(MainWindow *mainwin, guint action,
3022 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3025 static void create_processing_cb(MainWindow *mainwin, guint action,
3028 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3031 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3034 prefs_filtering_open(&pre_global_processing,
3035 _("Processing rules to apply before folder rules"),
3039 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3042 prefs_filtering_open(&post_global_processing,
3043 _("Processing rules to apply after folder rules"),
3047 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3050 prefs_filtering_open(&filtering_rules,
3051 _("Filtering configuration"),
3055 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3058 prefs_template_open();
3061 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3064 prefs_actions_open(mainwin);
3067 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3070 ssl_manager_open(mainwin);
3073 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3077 new_account_cb(mainwin, 0, widget);
3079 account_open(cur_account);
3083 static void new_account_cb(MainWindow *mainwin, guint action,
3086 account_edit_open();
3087 if (!compose_get_compose_list()) account_add();
3090 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3092 cur_account = (PrefsAccount *)data;
3093 FolderItem *item = NULL;
3095 if (!mainwindow_get_mainwindow())
3097 main_window_show_cur_account(mainwindow_get_mainwindow());
3098 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3099 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3100 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3101 gtk_button_set_relief(GTK_BUTTON(mainwindow_get_mainwindow()->ac_button), GTK_RELIEF_NONE);
3102 item = folderview_get_selected_item(
3103 mainwindow_get_mainwindow()->folderview);
3105 toolbar_set_compose_button
3106 (mainwindow_get_mainwindow()->toolbar,
3107 FOLDER_TYPE(item->folder) == F_NEWS ?
3108 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3112 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3114 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3115 PrefsAccount *account = (PrefsAccount *)data;
3117 inc_account_mail(mainwin, account);
3120 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3125 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3127 pluginwindow_create();
3130 static void manual_open_cb(MainWindow *mainwin, guint action,
3133 manual_open((ManualType)action);
3136 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3138 MainWindow *mainwin = (MainWindow *)data;
3142 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3143 LOCAL_FOLDER(folder)->rootpath,
3147 str = g_strdup_printf(_("Scanning folder %s ..."),
3148 LOCAL_FOLDER(folder)->rootpath);
3150 STATUSBAR_PUSH(mainwin, str);
3151 STATUSBAR_POP(mainwin);
3155 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3158 SummaryView *summary;
3160 g_return_val_if_fail(data, FALSE);
3161 summary = ((MainWindow *)data)->summaryview;
3162 g_return_val_if_fail(summary, FALSE);
3164 if (GTK_CLIST(summary->ctree)->selection &&
3165 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3168 if (summary->selected != summary->displayed)
3169 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3173 #define BREAK_ON_MODIFIER_KEY() \
3174 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3176 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3179 MainWindow *mainwin = (MainWindow*) data;
3181 if (!mainwin || !event)
3184 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3187 switch (event->keyval) {
3188 case GDK_Q: /* Quit */
3189 BREAK_ON_MODIFIER_KEY();
3191 app_exit_cb(mainwin, 0, NULL);
3194 if (mainwin->folderview && mainwin->summaryview
3195 && !mainwin->summaryview->displayed) {
3196 summary_lock(mainwin->summaryview);
3197 folderview_select_next_unread(mainwin->folderview);
3198 summary_unlock(mainwin->summaryview);
3207 #undef BREAK_ON_MODIFIER_KEY
3210 * Harvest addresses for selected folder.
3212 static void addr_harvest_cb( MainWindow *mainwin,
3216 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3220 * Harvest addresses for selected messages in summary view.
3222 static void addr_harvest_msg_cb( MainWindow *mainwin,
3226 summary_harvest_address( mainwin->summaryview );
3230 *\brief get a MainWindow
3232 *\return MainWindow * The first mainwindow in the mainwin_list
3234 MainWindow *mainwindow_get_mainwindow(void)
3236 if (mainwin_list && mainwin_list->data)
3237 return (MainWindow *)(mainwin_list->data);
3242 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3244 ProgressData *data = (ProgressData *) source;
3245 MainWindow *mainwin = (MainWindow *) userdata;
3247 switch (data->cmd) {
3248 case PROGRESS_COMMAND_START:
3249 case PROGRESS_COMMAND_STOP:
3250 gtk_progress_bar_set_fraction
3251 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3253 case PROGRESS_COMMAND_SET_PERCENTAGE:
3254 gtk_progress_bar_set_fraction
3255 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3258 while (gtk_events_pending()) gtk_main_iteration ();