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/Exp_ort 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/Simplified Chinese (GBK)"),
610 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
612 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
613 ENC_ACTION(C_EUC_TW)},
614 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
615 ENC_ACTION(C_ISO_2022_CN)},
618 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
619 ENC_ACTION(C_EUC_KR)},
620 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
621 ENC_ACTION(C_ISO_2022_KR)},
624 {N_("/_View/Character _encoding/Thai (TIS-620)"),
625 ENC_ACTION(C_TIS_620)},
626 {N_("/_View/Character _encoding/Thai (Windows-874)"),
627 ENC_ACTION(C_WINDOWS_874)},
632 #define DEC_SEPARATOR \
633 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
634 #define DEC_ACTION(action) \
635 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
636 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
637 {N_("/_View/Decode/_Auto detect"),
638 NULL, set_decode_cb, 0, "<RadioItem>"},
639 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
641 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
642 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
643 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
648 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
649 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
650 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
651 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
652 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
655 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
656 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
657 {N_("/_Message/Recei_ve/Get from _current account"),
658 "<control>I", inc_mail_cb, 0, NULL},
659 {N_("/_Message/Recei_ve/Get from _all accounts"),
660 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
661 {N_("/_Message/Recei_ve/Cancel receivin_g"),
662 NULL, inc_cancel_cb, 0, NULL},
663 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
665 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
666 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
667 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
668 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
669 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
671 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
672 {N_("/_Message/Repl_y to/mailing _list"),
673 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
674 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
675 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
676 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD, NULL},
677 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
678 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
680 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
681 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
682 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
683 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
685 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
686 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
687 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
688 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
689 {N_("/_Message/_Mark/Mark as rea_d"),
690 NULL, mark_as_read_cb, 0, NULL},
691 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
692 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
693 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
695 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
696 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
697 {N_("/_Tools/Add sender to address boo_k"),
698 NULL, add_address_cb, 0, NULL},
699 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Tools/_Harvest addresses/from _Folder..."),
701 NULL, addr_harvest_cb, 0, NULL},
702 {N_("/_Tools/_Harvest addresses/from _Messages..."),
703 NULL, addr_harvest_msg_cb, 0, NULL},
704 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
705 {N_("/_Tools/_Filter all messages in folder"),
706 NULL, filter_cb, 0, NULL},
707 {N_("/_Tools/Filter _selected messages"),
708 NULL, filter_cb, 1, NULL},
709 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
710 {N_("/_Tools/_Create filter rule/_Automatically"),
711 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
712 {N_("/_Tools/_Create filter rule/by _From"),
713 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
714 {N_("/_Tools/_Create filter rule/by _To"),
715 NULL, create_filter_cb, FILTER_BY_TO, NULL},
716 {N_("/_Tools/_Create filter rule/by _Subject"),
717 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
718 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
719 {N_("/_Tools/C_reate processing rule/_Automatically"),
720 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
721 {N_("/_Tools/C_reate processing rule/by _From"),
722 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
723 {N_("/_Tools/C_reate processing rule/by _To"),
724 NULL, create_processing_cb, FILTER_BY_TO, NULL},
725 {N_("/_Tools/C_reate processing rule/by _Subject"),
726 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
727 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
729 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_Tools/Ch_eck for new messages in all folders"),
731 NULL, update_folderview_cb, 0, NULL},
732 {N_("/_Tools/Delete du_plicated messages"),
733 NULL, NULL, 0, "<Branch>"},
734 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
735 NULL, delete_duplicated_cb, 0, NULL},
736 {N_("/_Tools/Delete du_plicated messages/In all folders"),
737 NULL, delete_duplicated_all_cb, 0, NULL},
738 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
739 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
741 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
742 {N_("/_Tools/SSL cer_tificates..."),
743 NULL, ssl_manager_open_cb, 0, NULL},
745 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
746 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
748 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
749 {N_("/_Configuration/C_hange current account"),
750 NULL, NULL, 0, "<Branch>"},
751 {N_("/_Configuration/_Preferences for current account..."),
752 NULL, prefs_account_open_cb, 0, NULL},
753 {N_("/_Configuration/Create _new account..."),
754 NULL, new_account_cb, 0, NULL},
755 {N_("/_Configuration/_Edit accounts..."),
756 NULL, account_edit_open, 0, NULL},
757 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
758 {N_("/_Configuration/P_references..."),
759 NULL, prefs_open_cb, 0, NULL},
760 {N_("/_Configuration/Pre-pr_ocessing..."),
761 NULL, prefs_pre_processing_open_cb, 0, NULL},
762 {N_("/_Configuration/Post-pro_cessing..."),
763 NULL, prefs_post_processing_open_cb, 0, NULL},
764 {N_("/_Configuration/_Filtering..."),
765 NULL, prefs_filtering_open_cb, 0, NULL},
766 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
767 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
768 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
770 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
771 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
772 {N_("/_Help/Ma_nual (Sylpheed Doc Homepage)"),
773 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
774 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
775 {N_("/_Help/FA_Q (Sylpheed Doc Homepage)"),
776 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
777 {N_("/_Help/_Claws FAQ (Claws Documentation)"),
778 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
779 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
780 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
783 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
789 MainWindow *mainwin = (MainWindow *)user_data;
791 if (mainwin->summaryview &&
792 mainwin->summaryview->quicksearch &&
793 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
794 (mod == 0 || mod == GDK_SHIFT_MASK)) {
795 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
801 MainWindow *main_window_create(SeparateType type)
807 GtkWidget *handlebox;
808 GtkWidget *vbox_body;
809 GtkWidget *hbox_stat;
810 GtkWidget *statusbar;
811 GtkWidget *progressbar;
812 GtkWidget *statuslabel;
813 GtkWidget *ac_button;
815 GtkWidget *online_pixmap;
816 GtkWidget *offline_pixmap;
817 GtkWidget *online_switch;
818 GtkWidget *offline_switch;
819 GtkTooltips *offline_tip;
820 GtkTooltips *online_tip;
821 GtkTooltips *sel_ac_tip;
823 FolderView *folderview;
824 SummaryView *summaryview;
825 MessageView *messageview;
826 GdkColormap *colormap;
829 GtkItemFactory *ifactory;
833 guint n_menu_entries;
834 gboolean hide_messageview = FALSE;
836 static GdkGeometry geometry;
838 debug_print("Creating main window...\n");
839 mainwin = g_new0(MainWindow, 1);
842 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
843 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
844 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
846 if (!geometry.min_height) {
847 geometry.min_width = 320;
848 geometry.min_height = 200;
850 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
853 g_signal_connect(G_OBJECT(window), "delete_event",
854 G_CALLBACK(main_window_close_cb), mainwin);
855 MANAGE_WINDOW_SIGNALS_CONNECT(window);
856 g_signal_connect(G_OBJECT(window), "focus_in_event",
857 G_CALLBACK(mainwindow_focus_in_event),
859 g_signal_connect(G_OBJECT(window), "key_press_event",
860 G_CALLBACK(mainwindow_key_pressed), mainwin);
862 gtk_widget_realize(window);
863 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
866 gtkut_widget_set_app_icon(window);
868 vbox = gtk_vbox_new(FALSE, 0);
869 gtk_widget_show(vbox);
870 gtk_container_add(GTK_CONTAINER(window), vbox);
873 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
874 menubar = menubar_create(window, mainwin_entries,
875 n_menu_entries, "<Main>", mainwin);
876 gtk_widget_show(menubar);
877 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
878 ifactory = gtk_item_factory_from_widget(menubar);
880 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
881 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
883 handlebox = gtk_handle_box_new();
884 gtk_widget_show(handlebox);
885 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
886 g_signal_connect(G_OBJECT(handlebox), "child_attached",
887 G_CALLBACK(toolbar_child_attached), mainwin);
888 g_signal_connect(G_OBJECT(handlebox), "child_detached",
889 G_CALLBACK(toolbar_child_detached), mainwin);
891 /* link window to mainwin->window to avoid gdk warnings */
892 mainwin->window = window;
895 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
899 /* vbox that contains body */
900 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
901 gtk_widget_show(vbox_body);
902 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
903 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
905 hbox_stat = gtk_hbox_new(FALSE, 2);
906 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
908 statusbar = statusbar_create();
909 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
911 progressbar = gtk_progress_bar_new();
912 gtk_widget_set_size_request(progressbar, 120, 1);
913 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
915 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
916 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
917 online_tip = gtk_tooltips_new();
918 online_switch = gtk_button_new ();
919 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
920 _("You are online. Click the icon to go offline"), NULL);
921 offline_tip = gtk_tooltips_new();
922 offline_switch = gtk_button_new ();
923 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
924 _("You are offline. Click the icon to go online"),
926 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
927 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
928 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
929 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
930 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
931 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
932 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
933 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
935 statuslabel = gtk_label_new("");
936 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
938 sel_ac_tip = gtk_tooltips_new();
939 ac_button = gtk_button_new();
940 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
941 ac_button, _("Select account"), NULL);
942 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
943 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
944 gtk_widget_set_size_request(ac_button, -1, 0);
945 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
946 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
947 G_CALLBACK(ac_label_button_pressed), mainwin);
949 ac_label = gtk_label_new("");
950 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
952 gtk_widget_show_all(hbox_stat);
954 gtk_widget_hide(offline_switch);
956 mainwin->folderview = folderview = folderview_create();
957 mainwin->summaryview = summaryview = summary_create();
958 mainwin->messageview = messageview = messageview_create(mainwin);
959 mainwin->logwin = log_window_create();
961 folderview->mainwin = mainwin;
962 folderview->summaryview = summaryview;
964 summaryview->mainwin = mainwin;
965 summaryview->folderview = folderview;
966 summaryview->messageview = messageview;
967 summaryview->window = window;
969 messageview->statusbar = statusbar;
970 mainwin->vbox = vbox;
971 mainwin->menubar = menubar;
972 mainwin->menu_factory = ifactory;
973 mainwin->handlebox = handlebox;
974 mainwin->vbox_body = vbox_body;
975 mainwin->hbox_stat = hbox_stat;
976 mainwin->statusbar = statusbar;
977 mainwin->progressbar = progressbar;
978 mainwin->statuslabel = statuslabel;
979 mainwin->online_switch = online_switch;
980 mainwin->online_pixmap = online_pixmap;
981 mainwin->offline_pixmap = offline_pixmap;
982 mainwin->ac_button = ac_button;
983 mainwin->ac_label = ac_label;
984 mainwin->offline_switch = offline_switch;
986 /* set context IDs for status bar */
987 mainwin->mainwin_cid = gtk_statusbar_get_context_id
988 (GTK_STATUSBAR(statusbar), "Main Window");
989 mainwin->folderview_cid = gtk_statusbar_get_context_id
990 (GTK_STATUSBAR(statusbar), "Folder View");
991 mainwin->summaryview_cid = gtk_statusbar_get_context_id
992 (GTK_STATUSBAR(statusbar), "Summary View");
993 mainwin->messageview_cid = gtk_statusbar_get_context_id
994 (GTK_STATUSBAR(statusbar), "Message View");
996 messageview->statusbar_cid = mainwin->messageview_cid;
998 /* allocate colors for summary view and folder view */
999 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1000 summaryview->color_marked.blue = (guint16)65535;
1002 summaryview->color_dim.red = summaryview->color_dim.green =
1003 summaryview->color_dim.blue = COLOR_DIM;
1005 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1006 &folderview->color_new);
1008 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1009 &folderview->color_op);
1011 summaryview->color_important.red = 0;
1012 summaryview->color_important.green = 0;
1013 summaryview->color_important.blue = (guint16)65535;
1015 color[0] = summaryview->color_marked;
1016 color[1] = summaryview->color_dim;
1017 color[2] = folderview->color_new;
1018 color[3] = folderview->color_op;
1020 colormap = gdk_window_get_colormap(window->window);
1021 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1022 for (i = 0; i < 4; i++) {
1023 if (success[i] == FALSE)
1024 g_warning("MainWindow: color allocation %d failed\n", i);
1027 debug_print("done.\n");
1029 messageview->visible = prefs_common.msgview_visible;
1030 hide_messageview = !messageview->visible;
1032 main_window_set_widgets(mainwin, type);
1034 g_signal_connect(G_OBJECT(window), "size_allocate",
1035 G_CALLBACK(main_window_size_allocate_cb),
1038 /* set menu items */
1039 menuitem = gtk_item_factory_get_item
1040 (ifactory, "/View/Character encoding/Auto detect");
1041 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1043 switch (prefs_common.toolbar_style) {
1045 menuitem = gtk_item_factory_get_item
1046 (ifactory, "/View/Show or hide/Toolbar/None");
1049 menuitem = gtk_item_factory_get_item
1050 (ifactory, "/View/Show or hide/Toolbar/Icon");
1053 menuitem = gtk_item_factory_get_item
1054 (ifactory, "/View/Show or hide/Toolbar/Text");
1057 menuitem = gtk_item_factory_get_item
1058 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1060 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1062 gtk_widget_hide(mainwin->hbox_stat);
1063 menuitem = gtk_item_factory_get_item
1064 (ifactory, "/View/Show or hide/Status bar");
1065 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1066 prefs_common.show_statusbar);
1068 /* set account selection menu */
1069 ac_menu = gtk_item_factory_get_widget
1070 (ifactory, "/Configuration/Change current account");
1071 g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1072 G_CALLBACK(ac_menu_popup_closed), mainwin);
1073 mainwin->ac_menu = ac_menu;
1075 toolbar_main_set_sensitive(mainwin);
1077 /* create actions menu */
1078 main_window_update_actions_menu(mainwin);
1080 /* attach accel groups to main window */
1081 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1082 gtk_window_add_accel_group \
1084 gtk_item_factory_from_widget(menu)->accel_group); \
1085 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1087 G_CALLBACK(main_window_accel_activate), mainwin);
1090 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1092 /* connect the accelerators for equivalent
1093 menu items in different menus */
1094 menu_connect_identical_items();
1098 /* show main window */
1099 gtk_widget_show(mainwin->window);
1101 /* initialize views */
1102 folderview_init(folderview);
1103 summary_init(summaryview);
1104 messageview_init(messageview);
1105 log_window_init(mainwin->logwin);
1106 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1107 prefs_common.loglength);
1109 sslcertwindow_register_hook();
1111 mainwin->lock_count = 0;
1112 mainwin->menu_lock_count = 0;
1113 mainwin->cursor_count = 0;
1115 mainwin->progressindicator_hook =
1116 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1119 watch_cursor = gdk_cursor_new(GDK_WATCH);
1121 mainwin_list = g_list_append(mainwin_list, mainwin);
1123 /* init work_offline */
1124 if (prefs_common.work_offline)
1125 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1127 if (mainwin->type == SEPARATE_NONE && hide_messageview)
1128 main_window_toggle_message_view(mainwin);
1133 void main_window_destroy(MainWindow *mainwin)
1135 /* TODO : destroy other component */
1136 messageview_destroy(mainwin->messageview);
1137 mainwin->messageview = NULL;
1140 void main_window_update_actions_menu(MainWindow *mainwin)
1142 GtkItemFactory *ifactory;
1144 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1145 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1148 void main_window_cursor_wait(MainWindow *mainwin)
1151 if (mainwin->cursor_count == 0)
1152 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1154 mainwin->cursor_count++;
1159 void main_window_cursor_normal(MainWindow *mainwin)
1161 if (mainwin->cursor_count)
1162 mainwin->cursor_count--;
1164 if (mainwin->cursor_count == 0)
1165 gdk_window_set_cursor(mainwin->window->window, NULL);
1170 /* lock / unlock the user-interface */
1171 void main_window_lock(MainWindow *mainwin)
1173 if (mainwin->lock_count == 0)
1174 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1176 mainwin->lock_count++;
1178 main_window_set_menu_sensitive(mainwin);
1179 toolbar_main_set_sensitive(mainwin);
1182 void main_window_unlock(MainWindow *mainwin)
1184 if (mainwin->lock_count)
1185 mainwin->lock_count--;
1187 main_window_set_menu_sensitive(mainwin);
1188 toolbar_main_set_sensitive(mainwin);
1190 if (mainwin->lock_count == 0)
1191 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1194 static void main_window_menu_callback_block(MainWindow *mainwin)
1196 mainwin->menu_lock_count++;
1199 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1201 if (mainwin->menu_lock_count)
1202 mainwin->menu_lock_count--;
1205 void main_window_reflect_prefs_all(void)
1207 main_window_reflect_prefs_all_real(FALSE);
1210 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1213 MainWindow *mainwin;
1216 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1217 mainwin = (MainWindow *)cur->data;
1219 main_window_show_cur_account(mainwin);
1220 main_window_set_menu_sensitive(mainwin);
1221 toolbar_main_set_sensitive(mainwin);
1224 if (pixmap_theme_changed) {
1225 toolbar_update(TOOLBAR_MAIN, mainwin);
1226 messageview_reflect_prefs_pixmap_theme();
1227 compose_reflect_prefs_pixmap_theme();
1228 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1229 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1231 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1232 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1233 mainwin->online_pixmap);
1234 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1235 gtk_widget_show(pixmap);
1236 mainwin->online_pixmap = pixmap;
1237 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1238 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1239 mainwin->offline_pixmap);
1240 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1241 gtk_widget_show(pixmap);
1242 mainwin->offline_pixmap = pixmap;
1245 summary_redisplay_msg(mainwin->summaryview);
1246 headerview_set_visibility(mainwin->messageview->headerview,
1247 prefs_common.display_header_pane);
1251 void main_window_set_summary_column(void)
1254 MainWindow *mainwin;
1256 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1257 mainwin = (MainWindow *)cur->data;
1258 summary_set_column_order(mainwin->summaryview);
1262 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1263 GList *account_list)
1265 GList *cur_ac, *cur_item;
1266 GtkWidget *menuitem;
1267 PrefsAccount *ac_prefs;
1269 /* destroy all previous menu item */
1270 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1271 while (cur_item != NULL) {
1272 GList *next = cur_item->next;
1273 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1277 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1278 ac_prefs = (PrefsAccount *)cur_ac->data;
1280 menuitem = gtk_menu_item_new_with_label
1281 (ac_prefs->account_name
1282 ? ac_prefs->account_name : _("Untitled"));
1283 gtk_widget_show(menuitem);
1284 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1285 g_signal_connect(G_OBJECT(menuitem), "activate",
1286 G_CALLBACK(account_selector_menu_cb),
1291 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1292 GList *account_list)
1294 GList *cur_ac, *cur_item;
1296 GtkWidget *menuitem;
1297 PrefsAccount *ac_prefs;
1299 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1300 "/Message/Receive");
1302 /* search for separator */
1303 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1304 cur_item = cur_item->next) {
1305 if (GTK_BIN(cur_item->data)->child == NULL) {
1306 cur_item = cur_item->next;
1311 /* destroy all previous menu item */
1312 while (cur_item != NULL) {
1313 GList *next = cur_item->next;
1314 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1318 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1319 ac_prefs = (PrefsAccount *)cur_ac->data;
1321 menuitem = gtk_menu_item_new_with_label
1322 (ac_prefs->account_name ? ac_prefs->account_name
1324 gtk_widget_show(menuitem);
1325 gtk_menu_append(GTK_MENU(menu), menuitem);
1326 g_signal_connect(G_OBJECT(menuitem), "activate",
1327 G_CALLBACK(account_receive_menu_cb),
1332 void main_window_set_account_menu(GList *account_list)
1335 MainWindow *mainwin;
1337 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1338 mainwin = (MainWindow *)cur->data;
1339 main_window_set_account_selector_menu(mainwin, account_list);
1340 main_window_set_account_receive_menu(mainwin, account_list);
1344 static void main_window_show_cur_account(MainWindow *mainwin)
1349 ac_name = g_strdup(cur_account
1350 ? (cur_account->account_name
1351 ? cur_account->account_name : _("Untitled"))
1355 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1357 buf = g_strdup(PROG_VERSION);
1358 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1361 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1362 gtk_widget_queue_resize(mainwin->ac_button);
1367 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1369 switch (mainwin->type) {
1370 case SEPARATE_FOLDER:
1371 return mainwin->win.sep_folder.folderwin;
1373 return mainwin->win.sep_both.folderwin;
1379 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1381 switch (mainwin->type) {
1382 case SEPARATE_MESSAGE:
1383 return mainwin->win.sep_message.messagewin;
1385 return mainwin->win.sep_both.messagewin;
1391 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1393 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1394 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1395 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1396 GtkWidget *message_wid = mainwin->messageview->vbox;
1398 debug_print("Changing window separation type from %d to %d\n",
1399 mainwin->type, type);
1401 if (mainwin->type == type) return;
1403 /* remove widgets from those containers */
1404 gtk_widget_ref(folder_wid);
1405 gtk_widget_ref(summary_wid);
1406 gtk_widget_ref(message_wid);
1407 gtkut_container_remove
1408 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1409 gtkut_container_remove
1410 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1411 gtkut_container_remove
1412 (GTK_CONTAINER(message_wid->parent), message_wid);
1414 /* clean containers */
1415 switch (mainwin->type) {
1417 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1419 case SEPARATE_FOLDER:
1420 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1421 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1423 case SEPARATE_MESSAGE:
1424 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1425 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1428 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1429 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1433 gtk_widget_hide(mainwin->window);
1434 main_window_set_widgets(mainwin, type);
1435 gtk_widget_show(mainwin->window);
1437 gtk_widget_unref(folder_wid);
1438 gtk_widget_unref(summary_wid);
1439 gtk_widget_unref(message_wid);
1442 void main_window_toggle_message_view(MainWindow *mainwin)
1444 SummaryView *summaryview = mainwin->summaryview;
1445 union CompositeWin *cwin = &mainwin->win;
1446 GtkWidget *vpaned = NULL;
1447 GtkWidget *container = NULL;
1448 GtkWidget *msgwin = NULL;
1450 switch (mainwin->type) {
1452 vpaned = cwin->sep_none.vpaned;
1453 container = cwin->sep_none.hpaned;
1455 case SEPARATE_FOLDER:
1456 vpaned = cwin->sep_folder.vpaned;
1457 container = mainwin->vbox_body;
1459 case SEPARATE_MESSAGE:
1460 msgwin = mainwin->win.sep_message.messagewin;
1463 msgwin = mainwin->win.sep_both.messagewin;
1468 if (GTK_WIDGET_VISIBLE(msgwin)) {
1469 gtk_widget_hide(msgwin);
1470 mainwin->messageview->visible = FALSE;
1471 summaryview->displayed = NULL;
1473 gtk_widget_show(msgwin);
1474 mainwin->messageview->visible = TRUE;
1476 } else if (vpaned->parent != NULL) {
1477 mainwin->messageview->visible = FALSE;
1478 summaryview->displayed = NULL;
1479 gtk_widget_ref(vpaned);
1480 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1481 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1483 mainwin->messageview->visible = TRUE;
1484 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1485 gtk_container_add(GTK_CONTAINER(container), vpaned);
1486 gtk_widget_unref(vpaned);
1489 if (messageview_is_visible(mainwin->messageview))
1490 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1491 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1493 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1494 GTK_ARROW_UP, GTK_SHADOW_OUT);
1496 if (mainwin->messageview->visible == FALSE)
1497 messageview_clear(mainwin->messageview);
1499 main_window_set_menu_sensitive(mainwin);
1501 prefs_common.msgview_visible = mainwin->messageview->visible;
1503 gtk_widget_grab_focus(summaryview->ctree);
1506 void main_window_get_size(MainWindow *mainwin)
1508 GtkAllocation *allocation;
1510 if (mainwin->messageview == NULL) {
1511 debug_print("called after messageview "
1512 "has been deallocated!\n");
1516 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1518 if (allocation->width > 1 && allocation->height > 1) {
1519 prefs_common.summaryview_width = allocation->width;
1521 if ((mainwin->type == SEPARATE_NONE ||
1522 mainwin->type == SEPARATE_FOLDER) &&
1523 messageview_is_visible(mainwin->messageview))
1524 prefs_common.summaryview_height = allocation->height;
1526 prefs_common.mainview_width = allocation->width;
1529 allocation = &mainwin->window->allocation;
1530 if (allocation->width > 1 && allocation->height > 1) {
1531 prefs_common.mainview_height = allocation->height;
1532 prefs_common.mainwin_width = allocation->width;
1533 prefs_common.mainwin_height = allocation->height;
1536 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1537 if (allocation->width > 1 && allocation->height > 1) {
1538 prefs_common.folderview_width = allocation->width;
1539 prefs_common.folderview_height = allocation->height;
1542 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1543 if (allocation->width > 1 && allocation->height > 1) {
1544 prefs_common.msgview_width = allocation->width;
1545 prefs_common.msgview_height = allocation->height;
1548 /* debug_print("summaryview size: %d x %d\n",
1549 prefs_common.summaryview_width,
1550 prefs_common.summaryview_height);
1551 debug_print("folderview size: %d x %d\n",
1552 prefs_common.folderview_width,
1553 prefs_common.folderview_height);
1554 debug_print("messageview size: %d x %d\n",
1555 prefs_common.msgview_width,
1556 prefs_common.msgview_height); */
1559 void main_window_get_position(MainWindow *mainwin)
1564 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1566 prefs_common.mainview_x = x;
1567 prefs_common.mainview_y = y;
1568 prefs_common.mainwin_x = x;
1569 prefs_common.mainwin_y = y;
1571 debug_print("main window position: %d, %d\n", x, y);
1573 window = main_window_get_folder_window(mainwin);
1575 gtkut_widget_get_uposition(window, &x, &y);
1576 prefs_common.folderwin_x = x;
1577 prefs_common.folderwin_y = y;
1578 debug_print("folder window position: %d, %d\n", x, y);
1580 window = main_window_get_message_window(mainwin);
1582 gtkut_widget_get_uposition(window, &x, &y);
1583 prefs_common.main_msgwin_x = x;
1584 prefs_common.main_msgwin_y = y;
1585 debug_print("message window position: %d, %d\n", x, y);
1589 void main_window_progress_on(MainWindow *mainwin)
1591 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1594 void main_window_progress_off(MainWindow *mainwin)
1596 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1597 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1600 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1604 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1605 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1606 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1607 (cur == 0 && total == 0) ? 0 :
1608 (gfloat)cur / (gfloat)total);
1611 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1617 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1618 folder = FOLDER(list->data);
1619 if (folder && folder->trash && folder->trash->total_msgs > 0)
1623 if (!has_trash) return;
1626 if (alertpanel(_("Empty trash"),
1627 _("Empty all messages in trash?"),
1628 GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1631 manage_window_focus_in(mainwin->window, NULL, NULL);
1634 procmsg_empty_all_trash();
1636 if (mainwin->summaryview->folder_item &&
1637 mainwin->summaryview->folder_item->stype == F_TRASH)
1638 gtk_widget_grab_focus(mainwin->folderview->ctree);
1641 void main_window_add_mailbox(MainWindow *mainwin)
1646 path = input_dialog(_("Add mailbox"),
1647 _("Input the location of mailbox.\n"
1648 "If the existing mailbox is specified, it will be\n"
1649 "scanned automatically."),
1652 if (folder_find_from_path(path)) {
1653 alertpanel_error(_("The mailbox `%s' already exists."), path);
1657 folder = folder_new(folder_get_class_from_string("mh"),
1658 !strcmp(path, "Mail") ? _("Mailbox") :
1659 g_path_get_basename(path), path);
1662 if (folder->klass->create_tree(folder) < 0) {
1663 alertpanel_error(_("Creation of the mailbox failed.\n"
1664 "Maybe some files already exist, or you don't have the permission to write there."));
1665 folder_destroy(folder);
1670 folder_set_ui_func(folder, scan_tree_func, mainwin);
1671 folder_scan_tree(folder);
1672 folder_set_ui_func(folder, NULL, NULL);
1675 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1677 SensitiveCond state = 0;
1678 SummarySelection selection;
1679 FolderItem *item = mainwin->summaryview->folder_item;
1680 GList *account_list = account_get_list();
1682 selection = summary_get_selection_type(mainwin->summaryview);
1684 if (mainwin->lock_count == 0)
1685 state |= M_UNLOCKED;
1686 if (selection != SUMMARY_NONE)
1687 state |= M_MSG_EXIST;
1688 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1690 /* if (item->folder->type != F_NEWS) */
1691 state |= M_ALLOW_DELETE;
1693 if (prefs_common.immediate_exec == 0
1694 && mainwin->lock_count == 0)
1695 state |= M_DELAY_EXEC;
1697 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1698 || selection != SUMMARY_NONE)
1699 state |= M_HIDE_READ_MSG;
1701 if (mainwin->summaryview->threaded)
1702 state |= M_THREADED;
1704 state |= M_UNTHREADED;
1705 if (selection == SUMMARY_SELECTED_SINGLE ||
1706 selection == SUMMARY_SELECTED_MULTIPLE)
1707 state |= M_TARGET_EXIST;
1708 if (selection == SUMMARY_SELECTED_SINGLE)
1709 state |= M_SINGLE_TARGET_EXIST;
1710 if (mainwin->summaryview->folder_item &&
1711 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1714 state |= M_NOT_NEWS;
1715 if (selection == SUMMARY_SELECTED_SINGLE &&
1717 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1718 item->stype == F_QUEUE)))
1719 state |= M_ALLOW_REEDIT;
1721 state |= M_HAVE_ACCOUNT;
1723 for ( ; account_list != NULL; account_list = account_list->next) {
1724 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1725 state |= M_HAVE_NEWS_ACCOUNT;
1730 if (inc_is_active())
1731 state |= M_INC_ACTIVE;
1738 void main_window_set_menu_sensitive(MainWindow *mainwin)
1740 GtkItemFactory *ifactory = mainwin->menu_factory;
1741 SensitiveCond state;
1744 GtkWidget *menuitem;
1745 SummaryView *summaryview;
1750 static const struct {
1754 {"/File/Add mailbox" , M_UNLOCKED},
1756 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1757 {"/File/Change folder order" , M_UNLOCKED},
1758 {"/File/Export to mbox file..." , M_UNLOCKED},
1759 {"/File/Empty all Trash folders" , M_UNLOCKED},
1760 {"/File/Work offline" , M_UNLOCKED},
1762 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1763 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1764 /* {"/File/Close" , M_UNLOCKED}, */
1765 {"/File/Exit" , M_UNLOCKED},
1767 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1769 {"/View/Sort" , M_EXEC},
1770 {"/View/Thread view" , M_EXEC},
1771 {"/View/Expand all threads" , M_MSG_EXIST},
1772 {"/View/Collapse all threads" , M_MSG_EXIST},
1773 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1774 {"/View/Go to/Prev message" , M_MSG_EXIST},
1775 {"/View/Go to/Next message" , M_MSG_EXIST},
1776 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1777 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1778 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1779 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1780 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1781 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1782 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1783 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1784 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1786 {"/Message/Receive/Get from current account"
1787 , M_HAVE_ACCOUNT|M_UNLOCKED},
1788 {"/Message/Receive/Get from all accounts"
1789 , M_HAVE_ACCOUNT|M_UNLOCKED},
1790 {"/Message/Receive/Cancel receiving"
1793 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1794 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1795 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1796 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1797 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1798 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1799 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1800 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1801 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1802 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1803 {"/Message/Mark" , M_TARGET_EXIST},
1804 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1806 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1807 {"/Tools/Harvest addresses" , M_UNLOCKED},
1808 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1809 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1810 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1811 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1812 {"/Tools/Execute" , M_DELAY_EXEC},
1813 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1815 {"/Configuration", M_UNLOCKED},
1820 state = main_window_get_current_state(mainwin);
1822 for (i = 0; entry[i].entry != NULL; i++) {
1823 sensitive = ((entry[i].cond & state) == entry[i].cond);
1824 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1827 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1829 /* search for separator */
1830 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1831 cur_item = cur_item->next) {
1832 if (GTK_BIN(cur_item->data)->child == NULL) {
1833 cur_item = cur_item->next;
1838 for (; cur_item != NULL; cur_item = cur_item->next) {
1839 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1840 (M_UNLOCKED & state) != 0);
1843 main_window_menu_callback_block(mainwin);
1845 #define SET_CHECK_MENU_ACTIVE(path, active) \
1847 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1848 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1851 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1852 messageview_is_visible(mainwin->messageview));
1854 summaryview = mainwin->summaryview;
1855 menu_path = "/View/Sort/Don't sort";
1857 switch (summaryview->sort_key) {
1858 case SORT_BY_NUMBER:
1859 menu_path = "/View/Sort/by number"; break;
1861 menu_path = "/View/Sort/by size"; break;
1863 menu_path = "/View/Sort/by date"; break;
1865 menu_path = "/View/Sort/by from"; break;
1867 menu_path = "/View/Sort/by recipient"; break;
1868 case SORT_BY_SUBJECT:
1869 menu_path = "/View/Sort/by subject"; break;
1871 menu_path = "/View/Sort/by color label"; break;
1873 menu_path = "/View/Sort/by mark"; break;
1874 case SORT_BY_STATUS:
1875 menu_path = "/View/Sort/by status"; break;
1877 menu_path = "/View/Sort/by attachment"; break;
1879 menu_path = "/View/Sort/by score"; break;
1880 case SORT_BY_LOCKED:
1881 menu_path = "/View/Sort/by locked"; break;
1884 menu_path = "/View/Sort/Don't sort"; break;
1886 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1888 if (summaryview->sort_type == SORT_ASCENDING) {
1889 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1891 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1894 if (summaryview->sort_key != SORT_BY_NONE) {
1895 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1896 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1898 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1899 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1902 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1903 mainwin->messageview->mimeview->textview->show_all_headers);
1904 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1906 #undef SET_CHECK_MENU_ACTIVE
1908 main_window_menu_callback_unblock(mainwin);
1911 void main_window_popup(MainWindow *mainwin)
1913 gtkut_window_popup(mainwin->window);
1915 switch (mainwin->type) {
1916 case SEPARATE_FOLDER:
1917 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1919 case SEPARATE_MESSAGE:
1920 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1923 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1924 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1931 void main_window_show(MainWindow *mainwin)
1933 gtk_widget_show(mainwin->window);
1934 gtk_widget_show(mainwin->vbox_body);
1936 gtk_widget_set_uposition(mainwin->window,
1937 prefs_common.mainwin_x,
1938 prefs_common.mainwin_y);
1940 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1941 prefs_common.folderview_width,
1942 prefs_common.folderview_height);
1943 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1944 prefs_common.summaryview_width,
1945 prefs_common.summaryview_height);
1946 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1947 prefs_common.msgview_width,
1948 prefs_common.msgview_height);
1950 if (mainwin->type & SEPARATE_FOLDER) {
1951 GtkWidget *folderwin;
1953 folderwin = main_window_get_folder_window(mainwin);
1954 gtk_widget_show(folderwin);
1955 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1956 prefs_common.folderwin_y);
1959 if (mainwin->type & SEPARATE_MESSAGE) {
1960 GtkWidget *messagewin;
1962 messagewin = main_window_get_message_window(mainwin);
1963 gtk_widget_show(messagewin);
1964 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1965 prefs_common.main_msgwin_y);
1969 void main_window_hide(MainWindow *mainwin)
1971 main_window_get_size(mainwin);
1972 main_window_get_position(mainwin);
1974 gtk_widget_hide(mainwin->window);
1975 gtk_widget_hide(mainwin->vbox_body);
1977 if (mainwin->type & SEPARATE_FOLDER) {
1978 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1981 if (mainwin->type & SEPARATE_MESSAGE) {
1982 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1986 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1988 GtkWidget *folderwin = NULL;
1989 GtkWidget *messagewin = NULL;
1992 GtkWidget *vbox_body = mainwin->vbox_body;
1993 GtkItemFactory *ifactory = mainwin->menu_factory;
1994 GtkWidget *menuitem;
1995 GtkItemFactory *msgview_ifactory;
1997 debug_print("Setting widgets... ");
1999 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2000 prefs_common.folderview_width,
2001 prefs_common.folderview_height);
2002 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2003 prefs_common.summaryview_width,
2004 prefs_common.summaryview_height);
2005 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2006 prefs_common.msgview_width,
2007 prefs_common.msgview_height);
2009 /* create separated window(s) if needed */
2010 if (type & SEPARATE_FOLDER) {
2011 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2012 gtk_window_set_title(GTK_WINDOW(folderwin),
2013 _("Sylpheed - Folder View"));
2014 gtk_window_set_resizable(GTK_WINDOW(folderwin), TRUE);
2015 gtk_window_move(GTK_WINDOW(folderwin), prefs_common.folderwin_x,
2016 prefs_common.folderwin_y);
2017 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2019 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2020 G_CALLBACK(folder_window_close_cb),
2022 gtk_container_add(GTK_CONTAINER(folderwin),
2023 GTK_WIDGET_PTR(mainwin->folderview));
2024 gtk_widget_realize(folderwin);
2025 if (prefs_common.folderview_visible)
2026 gtk_widget_show(folderwin);
2029 if (type & SEPARATE_MESSAGE) {
2030 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2031 gtk_window_set_title(GTK_WINDOW(messagewin),
2032 _("Sylpheed - Message View"));
2033 gtk_window_set_resizable(GTK_WINDOW(messagewin), TRUE);
2034 gtk_window_move(GTK_WINDOW(messagewin),
2035 prefs_common.main_msgwin_x,
2036 prefs_common.main_msgwin_y);
2037 gtk_widget_set_size_request(messagewin,
2038 prefs_common.msgwin_width,
2039 prefs_common.msgwin_height);
2040 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2042 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2043 G_CALLBACK(message_window_close_cb),
2045 if (messageview_is_visible(mainwin->messageview))
2046 gtk_widget_show(messagewin);
2048 mainwin->messageview->statusbar = mainwin->statusbar;
2049 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2054 hpaned = gtk_hpaned_new();
2055 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2056 gtk_paned_add1(GTK_PANED(hpaned),
2057 GTK_WIDGET_PTR(mainwin->folderview));
2058 gtk_widget_show(hpaned);
2059 gtk_widget_queue_resize(hpaned);
2061 vpaned = gtk_vpaned_new();
2062 if (messageview_is_visible(mainwin->messageview)) {
2063 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2064 gtk_paned_add1(GTK_PANED(vpaned),
2065 GTK_WIDGET_PTR(mainwin->summaryview));
2067 gtk_paned_add2(GTK_PANED(hpaned),
2068 GTK_WIDGET_PTR(mainwin->summaryview));
2069 gtk_widget_ref(vpaned);
2071 gtk_paned_add2(GTK_PANED(vpaned),
2072 GTK_WIDGET_PTR(mainwin->messageview));
2073 gtk_widget_show(vpaned);
2074 gtk_widget_queue_resize(vpaned);
2076 mainwin->win.sep_none.hpaned = hpaned;
2077 mainwin->win.sep_none.vpaned = vpaned;
2079 /* remove headerview if not in prefs */
2080 headerview_set_visibility(mainwin->messageview->headerview,
2081 prefs_common.display_header_pane);
2083 case SEPARATE_FOLDER:
2084 vpaned = gtk_vpaned_new();
2085 if (messageview_is_visible(mainwin->messageview)) {
2086 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2088 gtk_paned_add1(GTK_PANED(vpaned),
2089 GTK_WIDGET_PTR(mainwin->summaryview));
2091 gtk_box_pack_start(GTK_BOX(vbox_body),
2092 GTK_WIDGET_PTR(mainwin->summaryview),
2094 gtk_widget_ref(vpaned);
2096 gtk_paned_add2(GTK_PANED(vpaned),
2097 GTK_WIDGET_PTR(mainwin->messageview));
2098 gtk_widget_show(vpaned);
2099 gtk_widget_queue_resize(vpaned);
2101 mainwin->win.sep_folder.folderwin = folderwin;
2102 mainwin->win.sep_folder.vpaned = vpaned;
2104 /* remove headerview if not in prefs */
2105 headerview_set_visibility(mainwin->messageview->headerview,
2106 prefs_common.display_header_pane);
2109 case SEPARATE_MESSAGE:
2110 hpaned = gtk_hpaned_new();
2111 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2112 gtk_paned_add1(GTK_PANED(hpaned),
2113 GTK_WIDGET_PTR(mainwin->folderview));
2114 gtk_paned_add2(GTK_PANED(hpaned),
2115 GTK_WIDGET_PTR(mainwin->summaryview));
2116 gtk_widget_show(hpaned);
2117 gtk_widget_queue_resize(hpaned);
2118 messageview_add_toolbar(mainwin->messageview, messagewin);
2119 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2120 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2122 mainwin->win.sep_message.messagewin = messagewin;
2123 mainwin->win.sep_message.hpaned = hpaned;
2125 gtk_widget_realize(messagewin);
2126 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2127 gtk_widget_show_all(messagewin);
2128 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2129 mainwin->messageview->handlebox,
2130 prefs_common.toolbar_style);
2134 messageview_add_toolbar(mainwin->messageview, messagewin);
2135 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2136 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2138 gtk_box_pack_start(GTK_BOX(vbox_body),
2139 GTK_WIDGET_PTR(mainwin->summaryview),
2142 mainwin->win.sep_both.folderwin = folderwin;
2143 mainwin->win.sep_both.messagewin = messagewin;
2145 gtk_widget_realize(messagewin);
2146 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2147 gtk_widget_show_all(messagewin);
2148 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2149 mainwin->messageview->handlebox,
2150 prefs_common.toolbar_style);
2155 if (messageview_is_visible(mainwin->messageview))
2156 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2157 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2159 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2160 GTK_ARROW_UP, GTK_SHADOW_OUT);
2162 gtk_window_move(GTK_WINDOW(mainwin->window),
2163 prefs_common.mainwin_x,
2164 prefs_common.mainwin_y);
2166 gtk_widget_queue_resize(vbox_body);
2167 gtk_widget_queue_resize(mainwin->vbox);
2168 gtk_widget_queue_resize(mainwin->window);
2169 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2170 * and mimeview icon list/ctree lose track of their visibility states */
2171 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2172 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2173 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2174 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2175 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2176 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2178 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2180 mainwin->type = type;
2183 /* toggle menu state */
2184 menuitem = gtk_item_factory_get_item
2185 (ifactory, "/View/Show or hide/Folder tree");
2186 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2187 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2188 prefs_common.folderview_visible);
2189 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2190 menuitem = gtk_item_factory_get_item
2191 (ifactory, "/View/Show or hide/Message view");
2192 gtk_check_menu_item_set_active
2193 (GTK_CHECK_MENU_ITEM(menuitem),
2194 messageview_is_visible(mainwin->messageview));
2196 menuitem = gtk_item_factory_get_item
2197 (ifactory, "/View/Separate folder tree");
2198 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2199 ((type & SEPARATE_FOLDER) != 0));
2200 menuitem = gtk_item_factory_get_item
2201 (ifactory, "/View/Separate message view");
2202 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2203 ((type & SEPARATE_MESSAGE) != 0));
2207 (G_OBJECT(folderwin), "size_allocate",
2208 G_CALLBACK(folder_window_size_allocate_cb),
2213 (G_OBJECT(messagewin), "size_allocate",
2214 G_CALLBACK(message_window_size_allocate_cb),
2218 debug_print("done.\n");
2221 void main_window_destroy_all(void)
2223 while (mainwin_list != NULL) {
2224 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2226 /* free toolbar stuff */
2227 toolbar_clear_list(TOOLBAR_MAIN);
2228 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2229 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2231 g_free(mainwin->toolbar);
2234 mainwin_list = g_list_remove(mainwin_list, mainwin);
2236 g_list_free(mainwin_list);
2240 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2241 GdkEventButton *event,
2244 MainWindow *mainwin = (MainWindow *)data;
2246 if (!event) return FALSE;
2247 if (event->button != 3) return FALSE;
2249 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2250 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2253 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2254 menu_button_position, widget,
2255 event->button, event->time);
2261 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2264 gtk_widget_set_size_request(child, 1, -1);
2267 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2270 gtk_widget_set_size_request(child, -1, -1);
2273 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2276 MainWindow *mainwin = (MainWindow *)data;
2278 if (!event) return FALSE;
2280 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2281 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2284 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2285 menu_button_position, widget,
2286 event->button, event->time);
2291 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2293 MainWindow *mainwin = (MainWindow *)data;
2296 button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2297 if (!button) return;
2298 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2299 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2300 manage_window_focus_in(mainwin->window, NULL, NULL);
2303 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2306 MainWindow *mainwin = (MainWindow *)data;
2308 if (mainwin->lock_count == 0)
2309 app_exit_cb(data, 0, widget);
2314 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2317 MainWindow *mainwin = (MainWindow *)data;
2318 GtkWidget *menuitem;
2320 menuitem = gtk_item_factory_get_item
2321 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2322 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2327 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2330 MainWindow *mainwin = (MainWindow *)data;
2331 GtkWidget *menuitem;
2333 menuitem = gtk_item_factory_get_item
2334 (mainwin->menu_factory, "/View/Show or hide/Message view");
2335 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2337 mainwin->messageview->statusbar = mainwin->statusbar;
2338 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2343 static void main_window_size_allocate_cb(GtkWidget *widget,
2344 GtkAllocation *allocation,
2347 MainWindow *mainwin = (MainWindow *)data;
2349 main_window_get_size(mainwin);
2352 static void folder_window_size_allocate_cb(GtkWidget *widget,
2353 GtkAllocation *allocation,
2356 MainWindow *mainwin = (MainWindow *)data;
2358 main_window_get_size(mainwin);
2361 static void message_window_size_allocate_cb(GtkWidget *widget,
2362 GtkAllocation *allocation,
2365 MainWindow *mainwin = (MainWindow *)data;
2367 main_window_get_size(mainwin);
2370 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2373 main_window_add_mailbox(mainwin);
2376 static void update_folderview_cb(MainWindow *mainwin, guint action,
2379 summary_show(mainwin->summaryview, NULL);
2380 folderview_check_new_all();
2383 static void foldersort_cb(MainWindow *mainwin, guint action,
2389 static void import_mbox_cb(MainWindow *mainwin, guint action,
2392 import_mbox(mainwin->summaryview->folder_item);
2395 static void export_mbox_cb(MainWindow *mainwin, guint action,
2398 export_mbox(mainwin->summaryview->folder_item);
2401 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2404 summaryview_export_mbox_list(mainwin->summaryview);
2407 static void empty_trash_cb(MainWindow *mainwin, guint action,
2410 main_window_empty_trash(mainwin, TRUE);
2413 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2415 summary_save_as(mainwin->summaryview);
2418 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2420 summary_print(mainwin->summaryview);
2423 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2425 if (prefs_common.confirm_on_exit) {
2426 if (alertpanel(_("Exit"), _("Exit this program?"),
2427 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
2430 manage_window_focus_in(mainwin->window, NULL, NULL);
2433 app_will_exit(widget, mainwin);
2436 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2439 summary_search(mainwin->summaryview);
2441 message_search(mainwin->messageview);
2444 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2449 active = GTK_CHECK_MENU_ITEM(widget)->active;
2451 switch (mainwin->type) {
2453 case SEPARATE_MESSAGE:
2456 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2458 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2461 case SEPARATE_FOLDER:
2462 debug_print("separate folder\n");
2464 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2466 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2470 gtk_widget_show(mainwin->win.sep_both.folderwin);
2472 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2476 prefs_common.folderview_visible = active;
2479 static void toggle_message_cb(MainWindow *mainwin, guint action,
2484 active = GTK_CHECK_MENU_ITEM(widget)->active;
2486 if (active != messageview_is_visible(mainwin->messageview))
2487 summary_toggle_view(mainwin->summaryview);
2490 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2493 toolbar_toggle(action, mainwin);
2496 void main_window_reply_cb(MainWindow *mainwin, guint action,
2499 MessageView *msgview = (MessageView*)mainwin->messageview;
2500 GSList *msginfo_list = NULL;
2502 g_return_if_fail(msgview != NULL);
2504 msginfo_list = summary_get_selection(mainwin->summaryview);
2505 g_return_if_fail(msginfo_list != NULL);
2506 compose_reply_from_messageview(msgview, msginfo_list, action);
2507 g_slist_free(msginfo_list);
2511 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2514 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2515 gtk_widget_show(mainwin->hbox_stat);
2516 prefs_common.show_statusbar = TRUE;
2518 gtk_widget_hide(mainwin->hbox_stat);
2519 prefs_common.show_statusbar = FALSE;
2523 static void separate_widget_cb(MainWindow *mainwin, guint action,
2528 if (GTK_CHECK_MENU_ITEM(widget)->active)
2529 type = mainwin->type | action;
2531 type = mainwin->type & ~action;
2533 main_window_separation_change(mainwin, type);
2535 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2536 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2539 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2542 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2544 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2547 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2549 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2552 static void online_switch_clicked (GtkButton *btn, gpointer data)
2554 MainWindow *mainwin;
2555 GtkItemFactory *ifactory;
2556 GtkCheckMenuItem *menuitem;
2558 mainwin = (MainWindow *) data;
2560 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2561 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2563 g_return_if_fail(mainwin != NULL);
2564 g_return_if_fail(menuitem != NULL);
2566 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2568 gtk_widget_hide (mainwin->online_switch);
2569 gtk_widget_show (mainwin->offline_switch);
2570 menuitem->active = TRUE;
2571 prefs_common.work_offline = TRUE;
2572 inc_autocheck_timer_remove();
2575 gtk_widget_hide (mainwin->offline_switch);
2576 gtk_widget_show (mainwin->online_switch);
2577 menuitem->active = FALSE;
2578 prefs_common.work_offline = FALSE;
2579 inc_autocheck_timer_set();
2583 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2586 addressbook_open(NULL);
2589 static void log_window_show_cb(MainWindow *mainwin, guint action,
2592 log_window_show(mainwin->logwin);
2595 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2600 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2602 summary_move_to(mainwin->summaryview);
2605 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2607 summary_copy_to(mainwin->summaryview);
2610 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 summary_delete(mainwin->summaryview);
2615 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2617 summary_cancel(mainwin->summaryview);
2620 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2622 summary_open_msg(mainwin->summaryview);
2625 static void view_source_cb(MainWindow *mainwin, guint action,
2628 summary_view_source(mainwin->summaryview);
2631 static void show_all_header_cb(MainWindow *mainwin, guint action,
2634 if (mainwin->menu_lock_count) return;
2635 summary_display_msg_selected(mainwin->summaryview,
2636 GTK_CHECK_MENU_ITEM(widget)->active);
2639 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2641 summary_mark(mainwin->summaryview);
2644 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2646 summary_unmark(mainwin->summaryview);
2649 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2652 summary_mark_as_unread(mainwin->summaryview);
2655 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2658 summary_mark_as_read(mainwin->summaryview);
2661 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2664 summary_mark_all_read(mainwin->summaryview);
2667 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2669 summary_reedit(mainwin->summaryview);
2672 static void add_address_cb(MainWindow *mainwin, guint action,
2675 summary_add_address(mainwin->summaryview);
2678 static void set_charset_cb(MainWindow *mainwin, guint action,
2683 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2684 str = conv_get_charset_str((CharSet)action);
2686 g_free(mainwin->messageview->forced_charset);
2687 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2688 procmime_force_charset(str);
2690 summary_redisplay_msg(mainwin->summaryview);
2692 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2696 static void set_decode_cb(MainWindow *mainwin, guint action,
2699 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2700 mainwin->messageview->forced_encoding = (EncodingType)action;
2702 summary_redisplay_msg(mainwin->summaryview);
2704 debug_print("forced encoding: %d\n", action);
2708 static void hide_read_messages (MainWindow *mainwin, guint action,
2711 if (!mainwin->summaryview->folder_item
2712 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2714 summary_toggle_show_read_messages(mainwin->summaryview);
2717 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2719 if (mainwin->menu_lock_count) return;
2720 if (!mainwin->summaryview->folder_item) return;
2722 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2723 summary_thread_build(mainwin->summaryview);
2724 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2726 summary_unthread(mainwin->summaryview);
2727 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2731 static void expand_threads_cb(MainWindow *mainwin, guint action,
2734 summary_expand_threads(mainwin->summaryview);
2737 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2740 summary_collapse_threads(mainwin->summaryview);
2743 static void set_display_item_cb(MainWindow *mainwin, guint action,
2746 prefs_summary_column_open();
2749 static void sort_summary_cb(MainWindow *mainwin, guint action,
2752 FolderItem *item = mainwin->summaryview->folder_item;
2753 GtkWidget *menuitem;
2755 if (mainwin->menu_lock_count) return;
2757 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2758 menuitem = gtk_item_factory_get_item
2759 (mainwin->menu_factory, "/View/Sort/Ascending");
2760 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2761 GTK_CHECK_MENU_ITEM(menuitem)->active
2762 ? SORT_ASCENDING : SORT_DESCENDING);
2763 item->sort_key = action;
2767 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2770 FolderItem *item = mainwin->summaryview->folder_item;
2772 if (mainwin->menu_lock_count) return;
2774 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2775 summary_sort(mainwin->summaryview,
2776 item->sort_key, (FolderSortType)action);
2779 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2782 summary_attract_by_subject(mainwin->summaryview);
2785 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2790 item = folderview_get_selected_item(mainwin->folderview);
2792 main_window_cursor_wait(mainwin);
2793 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2795 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2796 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2798 STATUSBAR_POP(mainwin);
2799 main_window_cursor_normal(mainwin);
2809 static void deldup_all(FolderItem *item, gpointer _data)
2811 struct DelDupsData *data = _data;
2814 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2816 data->dups += result;
2821 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2824 struct DelDupsData data = {0, 0};
2826 folder_func_to_all_folders(deldup_all, &data);
2827 alertpanel_notice(_("Deleted %d duplicate message(s) in %d folders.\n"),
2828 data.dups, data.folders);
2831 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2833 summary_filter(mainwin->summaryview, (gboolean)action);
2836 static void execute_summary_cb(MainWindow *mainwin, guint action,
2839 summary_execute(mainwin->summaryview);
2842 static void update_summary_cb(MainWindow *mainwin, guint action,
2846 FolderView *folderview = mainwin->folderview;
2848 if (!mainwin->summaryview->folder_item) return;
2849 if (!folderview->opened) return;
2851 folder_update_op_count();
2853 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2854 folderview->opened);
2857 folder_item_scan(fitem);
2858 summary_show(mainwin->summaryview, fitem);
2861 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2863 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2866 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2868 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2871 static void prev_unread_cb(MainWindow *mainwin, guint action,
2874 summary_select_prev_unread(mainwin->summaryview);
2877 static void next_unread_cb(MainWindow *mainwin, guint action,
2880 summary_select_next_unread(mainwin->summaryview);
2883 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2885 summary_select_prev_new(mainwin->summaryview);
2888 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2890 summary_select_next_new(mainwin->summaryview);
2893 static void prev_marked_cb(MainWindow *mainwin, guint action,
2896 summary_select_prev_marked(mainwin->summaryview);
2899 static void next_marked_cb(MainWindow *mainwin, guint action,
2902 summary_select_next_marked(mainwin->summaryview);
2905 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2908 summary_select_prev_labeled(mainwin->summaryview);
2911 static void next_labeled_cb(MainWindow *mainwin, guint action,
2914 summary_select_next_labeled(mainwin->summaryview);
2917 static void goto_folder_cb(MainWindow *mainwin, guint action,
2920 FolderItem *to_folder;
2922 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2925 folderview_select(mainwin->folderview, to_folder);
2928 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2930 messageview_copy_clipboard(mainwin->messageview);
2933 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2935 MessageView *msgview = mainwin->messageview;
2937 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2938 summary_select_all(mainwin->summaryview);
2939 else if (messageview_is_visible(msgview) &&
2940 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
2941 messageview_select_all(mainwin->messageview);
2944 static void select_thread_cb(MainWindow *mainwin, guint action,
2947 summary_select_thread(mainwin->summaryview);
2950 static void create_filter_cb(MainWindow *mainwin, guint action,
2953 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
2956 static void create_processing_cb(MainWindow *mainwin, guint action,
2959 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
2962 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2965 /* prefs_common_open(); */
2968 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
2971 prefs_filtering_open(&pre_global_processing,
2972 _("Processing rules to apply before folder rules"),
2976 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
2979 prefs_filtering_open(&post_global_processing,
2980 _("Processing rules to apply after folder rules"),
2984 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2987 prefs_filtering_open(&filtering_rules,
2988 _("Filtering configuration"),
2992 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2995 prefs_template_open();
2998 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3001 prefs_actions_open(mainwin);
3004 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3007 ssl_manager_open(mainwin);
3010 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3014 new_account_cb(mainwin, 0, widget);
3016 account_open(cur_account);
3020 static void new_account_cb(MainWindow *mainwin, guint action,
3023 account_edit_open();
3024 if (!compose_get_compose_list()) account_add();
3027 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3029 cur_account = (PrefsAccount *)data;
3030 main_window_reflect_prefs_all();
3033 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3035 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3036 PrefsAccount *account = (PrefsAccount *)data;
3038 inc_account_mail(mainwin, account);
3041 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3046 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3048 pluginwindow_create();
3051 static void manual_open_cb(MainWindow *mainwin, guint action,
3054 manual_open((ManualType)action);
3057 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3059 MainWindow *mainwin = (MainWindow *)data;
3063 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3064 LOCAL_FOLDER(folder)->rootpath,
3068 str = g_strdup_printf(_("Scanning folder %s ..."),
3069 LOCAL_FOLDER(folder)->rootpath);
3071 STATUSBAR_PUSH(mainwin, str);
3072 STATUSBAR_POP(mainwin);
3076 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3079 SummaryView *summary;
3081 g_return_val_if_fail(data, FALSE);
3082 summary = ((MainWindow *)data)->summaryview;
3083 g_return_val_if_fail(summary, FALSE);
3085 if (GTK_CLIST(summary->ctree)->selection &&
3086 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3089 if (summary->selected != summary->displayed)
3090 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3094 #define BREAK_ON_MODIFIER_KEY() \
3095 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3097 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3100 MainWindow *mainwin = (MainWindow*) data;
3102 if (!mainwin || !event)
3105 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3108 switch (event->keyval) {
3109 case GDK_Q: /* Quit */
3110 BREAK_ON_MODIFIER_KEY();
3112 app_exit_cb(mainwin, 0, NULL);
3115 if (mainwin->folderview && mainwin->summaryview
3116 && !mainwin->summaryview->displayed) {
3117 summary_lock(mainwin->summaryview);
3118 folderview_select_next_unread(mainwin->folderview);
3119 summary_unlock(mainwin->summaryview);
3128 #undef BREAK_ON_MODIFIER_KEY
3131 * Harvest addresses for selected folder.
3133 static void addr_harvest_cb( MainWindow *mainwin,
3137 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3141 * Harvest addresses for selected messages in summary view.
3143 static void addr_harvest_msg_cb( MainWindow *mainwin,
3147 summary_harvest_address( mainwin->summaryview );
3151 *\brief get a MainWindow
3153 *\return MainWindow * The first mainwindow in the mainwin_list
3155 MainWindow *mainwindow_get_mainwindow(void)
3157 if (mainwin_list && mainwin_list->data)
3158 return (MainWindow *)(mainwin_list->data);
3163 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3165 ProgressData *data = (ProgressData *) source;
3166 MainWindow *mainwin = (MainWindow *) userdata;
3168 switch (data->cmd) {
3169 case PROGRESS_COMMAND_START:
3170 case PROGRESS_COMMAND_STOP:
3171 gtk_progress_bar_set_fraction
3172 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3174 case PROGRESS_COMMAND_SET_PERCENTAGE:
3175 gtk_progress_bar_set_fraction
3176 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3179 while (gtk_events_pending()) gtk_main_iteration ();