2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
42 #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 void 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 void 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 m_essage 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 CODESET_SEPARATOR \
548 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
549 #define CODESET_ACTION(action) \
550 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
552 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
553 {N_("/_View/_Code set/_Auto detect"),
554 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
555 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
557 CODESET_ACTION(C_US_ASCII)},
560 {N_("/_View/_Code set/Unicode (_UTF-8)"),
561 CODESET_ACTION(C_UTF_8)},
564 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
565 CODESET_ACTION(C_ISO_8859_1)},
566 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
567 CODESET_ACTION(C_ISO_8859_15)},
570 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
571 CODESET_ACTION(C_ISO_8859_2)},
573 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
574 CODESET_ACTION(C_ISO_8859_13)},
575 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
576 CODESET_ACTION(C_ISO_8859_4)},
578 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
579 CODESET_ACTION(C_ISO_8859_7)},
581 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
582 CODESET_ACTION(C_ISO_8859_9)},
584 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
585 CODESET_ACTION(C_ISO_8859_5)},
586 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
587 CODESET_ACTION(C_KOI8_R)},
588 {N_("/_View/_Code set/Cyrillic (KOI8-U)"),
589 CODESET_ACTION(C_KOI8_U)},
590 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
591 CODESET_ACTION(C_WINDOWS_1251)},
594 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
595 CODESET_ACTION(C_ISO_2022_JP)},
597 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
598 CODESET_ACTION(C_ISO_2022_JP_2)},
600 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
601 CODESET_ACTION(C_EUC_JP)},
602 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
603 CODESET_ACTION(C_SHIFT_JIS)},
606 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
607 CODESET_ACTION(C_GB2312)},
608 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
609 CODESET_ACTION(C_BIG5)},
610 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
611 CODESET_ACTION(C_EUC_TW)},
612 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
613 CODESET_ACTION(C_ISO_2022_CN)},
615 {N_("/_View/_Code set/Korean (EUC-_KR)"),
616 CODESET_ACTION(C_EUC_KR)},
617 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
618 CODESET_ACTION(C_ISO_2022_KR)},
620 {N_("/_View/_Code set/Thai (TIS-620)"),
621 CODESET_ACTION(C_TIS_620)},
622 {N_("/_View/_Code set/Thai (Windows-874)"),
623 CODESET_ACTION(C_WINDOWS_874)},
626 #undef CODESET_SEPARATOR
627 #undef CODESET_ACTION
629 #define DECODE_SEPARATOR \
630 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
631 #define DECODE_ACTION(action) \
632 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
633 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
634 {N_("/_View/Decode/_Auto detect"),
635 NULL, set_decode_cb, 0, "<RadioItem>"},
636 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
637 {N_("/_View/Decode/_8bit"), DECODE_ACTION(ENC_8BIT)},
638 {N_("/_View/Decode/_Quoted printable"), DECODE_ACTION(ENC_QUOTED_PRINTABLE)},
639 {N_("/_View/Decode/_Base64"), DECODE_ACTION(ENC_BASE64)},
640 {N_("/_View/Decode/_Uuencode"), DECODE_ACTION(ENC_X_UUENCODE)},
642 #undef DECODE_SEPARATOR
645 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
646 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
647 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
648 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
649 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
650 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
652 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
653 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
654 {N_("/_Message/Recei_ve/Get from _current account"),
655 "<control>I", inc_mail_cb, 0, NULL},
656 {N_("/_Message/Recei_ve/Get from _all accounts"),
657 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
658 {N_("/_Message/Recei_ve/Cancel receivin_g"),
659 NULL, inc_cancel_cb, 0, NULL},
660 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
661 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
662 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
663 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
664 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
665 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
666 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
667 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
668 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
669 {N_("/_Message/Repl_y to/mailing _list"),
670 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
671 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
672 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
674 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
675 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
676 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
677 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
678 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
679 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
680 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
682 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
683 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
684 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
685 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
686 {N_("/_Message/_Mark/Mark as rea_d"),
687 NULL, mark_as_read_cb, 0, NULL},
688 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
689 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
692 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
693 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
694 {N_("/_Tools/Add sender to address boo_k"),
695 NULL, add_address_cb, 0, NULL},
696 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
697 {N_("/_Tools/_Harvest addresses/from _Folder..."),
698 NULL, addr_harvest_cb, 0, NULL},
699 {N_("/_Tools/_Harvest addresses/from _Messages..."),
700 NULL, addr_harvest_msg_cb, 0, NULL},
701 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Tools/_Filter all messages in folder"),
703 NULL, filter_cb, 0, NULL},
704 {N_("/_Tools/Filter _selected messages"),
705 NULL, filter_cb, 1, NULL},
706 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Tools/_Create filter rule/_Automatically"),
708 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
709 {N_("/_Tools/_Create filter rule/by _From"),
710 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
711 {N_("/_Tools/_Create filter rule/by _To"),
712 NULL, create_filter_cb, FILTER_BY_TO, NULL},
713 {N_("/_Tools/_Create filter rule/by _Subject"),
714 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
715 {N_("/_Tools/_Create processing rule"), NULL, NULL, 0, "<Branch>"},
716 {N_("/_Tools/_Create processing rule/_Automatically"),
717 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
718 {N_("/_Tools/_Create processing rule/by _From"),
719 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
720 {N_("/_Tools/_Create processing rule/by _To"),
721 NULL, create_processing_cb, FILTER_BY_TO, NULL},
722 {N_("/_Tools/_Create processing rule/by _Subject"),
723 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
724 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
725 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
726 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Tools/_Check for new messages in all folders"),
728 NULL, update_folderview_cb, 0, NULL},
729 {N_("/_Tools/Delete du_plicated messages"),
730 NULL, NULL, 0, "<Branch>"},
731 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
732 NULL, delete_duplicated_cb, 0, NULL},
733 {N_("/_Tools/Delete du_plicated messages/In all folders"),
734 NULL, delete_duplicated_all_cb, 0, NULL},
735 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
736 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
738 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
739 {N_("/_Tools/SSL certi_ficates..."),
740 NULL, ssl_manager_open_cb, 0, NULL},
742 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
743 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
745 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
746 {N_("/_Configuration/C_hange current account"),
747 NULL, NULL, 0, "<Branch>"},
748 {N_("/_Configuration/_Preferences for current account..."),
749 NULL, prefs_account_open_cb, 0, NULL},
750 {N_("/_Configuration/Create _new account..."),
751 NULL, new_account_cb, 0, NULL},
752 {N_("/_Configuration/_Edit accounts..."),
753 NULL, account_edit_open, 0, NULL},
754 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
755 {N_("/_Configuration/_Preferences..."),
756 NULL, prefs_open_cb, 0, NULL},
757 {N_("/_Configuration/Pre-processing..."),
758 NULL, prefs_pre_processing_open_cb, 0, NULL},
759 {N_("/_Configuration/Post-processing..."),
760 NULL, prefs_post_processing_open_cb, 0, NULL},
761 {N_("/_Configuration/_Filtering..."),
762 NULL, prefs_filtering_open_cb, 0, NULL},
763 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
764 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
765 {N_("/_Configuration/Plugins..."), NULL, plugins_open_cb, 0, NULL},
767 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
768 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
769 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
770 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
771 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
772 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
773 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
774 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
775 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
776 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
777 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
780 MainWindow *main_window_create(SeparateType type)
786 GtkWidget *handlebox;
787 GtkWidget *vbox_body;
788 GtkWidget *hbox_stat;
789 GtkWidget *statusbar;
790 GtkWidget *progressbar;
791 GtkWidget *statuslabel;
792 GtkWidget *ac_button;
794 GtkWidget *online_pixmap;
795 GtkWidget *offline_pixmap;
796 GtkWidget *online_switch;
797 GtkWidget *offline_switch;
798 GtkTooltips *offline_tip;
799 GtkTooltips *online_tip;
800 GtkTooltips *sel_ac_tip;
802 FolderView *folderview;
803 SummaryView *summaryview;
804 MessageView *messageview;
805 GdkColormap *colormap;
808 GtkItemFactory *ifactory;
812 guint n_menu_entries;
813 gboolean hide_messageview = FALSE;
815 static GdkGeometry geometry;
817 debug_print("Creating main window...\n");
818 mainwin = g_new0(MainWindow, 1);
821 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
822 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
823 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
824 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
826 if (!geometry.min_height) {
827 geometry.min_width = 320;
828 geometry.min_height = 200;
830 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
833 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
834 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
835 MANAGE_WINDOW_SIGNALS_CONNECT(window);
836 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
837 GTK_SIGNAL_FUNC(mainwindow_focus_in_event),
839 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
840 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
842 gtk_widget_realize(window);
843 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
846 gtkut_widget_set_app_icon(window);
848 vbox = gtk_vbox_new(FALSE, 0);
849 gtk_widget_show(vbox);
850 gtk_container_add(GTK_CONTAINER(window), vbox);
853 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
854 menubar = menubar_create(window, mainwin_entries,
855 n_menu_entries, "<Main>", mainwin);
856 gtk_widget_show(menubar);
857 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
858 ifactory = gtk_item_factory_from_widget(menubar);
860 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
861 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
863 handlebox = gtk_handle_box_new();
864 gtk_widget_show(handlebox);
865 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
866 gtk_signal_connect(GTK_OBJECT(handlebox), "child_attached",
867 GTK_SIGNAL_FUNC(toolbar_child_attached), mainwin);
868 gtk_signal_connect(GTK_OBJECT(handlebox), "child_detached",
869 GTK_SIGNAL_FUNC(toolbar_child_detached), mainwin);
871 /* link window to mainwin->window to avoid gdk warnings */
872 mainwin->window = window;
875 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
879 /* vbox that contains body */
880 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
881 gtk_widget_show(vbox_body);
882 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
883 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
885 hbox_stat = gtk_hbox_new(FALSE, 2);
886 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
888 statusbar = statusbar_create();
889 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
891 progressbar = gtk_progress_bar_new();
892 gtk_widget_set_usize(progressbar, 120, 1);
893 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
895 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
896 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
897 online_tip = gtk_tooltips_new();
898 online_switch = gtk_button_new ();
899 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
900 _("You are online. Click the icon to go offline"), NULL);
901 offline_tip = gtk_tooltips_new();
902 offline_switch = gtk_button_new ();
903 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
904 _("You are offline. Click the icon to go online"),
906 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
907 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
908 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
909 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
910 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
911 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
912 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
913 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
915 statuslabel = gtk_label_new("");
916 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
918 sel_ac_tip = gtk_tooltips_new();
919 ac_button = gtk_button_new();
920 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
921 ac_button, _("Select account"), NULL);
922 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
923 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
924 gtk_widget_set_usize(ac_button, -1, 1);
925 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
926 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
927 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
929 ac_label = gtk_label_new("");
930 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
932 gtk_widget_show_all(hbox_stat);
934 gtk_widget_hide(offline_switch);
936 mainwin->folderview = folderview = folderview_create();
937 mainwin->summaryview = summaryview = summary_create();
938 mainwin->messageview = messageview = messageview_create(mainwin);
939 mainwin->logwin = log_window_create();
941 folderview->mainwin = mainwin;
942 folderview->summaryview = summaryview;
944 summaryview->mainwin = mainwin;
945 summaryview->folderview = folderview;
946 summaryview->messageview = messageview;
947 summaryview->window = window;
949 messageview->statusbar = statusbar;
950 mainwin->vbox = vbox;
951 mainwin->menubar = menubar;
952 mainwin->menu_factory = ifactory;
953 mainwin->handlebox = handlebox;
954 mainwin->vbox_body = vbox_body;
955 mainwin->hbox_stat = hbox_stat;
956 mainwin->statusbar = statusbar;
957 mainwin->progressbar = progressbar;
958 mainwin->statuslabel = statuslabel;
959 mainwin->online_switch = online_switch;
960 mainwin->online_pixmap = online_pixmap;
961 mainwin->offline_pixmap = offline_pixmap;
962 mainwin->ac_button = ac_button;
963 mainwin->ac_label = ac_label;
964 mainwin->offline_switch = offline_switch;
966 /* set context IDs for status bar */
967 mainwin->mainwin_cid = gtk_statusbar_get_context_id
968 (GTK_STATUSBAR(statusbar), "Main Window");
969 mainwin->folderview_cid = gtk_statusbar_get_context_id
970 (GTK_STATUSBAR(statusbar), "Folder View");
971 mainwin->summaryview_cid = gtk_statusbar_get_context_id
972 (GTK_STATUSBAR(statusbar), "Summary View");
973 mainwin->messageview_cid = gtk_statusbar_get_context_id
974 (GTK_STATUSBAR(statusbar), "Message View");
976 messageview->statusbar_cid = mainwin->messageview_cid;
978 /* allocate colors for summary view and folder view */
979 summaryview->color_marked.red = summaryview->color_marked.green = 0;
980 summaryview->color_marked.blue = (guint16)65535;
982 summaryview->color_dim.red = summaryview->color_dim.green =
983 summaryview->color_dim.blue = COLOR_DIM;
985 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
986 &folderview->color_new);
988 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
989 &folderview->color_op);
991 summaryview->color_important.red = 0;
992 summaryview->color_important.green = 0;
993 summaryview->color_important.blue = (guint16)65535;
995 color[0] = summaryview->color_marked;
996 color[1] = summaryview->color_dim;
997 color[2] = folderview->color_new;
998 color[3] = folderview->color_op;
1000 colormap = gdk_window_get_colormap(window->window);
1001 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1002 for (i = 0; i < 4; i++) {
1003 if (success[i] == FALSE)
1004 g_warning("MainWindow: color allocation %d failed\n", i);
1007 debug_print("done.\n");
1009 messageview->visible = prefs_common.msgview_visible;
1010 hide_messageview = !messageview->visible;
1012 main_window_set_widgets(mainwin, type);
1014 gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
1015 GTK_SIGNAL_FUNC(main_window_size_allocate_cb),
1018 /* set menu items */
1019 menuitem = gtk_item_factory_get_item
1020 (ifactory, "/View/Code set/Auto detect");
1021 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1023 switch (prefs_common.toolbar_style) {
1025 menuitem = gtk_item_factory_get_item
1026 (ifactory, "/View/Show or hide/Toolbar/None");
1029 menuitem = gtk_item_factory_get_item
1030 (ifactory, "/View/Show or hide/Toolbar/Icon");
1033 menuitem = gtk_item_factory_get_item
1034 (ifactory, "/View/Show or hide/Toolbar/Text");
1037 menuitem = gtk_item_factory_get_item
1038 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1040 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1042 gtk_widget_hide(mainwin->hbox_stat);
1043 menuitem = gtk_item_factory_get_item
1044 (ifactory, "/View/Show or hide/Status bar");
1045 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1046 prefs_common.show_statusbar);
1048 /* set account selection menu */
1049 ac_menu = gtk_item_factory_get_widget
1050 (ifactory, "/Configuration/Change current account");
1051 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1052 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1053 mainwin->ac_menu = ac_menu;
1055 toolbar_main_set_sensitive(mainwin);
1057 /* create actions menu */
1058 main_window_update_actions_menu(mainwin);
1060 /* attach accel groups to main window */
1061 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1062 gtk_window_add_accel_group \
1064 gtk_item_factory_from_widget(menu)->accel_group)
1066 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1068 /* connect the accelerators for equivalent
1069 menu items in different menus */
1070 menu_connect_identical_items();
1074 /* show main window */
1075 gtk_widget_show(mainwin->window);
1077 /* initialize views */
1078 folderview_init(folderview);
1079 summary_init(summaryview);
1080 messageview_init(messageview);
1081 log_window_init(mainwin->logwin);
1082 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1083 prefs_common.loglength);
1085 sslcertwindow_register_hook();
1087 mainwin->lock_count = 0;
1088 mainwin->menu_lock_count = 0;
1089 mainwin->cursor_count = 0;
1091 mainwin->progressindicator_hook =
1092 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1095 watch_cursor = gdk_cursor_new(GDK_WATCH);
1097 mainwin_list = g_list_append(mainwin_list, mainwin);
1099 /* init work_offline */
1100 if (prefs_common.work_offline)
1101 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1103 if (mainwin->type == SEPARATE_NONE && hide_messageview)
1104 main_window_toggle_message_view(mainwin);
1109 void main_window_destroy(MainWindow *mainwin)
1111 /* TODO : destroy other component */
1112 messageview_destroy(mainwin->messageview);
1113 mainwin->messageview = NULL;
1116 void main_window_update_actions_menu(MainWindow *mainwin)
1118 GtkItemFactory *ifactory;
1120 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1121 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1124 void main_window_cursor_wait(MainWindow *mainwin)
1127 if (mainwin->cursor_count == 0)
1128 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1130 mainwin->cursor_count++;
1135 void main_window_cursor_normal(MainWindow *mainwin)
1137 if (mainwin->cursor_count)
1138 mainwin->cursor_count--;
1140 if (mainwin->cursor_count == 0)
1141 gdk_window_set_cursor(mainwin->window->window, NULL);
1146 /* lock / unlock the user-interface */
1147 void main_window_lock(MainWindow *mainwin)
1149 if (mainwin->lock_count == 0)
1150 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1152 mainwin->lock_count++;
1154 main_window_set_menu_sensitive(mainwin);
1155 toolbar_main_set_sensitive(mainwin);
1158 void main_window_unlock(MainWindow *mainwin)
1160 if (mainwin->lock_count)
1161 mainwin->lock_count--;
1163 main_window_set_menu_sensitive(mainwin);
1164 toolbar_main_set_sensitive(mainwin);
1166 if (mainwin->lock_count == 0)
1167 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1170 static void main_window_menu_callback_block(MainWindow *mainwin)
1172 mainwin->menu_lock_count++;
1175 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1177 if (mainwin->menu_lock_count)
1178 mainwin->menu_lock_count--;
1181 void main_window_reflect_prefs_all(void)
1183 main_window_reflect_prefs_all_real(FALSE);
1186 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1189 MainWindow *mainwin;
1192 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1193 mainwin = (MainWindow *)cur->data;
1195 main_window_show_cur_account(mainwin);
1196 main_window_set_menu_sensitive(mainwin);
1197 toolbar_main_set_sensitive(mainwin);
1200 if (pixmap_theme_changed) {
1201 toolbar_update(TOOLBAR_MAIN, mainwin);
1202 messageview_reflect_prefs_pixmap_theme();
1203 compose_reflect_prefs_pixmap_theme();
1204 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1205 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1207 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1208 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1209 mainwin->online_pixmap);
1210 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1211 gtk_widget_show(pixmap);
1212 mainwin->online_pixmap = pixmap;
1213 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1214 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1215 mainwin->offline_pixmap);
1216 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1217 gtk_widget_show(pixmap);
1218 mainwin->offline_pixmap = pixmap;
1221 summary_redisplay_msg(mainwin->summaryview);
1222 headerview_set_visibility(mainwin->messageview->headerview,
1223 prefs_common.display_header_pane);
1227 void main_window_set_summary_column(void)
1230 MainWindow *mainwin;
1232 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1233 mainwin = (MainWindow *)cur->data;
1234 summary_set_column_order(mainwin->summaryview);
1238 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1239 GList *account_list)
1241 GList *cur_ac, *cur_item;
1242 GtkWidget *menuitem;
1243 PrefsAccount *ac_prefs;
1245 /* destroy all previous menu item */
1246 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1247 while (cur_item != NULL) {
1248 GList *next = cur_item->next;
1249 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1253 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1254 ac_prefs = (PrefsAccount *)cur_ac->data;
1256 menuitem = gtk_menu_item_new_with_label
1257 (ac_prefs->account_name
1258 ? ac_prefs->account_name : _("Untitled"));
1259 gtk_widget_show(menuitem);
1260 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1261 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1262 GTK_SIGNAL_FUNC(account_selector_menu_cb),
1267 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1268 GList *account_list)
1270 GList *cur_ac, *cur_item;
1272 GtkWidget *menuitem;
1273 PrefsAccount *ac_prefs;
1275 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1276 "/Message/Receive");
1278 /* search for separator */
1279 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1280 cur_item = cur_item->next) {
1281 if (GTK_BIN(cur_item->data)->child == NULL) {
1282 cur_item = cur_item->next;
1287 /* destroy all previous menu item */
1288 while (cur_item != NULL) {
1289 GList *next = cur_item->next;
1290 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1294 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1295 ac_prefs = (PrefsAccount *)cur_ac->data;
1297 menuitem = gtk_menu_item_new_with_label
1298 (ac_prefs->account_name ? ac_prefs->account_name
1300 gtk_widget_show(menuitem);
1301 gtk_menu_append(GTK_MENU(menu), menuitem);
1302 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1303 GTK_SIGNAL_FUNC(account_receive_menu_cb),
1308 void main_window_set_account_menu(GList *account_list)
1311 MainWindow *mainwin;
1313 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1314 mainwin = (MainWindow *)cur->data;
1315 main_window_set_account_selector_menu(mainwin, account_list);
1316 main_window_set_account_receive_menu(mainwin, account_list);
1320 static void main_window_show_cur_account(MainWindow *mainwin)
1325 ac_name = g_strdup(cur_account
1326 ? (cur_account->account_name
1327 ? cur_account->account_name : _("Untitled"))
1331 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1333 buf = g_strdup(PROG_VERSION);
1334 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1337 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1338 gtk_widget_queue_resize(mainwin->ac_button);
1343 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1345 switch (mainwin->type) {
1346 case SEPARATE_FOLDER:
1347 return mainwin->win.sep_folder.folderwin;
1349 return mainwin->win.sep_both.folderwin;
1355 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1357 switch (mainwin->type) {
1358 case SEPARATE_MESSAGE:
1359 return mainwin->win.sep_message.messagewin;
1361 return mainwin->win.sep_both.messagewin;
1367 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1369 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1370 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1371 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1372 GtkWidget *message_wid = mainwin->messageview->vbox;
1374 debug_print("Changing window separation type from %d to %d\n",
1375 mainwin->type, type);
1377 if (mainwin->type == type) return;
1379 /* remove widgets from those containers */
1380 gtk_widget_ref(folder_wid);
1381 gtk_widget_ref(summary_wid);
1382 gtk_widget_ref(message_wid);
1383 gtkut_container_remove
1384 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1385 gtkut_container_remove
1386 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1387 gtkut_container_remove
1388 (GTK_CONTAINER(message_wid->parent), message_wid);
1390 /* clean containers */
1391 switch (mainwin->type) {
1393 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1395 case SEPARATE_FOLDER:
1396 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1397 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1399 case SEPARATE_MESSAGE:
1400 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1401 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1404 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1405 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1409 gtk_widget_hide(mainwin->window);
1410 main_window_set_widgets(mainwin, type);
1411 gtk_widget_show(mainwin->window);
1413 gtk_widget_unref(folder_wid);
1414 gtk_widget_unref(summary_wid);
1415 gtk_widget_unref(message_wid);
1418 void main_window_toggle_message_view(MainWindow *mainwin)
1420 SummaryView *summaryview = mainwin->summaryview;
1421 union CompositeWin *cwin = &mainwin->win;
1422 GtkWidget *vpaned = NULL;
1423 GtkWidget *container = NULL;
1424 GtkWidget *msgwin = NULL;
1426 switch (mainwin->type) {
1428 vpaned = cwin->sep_none.vpaned;
1429 container = cwin->sep_none.hpaned;
1431 case SEPARATE_FOLDER:
1432 vpaned = cwin->sep_folder.vpaned;
1433 container = mainwin->vbox_body;
1435 case SEPARATE_MESSAGE:
1436 msgwin = mainwin->win.sep_message.messagewin;
1439 msgwin = mainwin->win.sep_both.messagewin;
1444 if (GTK_WIDGET_VISIBLE(msgwin)) {
1445 gtk_widget_hide(msgwin);
1446 mainwin->messageview->visible = FALSE;
1447 summaryview->displayed = NULL;
1449 gtk_widget_show(msgwin);
1450 mainwin->messageview->visible = TRUE;
1452 } else if (vpaned->parent != NULL) {
1453 mainwin->messageview->visible = FALSE;
1454 summaryview->displayed = NULL;
1455 gtk_widget_ref(vpaned);
1456 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1457 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1458 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1459 GTK_ARROW_UP, GTK_SHADOW_OUT);
1461 mainwin->messageview->visible = TRUE;
1462 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1463 gtk_container_add(GTK_CONTAINER(container), vpaned);
1464 gtk_widget_unref(vpaned);
1465 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1466 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1469 if (mainwin->messageview->visible == FALSE)
1470 messageview_clear(mainwin->messageview);
1472 main_window_set_menu_sensitive(mainwin);
1474 prefs_common.msgview_visible = mainwin->messageview->visible;
1476 gtk_widget_grab_focus(summaryview->ctree);
1479 void main_window_get_size(MainWindow *mainwin)
1481 GtkAllocation *allocation;
1483 if (mainwin->messageview == NULL) {
1484 debug_print("called after messageview "
1485 "has been deallocated!\n");
1489 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1491 if (allocation->width > 1 && allocation->height > 1) {
1492 prefs_common.summaryview_width = allocation->width;
1494 if ((mainwin->type == SEPARATE_NONE ||
1495 mainwin->type == SEPARATE_FOLDER) &&
1496 messageview_is_visible(mainwin->messageview))
1497 prefs_common.summaryview_height = allocation->height;
1499 prefs_common.mainview_width = allocation->width;
1502 allocation = &mainwin->window->allocation;
1503 if (allocation->width > 1 && allocation->height > 1) {
1504 prefs_common.mainview_height = allocation->height;
1505 prefs_common.mainwin_width = allocation->width;
1506 prefs_common.mainwin_height = allocation->height;
1509 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1510 if (allocation->width > 1 && allocation->height > 1) {
1511 prefs_common.folderview_width = allocation->width;
1512 prefs_common.folderview_height = allocation->height;
1515 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1516 if (allocation->width > 1 && allocation->height > 1) {
1517 prefs_common.msgview_width = allocation->width;
1518 prefs_common.msgview_height = allocation->height;
1521 debug_print("summaryview size: %d x %d\n",
1522 prefs_common.summaryview_width,
1523 prefs_common.summaryview_height);
1524 debug_print("folderview size: %d x %d\n",
1525 prefs_common.folderview_width,
1526 prefs_common.folderview_height);
1527 debug_print("messageview size: %d x %d\n",
1528 prefs_common.msgview_width,
1529 prefs_common.msgview_height);
1532 void main_window_get_position(MainWindow *mainwin)
1537 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1539 prefs_common.mainview_x = x;
1540 prefs_common.mainview_y = y;
1541 prefs_common.mainwin_x = x;
1542 prefs_common.mainwin_y = y;
1544 debug_print("main window position: %d, %d\n", x, y);
1546 window = main_window_get_folder_window(mainwin);
1548 gtkut_widget_get_uposition(window, &x, &y);
1549 prefs_common.folderwin_x = x;
1550 prefs_common.folderwin_y = y;
1551 debug_print("folder window position: %d, %d\n", x, y);
1553 window = main_window_get_message_window(mainwin);
1555 gtkut_widget_get_uposition(window, &x, &y);
1556 prefs_common.main_msgwin_x = x;
1557 prefs_common.main_msgwin_y = y;
1558 debug_print("message window position: %d, %d\n", x, y);
1562 void main_window_progress_on(MainWindow *mainwin)
1564 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE);
1565 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1568 void main_window_progress_off(MainWindow *mainwin)
1570 gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE);
1571 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1572 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1575 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1579 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1580 gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf);
1581 gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar),
1582 (cur == 0 && total == 0) ? 0 :
1583 (gfloat)cur / (gfloat)total);
1586 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1592 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1593 folder = FOLDER(list->data);
1594 if (folder && folder->trash && folder->trash->total_msgs > 0)
1598 if (!has_trash) return;
1601 if (alertpanel(_("Empty trash"),
1602 _("Empty all messages in trash?"),
1603 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1605 manage_window_focus_in(mainwin->window, NULL, NULL);
1608 procmsg_empty_all_trash();
1610 if (mainwin->summaryview->folder_item &&
1611 mainwin->summaryview->folder_item->stype == F_TRASH)
1612 gtk_widget_grab_focus(mainwin->folderview->ctree);
1615 void main_window_add_mailbox(MainWindow *mainwin)
1620 path = input_dialog(_("Add mailbox"),
1621 _("Input the location of mailbox.\n"
1622 "If the existing mailbox is specified, it will be\n"
1623 "scanned automatically."),
1626 if (folder_find_from_path(path)) {
1627 alertpanel_error(_("The mailbox `%s' already exists."), path);
1631 folder = folder_new(folder_get_class_from_string("mh"),
1632 !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path),
1636 if (folder->klass->create_tree(folder) < 0) {
1637 alertpanel_error(_("Creation of the mailbox failed.\n"
1638 "Maybe some files already exist, or you don't have the permission to write there."));
1639 folder_destroy(folder);
1644 folder_set_ui_func(folder, scan_tree_func, mainwin);
1645 folder_scan_tree(folder);
1646 folder_set_ui_func(folder, NULL, NULL);
1649 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1651 SensitiveCond state = 0;
1652 SummarySelection selection;
1653 FolderItem *item = mainwin->summaryview->folder_item;
1654 GList *account_list = account_get_list();
1656 selection = summary_get_selection_type(mainwin->summaryview);
1658 if (mainwin->lock_count == 0)
1659 state |= M_UNLOCKED;
1660 if (selection != SUMMARY_NONE)
1661 state |= M_MSG_EXIST;
1662 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1664 /* if (item->folder->type != F_NEWS) */
1665 state |= M_ALLOW_DELETE;
1667 if (prefs_common.immediate_exec == 0
1668 && mainwin->lock_count == 0)
1669 state |= M_DELAY_EXEC;
1671 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1672 || selection != SUMMARY_NONE)
1673 state |= M_HIDE_READ_MSG;
1675 if (mainwin->summaryview->threaded)
1676 state |= M_THREADED;
1678 state |= M_UNTHREADED;
1679 if (selection == SUMMARY_SELECTED_SINGLE ||
1680 selection == SUMMARY_SELECTED_MULTIPLE)
1681 state |= M_TARGET_EXIST;
1682 if (selection == SUMMARY_SELECTED_SINGLE)
1683 state |= M_SINGLE_TARGET_EXIST;
1684 if (mainwin->summaryview->folder_item &&
1685 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1688 state |= M_NOT_NEWS;
1689 if (selection == SUMMARY_SELECTED_SINGLE &&
1691 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1692 item->stype == F_QUEUE)))
1693 state |= M_ALLOW_REEDIT;
1695 state |= M_HAVE_ACCOUNT;
1697 for ( ; account_list != NULL; account_list = account_list->next) {
1698 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1699 state |= M_HAVE_NEWS_ACCOUNT;
1704 if (inc_is_active())
1705 state |= M_INC_ACTIVE;
1712 void main_window_set_menu_sensitive(MainWindow *mainwin)
1714 GtkItemFactory *ifactory = mainwin->menu_factory;
1715 SensitiveCond state;
1718 GtkWidget *menuitem;
1719 SummaryView *summaryview;
1724 static const struct {
1728 {"/File/Add mailbox" , M_UNLOCKED},
1730 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1731 {"/File/Change folder order" , M_UNLOCKED},
1732 {"/File/Export to mbox file..." , M_UNLOCKED},
1733 {"/File/Empty all Trash folders" , M_UNLOCKED},
1734 {"/File/Work offline" , M_UNLOCKED},
1736 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1737 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1738 /* {"/File/Close" , M_UNLOCKED}, */
1739 {"/File/Exit" , M_UNLOCKED},
1741 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1743 {"/View/Sort" , M_EXEC},
1744 {"/View/Thread view" , M_EXEC},
1745 {"/View/Expand all threads" , M_MSG_EXIST},
1746 {"/View/Collapse all threads" , M_MSG_EXIST},
1747 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1748 {"/View/Go to/Prev message" , M_MSG_EXIST},
1749 {"/View/Go to/Next message" , M_MSG_EXIST},
1750 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1751 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1752 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1753 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1754 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1755 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1756 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1757 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1758 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1760 {"/Message/Receive/Get from current account"
1761 , M_HAVE_ACCOUNT|M_UNLOCKED},
1762 {"/Message/Receive/Get from all accounts"
1763 , M_HAVE_ACCOUNT|M_UNLOCKED},
1764 {"/Message/Receive/Cancel receiving"
1767 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1768 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1769 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1770 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1771 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1772 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1773 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1774 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1775 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1776 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1777 {"/Message/Mark" , M_TARGET_EXIST},
1778 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1780 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1781 {"/Tools/Harvest addresses" , M_UNLOCKED},
1782 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1783 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1784 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1785 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1786 {"/Tools/Execute" , M_DELAY_EXEC},
1787 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1789 {"/Configuration", M_UNLOCKED},
1794 state = main_window_get_current_state(mainwin);
1796 for (i = 0; entry[i].entry != NULL; i++) {
1797 sensitive = ((entry[i].cond & state) == entry[i].cond);
1798 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1801 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1803 /* search for separator */
1804 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1805 cur_item = cur_item->next) {
1806 if (GTK_BIN(cur_item->data)->child == NULL) {
1807 cur_item = cur_item->next;
1812 for (; cur_item != NULL; cur_item = cur_item->next) {
1813 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1814 (M_UNLOCKED & state) != 0);
1817 main_window_menu_callback_block(mainwin);
1819 #define SET_CHECK_MENU_ACTIVE(path, active) \
1821 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1822 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1825 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1826 messageview_is_visible(mainwin->messageview));
1828 summaryview = mainwin->summaryview;
1829 menu_path = "/View/Sort/Don't sort";
1831 switch (summaryview->sort_key) {
1832 case SORT_BY_NUMBER:
1833 menu_path = "/View/Sort/by number"; break;
1835 menu_path = "/View/Sort/by size"; break;
1837 menu_path = "/View/Sort/by date"; break;
1839 menu_path = "/View/Sort/by from"; break;
1841 menu_path = "/View/Sort/by recipient"; break;
1842 case SORT_BY_SUBJECT:
1843 menu_path = "/View/Sort/by subject"; break;
1845 menu_path = "/View/Sort/by color label"; break;
1847 menu_path = "/View/Sort/by mark"; break;
1848 case SORT_BY_STATUS:
1849 menu_path = "/View/Sort/by status"; break;
1851 menu_path = "/View/Sort/by attachment"; break;
1853 menu_path = "/View/Sort/by score"; break;
1854 case SORT_BY_LOCKED:
1855 menu_path = "/View/Sort/by locked"; break;
1858 menu_path = "/View/Sort/Don't sort"; break;
1860 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1862 if (summaryview->sort_type == SORT_ASCENDING) {
1863 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1865 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1868 if (summaryview->sort_key != SORT_BY_NONE) {
1869 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1870 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1872 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1873 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1876 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1877 mainwin->messageview->mimeview->textview->show_all_headers);
1878 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1880 #undef SET_CHECK_MENU_ACTIVE
1882 main_window_menu_callback_unblock(mainwin);
1885 void main_window_popup(MainWindow *mainwin)
1887 gtkut_window_popup(mainwin->window);
1889 switch (mainwin->type) {
1890 case SEPARATE_FOLDER:
1891 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1893 case SEPARATE_MESSAGE:
1894 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1897 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1898 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1905 void main_window_show(MainWindow *mainwin)
1907 gtk_widget_show(mainwin->window);
1908 gtk_widget_show(mainwin->vbox_body);
1910 gtk_widget_set_uposition(mainwin->window,
1911 prefs_common.mainwin_x,
1912 prefs_common.mainwin_y);
1914 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
1915 prefs_common.folderview_width,
1916 prefs_common.folderview_height);
1917 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1918 prefs_common.summaryview_width,
1919 prefs_common.summaryview_height);
1920 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1921 prefs_common.msgview_width,
1922 prefs_common.msgview_height);
1924 if (mainwin->type & SEPARATE_FOLDER) {
1925 GtkWidget *folderwin;
1927 folderwin = main_window_get_folder_window(mainwin);
1928 gtk_widget_show(folderwin);
1929 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1930 prefs_common.folderwin_y);
1933 if (mainwin->type & SEPARATE_MESSAGE) {
1934 GtkWidget *messagewin;
1936 messagewin = main_window_get_message_window(mainwin);
1937 gtk_widget_show(messagewin);
1938 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1939 prefs_common.main_msgwin_y);
1943 void main_window_hide(MainWindow *mainwin)
1945 main_window_get_size(mainwin);
1946 main_window_get_position(mainwin);
1948 gtk_widget_hide(mainwin->window);
1949 gtk_widget_hide(mainwin->vbox_body);
1951 if (mainwin->type & SEPARATE_FOLDER) {
1952 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1955 if (mainwin->type & SEPARATE_MESSAGE) {
1956 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1960 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1962 GtkWidget *folderwin = NULL;
1963 GtkWidget *messagewin = NULL;
1966 GtkWidget *vbox_body = mainwin->vbox_body;
1967 GtkItemFactory *ifactory = mainwin->menu_factory;
1968 GtkWidget *menuitem;
1969 GtkItemFactory *msgview_ifactory;
1971 debug_print("Setting widgets... ");
1973 /* create separated window(s) if needed */
1974 if (type & SEPARATE_FOLDER) {
1975 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1976 gtk_window_set_title(GTK_WINDOW(folderwin),
1977 _("Sylpheed - Folder View"));
1978 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1979 "folder_view", "Sylpheed");
1980 gtk_window_set_policy(GTK_WINDOW(folderwin),
1982 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1983 prefs_common.folderwin_y);
1984 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1986 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1987 GTK_SIGNAL_FUNC(folder_window_close_cb),
1989 gtk_container_add(GTK_CONTAINER(folderwin),
1990 GTK_WIDGET_PTR(mainwin->folderview));
1991 gtk_widget_realize(folderwin);
1992 if (prefs_common.folderview_visible)
1993 gtk_widget_show(folderwin);
1996 if (type & SEPARATE_MESSAGE) {
1997 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1998 gtk_window_set_title(GTK_WINDOW(messagewin),
1999 _("Sylpheed - Message View"));
2000 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
2001 "message_view", "Sylpheed");
2002 gtk_window_set_policy(GTK_WINDOW(messagewin),
2004 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2005 prefs_common.main_msgwin_y);
2006 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2008 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
2009 GTK_SIGNAL_FUNC(message_window_close_cb),
2011 if (messageview_is_visible(mainwin->messageview))
2012 gtk_widget_show(messagewin);
2014 mainwin->messageview->statusbar = mainwin->statusbar;
2015 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2018 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->folderview),
2019 prefs_common.folderview_width,
2020 prefs_common.folderview_height);
2021 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2022 prefs_common.summaryview_width,
2023 prefs_common.summaryview_height);
2024 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
2025 prefs_common.msgview_width,
2026 prefs_common.msgview_height);
2030 hpaned = gtk_hpaned_new();
2031 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2032 gtk_paned_add1(GTK_PANED(hpaned),
2033 GTK_WIDGET_PTR(mainwin->folderview));
2034 gtk_widget_show(hpaned);
2035 gtk_widget_queue_resize(hpaned);
2037 vpaned = gtk_vpaned_new();
2038 if (messageview_is_visible(mainwin->messageview)) {
2039 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2040 gtk_paned_add1(GTK_PANED(vpaned),
2041 GTK_WIDGET_PTR(mainwin->summaryview));
2043 gtk_paned_add2(GTK_PANED(hpaned),
2044 GTK_WIDGET_PTR(mainwin->summaryview));
2045 gtk_widget_ref(vpaned);
2047 gtk_paned_add2(GTK_PANED(vpaned),
2048 GTK_WIDGET_PTR(mainwin->messageview));
2049 gtk_widget_show(vpaned);
2050 gtk_widget_queue_resize(vpaned);
2052 mainwin->win.sep_none.hpaned = hpaned;
2053 mainwin->win.sep_none.vpaned = vpaned;
2055 /* remove headerview if not in prefs */
2056 headerview_set_visibility(mainwin->messageview->headerview,
2057 prefs_common.display_header_pane);
2059 case SEPARATE_FOLDER:
2060 vpaned = gtk_vpaned_new();
2061 if (messageview_is_visible(mainwin->messageview)) {
2062 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2064 gtk_paned_add1(GTK_PANED(vpaned),
2065 GTK_WIDGET_PTR(mainwin->summaryview));
2067 gtk_box_pack_start(GTK_BOX(vbox_body),
2068 GTK_WIDGET_PTR(mainwin->summaryview),
2070 gtk_widget_ref(vpaned);
2072 gtk_paned_add2(GTK_PANED(vpaned),
2073 GTK_WIDGET_PTR(mainwin->messageview));
2074 gtk_widget_show(vpaned);
2075 gtk_widget_queue_resize(vpaned);
2077 mainwin->win.sep_folder.folderwin = folderwin;
2078 mainwin->win.sep_folder.vpaned = vpaned;
2080 /* remove headerview if not in prefs */
2081 headerview_set_visibility(mainwin->messageview->headerview,
2082 prefs_common.display_header_pane);
2085 case SEPARATE_MESSAGE:
2086 hpaned = gtk_hpaned_new();
2087 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2088 gtk_paned_add1(GTK_PANED(hpaned),
2089 GTK_WIDGET_PTR(mainwin->folderview));
2090 gtk_paned_add2(GTK_PANED(hpaned),
2091 GTK_WIDGET_PTR(mainwin->summaryview));
2092 gtk_widget_show(hpaned);
2093 gtk_widget_queue_resize(hpaned);
2094 messageview_add_toolbar(mainwin->messageview, messagewin);
2095 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2096 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2098 mainwin->win.sep_message.messagewin = messagewin;
2099 mainwin->win.sep_message.hpaned = hpaned;
2101 gtk_widget_realize(messagewin);
2102 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2103 gtk_widget_show_all(messagewin);
2104 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2105 mainwin->messageview->handlebox,
2106 prefs_common.toolbar_style);
2110 messageview_add_toolbar(mainwin->messageview, messagewin);
2111 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2112 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2114 gtk_box_pack_start(GTK_BOX(vbox_body),
2115 GTK_WIDGET_PTR(mainwin->summaryview),
2118 mainwin->win.sep_both.folderwin = folderwin;
2119 mainwin->win.sep_both.messagewin = messagewin;
2121 gtk_widget_realize(messagewin);
2122 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2123 gtk_widget_show_all(messagewin);
2124 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2125 mainwin->messageview->handlebox,
2126 prefs_common.toolbar_style);
2131 gtk_widget_set_uposition(mainwin->window,
2132 prefs_common.mainwin_x,
2133 prefs_common.mainwin_y);
2135 gtk_widget_queue_resize(vbox_body);
2136 gtk_widget_queue_resize(mainwin->vbox);
2137 gtk_widget_queue_resize(mainwin->window);
2138 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2139 * and mimeview icon list/ctree lose track of their visibility states */
2140 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2141 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2142 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2143 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2144 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2145 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2147 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2149 mainwin->type = type;
2152 /* toggle menu state */
2153 menuitem = gtk_item_factory_get_item
2154 (ifactory, "/View/Show or hide/Folder tree");
2155 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2156 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2157 prefs_common.folderview_visible);
2158 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2159 menuitem = gtk_item_factory_get_item
2160 (ifactory, "/View/Show or hide/Message view");
2161 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2162 (type & SEPARATE_MESSAGE) == 0 ? TRUE :
2163 prefs_common.msgview_visible);
2165 menuitem = gtk_item_factory_get_item
2166 (ifactory, "/View/Separate folder tree");
2167 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2168 ((type & SEPARATE_FOLDER) != 0));
2169 menuitem = gtk_item_factory_get_item
2170 (ifactory, "/View/Separate message view");
2171 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2172 ((type & SEPARATE_MESSAGE) != 0));
2176 (GTK_OBJECT(folderwin), "size_allocate",
2177 GTK_SIGNAL_FUNC(folder_window_size_allocate_cb),
2182 (GTK_OBJECT(messagewin), "size_allocate",
2183 GTK_SIGNAL_FUNC(message_window_size_allocate_cb),
2187 debug_print("done.\n");
2190 void main_window_destroy_all(void)
2192 while (mainwin_list != NULL) {
2193 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2195 /* free toolbar stuff */
2196 toolbar_clear_list(TOOLBAR_MAIN);
2197 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2198 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2200 g_free(mainwin->toolbar);
2203 mainwin_list = g_list_remove(mainwin_list, mainwin);
2205 g_list_free(mainwin_list);
2209 static void toolbar_account_button_pressed(GtkWidget *widget,
2210 GdkEventButton *event,
2213 MainWindow *mainwin = (MainWindow *)data;
2216 if (event->button != 3) return;
2218 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2219 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2222 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2223 menu_button_position, widget,
2224 event->button, event->time);
2228 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2231 gtk_widget_set_usize(child, 1, -1);
2234 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2237 gtk_widget_set_usize(child, -1, -1);
2240 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2243 MainWindow *mainwin = (MainWindow *)data;
2247 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2248 gtk_object_set_data(GTK_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);
2256 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2258 MainWindow *mainwin = (MainWindow *)data;
2261 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2262 if (!button) return;
2263 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2264 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2265 manage_window_focus_in(mainwin->window, NULL, NULL);
2268 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2271 MainWindow *mainwin = (MainWindow *)data;
2273 if (mainwin->lock_count == 0)
2274 app_exit_cb(data, 0, widget);
2279 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2282 MainWindow *mainwin = (MainWindow *)data;
2283 GtkWidget *menuitem;
2285 menuitem = gtk_item_factory_get_item
2286 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2287 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2292 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2295 MainWindow *mainwin = (MainWindow *)data;
2296 GtkWidget *menuitem;
2298 menuitem = gtk_item_factory_get_item
2299 (mainwin->menu_factory, "/View/Show or hide/Message view");
2300 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2302 mainwin->messageview->statusbar = mainwin->statusbar;
2303 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2308 static void main_window_size_allocate_cb(GtkWidget *widget,
2309 GtkAllocation *allocation,
2312 MainWindow *mainwin = (MainWindow *)data;
2314 main_window_get_size(mainwin);
2317 static void folder_window_size_allocate_cb(GtkWidget *widget,
2318 GtkAllocation *allocation,
2321 MainWindow *mainwin = (MainWindow *)data;
2323 main_window_get_size(mainwin);
2326 static void message_window_size_allocate_cb(GtkWidget *widget,
2327 GtkAllocation *allocation,
2330 MainWindow *mainwin = (MainWindow *)data;
2332 main_window_get_size(mainwin);
2335 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2338 main_window_add_mailbox(mainwin);
2341 static void update_folderview_cb(MainWindow *mainwin, guint action,
2344 summary_show(mainwin->summaryview, NULL);
2345 folderview_check_new_all();
2348 static void foldersort_cb(MainWindow *mainwin, guint action,
2354 static void import_mbox_cb(MainWindow *mainwin, guint action,
2357 import_mbox(mainwin->summaryview->folder_item);
2360 static void export_mbox_cb(MainWindow *mainwin, guint action,
2363 export_mbox(mainwin->summaryview->folder_item);
2366 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2369 summaryview_export_mbox_list(mainwin->summaryview);
2372 static void empty_trash_cb(MainWindow *mainwin, guint action,
2375 main_window_empty_trash(mainwin, TRUE);
2378 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2380 summary_save_as(mainwin->summaryview);
2383 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2385 summary_print(mainwin->summaryview);
2388 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2390 if (prefs_common.confirm_on_exit) {
2391 if (alertpanel(_("Exit"), _("Exit this program?"),
2392 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2394 manage_window_focus_in(mainwin->window, NULL, NULL);
2397 app_will_exit(widget, mainwin);
2400 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2403 summary_search(mainwin->summaryview);
2405 message_search(mainwin->messageview);
2408 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2413 active = GTK_CHECK_MENU_ITEM(widget)->active;
2415 switch (mainwin->type) {
2417 case SEPARATE_MESSAGE:
2420 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2422 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2425 case SEPARATE_FOLDER:
2426 debug_print("separate folder\n");
2428 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2430 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2434 gtk_widget_show(mainwin->win.sep_both.folderwin);
2436 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2440 prefs_common.folderview_visible = active;
2443 static void toggle_message_cb(MainWindow *mainwin, guint action,
2448 active = GTK_CHECK_MENU_ITEM(widget)->active;
2450 if (active != messageview_is_visible(mainwin->messageview))
2451 summary_toggle_view(mainwin->summaryview);
2454 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2457 toolbar_toggle(action, mainwin);
2460 void main_window_reply_cb(MainWindow *mainwin, guint action,
2463 MessageView *msgview = (MessageView*)mainwin->messageview;
2464 GSList *msginfo_list = NULL;
2466 g_return_if_fail(msgview != NULL);
2468 msginfo_list = summary_get_selection(mainwin->summaryview);
2469 g_return_if_fail(msginfo_list != NULL);
2470 compose_reply_from_messageview(msgview, msginfo_list, action);
2471 g_slist_free(msginfo_list);
2475 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2478 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2479 gtk_widget_show(mainwin->hbox_stat);
2480 prefs_common.show_statusbar = TRUE;
2482 gtk_widget_hide(mainwin->hbox_stat);
2483 prefs_common.show_statusbar = FALSE;
2487 static void separate_widget_cb(MainWindow *mainwin, guint action,
2492 if (GTK_CHECK_MENU_ITEM(widget)->active)
2493 type = mainwin->type | action;
2495 type = mainwin->type & ~action;
2497 main_window_separation_change(mainwin, type);
2499 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2500 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2503 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2506 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2508 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2511 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2513 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2516 static void online_switch_clicked (GtkButton *btn, gpointer data)
2518 MainWindow *mainwin;
2519 GtkItemFactory *ifactory;
2520 GtkCheckMenuItem *menuitem;
2522 mainwin = (MainWindow *) data;
2524 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2525 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2527 g_return_if_fail(mainwin != NULL);
2528 g_return_if_fail(menuitem != NULL);
2530 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2532 gtk_widget_hide (mainwin->online_switch);
2533 gtk_widget_show (mainwin->offline_switch);
2534 menuitem->active = TRUE;
2535 prefs_common.work_offline = TRUE;
2536 inc_autocheck_timer_remove();
2539 gtk_widget_hide (mainwin->offline_switch);
2540 gtk_widget_show (mainwin->online_switch);
2541 menuitem->active = FALSE;
2542 prefs_common.work_offline = FALSE;
2543 inc_autocheck_timer_set();
2547 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2550 addressbook_open(NULL);
2553 static void log_window_show_cb(MainWindow *mainwin, guint action,
2556 log_window_show(mainwin->logwin);
2559 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2564 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2566 summary_move_to(mainwin->summaryview);
2569 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2571 summary_copy_to(mainwin->summaryview);
2574 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2576 summary_delete(mainwin->summaryview);
2579 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2581 summary_cancel(mainwin->summaryview);
2584 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2586 summary_open_msg(mainwin->summaryview);
2589 static void view_source_cb(MainWindow *mainwin, guint action,
2592 summary_view_source(mainwin->summaryview);
2595 static void show_all_header_cb(MainWindow *mainwin, guint action,
2598 if (mainwin->menu_lock_count) return;
2599 summary_display_msg_selected(mainwin->summaryview,
2600 GTK_CHECK_MENU_ITEM(widget)->active);
2603 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2605 summary_mark(mainwin->summaryview);
2608 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2610 summary_unmark(mainwin->summaryview);
2613 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2616 summary_mark_as_unread(mainwin->summaryview);
2619 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2622 summary_mark_as_read(mainwin->summaryview);
2625 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2628 summary_mark_all_read(mainwin->summaryview);
2631 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2633 summary_reedit(mainwin->summaryview);
2636 static void add_address_cb(MainWindow *mainwin, guint action,
2639 summary_add_address(mainwin->summaryview);
2642 static void set_charset_cb(MainWindow *mainwin, guint action,
2647 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2648 str = conv_get_charset_str((CharSet)action);
2650 g_free(mainwin->messageview->forced_charset);
2651 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2652 procmime_force_charset(str);
2654 summary_redisplay_msg(mainwin->summaryview);
2656 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2660 static void set_decode_cb(MainWindow *mainwin, guint action,
2663 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2664 mainwin->messageview->forced_encoding = (EncodingType)action;
2666 summary_redisplay_msg(mainwin->summaryview);
2668 debug_print("forced encoding: %d\n", action);
2672 static void hide_read_messages (MainWindow *mainwin, guint action,
2675 if (!mainwin->summaryview->folder_item
2676 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2678 summary_toggle_show_read_messages(mainwin->summaryview);
2681 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2683 if (mainwin->menu_lock_count) return;
2684 if (!mainwin->summaryview->folder_item) return;
2686 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2687 summary_thread_build(mainwin->summaryview);
2688 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2690 summary_unthread(mainwin->summaryview);
2691 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2695 static void expand_threads_cb(MainWindow *mainwin, guint action,
2698 summary_expand_threads(mainwin->summaryview);
2701 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2704 summary_collapse_threads(mainwin->summaryview);
2707 static void set_display_item_cb(MainWindow *mainwin, guint action,
2710 prefs_summary_column_open();
2713 static void sort_summary_cb(MainWindow *mainwin, guint action,
2716 FolderItem *item = mainwin->summaryview->folder_item;
2717 GtkWidget *menuitem;
2719 if (mainwin->menu_lock_count) return;
2721 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2722 menuitem = gtk_item_factory_get_item
2723 (mainwin->menu_factory, "/View/Sort/Ascending");
2724 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2725 GTK_CHECK_MENU_ITEM(menuitem)->active
2726 ? SORT_ASCENDING : SORT_DESCENDING);
2730 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2733 FolderItem *item = mainwin->summaryview->folder_item;
2735 if (mainwin->menu_lock_count) return;
2737 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2738 summary_sort(mainwin->summaryview,
2739 item->sort_key, (FolderSortType)action);
2742 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2745 summary_attract_by_subject(mainwin->summaryview);
2748 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2753 item = folderview_get_selected_item(mainwin->folderview);
2755 main_window_cursor_wait(mainwin);
2756 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2758 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2759 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2761 STATUSBAR_POP(mainwin);
2762 main_window_cursor_normal(mainwin);
2772 static void deldup_all(FolderItem *item, gpointer _data)
2774 struct DelDupsData *data = _data;
2777 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2779 data->dups += result;
2784 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2787 struct DelDupsData data = {0, 0};
2789 folder_func_to_all_folders(deldup_all, &data);
2790 alertpanel_notice(_("Deleted %d duplicate message(s) in %d folders.\n"),
2791 data.dups, data.folders);
2794 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2796 summary_filter(mainwin->summaryview, (gboolean)action);
2799 static void execute_summary_cb(MainWindow *mainwin, guint action,
2802 summary_execute(mainwin->summaryview);
2805 static void update_summary_cb(MainWindow *mainwin, guint action,
2809 FolderView *folderview = mainwin->folderview;
2811 if (!mainwin->summaryview->folder_item) return;
2812 if (!folderview->opened) return;
2814 folder_update_op_count();
2816 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2817 folderview->opened);
2820 folder_item_scan(fitem);
2821 summary_show(mainwin->summaryview, fitem);
2824 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2826 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2829 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2831 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2834 static void prev_unread_cb(MainWindow *mainwin, guint action,
2837 summary_select_prev_unread(mainwin->summaryview);
2840 static void next_unread_cb(MainWindow *mainwin, guint action,
2843 summary_select_next_unread(mainwin->summaryview);
2846 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2848 summary_select_prev_new(mainwin->summaryview);
2851 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2853 summary_select_next_new(mainwin->summaryview);
2856 static void prev_marked_cb(MainWindow *mainwin, guint action,
2859 summary_select_prev_marked(mainwin->summaryview);
2862 static void next_marked_cb(MainWindow *mainwin, guint action,
2865 summary_select_next_marked(mainwin->summaryview);
2868 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2871 summary_select_prev_labeled(mainwin->summaryview);
2874 static void next_labeled_cb(MainWindow *mainwin, guint action,
2877 summary_select_next_labeled(mainwin->summaryview);
2880 static void goto_folder_cb(MainWindow *mainwin, guint action,
2883 FolderItem *to_folder;
2885 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2888 folderview_select(mainwin->folderview, to_folder);
2891 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2893 messageview_copy_clipboard(mainwin->messageview);
2896 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2898 MessageView *msgview = mainwin->messageview;
2900 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2901 summary_select_all(mainwin->summaryview);
2902 else if (messageview_is_visible(msgview) &&
2903 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2904 messageview_select_all(mainwin->messageview);
2907 static void select_thread_cb(MainWindow *mainwin, guint action,
2910 summary_select_thread(mainwin->summaryview);
2913 static void create_filter_cb(MainWindow *mainwin, guint action,
2916 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2919 static void create_processing_cb(MainWindow *mainwin, guint action,
2922 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2925 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2928 /* prefs_common_open(); */
2931 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2934 prefs_filtering_open(&pre_global_processing,
2935 _("Processing rules to apply before folder rules"),
2939 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2942 prefs_filtering_open(&post_global_processing,
2943 _("Processing rules to apply after folder rules"),
2947 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2950 prefs_filtering_open(&filtering_rules,
2951 _("Filtering configuration"),
2955 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2958 prefs_template_open();
2961 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2964 prefs_actions_open(mainwin);
2967 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
2970 ssl_manager_open(mainwin);
2973 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2977 new_account_cb(mainwin, 0, widget);
2979 account_open(cur_account);
2983 static void new_account_cb(MainWindow *mainwin, guint action,
2986 account_edit_open();
2987 if (!compose_get_compose_list()) account_add();
2990 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
2992 cur_account = (PrefsAccount *)data;
2993 main_window_reflect_prefs_all();
2996 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
2998 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
2999 PrefsAccount *account = (PrefsAccount *)data;
3001 inc_account_mail(mainwin, account);
3004 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3009 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3011 pluginwindow_create();
3014 static void manual_open_cb(MainWindow *mainwin, guint action,
3017 manual_open((ManualType)action);
3020 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3022 MainWindow *mainwin = (MainWindow *)data;
3026 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3027 LOCAL_FOLDER(folder)->rootpath,
3031 str = g_strdup_printf(_("Scanning folder %s ..."),
3032 LOCAL_FOLDER(folder)->rootpath);
3034 STATUSBAR_PUSH(mainwin, str);
3035 STATUSBAR_POP(mainwin);
3039 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3042 SummaryView *summary;
3044 g_return_val_if_fail(data, FALSE);
3045 summary = ((MainWindow *)data)->summaryview;
3046 g_return_val_if_fail(summary, FALSE);
3048 if (GTK_CLIST(summary->ctree)->selection &&
3049 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3052 if (summary->selected != summary->displayed)
3053 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3057 #define BREAK_ON_MODIFIER_KEY() \
3058 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3060 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3063 MainWindow *mainwin = (MainWindow*) data;
3065 if (!mainwin || !event) return;
3067 switch (event->keyval) {
3068 case GDK_Q: /* Quit */
3069 BREAK_ON_MODIFIER_KEY();
3071 app_exit_cb(mainwin, 0, NULL);
3074 if (mainwin->folderview && mainwin->summaryview
3075 && !mainwin->summaryview->displayed) {
3076 summary_lock(mainwin->summaryview);
3077 folderview_select_next_unread(mainwin->folderview);
3078 summary_unlock(mainwin->summaryview);
3086 #undef BREAK_ON_MODIFIER_KEY
3089 * Harvest addresses for selected folder.
3091 static void addr_harvest_cb( MainWindow *mainwin,
3095 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3099 * Harvest addresses for selected messages in summary view.
3101 static void addr_harvest_msg_cb( MainWindow *mainwin,
3105 summary_harvest_address( mainwin->summaryview );
3109 *\brief get a MainWindow
3111 *\return MainWindow * The first mainwindow in the mainwin_list
3113 MainWindow *mainwindow_get_mainwindow(void)
3115 if (mainwin_list && mainwin_list->data)
3116 return (MainWindow *)(mainwin_list->data);
3121 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3123 ProgressData *data = (ProgressData *) source;
3124 MainWindow *mainwin = (MainWindow *) userdata;
3126 switch (data->cmd) {
3127 case PROGRESS_COMMAND_START:
3128 case PROGRESS_COMMAND_STOP:
3129 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), 0.0);
3131 case PROGRESS_COMMAND_SET_PERCENTAGE:
3132 gtk_progress_set_percentage(GTK_PROGRESS(mainwin->progressbar), data->value);
3135 while (gtk_events_pending()) gtk_main_iteration ();