2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2005 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkwindow.h>
27 #include <gtk/gtkwidget.h>
28 #include <gtk/gtksignal.h>
29 #include <gtk/gtkvbox.h>
30 #include <gtk/gtkcontainer.h>
31 #include <gtk/gtkstatusbar.h>
32 #include <gtk/gtkprogressbar.h>
33 #include <gtk/gtkhpaned.h>
34 #include <gtk/gtkvpaned.h>
35 #include <gtk/gtkcheckmenuitem.h>
36 #include <gtk/gtkitemfactory.h>
37 #include <gtk/gtkeditable.h>
38 #include <gtk/gtkmenu.h>
39 #include <gtk/gtkmenuitem.h>
40 #include <gtk/gtkhandlebox.h>
41 #include <gtk/gtktoolbar.h>
42 #include <gtk/gtkbutton.h>
43 #include <gtk/gtktooltips.h>
47 #include "mainwindow.h"
48 #include "folderview.h"
49 #include "foldersel.h"
50 #include "summaryview.h"
51 #include "summary_search.h"
52 #include "messageview.h"
53 #include "message_search.h"
54 #include "headerview.h"
56 #include "stock_pixmap.h"
63 #include "prefs_common.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
83 #include "ssl_manager.h"
84 #include "sslcertwindow.h"
85 #include "prefs_gtk.h"
86 #include "pluginwindow.h"
88 #include "progressindicator.h"
89 #include "localfolder.h"
90 #include "filtering.h"
91 #include "folderutils.h"
92 #include "foldersort.h"
94 #define AC_LABEL_WIDTH 240
96 /* list of all instantiated MainWindow */
97 static GList *mainwin_list = NULL;
99 static GdkCursor *watch_cursor;
101 static void main_window_menu_callback_block (MainWindow *mainwin);
102 static void main_window_menu_callback_unblock (MainWindow *mainwin);
104 static void main_window_show_cur_account (MainWindow *mainwin);
106 static void main_window_set_widgets (MainWindow *mainwin,
110 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
111 GdkEventButton *event,
115 static void toolbar_child_attached (GtkWidget *widget,
118 static void toolbar_child_detached (GtkWidget *widget,
122 static gboolean ac_label_button_pressed (GtkWidget *widget,
123 GdkEventButton *event,
125 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
128 static gint main_window_close_cb (GtkWidget *widget,
131 static gint folder_window_close_cb (GtkWidget *widget,
134 static gint message_window_close_cb (GtkWidget *widget,
138 static void main_window_size_allocate_cb (GtkWidget *widget,
139 GtkAllocation *allocation,
141 static void folder_window_size_allocate_cb (GtkWidget *widget,
142 GtkAllocation *allocation,
144 static void message_window_size_allocate_cb (GtkWidget *widget,
145 GtkAllocation *allocation,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void foldersort_cb (MainWindow *mainwin,
157 static void import_mbox_cb (MainWindow *mainwin,
160 static void export_mbox_cb (MainWindow *mainwin,
163 static void export_list_mbox_cb (MainWindow *mainwin,
166 static void empty_trash_cb (MainWindow *mainwin,
170 static void save_as_cb (MainWindow *mainwin,
173 static void print_cb (MainWindow *mainwin,
176 static void app_exit_cb (MainWindow *mainwin,
180 static void search_cb (MainWindow *mainwin,
184 static void toggle_folder_cb (MainWindow *mainwin,
187 static void toggle_message_cb (MainWindow *mainwin,
190 static void toggle_toolbar_cb (MainWindow *mainwin,
193 static void toggle_statusbar_cb (MainWindow *mainwin,
196 static void separate_widget_cb (MainWindow *mainwin,
200 static void addressbook_open_cb (MainWindow *mainwin,
203 static void log_window_show_cb (MainWindow *mainwin,
207 static void inc_cancel_cb (MainWindow *mainwin,
211 static void open_msg_cb (MainWindow *mainwin,
215 static void view_source_cb (MainWindow *mainwin,
219 static void show_all_header_cb (MainWindow *mainwin,
223 static void move_to_cb (MainWindow *mainwin,
226 static void copy_to_cb (MainWindow *mainwin,
229 static void delete_cb (MainWindow *mainwin,
233 static void cancel_cb (MainWindow *mainwin,
237 static void mark_cb (MainWindow *mainwin,
240 static void unmark_cb (MainWindow *mainwin,
244 static void mark_as_unread_cb (MainWindow *mainwin,
247 static void mark_as_read_cb (MainWindow *mainwin,
250 static void mark_all_read_cb (MainWindow *mainwin,
254 static void reedit_cb (MainWindow *mainwin,
258 static void add_address_cb (MainWindow *mainwin,
262 static void set_charset_cb (MainWindow *mainwin,
266 static void set_decode_cb (MainWindow *mainwin,
270 static void hide_read_messages (MainWindow *mainwin,
274 static void thread_cb (MainWindow *mainwin,
277 static void expand_threads_cb (MainWindow *mainwin,
280 static void collapse_threads_cb (MainWindow *mainwin,
284 static void set_display_item_cb (MainWindow *mainwin,
287 static void sort_summary_cb (MainWindow *mainwin,
290 static void sort_summary_type_cb (MainWindow *mainwin,
293 static void attract_by_subject_cb(MainWindow *mainwin,
297 static void delete_duplicated_cb (MainWindow *mainwin,
300 static void delete_duplicated_all_cb (MainWindow *mainwin,
303 static void filter_cb (MainWindow *mainwin,
306 static void execute_summary_cb (MainWindow *mainwin,
309 static void update_summary_cb (MainWindow *mainwin,
313 static void prev_cb (MainWindow *mainwin,
316 static void next_cb (MainWindow *mainwin,
319 static void next_unread_cb (MainWindow *mainwin,
322 static void prev_unread_cb (MainWindow *mainwin,
326 static void prev_new_cb (MainWindow *mainwin,
329 static void next_new_cb (MainWindow *mainwin,
332 static void prev_marked_cb (MainWindow *mainwin,
335 static void next_marked_cb (MainWindow *mainwin,
338 static void prev_labeled_cb (MainWindow *mainwin,
341 static void next_labeled_cb (MainWindow *mainwin,
345 static void goto_folder_cb (MainWindow *mainwin,
349 static void copy_cb (MainWindow *mainwin,
352 static void allsel_cb (MainWindow *mainwin,
355 static void select_thread_cb (MainWindow *mainwin,
359 static void create_filter_cb (MainWindow *mainwin,
362 static void create_processing_cb (MainWindow *mainwin,
366 static void prefs_common_open_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
440 static GtkItemFactoryEntry mainwin_entries[] =
442 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
443 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
444 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
445 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
446 {N_("/_File/Change folder order"), NULL, foldersort_cb, 0, NULL},
447 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
448 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
449 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
450 {N_("/_File/_Export selected to mbox file..."),
451 NULL, export_list_mbox_cb, 0, NULL},
452 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
453 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
454 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
455 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
456 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
457 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
459 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
460 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
461 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
463 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
464 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
465 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
466 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
467 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
468 {N_("/_Edit/_Find in current message..."),
469 "<control>F", search_cb, 0, NULL},
470 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
471 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
472 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
473 {N_("/_View/Show or hi_de/_Folder tree"),
474 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
475 {N_("/_View/Show or hi_de/_Message view"),
476 "V", toggle_message_cb, 0, "<ToggleItem>"},
477 {N_("/_View/Show or hi_de/_Toolbar"),
478 NULL, NULL, 0, "<Branch>"},
479 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
480 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
481 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
482 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
483 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
484 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
485 {N_("/_View/Show or hi_de/_Toolbar/_None"),
486 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
487 {N_("/_View/Show or hi_de/Status _bar"),
488 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
489 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
491 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
492 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
494 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
495 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
496 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
497 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
498 {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
499 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
500 {N_("/_View/_Sort/by _color label"),
501 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
502 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
503 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
504 {N_("/_View/_Sort/by a_ttachment"),
505 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
506 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
507 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
508 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
509 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
511 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
512 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_View/_Sort/_Attract by subject"),
514 NULL, attract_by_subject_cb, 0, NULL},
515 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
516 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
517 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
518 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
519 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
521 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
522 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
523 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
524 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
525 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_View/_Go to/P_rev unread message"),
527 "<shift>P", prev_unread_cb, 0, NULL},
528 {N_("/_View/_Go to/N_ext unread message"),
529 "<shift>N", next_unread_cb, 0, NULL},
530 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
532 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
533 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_View/_Go to/Prev _marked message"),
535 NULL, prev_marked_cb, 0, NULL},
536 {N_("/_View/_Go to/Next m_arked message"),
537 NULL, next_marked_cb, 0, NULL},
538 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_View/_Go to/Prev _labeled message"),
540 NULL, prev_labeled_cb, 0, NULL},
541 {N_("/_View/_Go to/Next la_beled message"),
542 NULL, next_labeled_cb, 0, NULL},
543 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
545 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
547 #define ENC_SEPARATOR \
548 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
549 #define ENC_ACTION(action) \
550 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
552 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
553 {N_("/_View/Character _encoding/_Auto detect"),
554 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
555 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
557 ENC_ACTION(C_US_ASCII)},
558 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
559 ENC_ACTION(C_UTF_8)},
562 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
563 ENC_ACTION(C_ISO_8859_1)},
564 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
565 ENC_ACTION(C_ISO_8859_15)},
568 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
569 ENC_ACTION(C_ISO_8859_2)},
572 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
573 ENC_ACTION(C_ISO_8859_13)},
574 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
575 ENC_ACTION(C_ISO_8859_4)},
578 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
579 ENC_ACTION(C_ISO_8859_7)},
582 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
583 ENC_ACTION(C_ISO_8859_9)},
586 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
587 ENC_ACTION(C_ISO_8859_5)},
588 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
589 ENC_ACTION(C_KOI8_R)},
590 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
591 ENC_ACTION(C_KOI8_U)},
592 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
593 ENC_ACTION(C_CP1251)},
596 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
597 ENC_ACTION(C_ISO_2022_JP)},
598 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
599 ENC_ACTION(C_ISO_2022_JP_2)},
600 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
601 ENC_ACTION(C_EUC_JP)},
602 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
603 ENC_ACTION(C_SHIFT_JIS)},
606 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
607 ENC_ACTION(C_GB2312)},
608 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
610 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
611 ENC_ACTION(C_EUC_TW)},
612 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
613 ENC_ACTION(C_ISO_2022_CN)},
616 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
617 ENC_ACTION(C_EUC_KR)},
618 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
619 ENC_ACTION(C_ISO_2022_KR)},
622 {N_("/_View/Character _encoding/Thai (TIS-620)"),
623 ENC_ACTION(C_TIS_620)},
624 {N_("/_View/Character _encoding/Thai (Windows-874)"),
625 ENC_ACTION(C_WINDOWS_874)},
630 #define DEC_SEPARATOR \
631 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
632 #define DEC_ACTION(action) \
633 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
634 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
635 {N_("/_View/Decode/_Auto detect"),
636 NULL, set_decode_cb, 0, "<RadioItem>"},
637 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
639 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
640 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
641 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
646 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
647 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
648 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
649 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
650 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
651 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
653 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
654 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
655 {N_("/_Message/Recei_ve/Get from _current account"),
656 "<control>I", inc_mail_cb, 0, NULL},
657 {N_("/_Message/Recei_ve/Get from _all accounts"),
658 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
659 {N_("/_Message/Recei_ve/Cancel receivin_g"),
660 NULL, inc_cancel_cb, 0, NULL},
661 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
663 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
665 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
666 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
667 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
668 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
669 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
670 {N_("/_Message/Repl_y to/mailing _list"),
671 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
672 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
673 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
675 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
676 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
677 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
678 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
679 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
680 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
681 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
682 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
683 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
684 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
685 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
686 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
687 {N_("/_Message/_Mark/Mark as rea_d"),
688 NULL, mark_as_read_cb, 0, NULL},
689 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
690 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
691 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
693 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
694 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
695 {N_("/_Tools/Add sender to address boo_k"),
696 NULL, add_address_cb, 0, NULL},
697 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
698 {N_("/_Tools/_Harvest addresses/from _Folder..."),
699 NULL, addr_harvest_cb, 0, NULL},
700 {N_("/_Tools/_Harvest addresses/from _Messages..."),
701 NULL, addr_harvest_msg_cb, 0, NULL},
702 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
703 {N_("/_Tools/_Filter all messages in folder"),
704 NULL, filter_cb, 0, NULL},
705 {N_("/_Tools/Filter _selected messages"),
706 NULL, filter_cb, 1, NULL},
707 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
708 {N_("/_Tools/_Create filter rule/_Automatically"),
709 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
710 {N_("/_Tools/_Create filter rule/by _From"),
711 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
712 {N_("/_Tools/_Create filter rule/by _To"),
713 NULL, create_filter_cb, FILTER_BY_TO, NULL},
714 {N_("/_Tools/_Create filter rule/by _Subject"),
715 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
716 {N_("/_Tools/_Create processing rule"), NULL, NULL, 0, "<Branch>"},
717 {N_("/_Tools/_Create processing rule/_Automatically"),
718 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
719 {N_("/_Tools/_Create processing rule/by _From"),
720 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
721 {N_("/_Tools/_Create processing rule/by _To"),
722 NULL, create_processing_cb, FILTER_BY_TO, NULL},
723 {N_("/_Tools/_Create processing rule/by _Subject"),
724 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
725 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
726 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
727 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Tools/_Check for new messages in all folders"),
729 NULL, update_folderview_cb, 0, NULL},
730 {N_("/_Tools/Delete du_plicated messages"),
731 NULL, NULL, 0, "<Branch>"},
732 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
733 NULL, delete_duplicated_cb, 0, NULL},
734 {N_("/_Tools/Delete du_plicated messages/In all folders"),
735 NULL, delete_duplicated_all_cb, 0, NULL},
736 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
737 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
739 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
740 {N_("/_Tools/SSL certi_ficates..."),
741 NULL, ssl_manager_open_cb, 0, NULL},
743 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
744 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
746 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Configuration/C_hange current account"),
748 NULL, NULL, 0, "<Branch>"},
749 {N_("/_Configuration/_Preferences for current account..."),
750 NULL, prefs_account_open_cb, 0, NULL},
751 {N_("/_Configuration/Create _new account..."),
752 NULL, new_account_cb, 0, NULL},
753 {N_("/_Configuration/_Edit accounts..."),
754 NULL, account_edit_open, 0, NULL},
755 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
756 {N_("/_Configuration/_Preferences..."),
757 NULL, prefs_open_cb, 0, NULL},
758 {N_("/_Configuration/Pre-processing..."),
759 NULL, prefs_pre_processing_open_cb, 0, NULL},
760 {N_("/_Configuration/Post-processing..."),
761 NULL, prefs_post_processing_open_cb, 0, NULL},
762 {N_("/_Configuration/_Filtering..."),
763 NULL, prefs_filtering_open_cb, 0, NULL},
764 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
765 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
766 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
768 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
769 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
770 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
771 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
772 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
773 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
774 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
775 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
776 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
777 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
778 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
781 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
787 MainWindow *mainwin = (MainWindow *)user_data;
789 if (mainwin->summaryview &&
790 mainwin->summaryview->quicksearch &&
791 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
792 (mod == 0 || mod == GDK_SHIFT_MASK)) {
793 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
799 MainWindow *main_window_create(SeparateType type)
805 GtkWidget *handlebox;
806 GtkWidget *vbox_body;
807 GtkWidget *hbox_stat;
808 GtkWidget *statusbar;
809 GtkWidget *progressbar;
810 GtkWidget *statuslabel;
811 GtkWidget *ac_button;
813 GtkWidget *online_pixmap;
814 GtkWidget *offline_pixmap;
815 GtkWidget *online_switch;
816 GtkWidget *offline_switch;
817 GtkTooltips *offline_tip;
818 GtkTooltips *online_tip;
819 GtkTooltips *sel_ac_tip;
821 FolderView *folderview;
822 SummaryView *summaryview;
823 MessageView *messageview;
824 GdkColormap *colormap;
827 GtkItemFactory *ifactory;
831 guint n_menu_entries;
832 gboolean hide_messageview = FALSE;
834 static GdkGeometry geometry;
836 debug_print("Creating main window...\n");
837 mainwin = g_new0(MainWindow, 1);
840 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
841 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
842 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
844 if (!geometry.min_height) {
845 geometry.min_width = 320;
846 geometry.min_height = 200;
848 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
851 g_signal_connect(G_OBJECT(window), "delete_event",
852 G_CALLBACK(main_window_close_cb), mainwin);
853 MANAGE_WINDOW_SIGNALS_CONNECT(window);
854 g_signal_connect(G_OBJECT(window), "focus_in_event",
855 G_CALLBACK(mainwindow_focus_in_event),
857 g_signal_connect(G_OBJECT(window), "key_press_event",
858 G_CALLBACK(mainwindow_key_pressed), mainwin);
860 gtk_widget_realize(window);
861 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
864 gtkut_widget_set_app_icon(window);
866 vbox = gtk_vbox_new(FALSE, 0);
867 gtk_widget_show(vbox);
868 gtk_container_add(GTK_CONTAINER(window), vbox);
871 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
872 menubar = menubar_create(window, mainwin_entries,
873 n_menu_entries, "<Main>", mainwin);
874 gtk_widget_show(menubar);
875 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
876 ifactory = gtk_item_factory_from_widget(menubar);
878 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
879 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
881 handlebox = gtk_handle_box_new();
882 gtk_widget_show(handlebox);
883 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
884 g_signal_connect(G_OBJECT(handlebox), "child_attached",
885 G_CALLBACK(toolbar_child_attached), mainwin);
886 g_signal_connect(G_OBJECT(handlebox), "child_detached",
887 G_CALLBACK(toolbar_child_detached), mainwin);
889 /* link window to mainwin->window to avoid gdk warnings */
890 mainwin->window = window;
893 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
897 /* vbox that contains body */
898 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
899 gtk_widget_show(vbox_body);
900 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
901 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
903 hbox_stat = gtk_hbox_new(FALSE, 2);
904 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
906 statusbar = statusbar_create();
907 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
909 progressbar = gtk_progress_bar_new();
910 gtk_widget_set_size_request(progressbar, 120, 1);
911 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
913 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
914 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
915 online_tip = gtk_tooltips_new();
916 online_switch = gtk_button_new ();
917 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
918 _("You are online. Click the icon to go offline"), NULL);
919 offline_tip = gtk_tooltips_new();
920 offline_switch = gtk_button_new ();
921 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
922 _("You are offline. Click the icon to go online"),
924 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
925 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
926 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
927 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
928 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
929 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
930 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
931 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
933 statuslabel = gtk_label_new("");
934 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
936 sel_ac_tip = gtk_tooltips_new();
937 ac_button = gtk_button_new();
938 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
939 ac_button, _("Select account"), NULL);
940 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
941 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
942 gtk_widget_set_size_request(ac_button, -1, 0);
943 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
944 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
945 G_CALLBACK(ac_label_button_pressed), mainwin);
947 ac_label = gtk_label_new("");
948 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
950 gtk_widget_show_all(hbox_stat);
952 gtk_widget_hide(offline_switch);
954 mainwin->folderview = folderview = folderview_create();
955 mainwin->summaryview = summaryview = summary_create();
956 mainwin->messageview = messageview = messageview_create(mainwin);
957 mainwin->logwin = log_window_create();
959 folderview->mainwin = mainwin;
960 folderview->summaryview = summaryview;
962 summaryview->mainwin = mainwin;
963 summaryview->folderview = folderview;
964 summaryview->messageview = messageview;
965 summaryview->window = window;
967 messageview->statusbar = statusbar;
968 mainwin->vbox = vbox;
969 mainwin->menubar = menubar;
970 mainwin->menu_factory = ifactory;
971 mainwin->handlebox = handlebox;
972 mainwin->vbox_body = vbox_body;
973 mainwin->hbox_stat = hbox_stat;
974 mainwin->statusbar = statusbar;
975 mainwin->progressbar = progressbar;
976 mainwin->statuslabel = statuslabel;
977 mainwin->online_switch = online_switch;
978 mainwin->online_pixmap = online_pixmap;
979 mainwin->offline_pixmap = offline_pixmap;
980 mainwin->ac_button = ac_button;
981 mainwin->ac_label = ac_label;
982 mainwin->offline_switch = offline_switch;
984 /* set context IDs for status bar */
985 mainwin->mainwin_cid = gtk_statusbar_get_context_id
986 (GTK_STATUSBAR(statusbar), "Main Window");
987 mainwin->folderview_cid = gtk_statusbar_get_context_id
988 (GTK_STATUSBAR(statusbar), "Folder View");
989 mainwin->summaryview_cid = gtk_statusbar_get_context_id
990 (GTK_STATUSBAR(statusbar), "Summary View");
991 mainwin->messageview_cid = gtk_statusbar_get_context_id
992 (GTK_STATUSBAR(statusbar), "Message View");
994 messageview->statusbar_cid = mainwin->messageview_cid;
996 /* allocate colors for summary view and folder view */
997 summaryview->color_marked.red = summaryview->color_marked.green = 0;
998 summaryview->color_marked.blue = (guint16)65535;
1000 summaryview->color_dim.red = summaryview->color_dim.green =
1001 summaryview->color_dim.blue = COLOR_DIM;
1003 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1004 &folderview->color_new);
1006 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1007 &folderview->color_op);
1009 summaryview->color_important.red = 0;
1010 summaryview->color_important.green = 0;
1011 summaryview->color_important.blue = (guint16)65535;
1013 color[0] = summaryview->color_marked;
1014 color[1] = summaryview->color_dim;
1015 color[2] = folderview->color_new;
1016 color[3] = folderview->color_op;
1018 colormap = gdk_window_get_colormap(window->window);
1019 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1020 for (i = 0; i < 4; i++) {
1021 if (success[i] == FALSE)
1022 g_warning("MainWindow: color allocation %d failed\n", i);
1025 debug_print("done.\n");
1027 messageview->visible = prefs_common.msgview_visible;
1028 hide_messageview = !messageview->visible;
1030 main_window_set_widgets(mainwin, type);
1032 g_signal_connect(G_OBJECT(window), "size_allocate",
1033 G_CALLBACK(main_window_size_allocate_cb),
1036 /* set menu items */
1037 menuitem = gtk_item_factory_get_item
1038 (ifactory, "/View/Character encoding/Auto detect");
1039 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1041 switch (prefs_common.toolbar_style) {
1043 menuitem = gtk_item_factory_get_item
1044 (ifactory, "/View/Show or hide/Toolbar/None");
1047 menuitem = gtk_item_factory_get_item
1048 (ifactory, "/View/Show or hide/Toolbar/Icon");
1051 menuitem = gtk_item_factory_get_item
1052 (ifactory, "/View/Show or hide/Toolbar/Text");
1055 menuitem = gtk_item_factory_get_item
1056 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1058 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1060 gtk_widget_hide(mainwin->hbox_stat);
1061 menuitem = gtk_item_factory_get_item
1062 (ifactory, "/View/Show or hide/Status bar");
1063 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1064 prefs_common.show_statusbar);
1066 /* set account selection menu */
1067 ac_menu = gtk_item_factory_get_widget
1068 (ifactory, "/Configuration/Change current account");
1069 g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1070 G_CALLBACK(ac_menu_popup_closed), mainwin);
1071 mainwin->ac_menu = ac_menu;
1073 toolbar_main_set_sensitive(mainwin);
1075 /* create actions menu */
1076 main_window_update_actions_menu(mainwin);
1078 /* attach accel groups to main window */
1079 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1080 gtk_window_add_accel_group \
1082 gtk_item_factory_from_widget(menu)->accel_group); \
1083 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1085 G_CALLBACK(main_window_accel_activate), mainwin);
1088 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1090 /* connect the accelerators for equivalent
1091 menu items in different menus */
1092 menu_connect_identical_items();
1096 /* show main window */
1097 gtk_widget_show(mainwin->window);
1099 /* initialize views */
1100 folderview_init(folderview);
1101 summary_init(summaryview);
1102 messageview_init(messageview);
1103 log_window_init(mainwin->logwin);
1104 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1105 prefs_common.loglength);
1107 sslcertwindow_register_hook();
1109 mainwin->lock_count = 0;
1110 mainwin->menu_lock_count = 0;
1111 mainwin->cursor_count = 0;
1113 mainwin->progressindicator_hook =
1114 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1117 watch_cursor = gdk_cursor_new(GDK_WATCH);
1119 mainwin_list = g_list_append(mainwin_list, mainwin);
1121 /* init work_offline */
1122 if (prefs_common.work_offline)
1123 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1125 if (mainwin->type == SEPARATE_NONE && hide_messageview)
1126 main_window_toggle_message_view(mainwin);
1131 void main_window_destroy(MainWindow *mainwin)
1133 /* TODO : destroy other component */
1134 messageview_destroy(mainwin->messageview);
1135 mainwin->messageview = NULL;
1138 void main_window_update_actions_menu(MainWindow *mainwin)
1140 GtkItemFactory *ifactory;
1142 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1143 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1146 void main_window_cursor_wait(MainWindow *mainwin)
1149 if (mainwin->cursor_count == 0)
1150 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1152 mainwin->cursor_count++;
1157 void main_window_cursor_normal(MainWindow *mainwin)
1159 if (mainwin->cursor_count)
1160 mainwin->cursor_count--;
1162 if (mainwin->cursor_count == 0)
1163 gdk_window_set_cursor(mainwin->window->window, NULL);
1168 /* lock / unlock the user-interface */
1169 void main_window_lock(MainWindow *mainwin)
1171 if (mainwin->lock_count == 0)
1172 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1174 mainwin->lock_count++;
1176 main_window_set_menu_sensitive(mainwin);
1177 toolbar_main_set_sensitive(mainwin);
1180 void main_window_unlock(MainWindow *mainwin)
1182 if (mainwin->lock_count)
1183 mainwin->lock_count--;
1185 main_window_set_menu_sensitive(mainwin);
1186 toolbar_main_set_sensitive(mainwin);
1188 if (mainwin->lock_count == 0)
1189 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1192 static void main_window_menu_callback_block(MainWindow *mainwin)
1194 mainwin->menu_lock_count++;
1197 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1199 if (mainwin->menu_lock_count)
1200 mainwin->menu_lock_count--;
1203 void main_window_reflect_prefs_all(void)
1205 main_window_reflect_prefs_all_real(FALSE);
1208 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1211 MainWindow *mainwin;
1214 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1215 mainwin = (MainWindow *)cur->data;
1217 main_window_show_cur_account(mainwin);
1218 main_window_set_menu_sensitive(mainwin);
1219 toolbar_main_set_sensitive(mainwin);
1222 if (pixmap_theme_changed) {
1223 toolbar_update(TOOLBAR_MAIN, mainwin);
1224 messageview_reflect_prefs_pixmap_theme();
1225 compose_reflect_prefs_pixmap_theme();
1226 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1227 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1229 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1230 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1231 mainwin->online_pixmap);
1232 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1233 gtk_widget_show(pixmap);
1234 mainwin->online_pixmap = pixmap;
1235 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1236 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1237 mainwin->offline_pixmap);
1238 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1239 gtk_widget_show(pixmap);
1240 mainwin->offline_pixmap = pixmap;
1243 summary_redisplay_msg(mainwin->summaryview);
1244 headerview_set_visibility(mainwin->messageview->headerview,
1245 prefs_common.display_header_pane);
1249 void main_window_set_summary_column(void)
1252 MainWindow *mainwin;
1254 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1255 mainwin = (MainWindow *)cur->data;
1256 summary_set_column_order(mainwin->summaryview);
1260 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1261 GList *account_list)
1263 GList *cur_ac, *cur_item;
1264 GtkWidget *menuitem;
1265 PrefsAccount *ac_prefs;
1267 /* destroy all previous menu item */
1268 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1269 while (cur_item != NULL) {
1270 GList *next = cur_item->next;
1271 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1275 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1276 ac_prefs = (PrefsAccount *)cur_ac->data;
1278 menuitem = gtk_menu_item_new_with_label
1279 (ac_prefs->account_name
1280 ? ac_prefs->account_name : _("Untitled"));
1281 gtk_widget_show(menuitem);
1282 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1283 g_signal_connect(G_OBJECT(menuitem), "activate",
1284 G_CALLBACK(account_selector_menu_cb),
1289 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1290 GList *account_list)
1292 GList *cur_ac, *cur_item;
1294 GtkWidget *menuitem;
1295 PrefsAccount *ac_prefs;
1297 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1298 "/Message/Receive");
1300 /* search for separator */
1301 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1302 cur_item = cur_item->next) {
1303 if (GTK_BIN(cur_item->data)->child == NULL) {
1304 cur_item = cur_item->next;
1309 /* destroy all previous menu item */
1310 while (cur_item != NULL) {
1311 GList *next = cur_item->next;
1312 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1316 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1317 ac_prefs = (PrefsAccount *)cur_ac->data;
1319 menuitem = gtk_menu_item_new_with_label
1320 (ac_prefs->account_name ? ac_prefs->account_name
1322 gtk_widget_show(menuitem);
1323 gtk_menu_append(GTK_MENU(menu), menuitem);
1324 g_signal_connect(G_OBJECT(menuitem), "activate",
1325 G_CALLBACK(account_receive_menu_cb),
1330 void main_window_set_account_menu(GList *account_list)
1333 MainWindow *mainwin;
1335 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1336 mainwin = (MainWindow *)cur->data;
1337 main_window_set_account_selector_menu(mainwin, account_list);
1338 main_window_set_account_receive_menu(mainwin, account_list);
1342 static void main_window_show_cur_account(MainWindow *mainwin)
1347 ac_name = g_strdup(cur_account
1348 ? (cur_account->account_name
1349 ? cur_account->account_name : _("Untitled"))
1353 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1355 buf = g_strdup(PROG_VERSION);
1356 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1359 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1360 gtk_widget_queue_resize(mainwin->ac_button);
1365 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1367 switch (mainwin->type) {
1368 case SEPARATE_FOLDER:
1369 return mainwin->win.sep_folder.folderwin;
1371 return mainwin->win.sep_both.folderwin;
1377 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1379 switch (mainwin->type) {
1380 case SEPARATE_MESSAGE:
1381 return mainwin->win.sep_message.messagewin;
1383 return mainwin->win.sep_both.messagewin;
1389 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1391 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1392 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1393 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1394 GtkWidget *message_wid = mainwin->messageview->vbox;
1396 debug_print("Changing window separation type from %d to %d\n",
1397 mainwin->type, type);
1399 if (mainwin->type == type) return;
1401 /* remove widgets from those containers */
1402 gtk_widget_ref(folder_wid);
1403 gtk_widget_ref(summary_wid);
1404 gtk_widget_ref(message_wid);
1405 gtkut_container_remove
1406 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1407 gtkut_container_remove
1408 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1409 gtkut_container_remove
1410 (GTK_CONTAINER(message_wid->parent), message_wid);
1412 /* clean containers */
1413 switch (mainwin->type) {
1415 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1417 case SEPARATE_FOLDER:
1418 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1419 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1421 case SEPARATE_MESSAGE:
1422 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1423 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1426 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1427 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1431 gtk_widget_hide(mainwin->window);
1432 main_window_set_widgets(mainwin, type);
1433 gtk_widget_show(mainwin->window);
1435 gtk_widget_unref(folder_wid);
1436 gtk_widget_unref(summary_wid);
1437 gtk_widget_unref(message_wid);
1440 void main_window_toggle_message_view(MainWindow *mainwin)
1442 SummaryView *summaryview = mainwin->summaryview;
1443 union CompositeWin *cwin = &mainwin->win;
1444 GtkWidget *vpaned = NULL;
1445 GtkWidget *container = NULL;
1446 GtkWidget *msgwin = NULL;
1448 switch (mainwin->type) {
1450 vpaned = cwin->sep_none.vpaned;
1451 container = cwin->sep_none.hpaned;
1453 case SEPARATE_FOLDER:
1454 vpaned = cwin->sep_folder.vpaned;
1455 container = mainwin->vbox_body;
1457 case SEPARATE_MESSAGE:
1458 msgwin = mainwin->win.sep_message.messagewin;
1461 msgwin = mainwin->win.sep_both.messagewin;
1466 if (GTK_WIDGET_VISIBLE(msgwin)) {
1467 gtk_widget_hide(msgwin);
1468 mainwin->messageview->visible = FALSE;
1469 summaryview->displayed = NULL;
1471 gtk_widget_show(msgwin);
1472 mainwin->messageview->visible = TRUE;
1474 } else if (vpaned->parent != NULL) {
1475 mainwin->messageview->visible = FALSE;
1476 summaryview->displayed = NULL;
1477 gtk_widget_ref(vpaned);
1478 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1479 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1481 mainwin->messageview->visible = TRUE;
1482 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1483 gtk_container_add(GTK_CONTAINER(container), vpaned);
1484 gtk_widget_unref(vpaned);
1487 if (messageview_is_visible(mainwin->messageview))
1488 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1489 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1491 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1492 GTK_ARROW_UP, GTK_SHADOW_OUT);
1494 if (mainwin->messageview->visible == FALSE)
1495 messageview_clear(mainwin->messageview);
1497 main_window_set_menu_sensitive(mainwin);
1499 prefs_common.msgview_visible = mainwin->messageview->visible;
1501 gtk_widget_grab_focus(summaryview->ctree);
1504 void main_window_get_size(MainWindow *mainwin)
1506 GtkAllocation *allocation;
1508 if (mainwin->messageview == NULL) {
1509 debug_print("called after messageview "
1510 "has been deallocated!\n");
1514 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1516 if (allocation->width > 1 && allocation->height > 1) {
1517 prefs_common.summaryview_width = allocation->width;
1519 if ((mainwin->type == SEPARATE_NONE ||
1520 mainwin->type == SEPARATE_FOLDER) &&
1521 messageview_is_visible(mainwin->messageview))
1522 prefs_common.summaryview_height = allocation->height;
1524 prefs_common.mainview_width = allocation->width;
1527 allocation = &mainwin->window->allocation;
1528 if (allocation->width > 1 && allocation->height > 1) {
1529 prefs_common.mainview_height = allocation->height;
1530 prefs_common.mainwin_width = allocation->width;
1531 prefs_common.mainwin_height = allocation->height;
1534 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1535 if (allocation->width > 1 && allocation->height > 1) {
1536 prefs_common.folderview_width = allocation->width;
1537 prefs_common.folderview_height = allocation->height;
1540 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1541 if (allocation->width > 1 && allocation->height > 1) {
1542 prefs_common.msgview_width = allocation->width;
1543 prefs_common.msgview_height = allocation->height;
1546 /* debug_print("summaryview size: %d x %d\n",
1547 prefs_common.summaryview_width,
1548 prefs_common.summaryview_height);
1549 debug_print("folderview size: %d x %d\n",
1550 prefs_common.folderview_width,
1551 prefs_common.folderview_height);
1552 debug_print("messageview size: %d x %d\n",
1553 prefs_common.msgview_width,
1554 prefs_common.msgview_height); */
1557 void main_window_get_position(MainWindow *mainwin)
1562 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1564 prefs_common.mainview_x = x;
1565 prefs_common.mainview_y = y;
1566 prefs_common.mainwin_x = x;
1567 prefs_common.mainwin_y = y;
1569 debug_print("main window position: %d, %d\n", x, y);
1571 window = main_window_get_folder_window(mainwin);
1573 gtkut_widget_get_uposition(window, &x, &y);
1574 prefs_common.folderwin_x = x;
1575 prefs_common.folderwin_y = y;
1576 debug_print("folder window position: %d, %d\n", x, y);
1578 window = main_window_get_message_window(mainwin);
1580 gtkut_widget_get_uposition(window, &x, &y);
1581 prefs_common.main_msgwin_x = x;
1582 prefs_common.main_msgwin_y = y;
1583 debug_print("message window position: %d, %d\n", x, y);
1587 void main_window_progress_on(MainWindow *mainwin)
1589 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1592 void main_window_progress_off(MainWindow *mainwin)
1594 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1595 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1598 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1602 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1603 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1604 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1605 (cur == 0 && total == 0) ? 0 :
1606 (gfloat)cur / (gfloat)total);
1609 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1615 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1616 folder = FOLDER(list->data);
1617 if (folder && folder->trash && folder->trash->total_msgs > 0)
1621 if (!has_trash) return;
1624 if (alertpanel(_("Empty trash"),
1625 _("Empty all messages in trash?"),
1626 GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1629 manage_window_focus_in(mainwin->window, NULL, NULL);
1632 procmsg_empty_all_trash();
1634 if (mainwin->summaryview->folder_item &&
1635 mainwin->summaryview->folder_item->stype == F_TRASH)
1636 gtk_widget_grab_focus(mainwin->folderview->ctree);
1639 void main_window_add_mailbox(MainWindow *mainwin)
1644 path = input_dialog(_("Add mailbox"),
1645 _("Input the location of mailbox.\n"
1646 "If the existing mailbox is specified, it will be\n"
1647 "scanned automatically."),
1650 if (folder_find_from_path(path)) {
1651 alertpanel_error(_("The mailbox `%s' already exists."), path);
1655 folder = folder_new(folder_get_class_from_string("mh"),
1656 !strcmp(path, "Mail") ? _("Mailbox") :
1657 g_path_get_basename(path), path);
1660 if (folder->klass->create_tree(folder) < 0) {
1661 alertpanel_error(_("Creation of the mailbox failed.\n"
1662 "Maybe some files already exist, or you don't have the permission to write there."));
1663 folder_destroy(folder);
1668 folder_set_ui_func(folder, scan_tree_func, mainwin);
1669 folder_scan_tree(folder);
1670 folder_set_ui_func(folder, NULL, NULL);
1673 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1675 SensitiveCond state = 0;
1676 SummarySelection selection;
1677 FolderItem *item = mainwin->summaryview->folder_item;
1678 GList *account_list = account_get_list();
1680 selection = summary_get_selection_type(mainwin->summaryview);
1682 if (mainwin->lock_count == 0)
1683 state |= M_UNLOCKED;
1684 if (selection != SUMMARY_NONE)
1685 state |= M_MSG_EXIST;
1686 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1688 /* if (item->folder->type != F_NEWS) */
1689 state |= M_ALLOW_DELETE;
1691 if (prefs_common.immediate_exec == 0
1692 && mainwin->lock_count == 0)
1693 state |= M_DELAY_EXEC;
1695 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1696 || selection != SUMMARY_NONE)
1697 state |= M_HIDE_READ_MSG;
1699 if (mainwin->summaryview->threaded)
1700 state |= M_THREADED;
1702 state |= M_UNTHREADED;
1703 if (selection == SUMMARY_SELECTED_SINGLE ||
1704 selection == SUMMARY_SELECTED_MULTIPLE)
1705 state |= M_TARGET_EXIST;
1706 if (selection == SUMMARY_SELECTED_SINGLE)
1707 state |= M_SINGLE_TARGET_EXIST;
1708 if (mainwin->summaryview->folder_item &&
1709 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1712 state |= M_NOT_NEWS;
1713 if (selection == SUMMARY_SELECTED_SINGLE &&
1715 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1716 item->stype == F_QUEUE)))
1717 state |= M_ALLOW_REEDIT;
1719 state |= M_HAVE_ACCOUNT;
1721 for ( ; account_list != NULL; account_list = account_list->next) {
1722 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1723 state |= M_HAVE_NEWS_ACCOUNT;
1728 if (inc_is_active())
1729 state |= M_INC_ACTIVE;
1736 void main_window_set_menu_sensitive(MainWindow *mainwin)
1738 GtkItemFactory *ifactory = mainwin->menu_factory;
1739 SensitiveCond state;
1742 GtkWidget *menuitem;
1743 SummaryView *summaryview;
1748 static const struct {
1752 {"/File/Add mailbox" , M_UNLOCKED},
1754 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1755 {"/File/Change folder order" , M_UNLOCKED},
1756 {"/File/Export to mbox file..." , M_UNLOCKED},
1757 {"/File/Empty all Trash folders" , M_UNLOCKED},
1758 {"/File/Work offline" , M_UNLOCKED},
1760 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1761 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1762 /* {"/File/Close" , M_UNLOCKED}, */
1763 {"/File/Exit" , M_UNLOCKED},
1765 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1767 {"/View/Sort" , M_EXEC},
1768 {"/View/Thread view" , M_EXEC},
1769 {"/View/Expand all threads" , M_MSG_EXIST},
1770 {"/View/Collapse all threads" , M_MSG_EXIST},
1771 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1772 {"/View/Go to/Prev message" , M_MSG_EXIST},
1773 {"/View/Go to/Next message" , M_MSG_EXIST},
1774 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1775 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1776 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1777 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1778 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1779 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1780 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1781 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1782 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1784 {"/Message/Receive/Get from current account"
1785 , M_HAVE_ACCOUNT|M_UNLOCKED},
1786 {"/Message/Receive/Get from all accounts"
1787 , M_HAVE_ACCOUNT|M_UNLOCKED},
1788 {"/Message/Receive/Cancel receiving"
1791 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1792 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1793 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1794 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1795 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1796 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1797 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1798 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1799 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1800 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1801 {"/Message/Mark" , M_TARGET_EXIST},
1802 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1804 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1805 {"/Tools/Harvest addresses" , M_UNLOCKED},
1806 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1807 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1808 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1809 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1810 {"/Tools/Execute" , M_DELAY_EXEC},
1811 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1813 {"/Configuration", M_UNLOCKED},
1818 state = main_window_get_current_state(mainwin);
1820 for (i = 0; entry[i].entry != NULL; i++) {
1821 sensitive = ((entry[i].cond & state) == entry[i].cond);
1822 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1825 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1827 /* search for separator */
1828 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1829 cur_item = cur_item->next) {
1830 if (GTK_BIN(cur_item->data)->child == NULL) {
1831 cur_item = cur_item->next;
1836 for (; cur_item != NULL; cur_item = cur_item->next) {
1837 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1838 (M_UNLOCKED & state) != 0);
1841 main_window_menu_callback_block(mainwin);
1843 #define SET_CHECK_MENU_ACTIVE(path, active) \
1845 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1846 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1849 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1850 messageview_is_visible(mainwin->messageview));
1852 summaryview = mainwin->summaryview;
1853 menu_path = "/View/Sort/Don't sort";
1855 switch (summaryview->sort_key) {
1856 case SORT_BY_NUMBER:
1857 menu_path = "/View/Sort/by number"; break;
1859 menu_path = "/View/Sort/by size"; break;
1861 menu_path = "/View/Sort/by date"; break;
1863 menu_path = "/View/Sort/by from"; break;
1865 menu_path = "/View/Sort/by recipient"; break;
1866 case SORT_BY_SUBJECT:
1867 menu_path = "/View/Sort/by subject"; break;
1869 menu_path = "/View/Sort/by color label"; break;
1871 menu_path = "/View/Sort/by mark"; break;
1872 case SORT_BY_STATUS:
1873 menu_path = "/View/Sort/by status"; break;
1875 menu_path = "/View/Sort/by attachment"; break;
1877 menu_path = "/View/Sort/by score"; break;
1878 case SORT_BY_LOCKED:
1879 menu_path = "/View/Sort/by locked"; break;
1882 menu_path = "/View/Sort/Don't sort"; break;
1884 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1886 if (summaryview->sort_type == SORT_ASCENDING) {
1887 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1889 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1892 if (summaryview->sort_key != SORT_BY_NONE) {
1893 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1894 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1896 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1897 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1900 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1901 mainwin->messageview->mimeview->textview->show_all_headers);
1902 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1904 #undef SET_CHECK_MENU_ACTIVE
1906 main_window_menu_callback_unblock(mainwin);
1909 void main_window_popup(MainWindow *mainwin)
1911 gtkut_window_popup(mainwin->window);
1913 switch (mainwin->type) {
1914 case SEPARATE_FOLDER:
1915 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1917 case SEPARATE_MESSAGE:
1918 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1921 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1922 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1929 void main_window_show(MainWindow *mainwin)
1931 gtk_widget_show(mainwin->window);
1932 gtk_widget_show(mainwin->vbox_body);
1934 gtk_widget_set_uposition(mainwin->window,
1935 prefs_common.mainwin_x,
1936 prefs_common.mainwin_y);
1938 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1939 prefs_common.folderview_width,
1940 prefs_common.folderview_height);
1941 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1942 prefs_common.summaryview_width,
1943 prefs_common.summaryview_height);
1944 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1945 prefs_common.msgview_width,
1946 prefs_common.msgview_height);
1948 if (mainwin->type & SEPARATE_FOLDER) {
1949 GtkWidget *folderwin;
1951 folderwin = main_window_get_folder_window(mainwin);
1952 gtk_widget_show(folderwin);
1953 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1954 prefs_common.folderwin_y);
1957 if (mainwin->type & SEPARATE_MESSAGE) {
1958 GtkWidget *messagewin;
1960 messagewin = main_window_get_message_window(mainwin);
1961 gtk_widget_show(messagewin);
1962 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1963 prefs_common.main_msgwin_y);
1967 void main_window_hide(MainWindow *mainwin)
1969 main_window_get_size(mainwin);
1970 main_window_get_position(mainwin);
1972 gtk_widget_hide(mainwin->window);
1973 gtk_widget_hide(mainwin->vbox_body);
1975 if (mainwin->type & SEPARATE_FOLDER) {
1976 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1979 if (mainwin->type & SEPARATE_MESSAGE) {
1980 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1984 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1986 GtkWidget *folderwin = NULL;
1987 GtkWidget *messagewin = NULL;
1990 GtkWidget *vbox_body = mainwin->vbox_body;
1991 GtkItemFactory *ifactory = mainwin->menu_factory;
1992 GtkWidget *menuitem;
1993 GtkItemFactory *msgview_ifactory;
1995 debug_print("Setting widgets... ");
1997 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1998 prefs_common.folderview_width,
1999 prefs_common.folderview_height);
2000 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2001 prefs_common.summaryview_width,
2002 prefs_common.summaryview_height);
2003 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2004 prefs_common.msgview_width,
2005 prefs_common.msgview_height);
2007 /* create separated window(s) if needed */
2008 if (type & SEPARATE_FOLDER) {
2009 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2010 gtk_window_set_title(GTK_WINDOW(folderwin),
2011 _("Sylpheed - Folder View"));
2012 gtk_window_set_resizable(GTK_WINDOW(folderwin), TRUE);
2013 gtk_window_move(GTK_WINDOW(folderwin), prefs_common.folderwin_x,
2014 prefs_common.folderwin_y);
2015 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2017 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2018 G_CALLBACK(folder_window_close_cb),
2020 gtk_container_add(GTK_CONTAINER(folderwin),
2021 GTK_WIDGET_PTR(mainwin->folderview));
2022 gtk_widget_realize(folderwin);
2023 if (prefs_common.folderview_visible)
2024 gtk_widget_show(folderwin);
2027 if (type & SEPARATE_MESSAGE) {
2028 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2029 gtk_window_set_title(GTK_WINDOW(messagewin),
2030 _("Sylpheed - Message View"));
2031 gtk_window_set_resizable(GTK_WINDOW(messagewin), TRUE);
2032 gtk_window_move(GTK_WINDOW(messagewin),
2033 prefs_common.main_msgwin_x,
2034 prefs_common.main_msgwin_y);
2035 gtk_widget_set_size_request(messagewin,
2036 prefs_common.msgwin_width,
2037 prefs_common.msgwin_height);
2038 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2040 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2041 G_CALLBACK(message_window_close_cb),
2043 if (messageview_is_visible(mainwin->messageview))
2044 gtk_widget_show(messagewin);
2046 mainwin->messageview->statusbar = mainwin->statusbar;
2047 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2052 hpaned = gtk_hpaned_new();
2053 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2054 gtk_paned_add1(GTK_PANED(hpaned),
2055 GTK_WIDGET_PTR(mainwin->folderview));
2056 gtk_widget_show(hpaned);
2057 gtk_widget_queue_resize(hpaned);
2059 vpaned = gtk_vpaned_new();
2060 if (messageview_is_visible(mainwin->messageview)) {
2061 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2062 gtk_paned_add1(GTK_PANED(vpaned),
2063 GTK_WIDGET_PTR(mainwin->summaryview));
2065 gtk_paned_add2(GTK_PANED(hpaned),
2066 GTK_WIDGET_PTR(mainwin->summaryview));
2067 gtk_widget_ref(vpaned);
2069 gtk_paned_add2(GTK_PANED(vpaned),
2070 GTK_WIDGET_PTR(mainwin->messageview));
2071 gtk_widget_show(vpaned);
2072 gtk_widget_queue_resize(vpaned);
2074 mainwin->win.sep_none.hpaned = hpaned;
2075 mainwin->win.sep_none.vpaned = vpaned;
2077 /* remove headerview if not in prefs */
2078 headerview_set_visibility(mainwin->messageview->headerview,
2079 prefs_common.display_header_pane);
2081 case SEPARATE_FOLDER:
2082 vpaned = gtk_vpaned_new();
2083 if (messageview_is_visible(mainwin->messageview)) {
2084 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2086 gtk_paned_add1(GTK_PANED(vpaned),
2087 GTK_WIDGET_PTR(mainwin->summaryview));
2089 gtk_box_pack_start(GTK_BOX(vbox_body),
2090 GTK_WIDGET_PTR(mainwin->summaryview),
2092 gtk_widget_ref(vpaned);
2094 gtk_paned_add2(GTK_PANED(vpaned),
2095 GTK_WIDGET_PTR(mainwin->messageview));
2096 gtk_widget_show(vpaned);
2097 gtk_widget_queue_resize(vpaned);
2099 mainwin->win.sep_folder.folderwin = folderwin;
2100 mainwin->win.sep_folder.vpaned = vpaned;
2102 /* remove headerview if not in prefs */
2103 headerview_set_visibility(mainwin->messageview->headerview,
2104 prefs_common.display_header_pane);
2107 case SEPARATE_MESSAGE:
2108 hpaned = gtk_hpaned_new();
2109 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2110 gtk_paned_add1(GTK_PANED(hpaned),
2111 GTK_WIDGET_PTR(mainwin->folderview));
2112 gtk_paned_add2(GTK_PANED(hpaned),
2113 GTK_WIDGET_PTR(mainwin->summaryview));
2114 gtk_widget_show(hpaned);
2115 gtk_widget_queue_resize(hpaned);
2116 messageview_add_toolbar(mainwin->messageview, messagewin);
2117 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2118 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2120 mainwin->win.sep_message.messagewin = messagewin;
2121 mainwin->win.sep_message.hpaned = hpaned;
2123 gtk_widget_realize(messagewin);
2124 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2125 gtk_widget_show_all(messagewin);
2126 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2127 mainwin->messageview->handlebox,
2128 prefs_common.toolbar_style);
2132 messageview_add_toolbar(mainwin->messageview, messagewin);
2133 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2134 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2136 gtk_box_pack_start(GTK_BOX(vbox_body),
2137 GTK_WIDGET_PTR(mainwin->summaryview),
2140 mainwin->win.sep_both.folderwin = folderwin;
2141 mainwin->win.sep_both.messagewin = messagewin;
2143 gtk_widget_realize(messagewin);
2144 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2145 gtk_widget_show_all(messagewin);
2146 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2147 mainwin->messageview->handlebox,
2148 prefs_common.toolbar_style);
2153 if (messageview_is_visible(mainwin->messageview))
2154 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2155 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2157 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2158 GTK_ARROW_UP, GTK_SHADOW_OUT);
2160 gtk_window_move(GTK_WINDOW(mainwin->window),
2161 prefs_common.mainwin_x,
2162 prefs_common.mainwin_y);
2164 gtk_widget_queue_resize(vbox_body);
2165 gtk_widget_queue_resize(mainwin->vbox);
2166 gtk_widget_queue_resize(mainwin->window);
2167 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2168 * and mimeview icon list/ctree lose track of their visibility states */
2169 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2170 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2171 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2172 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2173 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2174 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2176 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2178 mainwin->type = type;
2181 /* toggle menu state */
2182 menuitem = gtk_item_factory_get_item
2183 (ifactory, "/View/Show or hide/Folder tree");
2184 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2185 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2186 prefs_common.folderview_visible);
2187 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2188 menuitem = gtk_item_factory_get_item
2189 (ifactory, "/View/Show or hide/Message view");
2190 gtk_check_menu_item_set_active
2191 (GTK_CHECK_MENU_ITEM(menuitem),
2192 messageview_is_visible(mainwin->messageview));
2194 menuitem = gtk_item_factory_get_item
2195 (ifactory, "/View/Separate folder tree");
2196 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2197 ((type & SEPARATE_FOLDER) != 0));
2198 menuitem = gtk_item_factory_get_item
2199 (ifactory, "/View/Separate message view");
2200 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2201 ((type & SEPARATE_MESSAGE) != 0));
2205 (G_OBJECT(folderwin), "size_allocate",
2206 G_CALLBACK(folder_window_size_allocate_cb),
2211 (G_OBJECT(messagewin), "size_allocate",
2212 G_CALLBACK(message_window_size_allocate_cb),
2216 debug_print("done.\n");
2219 void main_window_destroy_all(void)
2221 while (mainwin_list != NULL) {
2222 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2224 /* free toolbar stuff */
2225 toolbar_clear_list(TOOLBAR_MAIN);
2226 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2227 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2229 g_free(mainwin->toolbar);
2232 mainwin_list = g_list_remove(mainwin_list, mainwin);
2234 g_list_free(mainwin_list);
2238 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2239 GdkEventButton *event,
2242 MainWindow *mainwin = (MainWindow *)data;
2244 if (!event) return FALSE;
2245 if (event->button != 3) return FALSE;
2247 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2248 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2251 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2252 menu_button_position, widget,
2253 event->button, event->time);
2259 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2262 gtk_widget_set_usize(child, 1, -1);
2265 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2268 gtk_widget_set_usize(child, -1, -1);
2271 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2274 MainWindow *mainwin = (MainWindow *)data;
2276 if (!event) return FALSE;
2278 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2279 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2282 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2283 menu_button_position, widget,
2284 event->button, event->time);
2289 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2291 MainWindow *mainwin = (MainWindow *)data;
2294 button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2295 if (!button) return;
2296 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2297 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2298 manage_window_focus_in(mainwin->window, NULL, NULL);
2301 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2304 MainWindow *mainwin = (MainWindow *)data;
2306 if (mainwin->lock_count == 0)
2307 app_exit_cb(data, 0, widget);
2312 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2315 MainWindow *mainwin = (MainWindow *)data;
2316 GtkWidget *menuitem;
2318 menuitem = gtk_item_factory_get_item
2319 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2320 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2325 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2328 MainWindow *mainwin = (MainWindow *)data;
2329 GtkWidget *menuitem;
2331 menuitem = gtk_item_factory_get_item
2332 (mainwin->menu_factory, "/View/Show or hide/Message view");
2333 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2335 mainwin->messageview->statusbar = mainwin->statusbar;
2336 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2341 static void main_window_size_allocate_cb(GtkWidget *widget,
2342 GtkAllocation *allocation,
2345 MainWindow *mainwin = (MainWindow *)data;
2347 main_window_get_size(mainwin);
2350 static void folder_window_size_allocate_cb(GtkWidget *widget,
2351 GtkAllocation *allocation,
2354 MainWindow *mainwin = (MainWindow *)data;
2356 main_window_get_size(mainwin);
2359 static void message_window_size_allocate_cb(GtkWidget *widget,
2360 GtkAllocation *allocation,
2363 MainWindow *mainwin = (MainWindow *)data;
2365 main_window_get_size(mainwin);
2368 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2371 main_window_add_mailbox(mainwin);
2374 static void update_folderview_cb(MainWindow *mainwin, guint action,
2377 summary_show(mainwin->summaryview, NULL);
2378 folderview_check_new_all();
2381 static void foldersort_cb(MainWindow *mainwin, guint action,
2387 static void import_mbox_cb(MainWindow *mainwin, guint action,
2390 import_mbox(mainwin->summaryview->folder_item);
2393 static void export_mbox_cb(MainWindow *mainwin, guint action,
2396 export_mbox(mainwin->summaryview->folder_item);
2399 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2402 summaryview_export_mbox_list(mainwin->summaryview);
2405 static void empty_trash_cb(MainWindow *mainwin, guint action,
2408 main_window_empty_trash(mainwin, TRUE);
2411 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2413 summary_save_as(mainwin->summaryview);
2416 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2418 summary_print(mainwin->summaryview);
2421 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2423 if (prefs_common.confirm_on_exit) {
2424 if (alertpanel(_("Exit"), _("Exit this program?"),
2425 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
2428 manage_window_focus_in(mainwin->window, NULL, NULL);
2431 app_will_exit(widget, mainwin);
2434 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2437 summary_search(mainwin->summaryview);
2439 message_search(mainwin->messageview);
2442 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2447 active = GTK_CHECK_MENU_ITEM(widget)->active;
2449 switch (mainwin->type) {
2451 case SEPARATE_MESSAGE:
2454 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2456 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2459 case SEPARATE_FOLDER:
2460 debug_print("separate folder\n");
2462 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2464 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2468 gtk_widget_show(mainwin->win.sep_both.folderwin);
2470 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2474 prefs_common.folderview_visible = active;
2477 static void toggle_message_cb(MainWindow *mainwin, guint action,
2482 active = GTK_CHECK_MENU_ITEM(widget)->active;
2484 if (active != messageview_is_visible(mainwin->messageview))
2485 summary_toggle_view(mainwin->summaryview);
2488 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2491 toolbar_toggle(action, mainwin);
2494 void main_window_reply_cb(MainWindow *mainwin, guint action,
2497 MessageView *msgview = (MessageView*)mainwin->messageview;
2498 GSList *msginfo_list = NULL;
2500 g_return_if_fail(msgview != NULL);
2502 msginfo_list = summary_get_selection(mainwin->summaryview);
2503 g_return_if_fail(msginfo_list != NULL);
2504 compose_reply_from_messageview(msgview, msginfo_list, action);
2505 g_slist_free(msginfo_list);
2509 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2512 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2513 gtk_widget_show(mainwin->hbox_stat);
2514 prefs_common.show_statusbar = TRUE;
2516 gtk_widget_hide(mainwin->hbox_stat);
2517 prefs_common.show_statusbar = FALSE;
2521 static void separate_widget_cb(MainWindow *mainwin, guint action,
2526 if (GTK_CHECK_MENU_ITEM(widget)->active)
2527 type = mainwin->type | action;
2529 type = mainwin->type & ~action;
2531 main_window_separation_change(mainwin, type);
2533 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2534 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2537 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2540 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2542 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2545 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2547 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2550 static void online_switch_clicked (GtkButton *btn, gpointer data)
2552 MainWindow *mainwin;
2553 GtkItemFactory *ifactory;
2554 GtkCheckMenuItem *menuitem;
2556 mainwin = (MainWindow *) data;
2558 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2559 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2561 g_return_if_fail(mainwin != NULL);
2562 g_return_if_fail(menuitem != NULL);
2564 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2566 gtk_widget_hide (mainwin->online_switch);
2567 gtk_widget_show (mainwin->offline_switch);
2568 menuitem->active = TRUE;
2569 prefs_common.work_offline = TRUE;
2570 inc_autocheck_timer_remove();
2573 gtk_widget_hide (mainwin->offline_switch);
2574 gtk_widget_show (mainwin->online_switch);
2575 menuitem->active = FALSE;
2576 prefs_common.work_offline = FALSE;
2577 inc_autocheck_timer_set();
2581 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2584 addressbook_open(NULL);
2587 static void log_window_show_cb(MainWindow *mainwin, guint action,
2590 log_window_show(mainwin->logwin);
2593 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2598 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2600 summary_move_to(mainwin->summaryview);
2603 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2605 summary_copy_to(mainwin->summaryview);
2608 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2610 summary_delete(mainwin->summaryview);
2613 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2615 summary_cancel(mainwin->summaryview);
2618 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2620 summary_open_msg(mainwin->summaryview);
2623 static void view_source_cb(MainWindow *mainwin, guint action,
2626 summary_view_source(mainwin->summaryview);
2629 static void show_all_header_cb(MainWindow *mainwin, guint action,
2632 if (mainwin->menu_lock_count) return;
2633 summary_display_msg_selected(mainwin->summaryview,
2634 GTK_CHECK_MENU_ITEM(widget)->active);
2637 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2639 summary_mark(mainwin->summaryview);
2642 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 summary_unmark(mainwin->summaryview);
2647 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2650 summary_mark_as_unread(mainwin->summaryview);
2653 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2656 summary_mark_as_read(mainwin->summaryview);
2659 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2662 summary_mark_all_read(mainwin->summaryview);
2665 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2667 summary_reedit(mainwin->summaryview);
2670 static void add_address_cb(MainWindow *mainwin, guint action,
2673 summary_add_address(mainwin->summaryview);
2676 static void set_charset_cb(MainWindow *mainwin, guint action,
2681 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2682 str = conv_get_charset_str((CharSet)action);
2684 g_free(mainwin->messageview->forced_charset);
2685 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2686 procmime_force_charset(str);
2688 summary_redisplay_msg(mainwin->summaryview);
2690 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2694 static void set_decode_cb(MainWindow *mainwin, guint action,
2697 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2698 mainwin->messageview->forced_encoding = (EncodingType)action;
2700 summary_redisplay_msg(mainwin->summaryview);
2702 debug_print("forced encoding: %d\n", action);
2706 static void hide_read_messages (MainWindow *mainwin, guint action,
2709 if (!mainwin->summaryview->folder_item
2710 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2712 summary_toggle_show_read_messages(mainwin->summaryview);
2715 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2717 if (mainwin->menu_lock_count) return;
2718 if (!mainwin->summaryview->folder_item) return;
2720 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2721 summary_thread_build(mainwin->summaryview);
2722 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2724 summary_unthread(mainwin->summaryview);
2725 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2729 static void expand_threads_cb(MainWindow *mainwin, guint action,
2732 summary_expand_threads(mainwin->summaryview);
2735 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2738 summary_collapse_threads(mainwin->summaryview);
2741 static void set_display_item_cb(MainWindow *mainwin, guint action,
2744 prefs_summary_column_open();
2747 static void sort_summary_cb(MainWindow *mainwin, guint action,
2750 FolderItem *item = mainwin->summaryview->folder_item;
2751 GtkWidget *menuitem;
2753 if (mainwin->menu_lock_count) return;
2755 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2756 menuitem = gtk_item_factory_get_item
2757 (mainwin->menu_factory, "/View/Sort/Ascending");
2758 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2759 GTK_CHECK_MENU_ITEM(menuitem)->active
2760 ? SORT_ASCENDING : SORT_DESCENDING);
2761 item->sort_key = action;
2765 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2768 FolderItem *item = mainwin->summaryview->folder_item;
2770 if (mainwin->menu_lock_count) return;
2772 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2773 summary_sort(mainwin->summaryview,
2774 item->sort_key, (FolderSortType)action);
2777 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2780 summary_attract_by_subject(mainwin->summaryview);
2783 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2788 item = folderview_get_selected_item(mainwin->folderview);
2790 main_window_cursor_wait(mainwin);
2791 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2793 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2794 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2796 STATUSBAR_POP(mainwin);
2797 main_window_cursor_normal(mainwin);
2807 static void deldup_all(FolderItem *item, gpointer _data)
2809 struct DelDupsData *data = _data;
2812 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2814 data->dups += result;
2819 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2822 struct DelDupsData data = {0, 0};
2824 folder_func_to_all_folders(deldup_all, &data);
2825 alertpanel_notice(_("Deleted %d duplicate message(s) in %d folders.\n"),
2826 data.dups, data.folders);
2829 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2831 summary_filter(mainwin->summaryview, (gboolean)action);
2834 static void execute_summary_cb(MainWindow *mainwin, guint action,
2837 summary_execute(mainwin->summaryview);
2840 static void update_summary_cb(MainWindow *mainwin, guint action,
2844 FolderView *folderview = mainwin->folderview;
2846 if (!mainwin->summaryview->folder_item) return;
2847 if (!folderview->opened) return;
2849 folder_update_op_count();
2851 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2852 folderview->opened);
2855 folder_item_scan(fitem);
2856 summary_show(mainwin->summaryview, fitem);
2859 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2861 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2864 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2866 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2869 static void prev_unread_cb(MainWindow *mainwin, guint action,
2872 summary_select_prev_unread(mainwin->summaryview);
2875 static void next_unread_cb(MainWindow *mainwin, guint action,
2878 summary_select_next_unread(mainwin->summaryview);
2881 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2883 summary_select_prev_new(mainwin->summaryview);
2886 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2888 summary_select_next_new(mainwin->summaryview);
2891 static void prev_marked_cb(MainWindow *mainwin, guint action,
2894 summary_select_prev_marked(mainwin->summaryview);
2897 static void next_marked_cb(MainWindow *mainwin, guint action,
2900 summary_select_next_marked(mainwin->summaryview);
2903 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2906 summary_select_prev_labeled(mainwin->summaryview);
2909 static void next_labeled_cb(MainWindow *mainwin, guint action,
2912 summary_select_next_labeled(mainwin->summaryview);
2915 static void goto_folder_cb(MainWindow *mainwin, guint action,
2918 FolderItem *to_folder;
2920 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2923 folderview_select(mainwin->folderview, to_folder);
2926 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2928 messageview_copy_clipboard(mainwin->messageview);
2931 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2933 MessageView *msgview = mainwin->messageview;
2935 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2936 summary_select_all(mainwin->summaryview);
2937 else if (messageview_is_visible(msgview) &&
2938 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2939 messageview_select_all(mainwin->messageview);
2942 static void select_thread_cb(MainWindow *mainwin, guint action,
2945 summary_select_thread(mainwin->summaryview);
2948 static void create_filter_cb(MainWindow *mainwin, guint action,
2951 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2954 static void create_processing_cb(MainWindow *mainwin, guint action,
2957 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2960 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2963 /* prefs_common_open(); */
2966 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2969 prefs_filtering_open(&pre_global_processing,
2970 _("Processing rules to apply before folder rules"),
2974 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2977 prefs_filtering_open(&post_global_processing,
2978 _("Processing rules to apply after folder rules"),
2982 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2985 prefs_filtering_open(&filtering_rules,
2986 _("Filtering configuration"),
2990 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2993 prefs_template_open();
2996 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2999 prefs_actions_open(mainwin);
3002 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3005 ssl_manager_open(mainwin);
3008 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3012 new_account_cb(mainwin, 0, widget);
3014 account_open(cur_account);
3018 static void new_account_cb(MainWindow *mainwin, guint action,
3021 account_edit_open();
3022 if (!compose_get_compose_list()) account_add();
3025 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3027 cur_account = (PrefsAccount *)data;
3028 main_window_reflect_prefs_all();
3031 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3033 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3034 PrefsAccount *account = (PrefsAccount *)data;
3036 inc_account_mail(mainwin, account);
3039 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3044 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3046 pluginwindow_create();
3049 static void manual_open_cb(MainWindow *mainwin, guint action,
3052 manual_open((ManualType)action);
3055 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3057 MainWindow *mainwin = (MainWindow *)data;
3061 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3062 LOCAL_FOLDER(folder)->rootpath,
3066 str = g_strdup_printf(_("Scanning folder %s ..."),
3067 LOCAL_FOLDER(folder)->rootpath);
3069 STATUSBAR_PUSH(mainwin, str);
3070 STATUSBAR_POP(mainwin);
3074 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3077 SummaryView *summary;
3079 g_return_val_if_fail(data, FALSE);
3080 summary = ((MainWindow *)data)->summaryview;
3081 g_return_val_if_fail(summary, FALSE);
3083 if (GTK_CLIST(summary->ctree)->selection &&
3084 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3087 if (summary->selected != summary->displayed)
3088 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3092 #define BREAK_ON_MODIFIER_KEY() \
3093 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3095 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3098 MainWindow *mainwin = (MainWindow*) data;
3100 if (!mainwin || !event)
3103 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3106 switch (event->keyval) {
3107 case GDK_Q: /* Quit */
3108 BREAK_ON_MODIFIER_KEY();
3110 app_exit_cb(mainwin, 0, NULL);
3113 if (mainwin->folderview && mainwin->summaryview
3114 && !mainwin->summaryview->displayed) {
3115 summary_lock(mainwin->summaryview);
3116 folderview_select_next_unread(mainwin->folderview);
3117 summary_unlock(mainwin->summaryview);
3126 #undef BREAK_ON_MODIFIER_KEY
3129 * Harvest addresses for selected folder.
3131 static void addr_harvest_cb( MainWindow *mainwin,
3135 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3139 * Harvest addresses for selected messages in summary view.
3141 static void addr_harvest_msg_cb( MainWindow *mainwin,
3145 summary_harvest_address( mainwin->summaryview );
3149 *\brief get a MainWindow
3151 *\return MainWindow * The first mainwindow in the mainwin_list
3153 MainWindow *mainwindow_get_mainwindow(void)
3155 if (mainwin_list && mainwin_list->data)
3156 return (MainWindow *)(mainwin_list->data);
3161 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3163 ProgressData *data = (ProgressData *) source;
3164 MainWindow *mainwin = (MainWindow *) userdata;
3166 switch (data->cmd) {
3167 case PROGRESS_COMMAND_START:
3168 case PROGRESS_COMMAND_STOP:
3169 gtk_progress_bar_set_fraction
3170 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3172 case PROGRESS_COMMAND_SET_PERCENTAGE:
3173 gtk_progress_bar_set_fraction
3174 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3177 while (gtk_events_pending()) gtk_main_iteration ();