2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2005 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkwindow.h>
27 #include <gtk/gtkwidget.h>
28 #include <gtk/gtksignal.h>
29 #include <gtk/gtkvbox.h>
30 #include <gtk/gtkcontainer.h>
31 #include <gtk/gtkstatusbar.h>
32 #include <gtk/gtkprogressbar.h>
33 #include <gtk/gtkhpaned.h>
34 #include <gtk/gtkvpaned.h>
35 #include <gtk/gtkcheckmenuitem.h>
36 #include <gtk/gtkitemfactory.h>
37 #include <gtk/gtkeditable.h>
38 #include <gtk/gtkmenu.h>
39 #include <gtk/gtkmenuitem.h>
40 #include <gtk/gtkhandlebox.h>
41 #include <gtk/gtktoolbar.h>
42 #include <gtk/gtkbutton.h>
43 #include <gtk/gtktooltips.h>
47 #include "mainwindow.h"
48 #include "folderview.h"
49 #include "foldersel.h"
50 #include "summaryview.h"
51 #include "summary_search.h"
52 #include "messageview.h"
53 #include "message_search.h"
54 #include "headerview.h"
56 #include "stock_pixmap.h"
63 #include "prefs_common.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "ssl_manager.h"
84 #include "sslcertwindow.h"
85 #include "prefs_gtk.h"
86 #include "pluginwindow.h"
88 #include "progressindicator.h"
89 #include "localfolder.h"
90 #include "filtering.h"
91 #include "folderutils.h"
92 #include "foldersort.h"
94 #define AC_LABEL_WIDTH 240
96 /* list of all instantiated MainWindow */
97 static GList *mainwin_list = NULL;
99 static GdkCursor *watch_cursor;
101 static void main_window_menu_callback_block (MainWindow *mainwin);
102 static void main_window_menu_callback_unblock (MainWindow *mainwin);
104 static void main_window_show_cur_account (MainWindow *mainwin);
106 static void main_window_set_widgets (MainWindow *mainwin,
110 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
111 GdkEventButton *event,
115 static void toolbar_child_attached (GtkWidget *widget,
118 static void toolbar_child_detached (GtkWidget *widget,
122 static gboolean ac_label_button_pressed (GtkWidget *widget,
123 GdkEventButton *event,
125 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
128 static gint main_window_close_cb (GtkWidget *widget,
131 static gint folder_window_close_cb (GtkWidget *widget,
134 static gint message_window_close_cb (GtkWidget *widget,
138 static void main_window_size_allocate_cb (GtkWidget *widget,
139 GtkAllocation *allocation,
141 static void folder_window_size_allocate_cb (GtkWidget *widget,
142 GtkAllocation *allocation,
144 static void message_window_size_allocate_cb (GtkWidget *widget,
145 GtkAllocation *allocation,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void foldersort_cb (MainWindow *mainwin,
157 static void import_mbox_cb (MainWindow *mainwin,
160 static void export_mbox_cb (MainWindow *mainwin,
163 static void export_list_mbox_cb (MainWindow *mainwin,
166 static void empty_trash_cb (MainWindow *mainwin,
170 static void save_as_cb (MainWindow *mainwin,
173 static void print_cb (MainWindow *mainwin,
176 static void app_exit_cb (MainWindow *mainwin,
180 static void search_cb (MainWindow *mainwin,
184 static void toggle_folder_cb (MainWindow *mainwin,
187 static void toggle_message_cb (MainWindow *mainwin,
190 static void toggle_toolbar_cb (MainWindow *mainwin,
193 static void toggle_statusbar_cb (MainWindow *mainwin,
196 static void separate_widget_cb (MainWindow *mainwin,
200 static void addressbook_open_cb (MainWindow *mainwin,
203 static void log_window_show_cb (MainWindow *mainwin,
207 static void inc_cancel_cb (MainWindow *mainwin,
211 static void open_msg_cb (MainWindow *mainwin,
215 static void view_source_cb (MainWindow *mainwin,
219 static void show_all_header_cb (MainWindow *mainwin,
223 static void move_to_cb (MainWindow *mainwin,
226 static void copy_to_cb (MainWindow *mainwin,
229 static void delete_cb (MainWindow *mainwin,
232 static void delete_trash_cb (MainWindow *mainwin,
236 static void cancel_cb (MainWindow *mainwin,
240 static void mark_cb (MainWindow *mainwin,
243 static void unmark_cb (MainWindow *mainwin,
247 static void mark_as_unread_cb (MainWindow *mainwin,
250 static void mark_as_read_cb (MainWindow *mainwin,
253 static void mark_all_read_cb (MainWindow *mainwin,
257 static void reedit_cb (MainWindow *mainwin,
261 static void add_address_cb (MainWindow *mainwin,
265 static void set_charset_cb (MainWindow *mainwin,
269 static void set_decode_cb (MainWindow *mainwin,
273 static void hide_read_messages (MainWindow *mainwin,
277 static void thread_cb (MainWindow *mainwin,
280 static void expand_threads_cb (MainWindow *mainwin,
283 static void collapse_threads_cb (MainWindow *mainwin,
287 static void set_display_item_cb (MainWindow *mainwin,
290 static void sort_summary_cb (MainWindow *mainwin,
293 static void sort_summary_type_cb (MainWindow *mainwin,
296 static void attract_by_subject_cb(MainWindow *mainwin,
300 static void delete_duplicated_cb (MainWindow *mainwin,
303 static void delete_duplicated_all_cb (MainWindow *mainwin,
306 static void filter_cb (MainWindow *mainwin,
309 static void execute_summary_cb (MainWindow *mainwin,
312 static void update_summary_cb (MainWindow *mainwin,
316 static void prev_cb (MainWindow *mainwin,
319 static void next_cb (MainWindow *mainwin,
322 static void next_unread_cb (MainWindow *mainwin,
325 static void prev_unread_cb (MainWindow *mainwin,
329 static void prev_new_cb (MainWindow *mainwin,
332 static void next_new_cb (MainWindow *mainwin,
335 static void prev_marked_cb (MainWindow *mainwin,
338 static void next_marked_cb (MainWindow *mainwin,
341 static void prev_labeled_cb (MainWindow *mainwin,
344 static void next_labeled_cb (MainWindow *mainwin,
348 static void goto_folder_cb (MainWindow *mainwin,
352 static void copy_cb (MainWindow *mainwin,
355 static void allsel_cb (MainWindow *mainwin,
358 static void select_thread_cb (MainWindow *mainwin,
362 static void create_filter_cb (MainWindow *mainwin,
365 static void create_processing_cb (MainWindow *mainwin,
369 static void prefs_template_open_cb (MainWindow *mainwin,
372 static void prefs_actions_open_cb (MainWindow *mainwin,
375 static void prefs_account_open_cb (MainWindow *mainwin,
379 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
383 static void prefs_post_processing_open_cb (MainWindow *mainwin,
387 static void prefs_filtering_open_cb (MainWindow *mainwin,
391 static void ssl_manager_open_cb (MainWindow *mainwin,
395 static void new_account_cb (MainWindow *mainwin,
399 static void account_selector_menu_cb (GtkMenuItem *menuitem,
401 static void account_receive_menu_cb (GtkMenuItem *menuitem,
404 static void prefs_open_cb (GtkMenuItem *menuitem,
406 static void plugins_open_cb (GtkMenuItem *menuitem,
409 static void online_switch_clicked(GtkButton *btn,
412 static void manual_open_cb (MainWindow *mainwin,
416 static void scan_tree_func (Folder *folder,
420 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
422 static void addr_harvest_cb ( MainWindow *mainwin,
426 static void addr_harvest_msg_cb ( MainWindow *mainwin,
430 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
431 GdkEventFocus *focus,
433 void main_window_reply_cb (MainWindow *mainwin,
436 gboolean mainwindow_progressindicator_hook (gpointer source,
438 #define SEPARATE_ACTION 500
439 static void mainwindow_quicksearch (MainWindow *mainwin,
443 static GtkItemFactoryEntry mainwin_entries[] =
445 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
446 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
447 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
448 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
449 {N_("/_File/Change folder order"), NULL, foldersort_cb, 0, NULL},
450 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
451 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
452 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
453 {N_("/_File/Exp_ort selected to mbox file..."),
454 NULL, export_list_mbox_cb, 0, NULL},
455 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
456 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
457 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
459 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
460 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
461 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
462 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
463 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
464 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
466 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
467 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
468 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
469 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
470 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
471 {N_("/_Edit/_Find in current message..."),
472 "<control>F", search_cb, 0, NULL},
473 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
474 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
475 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
476 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
477 {N_("/_View/Show or hi_de/_Folder tree"),
478 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
479 {N_("/_View/Show or hi_de/_Message view"),
480 "V", toggle_message_cb, 0, "<ToggleItem>"},
481 {N_("/_View/Show or hi_de/_Toolbar"),
482 NULL, NULL, 0, "<Branch>"},
483 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
484 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
485 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
486 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
487 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
488 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
489 {N_("/_View/Show or hi_de/_Toolbar/_None"),
490 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
491 {N_("/_View/Show or hi_de/Status _bar"),
492 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
493 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
495 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
496 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
497 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
498 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
499 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
500 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
501 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
502 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
503 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
504 {N_("/_View/_Sort/by _color label"),
505 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
506 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
507 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
508 {N_("/_View/_Sort/by a_ttachment"),
509 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
510 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
511 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
512 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
513 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
515 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
516 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
517 {N_("/_View/_Sort/_Attract by subject"),
518 NULL, attract_by_subject_cb, 0, NULL},
519 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
520 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
521 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
522 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
523 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
525 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
527 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
528 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
529 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_View/_Go to/P_rev unread message"),
531 "<shift>P", prev_unread_cb, 0, NULL},
532 {N_("/_View/_Go to/N_ext unread message"),
533 "<shift>N", next_unread_cb, 0, NULL},
534 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
535 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
536 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
537 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_View/_Go to/Prev _marked message"),
539 NULL, prev_marked_cb, 0, NULL},
540 {N_("/_View/_Go to/Next m_arked message"),
541 NULL, next_marked_cb, 0, NULL},
542 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
543 {N_("/_View/_Go to/Prev _labeled message"),
544 NULL, prev_labeled_cb, 0, NULL},
545 {N_("/_View/_Go to/Next la_beled message"),
546 NULL, next_labeled_cb, 0, NULL},
547 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
549 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
551 #define ENC_SEPARATOR \
552 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
553 #define ENC_ACTION(action) \
554 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
556 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
557 {N_("/_View/Character _encoding/_Auto detect"),
558 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
559 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
561 ENC_ACTION(C_US_ASCII)},
562 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
563 ENC_ACTION(C_UTF_8)},
566 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
567 ENC_ACTION(C_ISO_8859_1)},
568 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
569 ENC_ACTION(C_ISO_8859_15)},
572 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
573 ENC_ACTION(C_ISO_8859_2)},
576 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
577 ENC_ACTION(C_ISO_8859_13)},
578 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
579 ENC_ACTION(C_ISO_8859_4)},
582 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
583 ENC_ACTION(C_ISO_8859_7)},
586 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
587 ENC_ACTION(C_ISO_8859_8)},
588 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
589 ENC_ACTION(C_CP1255)},
592 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
593 ENC_ACTION(C_ISO_8859_9)},
596 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
597 ENC_ACTION(C_ISO_8859_5)},
598 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
599 ENC_ACTION(C_KOI8_R)},
600 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
601 ENC_ACTION(C_KOI8_U)},
602 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
603 ENC_ACTION(C_CP1251)},
606 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
607 ENC_ACTION(C_ISO_2022_JP)},
608 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
609 ENC_ACTION(C_ISO_2022_JP_2)},
610 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
611 ENC_ACTION(C_EUC_JP)},
612 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
613 ENC_ACTION(C_SHIFT_JIS)},
616 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
617 ENC_ACTION(C_GB2312)},
618 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
620 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
622 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
623 ENC_ACTION(C_EUC_TW)},
624 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
625 ENC_ACTION(C_ISO_2022_CN)},
628 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
629 ENC_ACTION(C_EUC_KR)},
630 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
631 ENC_ACTION(C_ISO_2022_KR)},
634 {N_("/_View/Character _encoding/Thai (TIS-620)"),
635 ENC_ACTION(C_TIS_620)},
636 {N_("/_View/Character _encoding/Thai (Windows-874)"),
637 ENC_ACTION(C_WINDOWS_874)},
642 #define DEC_SEPARATOR \
643 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
644 #define DEC_ACTION(action) \
645 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
646 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
647 {N_("/_View/Decode/_Auto detect"),
648 NULL, set_decode_cb, 0, "<RadioItem>"},
649 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
650 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
651 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
652 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
653 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
658 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
660 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
661 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
662 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
663 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
665 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
666 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
667 {N_("/_Message/Recei_ve/Get from _current account"),
668 "<control>I", inc_mail_cb, 0, NULL},
669 {N_("/_Message/Recei_ve/Get from _all accounts"),
670 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
671 {N_("/_Message/Recei_ve/Cancel receivin_g"),
672 NULL, inc_cancel_cb, 0, NULL},
673 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
675 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
676 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
677 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
678 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
679 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
680 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
681 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
682 {N_("/_Message/Repl_y to/mailing _list"),
683 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
684 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
685 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
686 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
687 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
688 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
689 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
690 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
691 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
692 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
693 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
694 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
695 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
696 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
697 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
698 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
700 {N_("/_Message/_Mark/Mark as rea_d"),
701 NULL, mark_as_read_cb, 0, NULL},
702 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
703 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
706 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
708 {N_("/_Tools/Add sender to address boo_k"),
709 NULL, add_address_cb, 0, NULL},
710 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
711 {N_("/_Tools/_Harvest addresses/from _Folder..."),
712 NULL, addr_harvest_cb, 0, NULL},
713 {N_("/_Tools/_Harvest addresses/from _Messages..."),
714 NULL, addr_harvest_msg_cb, 0, NULL},
715 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
716 {N_("/_Tools/_Filter all messages in folder"),
717 NULL, filter_cb, 0, NULL},
718 {N_("/_Tools/Filter _selected messages"),
719 NULL, filter_cb, 1, NULL},
720 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
721 {N_("/_Tools/_Create filter rule/_Automatically"),
722 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
723 {N_("/_Tools/_Create filter rule/by _From"),
724 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
725 {N_("/_Tools/_Create filter rule/by _To"),
726 NULL, create_filter_cb, FILTER_BY_TO, NULL},
727 {N_("/_Tools/_Create filter rule/by _Subject"),
728 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
729 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
730 {N_("/_Tools/C_reate processing rule/_Automatically"),
731 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
732 {N_("/_Tools/C_reate processing rule/by _From"),
733 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
734 {N_("/_Tools/C_reate processing rule/by _To"),
735 NULL, create_processing_cb, FILTER_BY_TO, NULL},
736 {N_("/_Tools/C_reate processing rule/by _Subject"),
737 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
738 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
739 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
740 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
741 {N_("/_Tools/Ch_eck for new messages in all folders"),
742 NULL, update_folderview_cb, 0, NULL},
743 {N_("/_Tools/Delete du_plicated messages"),
744 NULL, NULL, 0, "<Branch>"},
745 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
746 NULL, delete_duplicated_cb, 0, NULL},
747 {N_("/_Tools/Delete du_plicated messages/In all folders"),
748 NULL, delete_duplicated_all_cb, 0, NULL},
749 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
750 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
752 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
753 {N_("/_Tools/SSL cer_tificates..."),
754 NULL, ssl_manager_open_cb, 0, NULL},
756 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
757 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
759 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
760 {N_("/_Configuration/C_hange current account"),
761 NULL, NULL, 0, "<Branch>"},
762 {N_("/_Configuration/_Preferences for current account..."),
763 NULL, prefs_account_open_cb, 0, NULL},
764 {N_("/_Configuration/Create _new account..."),
765 NULL, new_account_cb, 0, NULL},
766 {N_("/_Configuration/_Edit accounts..."),
767 NULL, account_edit_open, 0, NULL},
768 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
769 {N_("/_Configuration/P_references..."),
770 NULL, prefs_open_cb, 0, NULL},
771 {N_("/_Configuration/Pre-pr_ocessing..."),
772 NULL, prefs_pre_processing_open_cb, 0, NULL},
773 {N_("/_Configuration/Post-pro_cessing..."),
774 NULL, prefs_post_processing_open_cb, 0, NULL},
775 {N_("/_Configuration/_Filtering..."),
776 NULL, prefs_filtering_open_cb, 0, NULL},
777 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
778 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
779 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
781 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
782 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
783 {N_("/_Help/Ma_nual (Sylpheed Doc Homepage)"),
784 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
785 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
786 {N_("/_Help/FA_Q (Sylpheed Doc Homepage)"),
787 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
788 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
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;
845 gboolean hide_messageview = FALSE;
847 static GdkGeometry geometry;
849 debug_print("Creating main window...\n");
850 mainwin = g_new0(MainWindow, 1);
853 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
854 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
855 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
857 if (!geometry.min_height) {
858 geometry.min_width = 320;
859 geometry.min_height = 200;
861 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
864 g_signal_connect(G_OBJECT(window), "delete_event",
865 G_CALLBACK(main_window_close_cb), mainwin);
866 MANAGE_WINDOW_SIGNALS_CONNECT(window);
867 g_signal_connect(G_OBJECT(window), "focus_in_event",
868 G_CALLBACK(mainwindow_focus_in_event),
870 g_signal_connect(G_OBJECT(window), "key_press_event",
871 G_CALLBACK(mainwindow_key_pressed), mainwin);
873 gtk_widget_realize(window);
874 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
877 gtkut_widget_set_app_icon(window);
879 vbox = gtk_vbox_new(FALSE, 0);
880 gtk_widget_show(vbox);
881 gtk_container_add(GTK_CONTAINER(window), vbox);
884 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
885 menubar = menubar_create(window, mainwin_entries,
886 n_menu_entries, "<Main>", mainwin);
887 gtk_widget_show(menubar);
888 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
889 ifactory = gtk_item_factory_from_widget(menubar);
891 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
892 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
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 /* link window to mainwin->window to avoid gdk warnings */
903 mainwin->window = window;
906 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
910 /* vbox that contains body */
911 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
912 gtk_widget_show(vbox_body);
913 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
914 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
916 hbox_stat = gtk_hbox_new(FALSE, 2);
917 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
919 statusbar = statusbar_create();
920 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
922 progressbar = gtk_progress_bar_new();
923 gtk_widget_set_size_request(progressbar, 120, 1);
924 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
926 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
927 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
928 online_tip = gtk_tooltips_new();
929 online_switch = gtk_button_new ();
930 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
931 _("You are online. Click the icon to go offline"), NULL);
932 offline_tip = gtk_tooltips_new();
933 offline_switch = gtk_button_new ();
934 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
935 _("You are offline. Click the icon to go online"),
937 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
938 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
939 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
940 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
941 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
942 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
943 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
944 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
946 statuslabel = gtk_label_new("");
947 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
949 sel_ac_tip = gtk_tooltips_new();
950 ac_button = gtk_button_new();
951 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
952 ac_button, _("Select account"), NULL);
953 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
954 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
955 gtk_widget_set_size_request(ac_button, -1, 0);
956 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
957 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
958 G_CALLBACK(ac_label_button_pressed), mainwin);
960 ac_label = gtk_label_new("");
961 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
963 gtk_widget_show_all(hbox_stat);
965 gtk_widget_hide(offline_switch);
967 mainwin->folderview = folderview = folderview_create();
968 mainwin->summaryview = summaryview = summary_create();
969 mainwin->messageview = messageview = messageview_create(mainwin);
970 mainwin->logwin = log_window_create();
972 folderview->mainwin = mainwin;
973 folderview->summaryview = summaryview;
975 summaryview->mainwin = mainwin;
976 summaryview->folderview = folderview;
977 summaryview->messageview = messageview;
978 summaryview->window = window;
980 messageview->statusbar = statusbar;
981 mainwin->vbox = vbox;
982 mainwin->menubar = menubar;
983 mainwin->menu_factory = ifactory;
984 mainwin->handlebox = handlebox;
985 mainwin->vbox_body = vbox_body;
986 mainwin->hbox_stat = hbox_stat;
987 mainwin->statusbar = statusbar;
988 mainwin->progressbar = progressbar;
989 mainwin->statuslabel = statuslabel;
990 mainwin->online_switch = online_switch;
991 mainwin->online_pixmap = online_pixmap;
992 mainwin->offline_pixmap = offline_pixmap;
993 mainwin->ac_button = ac_button;
994 mainwin->ac_label = ac_label;
995 mainwin->offline_switch = offline_switch;
997 /* set context IDs for status bar */
998 mainwin->mainwin_cid = gtk_statusbar_get_context_id
999 (GTK_STATUSBAR(statusbar), "Main Window");
1000 mainwin->folderview_cid = gtk_statusbar_get_context_id
1001 (GTK_STATUSBAR(statusbar), "Folder View");
1002 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1003 (GTK_STATUSBAR(statusbar), "Summary View");
1004 mainwin->messageview_cid = gtk_statusbar_get_context_id
1005 (GTK_STATUSBAR(statusbar), "Message View");
1007 messageview->statusbar_cid = mainwin->messageview_cid;
1009 /* allocate colors for summary view and folder view */
1010 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1011 summaryview->color_marked.blue = (guint16)65535;
1013 summaryview->color_dim.red = summaryview->color_dim.green =
1014 summaryview->color_dim.blue = COLOR_DIM;
1016 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1017 &folderview->color_new);
1019 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1020 &folderview->color_op);
1022 summaryview->color_important.red = 0;
1023 summaryview->color_important.green = 0;
1024 summaryview->color_important.blue = (guint16)65535;
1026 color[0] = summaryview->color_marked;
1027 color[1] = summaryview->color_dim;
1028 color[2] = folderview->color_new;
1029 color[3] = folderview->color_op;
1031 colormap = gdk_window_get_colormap(window->window);
1032 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1033 for (i = 0; i < 4; i++) {
1034 if (success[i] == FALSE)
1035 g_warning("MainWindow: color allocation %d failed\n", i);
1038 debug_print("done.\n");
1040 messageview->visible = prefs_common.msgview_visible;
1041 hide_messageview = !messageview->visible;
1043 main_window_set_widgets(mainwin, type);
1045 g_signal_connect(G_OBJECT(window), "size_allocate",
1046 G_CALLBACK(main_window_size_allocate_cb),
1049 /* set menu items */
1050 menuitem = gtk_item_factory_get_item
1051 (ifactory, "/View/Character encoding/Auto detect");
1052 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1054 switch (prefs_common.toolbar_style) {
1056 menuitem = gtk_item_factory_get_item
1057 (ifactory, "/View/Show or hide/Toolbar/None");
1060 menuitem = gtk_item_factory_get_item
1061 (ifactory, "/View/Show or hide/Toolbar/Icon");
1064 menuitem = gtk_item_factory_get_item
1065 (ifactory, "/View/Show or hide/Toolbar/Text");
1068 menuitem = gtk_item_factory_get_item
1069 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1071 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1073 gtk_widget_hide(mainwin->hbox_stat);
1074 menuitem = gtk_item_factory_get_item
1075 (ifactory, "/View/Show or hide/Status bar");
1076 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1077 prefs_common.show_statusbar);
1079 /* set account selection menu */
1080 ac_menu = gtk_item_factory_get_widget
1081 (ifactory, "/Configuration/Change current account");
1082 g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1083 G_CALLBACK(ac_menu_popup_closed), mainwin);
1084 mainwin->ac_menu = ac_menu;
1086 toolbar_main_set_sensitive(mainwin);
1088 /* create actions menu */
1089 main_window_update_actions_menu(mainwin);
1091 /* attach accel groups to main window */
1092 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1093 gtk_window_add_accel_group \
1095 gtk_item_factory_from_widget(menu)->accel_group); \
1096 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1098 G_CALLBACK(main_window_accel_activate), mainwin);
1101 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1103 /* connect the accelerators for equivalent
1104 menu items in different menus */
1105 menu_connect_identical_items();
1109 /* show main window */
1110 gtk_widget_show(mainwin->window);
1112 /* initialize views */
1113 folderview_init(folderview);
1114 summary_init(summaryview);
1115 messageview_init(messageview);
1116 log_window_init(mainwin->logwin);
1117 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1118 prefs_common.loglength);
1120 sslcertwindow_register_hook();
1122 mainwin->lock_count = 0;
1123 mainwin->menu_lock_count = 0;
1124 mainwin->cursor_count = 0;
1126 mainwin->progressindicator_hook =
1127 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1130 watch_cursor = gdk_cursor_new(GDK_WATCH);
1132 mainwin_list = g_list_append(mainwin_list, mainwin);
1134 /* init work_offline */
1135 if (prefs_common.work_offline)
1136 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1138 if (mainwin->type == SEPARATE_NONE && hide_messageview)
1139 main_window_toggle_message_view(mainwin);
1144 void main_window_destroy(MainWindow *mainwin)
1146 /* TODO : destroy other component */
1147 messageview_destroy(mainwin->messageview);
1148 mainwin->messageview = NULL;
1151 void main_window_update_actions_menu(MainWindow *mainwin)
1153 GtkItemFactory *ifactory;
1155 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1156 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1159 void main_window_cursor_wait(MainWindow *mainwin)
1162 if (mainwin->cursor_count == 0)
1163 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1165 mainwin->cursor_count++;
1170 void main_window_cursor_normal(MainWindow *mainwin)
1172 if (mainwin->cursor_count)
1173 mainwin->cursor_count--;
1175 if (mainwin->cursor_count == 0)
1176 gdk_window_set_cursor(mainwin->window->window, NULL);
1181 /* lock / unlock the user-interface */
1182 void main_window_lock(MainWindow *mainwin)
1184 if (mainwin->lock_count == 0)
1185 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1187 mainwin->lock_count++;
1189 main_window_set_menu_sensitive(mainwin);
1190 toolbar_main_set_sensitive(mainwin);
1193 void main_window_unlock(MainWindow *mainwin)
1195 if (mainwin->lock_count)
1196 mainwin->lock_count--;
1198 main_window_set_menu_sensitive(mainwin);
1199 toolbar_main_set_sensitive(mainwin);
1201 if (mainwin->lock_count == 0)
1202 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1205 static void main_window_menu_callback_block(MainWindow *mainwin)
1207 mainwin->menu_lock_count++;
1210 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1212 if (mainwin->menu_lock_count)
1213 mainwin->menu_lock_count--;
1216 void main_window_reflect_prefs_all(void)
1218 main_window_reflect_prefs_all_real(FALSE);
1221 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1224 MainWindow *mainwin;
1227 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1228 mainwin = (MainWindow *)cur->data;
1230 main_window_show_cur_account(mainwin);
1231 main_window_set_menu_sensitive(mainwin);
1232 toolbar_main_set_sensitive(mainwin);
1235 if (pixmap_theme_changed) {
1236 toolbar_update(TOOLBAR_MAIN, mainwin);
1237 messageview_reflect_prefs_pixmap_theme();
1238 compose_reflect_prefs_pixmap_theme();
1239 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1240 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1242 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1243 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1244 mainwin->online_pixmap);
1245 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1246 gtk_widget_show(pixmap);
1247 mainwin->online_pixmap = pixmap;
1248 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1249 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1250 mainwin->offline_pixmap);
1251 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1252 gtk_widget_show(pixmap);
1253 mainwin->offline_pixmap = pixmap;
1256 headerview_set_visibility(mainwin->messageview->headerview,
1257 prefs_common.display_header_pane);
1259 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1261 summary_redisplay_msg(mainwin->summaryview);
1265 void main_window_set_summary_column(void)
1268 MainWindow *mainwin;
1270 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1271 mainwin = (MainWindow *)cur->data;
1272 summary_set_column_order(mainwin->summaryview);
1276 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1277 GList *account_list)
1279 GList *cur_ac, *cur_item;
1280 GtkWidget *menuitem;
1281 PrefsAccount *ac_prefs;
1283 /* destroy all previous menu item */
1284 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1285 while (cur_item != NULL) {
1286 GList *next = cur_item->next;
1287 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1291 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1292 ac_prefs = (PrefsAccount *)cur_ac->data;
1294 menuitem = gtk_menu_item_new_with_label
1295 (ac_prefs->account_name
1296 ? ac_prefs->account_name : _("Untitled"));
1297 gtk_widget_show(menuitem);
1298 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1299 g_signal_connect(G_OBJECT(menuitem), "activate",
1300 G_CALLBACK(account_selector_menu_cb),
1305 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1306 GList *account_list)
1308 GList *cur_ac, *cur_item;
1310 GtkWidget *menuitem;
1311 PrefsAccount *ac_prefs;
1313 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1314 "/Message/Receive");
1316 /* search for separator */
1317 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1318 cur_item = cur_item->next) {
1319 if (GTK_BIN(cur_item->data)->child == NULL) {
1320 cur_item = cur_item->next;
1325 /* destroy all previous menu item */
1326 while (cur_item != NULL) {
1327 GList *next = cur_item->next;
1328 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1332 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1333 ac_prefs = (PrefsAccount *)cur_ac->data;
1335 menuitem = gtk_menu_item_new_with_label
1336 (ac_prefs->account_name ? ac_prefs->account_name
1338 gtk_widget_show(menuitem);
1339 gtk_menu_append(GTK_MENU(menu), menuitem);
1340 g_signal_connect(G_OBJECT(menuitem), "activate",
1341 G_CALLBACK(account_receive_menu_cb),
1346 void main_window_set_account_menu(GList *account_list)
1349 MainWindow *mainwin;
1351 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1352 mainwin = (MainWindow *)cur->data;
1353 main_window_set_account_selector_menu(mainwin, account_list);
1354 main_window_set_account_receive_menu(mainwin, account_list);
1358 static void main_window_show_cur_account(MainWindow *mainwin)
1363 ac_name = g_strdup(cur_account
1364 ? (cur_account->account_name
1365 ? cur_account->account_name : _("Untitled"))
1369 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1371 buf = g_strdup(PROG_VERSION);
1372 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1375 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1376 gtk_widget_queue_resize(mainwin->ac_button);
1381 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1383 switch (mainwin->type) {
1384 case SEPARATE_FOLDER:
1385 return mainwin->win.sep_folder.folderwin;
1387 return mainwin->win.sep_both.folderwin;
1393 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1395 switch (mainwin->type) {
1396 case SEPARATE_MESSAGE:
1397 return mainwin->win.sep_message.messagewin;
1399 return mainwin->win.sep_both.messagewin;
1405 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1407 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1408 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1409 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1410 GtkWidget *message_wid = mainwin->messageview->vbox;
1412 debug_print("Changing window separation type from %d to %d\n",
1413 mainwin->type, type);
1415 if (mainwin->type == type) return;
1417 /* remove widgets from those containers */
1418 gtk_widget_ref(folder_wid);
1419 gtk_widget_ref(summary_wid);
1420 gtk_widget_ref(message_wid);
1421 gtkut_container_remove
1422 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1423 gtkut_container_remove
1424 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1425 gtkut_container_remove
1426 (GTK_CONTAINER(message_wid->parent), message_wid);
1428 /* clean containers */
1429 switch (mainwin->type) {
1431 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1433 case SEPARATE_FOLDER:
1434 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1435 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1437 case SEPARATE_MESSAGE:
1438 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1439 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1442 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1443 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1447 gtk_widget_hide(mainwin->window);
1448 main_window_set_widgets(mainwin, type);
1449 gtk_widget_show(mainwin->window);
1451 gtk_widget_unref(folder_wid);
1452 gtk_widget_unref(summary_wid);
1453 gtk_widget_unref(message_wid);
1456 void main_window_toggle_message_view(MainWindow *mainwin)
1458 SummaryView *summaryview = mainwin->summaryview;
1459 union CompositeWin *cwin = &mainwin->win;
1460 GtkWidget *vpaned = NULL;
1461 GtkWidget *container = NULL;
1462 GtkWidget *msgwin = NULL;
1464 switch (mainwin->type) {
1466 vpaned = cwin->sep_none.vpaned;
1467 container = cwin->sep_none.hpaned;
1469 case SEPARATE_FOLDER:
1470 vpaned = cwin->sep_folder.vpaned;
1471 container = mainwin->vbox_body;
1473 case SEPARATE_MESSAGE:
1474 msgwin = mainwin->win.sep_message.messagewin;
1477 msgwin = mainwin->win.sep_both.messagewin;
1482 if (GTK_WIDGET_VISIBLE(msgwin)) {
1483 gtk_widget_hide(msgwin);
1484 mainwin->messageview->visible = FALSE;
1485 summaryview->displayed = NULL;
1487 gtk_widget_show(msgwin);
1488 mainwin->messageview->visible = TRUE;
1490 } else if (vpaned->parent != NULL) {
1491 mainwin->messageview->visible = FALSE;
1492 summaryview->displayed = NULL;
1493 gtk_widget_ref(vpaned);
1494 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1495 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1497 mainwin->messageview->visible = TRUE;
1498 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1499 gtk_container_add(GTK_CONTAINER(container), vpaned);
1500 gtk_widget_unref(vpaned);
1503 if (messageview_is_visible(mainwin->messageview))
1504 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1505 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1507 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1508 GTK_ARROW_UP, GTK_SHADOW_OUT);
1510 if (mainwin->messageview->visible == FALSE)
1511 messageview_clear(mainwin->messageview);
1513 main_window_set_menu_sensitive(mainwin);
1515 prefs_common.msgview_visible = mainwin->messageview->visible;
1517 gtk_widget_grab_focus(summaryview->ctree);
1520 void main_window_get_size(MainWindow *mainwin)
1522 GtkAllocation *allocation;
1524 if (mainwin->messageview == NULL) {
1525 debug_print("called after messageview "
1526 "has been deallocated!\n");
1530 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1532 if (allocation->width > 1 && allocation->height > 1) {
1533 prefs_common.summaryview_width = allocation->width;
1535 if ((mainwin->type == SEPARATE_NONE ||
1536 mainwin->type == SEPARATE_FOLDER) &&
1537 messageview_is_visible(mainwin->messageview))
1538 prefs_common.summaryview_height = allocation->height;
1540 prefs_common.mainview_width = allocation->width;
1543 allocation = &mainwin->window->allocation;
1544 if (allocation->width > 1 && allocation->height > 1) {
1545 prefs_common.mainview_height = allocation->height;
1546 prefs_common.mainwin_width = allocation->width;
1547 prefs_common.mainwin_height = allocation->height;
1550 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1551 if (allocation->width > 1 && allocation->height > 1) {
1552 prefs_common.folderview_width = allocation->width;
1553 prefs_common.folderview_height = allocation->height;
1556 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1557 if (allocation->width > 1 && allocation->height > 1) {
1558 prefs_common.msgview_width = allocation->width;
1559 prefs_common.msgview_height = allocation->height;
1562 /* debug_print("summaryview size: %d x %d\n",
1563 prefs_common.summaryview_width,
1564 prefs_common.summaryview_height);
1565 debug_print("folderview size: %d x %d\n",
1566 prefs_common.folderview_width,
1567 prefs_common.folderview_height);
1568 debug_print("messageview size: %d x %d\n",
1569 prefs_common.msgview_width,
1570 prefs_common.msgview_height); */
1573 void main_window_get_position(MainWindow *mainwin)
1578 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1580 prefs_common.mainview_x = x;
1581 prefs_common.mainview_y = y;
1582 prefs_common.mainwin_x = x;
1583 prefs_common.mainwin_y = y;
1585 debug_print("main window position: %d, %d\n", x, y);
1587 window = main_window_get_folder_window(mainwin);
1589 gtkut_widget_get_uposition(window, &x, &y);
1590 prefs_common.folderwin_x = x;
1591 prefs_common.folderwin_y = y;
1592 debug_print("folder window position: %d, %d\n", x, y);
1594 window = main_window_get_message_window(mainwin);
1596 gtkut_widget_get_uposition(window, &x, &y);
1597 prefs_common.main_msgwin_x = x;
1598 prefs_common.main_msgwin_y = y;
1599 debug_print("message window position: %d, %d\n", x, y);
1603 void main_window_progress_on(MainWindow *mainwin)
1605 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1608 void main_window_progress_off(MainWindow *mainwin)
1610 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1611 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1614 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1618 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1619 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1620 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1621 (cur == 0 && total == 0) ? 0 :
1622 (gfloat)cur / (gfloat)total);
1625 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1631 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1632 folder = FOLDER(list->data);
1633 if (folder && folder->trash && folder->trash->total_msgs > 0)
1637 if (!has_trash) return;
1640 if (alertpanel(_("Empty trash"),
1641 _("Empty all messages in trash?"),
1642 GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1645 manage_window_focus_in(mainwin->window, NULL, NULL);
1648 procmsg_empty_all_trash();
1650 if (mainwin->summaryview->folder_item &&
1651 mainwin->summaryview->folder_item->stype == F_TRASH)
1652 gtk_widget_grab_focus(mainwin->folderview->ctree);
1655 void main_window_add_mailbox(MainWindow *mainwin)
1660 path = input_dialog(_("Add mailbox"),
1661 _("Input the location of mailbox.\n"
1662 "If the existing mailbox is specified, it will be\n"
1663 "scanned automatically."),
1666 if (folder_find_from_path(path)) {
1667 alertpanel_error(_("The mailbox '%s' already exists."), path);
1671 folder = folder_new(folder_get_class_from_string("mh"),
1672 !strcmp(path, "Mail") ? _("Mailbox") :
1673 g_path_get_basename(path), path);
1676 if (folder->klass->create_tree(folder) < 0) {
1677 alertpanel_error(_("Creation of the mailbox failed.\n"
1678 "Maybe some files already exist, or you don't have the permission to write there."));
1679 folder_destroy(folder);
1684 folder_set_ui_func(folder, scan_tree_func, mainwin);
1685 folder_scan_tree(folder);
1686 folder_set_ui_func(folder, NULL, NULL);
1689 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1691 SensitiveCond state = 0;
1692 SummarySelection selection;
1693 FolderItem *item = mainwin->summaryview->folder_item;
1694 GList *account_list = account_get_list();
1696 selection = summary_get_selection_type(mainwin->summaryview);
1698 if (mainwin->lock_count == 0)
1699 state |= M_UNLOCKED;
1700 if (selection != SUMMARY_NONE)
1701 state |= M_MSG_EXIST;
1702 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1704 /* if (item->folder->type != F_NEWS) */
1705 state |= M_ALLOW_DELETE;
1707 if (prefs_common.immediate_exec == 0
1708 && mainwin->lock_count == 0)
1709 state |= M_DELAY_EXEC;
1711 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1712 || selection != SUMMARY_NONE)
1713 state |= M_HIDE_READ_MSG;
1715 if (mainwin->summaryview->threaded)
1716 state |= M_THREADED;
1718 state |= M_UNTHREADED;
1719 if (selection == SUMMARY_SELECTED_SINGLE ||
1720 selection == SUMMARY_SELECTED_MULTIPLE)
1721 state |= M_TARGET_EXIST;
1722 if (selection == SUMMARY_SELECTED_SINGLE)
1723 state |= M_SINGLE_TARGET_EXIST;
1724 if (mainwin->summaryview->folder_item &&
1725 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1728 state |= M_NOT_NEWS;
1729 if (selection == SUMMARY_SELECTED_SINGLE &&
1731 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1732 item->stype == F_QUEUE)))
1733 state |= M_ALLOW_REEDIT;
1735 state |= M_HAVE_ACCOUNT;
1737 for ( ; account_list != NULL; account_list = account_list->next) {
1738 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1739 state |= M_HAVE_NEWS_ACCOUNT;
1744 if (inc_is_active())
1745 state |= M_INC_ACTIVE;
1752 void main_window_set_menu_sensitive(MainWindow *mainwin)
1754 GtkItemFactory *ifactory = mainwin->menu_factory;
1755 SensitiveCond state;
1758 GtkWidget *menuitem;
1759 SummaryView *summaryview;
1764 static const struct {
1768 {"/File/Add mailbox" , M_UNLOCKED},
1770 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1771 {"/File/Change folder order" , M_UNLOCKED},
1772 {"/File/Export to mbox file..." , M_UNLOCKED},
1773 {"/File/Empty all Trash folders" , M_UNLOCKED},
1774 {"/File/Work offline" , M_UNLOCKED},
1776 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1777 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1778 /* {"/File/Close" , M_UNLOCKED}, */
1779 {"/File/Exit" , M_UNLOCKED},
1781 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1783 {"/View/Sort" , M_EXEC},
1784 {"/View/Thread view" , M_EXEC},
1785 {"/View/Expand all threads" , M_MSG_EXIST},
1786 {"/View/Collapse all threads" , M_MSG_EXIST},
1787 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1788 {"/View/Go to/Prev message" , M_MSG_EXIST},
1789 {"/View/Go to/Next message" , M_MSG_EXIST},
1790 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1791 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1792 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1793 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1794 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1795 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1796 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1797 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1798 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1800 {"/Message/Receive/Get from current account"
1801 , M_HAVE_ACCOUNT|M_UNLOCKED},
1802 {"/Message/Receive/Get from all accounts"
1803 , M_HAVE_ACCOUNT|M_UNLOCKED},
1804 {"/Message/Receive/Cancel receiving"
1807 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1808 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1809 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1810 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1811 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1812 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1813 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1814 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1815 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1816 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1817 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1818 {"/Message/Mark" , M_TARGET_EXIST},
1819 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1821 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1822 {"/Tools/Harvest addresses" , M_UNLOCKED},
1823 {"/Tools/Harvest addresses/from Folder..."
1824 , M_UNLOCKED|M_MSG_EXIST},
1825 {"/Tools/Harvest addresses/from Messages..."
1826 , M_UNLOCKED|M_MSG_EXIST|M_TARGET_EXIST},
1827 {"/Tools/Harvest addresses" , M_UNLOCKED},
1828 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1829 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1830 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1831 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1832 {"/Tools/Execute" , M_DELAY_EXEC},
1833 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1835 {"/Configuration", M_UNLOCKED},
1840 state = main_window_get_current_state(mainwin);
1842 for (i = 0; entry[i].entry != NULL; i++) {
1843 sensitive = ((entry[i].cond & state) == entry[i].cond);
1844 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1847 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1849 /* search for separator */
1850 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1851 cur_item = cur_item->next) {
1852 if (GTK_BIN(cur_item->data)->child == NULL) {
1853 cur_item = cur_item->next;
1858 for (; cur_item != NULL; cur_item = cur_item->next) {
1859 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1860 (M_UNLOCKED & state) != 0);
1863 main_window_menu_callback_block(mainwin);
1865 #define SET_CHECK_MENU_ACTIVE(path, active) \
1867 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1868 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1871 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1872 messageview_is_visible(mainwin->messageview));
1874 summaryview = mainwin->summaryview;
1875 menu_path = "/View/Sort/Don't sort";
1877 switch (summaryview->sort_key) {
1878 case SORT_BY_NUMBER:
1879 menu_path = "/View/Sort/by number"; break;
1881 menu_path = "/View/Sort/by size"; break;
1883 menu_path = "/View/Sort/by date"; break;
1885 menu_path = "/View/Sort/by from"; break;
1887 menu_path = "/View/Sort/by recipient"; break;
1888 case SORT_BY_SUBJECT:
1889 menu_path = "/View/Sort/by subject"; break;
1891 menu_path = "/View/Sort/by color label"; break;
1893 menu_path = "/View/Sort/by mark"; break;
1894 case SORT_BY_STATUS:
1895 menu_path = "/View/Sort/by status"; break;
1897 menu_path = "/View/Sort/by attachment"; break;
1899 menu_path = "/View/Sort/by score"; break;
1900 case SORT_BY_LOCKED:
1901 menu_path = "/View/Sort/by locked"; break;
1904 menu_path = "/View/Sort/Don't sort"; break;
1906 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1908 if (summaryview->sort_type == SORT_ASCENDING) {
1909 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1911 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1914 if (summaryview->sort_key != SORT_BY_NONE) {
1915 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1916 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1918 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1919 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1922 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1923 mainwin->messageview->mimeview->textview->show_all_headers);
1924 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1926 #undef SET_CHECK_MENU_ACTIVE
1928 main_window_menu_callback_unblock(mainwin);
1931 void main_window_popup(MainWindow *mainwin)
1933 gtkut_window_popup(mainwin->window);
1935 switch (mainwin->type) {
1936 case SEPARATE_FOLDER:
1937 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1939 case SEPARATE_MESSAGE:
1940 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1943 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1944 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1951 void main_window_show(MainWindow *mainwin)
1953 gtk_widget_show(mainwin->window);
1954 gtk_widget_show(mainwin->vbox_body);
1956 gtk_widget_set_uposition(mainwin->window,
1957 prefs_common.mainwin_x,
1958 prefs_common.mainwin_y);
1960 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1961 prefs_common.folderview_width,
1962 prefs_common.folderview_height);
1963 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1964 prefs_common.summaryview_width,
1965 prefs_common.summaryview_height);
1966 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1967 prefs_common.msgview_width,
1968 prefs_common.msgview_height);
1970 if (mainwin->type & SEPARATE_FOLDER) {
1971 GtkWidget *folderwin;
1973 folderwin = main_window_get_folder_window(mainwin);
1974 gtk_widget_show(folderwin);
1975 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1976 prefs_common.folderwin_y);
1979 if (mainwin->type & SEPARATE_MESSAGE) {
1980 GtkWidget *messagewin;
1982 messagewin = main_window_get_message_window(mainwin);
1983 gtk_widget_show(messagewin);
1984 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1985 prefs_common.main_msgwin_y);
1989 void main_window_hide(MainWindow *mainwin)
1991 main_window_get_size(mainwin);
1992 main_window_get_position(mainwin);
1994 gtk_widget_hide(mainwin->window);
1995 gtk_widget_hide(mainwin->vbox_body);
1997 if (mainwin->type & SEPARATE_FOLDER) {
1998 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2001 if (mainwin->type & SEPARATE_MESSAGE) {
2002 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2006 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2008 GtkWidget *folderwin = NULL;
2009 GtkWidget *messagewin = NULL;
2012 GtkWidget *vbox_body = mainwin->vbox_body;
2013 GtkItemFactory *ifactory = mainwin->menu_factory;
2014 GtkWidget *menuitem;
2015 GtkItemFactory *msgview_ifactory;
2017 debug_print("Setting widgets... ");
2019 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2020 prefs_common.folderview_width,
2021 prefs_common.folderview_height);
2022 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2023 prefs_common.summaryview_width,
2024 prefs_common.summaryview_height);
2025 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2026 prefs_common.msgview_width,
2027 prefs_common.msgview_height);
2029 /* create separated window(s) if needed */
2030 if (type & SEPARATE_FOLDER) {
2031 static GdkGeometry folderwin_geometry;
2033 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2034 gtk_window_set_title(GTK_WINDOW(folderwin),
2035 _("Sylpheed - Folder View"));
2037 gtk_window_move(GTK_WINDOW(folderwin),
2038 prefs_common.folderwin_x,
2039 prefs_common.folderwin_y);
2041 if (!folderwin_geometry.min_height) {
2042 folderwin_geometry.min_width = 320;
2043 folderwin_geometry.min_height = 200;
2045 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2046 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2048 gtk_widget_set_size_request(folderwin,
2049 prefs_common.folderview_width,
2050 prefs_common.folderview_height);
2052 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2055 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2056 G_CALLBACK(folder_window_close_cb),
2058 gtk_container_add(GTK_CONTAINER(folderwin),
2059 GTK_WIDGET_PTR(mainwin->folderview));
2060 gtk_widget_realize(folderwin);
2062 if (prefs_common.folderview_visible)
2063 gtk_widget_show(folderwin);
2066 if (type & SEPARATE_MESSAGE) {
2067 static GdkGeometry msgwin_geometry;
2069 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2070 gtk_window_set_title(GTK_WINDOW(messagewin),
2071 _("Sylpheed - Message View"));
2073 gtk_window_move(GTK_WINDOW(messagewin),
2074 prefs_common.main_msgwin_x,
2075 prefs_common.main_msgwin_y);
2077 if (!msgwin_geometry.min_height) {
2078 msgwin_geometry.min_width = 320;
2079 msgwin_geometry.min_height = 200;
2081 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2082 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2084 gtk_widget_set_size_request(messagewin,
2085 prefs_common.msgwin_width,
2086 prefs_common.msgwin_height);
2088 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2090 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2091 G_CALLBACK(message_window_close_cb),
2093 if (messageview_is_visible(mainwin->messageview))
2094 gtk_widget_show(messagewin);
2096 mainwin->messageview->statusbar = mainwin->statusbar;
2097 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2102 hpaned = gtk_hpaned_new();
2103 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2104 gtk_paned_add1(GTK_PANED(hpaned),
2105 GTK_WIDGET_PTR(mainwin->folderview));
2106 gtk_widget_show(hpaned);
2107 gtk_widget_queue_resize(hpaned);
2109 vpaned = gtk_vpaned_new();
2110 if (messageview_is_visible(mainwin->messageview)) {
2111 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2112 gtk_paned_add1(GTK_PANED(vpaned),
2113 GTK_WIDGET_PTR(mainwin->summaryview));
2115 gtk_paned_add2(GTK_PANED(hpaned),
2116 GTK_WIDGET_PTR(mainwin->summaryview));
2117 gtk_widget_ref(vpaned);
2119 gtk_paned_add2(GTK_PANED(vpaned),
2120 GTK_WIDGET_PTR(mainwin->messageview));
2121 gtk_widget_show(vpaned);
2122 gtk_widget_queue_resize(vpaned);
2124 mainwin->win.sep_none.hpaned = hpaned;
2125 mainwin->win.sep_none.vpaned = vpaned;
2127 /* remove headerview if not in prefs */
2128 headerview_set_visibility(mainwin->messageview->headerview,
2129 prefs_common.display_header_pane);
2131 case SEPARATE_FOLDER:
2132 vpaned = gtk_vpaned_new();
2133 if (messageview_is_visible(mainwin->messageview)) {
2134 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2136 gtk_paned_add1(GTK_PANED(vpaned),
2137 GTK_WIDGET_PTR(mainwin->summaryview));
2139 gtk_box_pack_start(GTK_BOX(vbox_body),
2140 GTK_WIDGET_PTR(mainwin->summaryview),
2142 gtk_widget_ref(vpaned);
2144 gtk_paned_add2(GTK_PANED(vpaned),
2145 GTK_WIDGET_PTR(mainwin->messageview));
2146 gtk_widget_show(vpaned);
2147 gtk_widget_queue_resize(vpaned);
2149 mainwin->win.sep_folder.folderwin = folderwin;
2150 mainwin->win.sep_folder.vpaned = vpaned;
2152 /* remove headerview if not in prefs */
2153 headerview_set_visibility(mainwin->messageview->headerview,
2154 prefs_common.display_header_pane);
2157 case SEPARATE_MESSAGE:
2158 hpaned = gtk_hpaned_new();
2159 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2160 gtk_paned_add1(GTK_PANED(hpaned),
2161 GTK_WIDGET_PTR(mainwin->folderview));
2162 gtk_paned_add2(GTK_PANED(hpaned),
2163 GTK_WIDGET_PTR(mainwin->summaryview));
2164 gtk_widget_show(hpaned);
2165 gtk_widget_queue_resize(hpaned);
2166 messageview_add_toolbar(mainwin->messageview, messagewin);
2167 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2168 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2170 mainwin->win.sep_message.messagewin = messagewin;
2171 mainwin->win.sep_message.hpaned = hpaned;
2173 gtk_widget_realize(messagewin);
2174 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2175 gtk_widget_show_all(messagewin);
2176 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2177 mainwin->messageview->handlebox,
2178 prefs_common.toolbar_style);
2182 messageview_add_toolbar(mainwin->messageview, messagewin);
2183 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2184 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2186 gtk_box_pack_start(GTK_BOX(vbox_body),
2187 GTK_WIDGET_PTR(mainwin->summaryview),
2190 mainwin->win.sep_both.folderwin = folderwin;
2191 mainwin->win.sep_both.messagewin = messagewin;
2193 gtk_widget_realize(messagewin);
2194 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2195 gtk_widget_show_all(messagewin);
2196 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2197 mainwin->messageview->handlebox,
2198 prefs_common.toolbar_style);
2203 if (messageview_is_visible(mainwin->messageview))
2204 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2205 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2207 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2208 GTK_ARROW_UP, GTK_SHADOW_OUT);
2210 gtk_window_move(GTK_WINDOW(mainwin->window),
2211 prefs_common.mainwin_x,
2212 prefs_common.mainwin_y);
2214 gtk_widget_queue_resize(vbox_body);
2215 gtk_widget_queue_resize(mainwin->vbox);
2216 gtk_widget_queue_resize(mainwin->window);
2217 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2218 * and mimeview icon list/ctree lose track of their visibility states */
2219 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2220 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2221 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2222 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2223 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2224 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2226 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2228 mainwin->type = type;
2231 /* toggle menu state */
2232 menuitem = gtk_item_factory_get_item
2233 (ifactory, "/View/Show or hide/Folder tree");
2234 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2235 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2236 prefs_common.folderview_visible);
2237 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2238 menuitem = gtk_item_factory_get_item
2239 (ifactory, "/View/Show or hide/Message view");
2240 gtk_check_menu_item_set_active
2241 (GTK_CHECK_MENU_ITEM(menuitem),
2242 messageview_is_visible(mainwin->messageview));
2244 menuitem = gtk_item_factory_get_item
2245 (ifactory, "/View/Separate folder tree");
2246 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2247 ((type & SEPARATE_FOLDER) != 0));
2248 menuitem = gtk_item_factory_get_item
2249 (ifactory, "/View/Separate message view");
2250 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2251 ((type & SEPARATE_MESSAGE) != 0));
2255 (G_OBJECT(folderwin), "size_allocate",
2256 G_CALLBACK(folder_window_size_allocate_cb),
2261 (G_OBJECT(messagewin), "size_allocate",
2262 G_CALLBACK(message_window_size_allocate_cb),
2266 debug_print("done.\n");
2269 void main_window_destroy_all(void)
2271 while (mainwin_list != NULL) {
2272 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2274 /* free toolbar stuff */
2275 toolbar_clear_list(TOOLBAR_MAIN);
2276 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2277 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2279 g_free(mainwin->toolbar);
2282 mainwin_list = g_list_remove(mainwin_list, mainwin);
2284 g_list_free(mainwin_list);
2288 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2289 GdkEventButton *event,
2292 MainWindow *mainwin = (MainWindow *)data;
2294 if (!event) return FALSE;
2295 if (event->button != 3) return FALSE;
2297 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2298 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2301 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2302 menu_button_position, widget,
2303 event->button, event->time);
2309 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2312 gtk_widget_set_size_request(child, 1, -1);
2315 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2318 gtk_widget_set_size_request(child, -1, -1);
2321 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2324 MainWindow *mainwin = (MainWindow *)data;
2326 if (!event) return FALSE;
2328 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2329 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2332 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2333 menu_button_position, widget,
2334 event->button, event->time);
2339 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2341 MainWindow *mainwin = (MainWindow *)data;
2344 button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2345 if (!button) return;
2346 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2347 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2348 manage_window_focus_in(mainwin->window, NULL, NULL);
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_display_item_cb(MainWindow *mainwin, guint action,
2807 prefs_summary_column_open();
2810 static void sort_summary_cb(MainWindow *mainwin, guint action,
2813 FolderItem *item = mainwin->summaryview->folder_item;
2814 GtkWidget *menuitem;
2816 if (mainwin->menu_lock_count) return;
2818 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2819 menuitem = gtk_item_factory_get_item
2820 (mainwin->menu_factory, "/View/Sort/Ascending");
2821 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2822 GTK_CHECK_MENU_ITEM(menuitem)->active
2823 ? SORT_ASCENDING : SORT_DESCENDING);
2824 item->sort_key = action;
2828 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2831 FolderItem *item = mainwin->summaryview->folder_item;
2833 if (mainwin->menu_lock_count) return;
2835 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2836 summary_sort(mainwin->summaryview,
2837 item->sort_key, (FolderSortType)action);
2840 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2843 summary_attract_by_subject(mainwin->summaryview);
2846 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2851 item = folderview_get_selected_item(mainwin->folderview);
2853 main_window_cursor_wait(mainwin);
2854 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2856 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2857 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2859 STATUSBAR_POP(mainwin);
2860 main_window_cursor_normal(mainwin);
2870 static void deldup_all(FolderItem *item, gpointer _data)
2872 struct DelDupsData *data = _data;
2875 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2877 data->dups += result;
2882 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2885 struct DelDupsData data = {0, 0};
2887 folder_func_to_all_folders(deldup_all, &data);
2888 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
2889 "Deleted %d duplicate messages in %d folders.\n",
2891 data.dups, data.folders);
2894 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2896 summary_filter(mainwin->summaryview, (gboolean)action);
2899 static void execute_summary_cb(MainWindow *mainwin, guint action,
2902 summary_execute(mainwin->summaryview);
2905 static void update_summary_cb(MainWindow *mainwin, guint action,
2909 FolderView *folderview = mainwin->folderview;
2911 if (!mainwin->summaryview->folder_item) return;
2912 if (!folderview->opened) return;
2914 folder_update_op_count();
2916 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2917 folderview->opened);
2920 folder_item_scan(fitem);
2921 summary_show(mainwin->summaryview, fitem);
2924 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2926 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2929 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2931 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2934 static void prev_unread_cb(MainWindow *mainwin, guint action,
2937 summary_select_prev_unread(mainwin->summaryview);
2940 static void next_unread_cb(MainWindow *mainwin, guint action,
2943 summary_select_next_unread(mainwin->summaryview);
2946 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2948 summary_select_prev_new(mainwin->summaryview);
2951 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2953 summary_select_next_new(mainwin->summaryview);
2956 static void prev_marked_cb(MainWindow *mainwin, guint action,
2959 summary_select_prev_marked(mainwin->summaryview);
2962 static void next_marked_cb(MainWindow *mainwin, guint action,
2965 summary_select_next_marked(mainwin->summaryview);
2968 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2971 summary_select_prev_labeled(mainwin->summaryview);
2974 static void next_labeled_cb(MainWindow *mainwin, guint action,
2977 summary_select_next_labeled(mainwin->summaryview);
2980 static void goto_folder_cb(MainWindow *mainwin, guint action,
2983 FolderItem *to_folder;
2985 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2988 folderview_select(mainwin->folderview, to_folder);
2991 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2993 messageview_copy_clipboard(mainwin->messageview);
2996 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2998 MessageView *msgview = mainwin->messageview;
3000 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3001 summary_select_all(mainwin->summaryview);
3002 else if (messageview_is_visible(msgview) &&
3003 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3004 messageview_select_all(mainwin->messageview);
3007 static void select_thread_cb(MainWindow *mainwin, guint action,
3010 summary_select_thread(mainwin->summaryview);
3013 static void create_filter_cb(MainWindow *mainwin, guint action,
3016 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3019 static void create_processing_cb(MainWindow *mainwin, guint action,
3022 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3025 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3028 prefs_filtering_open(&pre_global_processing,
3029 _("Processing rules to apply before folder rules"),
3033 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3036 prefs_filtering_open(&post_global_processing,
3037 _("Processing rules to apply after folder rules"),
3041 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3044 prefs_filtering_open(&filtering_rules,
3045 _("Filtering configuration"),
3049 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3052 prefs_template_open();
3055 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3058 prefs_actions_open(mainwin);
3061 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3064 ssl_manager_open(mainwin);
3067 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3071 new_account_cb(mainwin, 0, widget);
3073 account_open(cur_account);
3077 static void new_account_cb(MainWindow *mainwin, guint action,
3080 account_edit_open();
3081 if (!compose_get_compose_list()) account_add();
3084 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3086 cur_account = (PrefsAccount *)data;
3087 main_window_reflect_prefs_all();
3090 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3092 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3093 PrefsAccount *account = (PrefsAccount *)data;
3095 inc_account_mail(mainwin, account);
3098 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3103 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3105 pluginwindow_create();
3108 static void manual_open_cb(MainWindow *mainwin, guint action,
3111 manual_open((ManualType)action);
3114 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3116 MainWindow *mainwin = (MainWindow *)data;
3120 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3121 LOCAL_FOLDER(folder)->rootpath,
3125 str = g_strdup_printf(_("Scanning folder %s ..."),
3126 LOCAL_FOLDER(folder)->rootpath);
3128 STATUSBAR_PUSH(mainwin, str);
3129 STATUSBAR_POP(mainwin);
3133 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3136 SummaryView *summary;
3138 g_return_val_if_fail(data, FALSE);
3139 summary = ((MainWindow *)data)->summaryview;
3140 g_return_val_if_fail(summary, FALSE);
3142 if (GTK_CLIST(summary->ctree)->selection &&
3143 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3146 if (summary->selected != summary->displayed)
3147 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3151 #define BREAK_ON_MODIFIER_KEY() \
3152 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3154 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3157 MainWindow *mainwin = (MainWindow*) data;
3159 if (!mainwin || !event)
3162 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3165 switch (event->keyval) {
3166 case GDK_Q: /* Quit */
3167 BREAK_ON_MODIFIER_KEY();
3169 app_exit_cb(mainwin, 0, NULL);
3172 if (mainwin->folderview && mainwin->summaryview
3173 && !mainwin->summaryview->displayed) {
3174 summary_lock(mainwin->summaryview);
3175 folderview_select_next_unread(mainwin->folderview);
3176 summary_unlock(mainwin->summaryview);
3185 #undef BREAK_ON_MODIFIER_KEY
3188 * Harvest addresses for selected folder.
3190 static void addr_harvest_cb( MainWindow *mainwin,
3194 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3198 * Harvest addresses for selected messages in summary view.
3200 static void addr_harvest_msg_cb( MainWindow *mainwin,
3204 summary_harvest_address( mainwin->summaryview );
3208 *\brief get a MainWindow
3210 *\return MainWindow * The first mainwindow in the mainwin_list
3212 MainWindow *mainwindow_get_mainwindow(void)
3214 if (mainwin_list && mainwin_list->data)
3215 return (MainWindow *)(mainwin_list->data);
3220 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3222 ProgressData *data = (ProgressData *) source;
3223 MainWindow *mainwin = (MainWindow *) userdata;
3225 switch (data->cmd) {
3226 case PROGRESS_COMMAND_START:
3227 case PROGRESS_COMMAND_STOP:
3228 gtk_progress_bar_set_fraction
3229 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3231 case PROGRESS_COMMAND_SET_PERCENTAGE:
3232 gtk_progress_bar_set_fraction
3233 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3236 while (gtk_events_pending()) gtk_main_iteration ();