2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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"
64 #include "prefs_common.h"
65 #include "prefs_actions.h"
66 #include "prefs_filtering.h"
67 #include "prefs_account.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_folder_column.h"
70 #include "prefs_template.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.h"
87 #include "prefs_gtk.h"
88 #include "pluginwindow.h"
90 #include "progressindicator.h"
91 #include "localfolder.h"
92 #include "filtering.h"
93 #include "folderutils.h"
94 #include "foldersort.h"
95 #include "icon_legend.h"
96 #include "colorlabel.h"
101 #define AC_LABEL_WIDTH 240
103 /* list of all instantiated MainWindow */
104 static GList *mainwin_list = NULL;
106 static GdkCursor *watch_cursor = NULL;
107 static GdkCursor *hand_cursor = NULL;
109 static gint iconified_count = 0;
111 static void main_window_menu_callback_block (MainWindow *mainwin);
112 static void main_window_menu_callback_unblock (MainWindow *mainwin);
114 static void main_window_show_cur_account (MainWindow *mainwin);
116 static void main_window_separation_change (MainWindow *mainwin,
117 LayoutType layout_mode);
119 static void main_window_set_widgets (MainWindow *mainwin,
120 LayoutType layout_mode);
122 static void toolbar_child_attached (GtkWidget *widget,
125 static void toolbar_child_detached (GtkWidget *widget,
129 static gboolean ac_label_button_pressed (GtkWidget *widget,
130 GdkEventButton *event,
133 static gint main_window_close_cb (GtkWidget *widget,
137 static void main_window_size_allocate_cb (GtkWidget *widget,
138 GtkAllocation *allocation,
140 static void folder_window_size_allocate_cb (GtkWidget *widget,
141 GtkAllocation *allocation,
143 static void message_window_size_allocate_cb (GtkWidget *widget,
144 GtkAllocation *allocation,
147 static void update_folderview_cb (MainWindow *mainwin,
150 static void add_mailbox_cb (MainWindow *mainwin,
153 static void foldersort_cb (MainWindow *mainwin,
156 static void import_mbox_cb (MainWindow *mainwin,
159 static void export_mbox_cb (MainWindow *mainwin,
162 static void export_list_mbox_cb (MainWindow *mainwin,
165 static void empty_trash_cb (MainWindow *mainwin,
169 static void save_as_cb (MainWindow *mainwin,
172 static void print_cb (MainWindow *mainwin,
175 static void app_exit_cb (MainWindow *mainwin,
179 static void search_cb (MainWindow *mainwin,
183 static void toggle_message_cb (MainWindow *mainwin,
186 static void toggle_toolbar_cb (MainWindow *mainwin,
189 static void toggle_statusbar_cb (MainWindow *mainwin,
192 static void set_layout_cb (MainWindow *mainwin,
196 static void addressbook_open_cb (MainWindow *mainwin,
199 static void log_window_show_cb (MainWindow *mainwin,
202 static void filtering_debug_window_show_cb (MainWindow *mainwin,
206 static void inc_cancel_cb (MainWindow *mainwin,
210 static void open_msg_cb (MainWindow *mainwin,
214 static void view_source_cb (MainWindow *mainwin,
218 static void show_all_header_cb (MainWindow *mainwin,
222 static void hide_quotes_cb(MainWindow *mainwin,
226 static void move_to_cb (MainWindow *mainwin,
229 static void copy_to_cb (MainWindow *mainwin,
232 static void delete_cb (MainWindow *mainwin,
235 static void delete_trash_cb (MainWindow *mainwin,
239 static void cancel_cb (MainWindow *mainwin,
243 static void mark_cb (MainWindow *mainwin,
246 static void unmark_cb (MainWindow *mainwin,
250 static void mark_as_unread_cb (MainWindow *mainwin,
253 static void mark_as_read_cb (MainWindow *mainwin,
256 static void mark_all_read_cb (MainWindow *mainwin,
259 static void mark_as_spam_cb (MainWindow *mainwin,
263 static void ignore_thread_cb (MainWindow *mainwin,
266 static void unignore_thread_cb (MainWindow *mainwin,
269 static void lock_msgs_cb (MainWindow *mainwin,
272 static void unlock_msgs_cb (MainWindow *mainwin,
276 static void reedit_cb (MainWindow *mainwin,
280 static void add_address_cb (MainWindow *mainwin,
284 static void set_charset_cb (MainWindow *mainwin,
288 static void set_decode_cb (MainWindow *mainwin,
292 static void hide_read_messages (MainWindow *mainwin,
296 static void thread_cb (MainWindow *mainwin,
299 static void expand_threads_cb (MainWindow *mainwin,
302 static void collapse_threads_cb (MainWindow *mainwin,
306 static void set_summary_display_item_cb (MainWindow *mainwin,
309 static void set_folder_display_item_cb (MainWindow *mainwin,
312 static void sort_summary_cb (MainWindow *mainwin,
315 static void sort_summary_type_cb (MainWindow *mainwin,
318 static void attract_by_subject_cb(MainWindow *mainwin,
322 static void delete_duplicated_cb (MainWindow *mainwin,
325 static void delete_duplicated_all_cb (MainWindow *mainwin,
328 static void filter_cb (MainWindow *mainwin,
331 static void execute_summary_cb (MainWindow *mainwin,
334 static void update_summary_cb (MainWindow *mainwin,
338 static void prev_cb (MainWindow *mainwin,
341 static void next_cb (MainWindow *mainwin,
344 static void next_unread_cb (MainWindow *mainwin,
347 static void prev_unread_cb (MainWindow *mainwin,
351 static void prev_new_cb (MainWindow *mainwin,
354 static void next_new_cb (MainWindow *mainwin,
357 static void prev_marked_cb (MainWindow *mainwin,
360 static void next_marked_cb (MainWindow *mainwin,
363 static void prev_labeled_cb (MainWindow *mainwin,
366 static void next_labeled_cb (MainWindow *mainwin,
369 static void last_read_cb (MainWindow *mainwin,
372 static void parent_cb (MainWindow *mainwin,
376 static void goto_folder_cb (MainWindow *mainwin,
379 static void goto_unread_folder_cb(MainWindow *mainwin,
383 static void copy_cb (MainWindow *mainwin,
386 static void allsel_cb (MainWindow *mainwin,
389 static void select_thread_cb (MainWindow *mainwin,
392 static void delete_thread_cb (MainWindow *mainwin,
396 static void create_filter_cb (MainWindow *mainwin,
399 static void create_processing_cb (MainWindow *mainwin,
402 static void open_urls_cb (MainWindow *mainwin,
406 static void prefs_template_open_cb (MainWindow *mainwin,
409 static void prefs_actions_open_cb (MainWindow *mainwin,
412 static void prefs_account_open_cb (MainWindow *mainwin,
416 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
420 static void prefs_post_processing_open_cb (MainWindow *mainwin,
424 static void prefs_filtering_open_cb (MainWindow *mainwin,
428 static void ssl_manager_open_cb (MainWindow *mainwin,
432 static void new_account_cb (MainWindow *mainwin,
436 static void account_selector_menu_cb (GtkMenuItem *menuitem,
438 static void account_receive_menu_cb (GtkMenuItem *menuitem,
440 static void account_compose_menu_cb (GtkMenuItem *menuitem,
443 static void prefs_open_cb (GtkMenuItem *menuitem,
445 static void plugins_open_cb (GtkMenuItem *menuitem,
448 static void online_switch_clicked(GtkButton *btn,
451 static void manual_open_cb (MainWindow *mainwin,
455 static void legend_open_cb (GtkMenuItem *menuitem,
458 static void scan_tree_func (Folder *folder,
462 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
464 static void addr_harvest_cb ( MainWindow *mainwin,
468 static void addr_harvest_msg_cb ( MainWindow *mainwin,
471 static void sync_cb ( MainWindow *mainwin,
475 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
476 GdkEventFocus *focus,
478 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
479 GdkEventVisibility *state,
481 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
482 GdkEventWindowState *state,
484 static void main_window_reply_cb (MainWindow *mainwin,
487 static gboolean mainwindow_progressindicator_hook (gpointer source,
490 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
493 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
495 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
497 static void mailing_list_compose(GtkWidget *w, gpointer *data);
499 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
500 #define SEPARATE_ACTION 500
501 static void mainwindow_quicksearch (MainWindow *mainwin,
504 static gboolean any_folder_want_synchronise(void);
506 static GtkItemFactoryEntry mainwin_entries[] =
508 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
509 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
510 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
511 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
513 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
515 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
516 {N_("/_File/Exp_ort selected to mbox file..."),
517 NULL, export_list_mbox_cb, 0, NULL},
518 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
520 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
522 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
523 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
525 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
526 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
527 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
528 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
530 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
531 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
532 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
533 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
534 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
535 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_Edit/_Find in current message..."),
537 "<control>F", search_cb, 0, NULL},
538 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
539 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
540 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
541 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
542 {N_("/_View/Show or hi_de/_Message view"),
543 "V", toggle_message_cb, 0, "<ToggleItem>"},
544 {N_("/_View/Show or hi_de/_Toolbar"),
545 NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
547 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
548 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
549 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
550 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
551 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
552 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
553 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
554 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
555 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
556 {N_("/_View/Show or hi_de/Status _bar"),
557 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
558 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
559 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
560 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
562 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
564 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
565 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
566 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
567 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
568 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
569 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
570 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
571 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
572 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
573 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
575 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
576 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
577 {N_("/_View/_Sort/by _color label"),
578 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
580 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
581 {N_("/_View/_Sort/by a_ttachment"),
582 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
583 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
584 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
585 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
586 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
588 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
589 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_View/_Sort/_Attract by subject"),
591 NULL, attract_by_subject_cb, 0, NULL},
592 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
593 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
594 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
595 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
597 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
599 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
600 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
601 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
602 {N_("/_View/_Go to/P_revious unread message"),
603 "<shift>P", prev_unread_cb, 0, NULL},
604 {N_("/_View/_Go to/N_ext unread message"),
605 "<shift>N", next_unread_cb, 0, NULL},
606 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
608 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/Previous _marked message"),
611 NULL, prev_marked_cb, 0, NULL},
612 {N_("/_View/_Go to/Next m_arked message"),
613 NULL, next_marked_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Previous _labeled message"),
616 NULL, prev_labeled_cb, 0, NULL},
617 {N_("/_View/_Go to/Next la_beled message"),
618 NULL, next_labeled_cb, 0, NULL},
619 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Go to/Last read message"),
621 NULL, last_read_cb, 0, NULL},
622 {N_("/_View/_Go to/Parent message"),
623 "<control>Up", parent_cb, 0, NULL},
624 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
626 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
627 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
629 #define ENC_SEPARATOR \
630 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
631 #define ENC_ACTION(action) \
632 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
634 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
635 {N_("/_View/Character _encoding/_Auto detect"),
636 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
637 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
639 ENC_ACTION(C_US_ASCII)},
640 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
641 ENC_ACTION(C_UTF_8)},
644 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
645 ENC_ACTION(C_ISO_8859_1)},
646 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
647 ENC_ACTION(C_ISO_8859_15)},
648 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
649 ENC_ACTION(C_WINDOWS_1252)},
652 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
653 ENC_ACTION(C_ISO_8859_2)},
656 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
657 ENC_ACTION(C_ISO_8859_13)},
658 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
659 ENC_ACTION(C_ISO_8859_4)},
662 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
663 ENC_ACTION(C_ISO_8859_7)},
666 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
667 ENC_ACTION(C_ISO_8859_8)},
668 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
669 ENC_ACTION(C_CP1255)},
672 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
673 ENC_ACTION(C_ISO_8859_6)},
674 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
675 ENC_ACTION(C_CP1256)},
678 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
679 ENC_ACTION(C_ISO_8859_9)},
682 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
683 ENC_ACTION(C_ISO_8859_5)},
684 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
685 ENC_ACTION(C_KOI8_R)},
686 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
687 ENC_ACTION(C_KOI8_U)},
688 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
689 ENC_ACTION(C_CP1251)},
692 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
693 ENC_ACTION(C_ISO_2022_JP)},
694 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
695 ENC_ACTION(C_ISO_2022_JP_2)},
696 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
697 ENC_ACTION(C_EUC_JP)},
698 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
699 ENC_ACTION(C_SHIFT_JIS)},
702 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
703 ENC_ACTION(C_GB2312)},
704 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
706 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
708 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
709 ENC_ACTION(C_EUC_TW)},
710 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
711 ENC_ACTION(C_ISO_2022_CN)},
714 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
715 ENC_ACTION(C_EUC_KR)},
716 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
717 ENC_ACTION(C_ISO_2022_KR)},
720 {N_("/_View/Character _encoding/Thai (TIS-620)"),
721 ENC_ACTION(C_TIS_620)},
722 {N_("/_View/Character _encoding/Thai (Windows-874)"),
723 ENC_ACTION(C_WINDOWS_874)},
728 #define DEC_SEPARATOR \
729 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
730 #define DEC_ACTION(action) \
731 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
732 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
733 {N_("/_View/Decode/_Auto detect"),
734 NULL, set_decode_cb, 0, "<RadioItem>"},
735 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
736 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
737 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
738 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
739 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
744 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
745 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
746 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
747 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
748 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
749 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
750 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
751 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
752 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
753 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
755 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
756 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_Message/Recei_ve/Get from _current account"),
758 "<control>I", inc_mail_cb, 0, NULL},
759 {N_("/_Message/Recei_ve/Get from _all accounts"),
760 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
761 {N_("/_Message/Recei_ve/Cancel receivin_g"),
762 NULL, inc_cancel_cb, 0, NULL},
763 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
764 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
765 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
766 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
767 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
768 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
769 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
770 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
771 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
772 {N_("/_Message/Repl_y to/mailing _list"),
773 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
774 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
775 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
776 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
777 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
778 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
780 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
781 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
782 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
783 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
784 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
785 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
786 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
788 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
789 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
790 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
791 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
792 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
793 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
794 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
795 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
796 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
797 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
798 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
799 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
800 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
801 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
802 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
803 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
804 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
805 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
806 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
807 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
808 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
809 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
810 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
811 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
812 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
814 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
815 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
816 {N_("/_Tools/Add sender to address boo_k"),
817 NULL, add_address_cb, 0, NULL},
818 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
819 {N_("/_Tools/_Harvest addresses/from _Folder..."),
820 NULL, addr_harvest_cb, 0, NULL},
821 {N_("/_Tools/_Harvest addresses/from _Messages..."),
822 NULL, addr_harvest_msg_cb, 0, NULL},
823 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
824 {N_("/_Tools/_Filter all messages in folder"),
825 NULL, filter_cb, 0, NULL},
826 {N_("/_Tools/Filter _selected messages"),
827 NULL, filter_cb, 1, NULL},
828 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
829 {N_("/_Tools/_Create filter rule/_Automatically"),
830 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
831 {N_("/_Tools/_Create filter rule/by _From"),
832 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
833 {N_("/_Tools/_Create filter rule/by _To"),
834 NULL, create_filter_cb, FILTER_BY_TO, NULL},
835 {N_("/_Tools/_Create filter rule/by _Subject"),
836 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
837 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
838 {N_("/_Tools/C_reate processing rule/_Automatically"),
839 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
840 {N_("/_Tools/C_reate processing rule/by _From"),
841 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
842 {N_("/_Tools/C_reate processing rule/by _To"),
843 NULL, create_processing_cb, FILTER_BY_TO, NULL},
844 {N_("/_Tools/C_reate processing rule/by _Subject"),
845 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
846 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
847 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
848 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
849 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
850 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
851 {N_("/_Tools/Ch_eck for new messages in all folders"),
852 NULL, update_folderview_cb, 0, NULL},
853 {N_("/_Tools/Delete du_plicated messages"),
854 NULL, NULL, 0, "<Branch>"},
855 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
856 NULL, delete_duplicated_cb, 0, NULL},
857 {N_("/_Tools/Delete du_plicated messages/In all folders"),
858 NULL, delete_duplicated_all_cb, 0, NULL},
859 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
860 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
862 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
863 {N_("/_Tools/SSL cer_tificates..."),
864 NULL, ssl_manager_open_cb, 0, NULL},
866 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
867 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
868 {N_("/_Tools/Protocol _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
870 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
871 {N_("/_Configuration/C_hange current account"),
872 NULL, NULL, 0, "<Branch>"},
873 {N_("/_Configuration/_Preferences for current account..."),
874 NULL, prefs_account_open_cb, 0, NULL},
875 {N_("/_Configuration/Create _new account..."),
876 NULL, new_account_cb, 0, NULL},
877 {N_("/_Configuration/_Edit accounts..."),
878 NULL, account_edit_open, 0, NULL},
879 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
880 {N_("/_Configuration/P_references..."),
881 NULL, prefs_open_cb, 0, NULL},
882 {N_("/_Configuration/Pre-pr_ocessing..."),
883 NULL, prefs_pre_processing_open_cb, 0, NULL},
884 {N_("/_Configuration/Post-pro_cessing..."),
885 NULL, prefs_post_processing_open_cb, 0, NULL},
886 {N_("/_Configuration/_Filtering..."),
887 NULL, prefs_filtering_open_cb, 0, NULL},
888 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
889 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
890 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
892 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
893 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
894 {N_("/_Help/_Online User-contributed FAQ"),
895 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
896 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
897 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
898 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
901 static gboolean offline_ask_sync = TRUE;
902 static guint lastkey;
903 static gboolean is_obscured = FALSE;
905 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
911 MainWindow *mainwin = (MainWindow *)user_data;
913 if (mainwin->summaryview &&
914 mainwin->summaryview->quicksearch &&
915 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
916 (mod == 0 || mod == GDK_SHIFT_MASK)) {
917 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
923 #define N_COLOR_LABELS colorlabel_get_color_count()
925 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
930 GtkCheckMenuItem **items;
935 mainwin = (MainWindow *)data;
936 g_return_if_fail(mainwin != NULL);
938 sel = summary_get_selection(mainwin->summaryview);
941 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
942 g_return_if_fail(menu != NULL);
944 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
946 /* NOTE: don't return prematurely because we set the "dont_toggle"
947 * state for check menu items */
948 g_object_set_data(G_OBJECT(menu), "dont_toggle",
951 /* clear items. get item pointers. */
952 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
953 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
954 gtk_check_menu_item_set_active
955 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
956 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
961 if (n == (N_COLOR_LABELS + 1)) {
962 /* iterate all messages and set the state of the appropriate
964 for (; sel != NULL; sel = sel->next) {
968 msginfo = (MsgInfo *)sel->data;
970 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
971 if (!items[clabel]->active)
972 gtk_check_menu_item_set_active
973 (items[clabel], TRUE);
977 g_warning("invalid number of color elements (%d)\n", n);
979 /* reset "dont_toggle" state */
980 g_object_set_data(G_OBJECT(menu), "dont_toggle",
984 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
987 guint color = GPOINTER_TO_UINT(data);
990 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
991 g_return_if_fail(mainwin != NULL);
993 /* "dont_toggle" state set? */
994 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
998 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1001 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1003 GtkWidget *label_menuitem;
1008 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1009 "/Message/Color label");
1010 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1011 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1013 gtk_widget_show(label_menuitem);
1015 menu = gtk_menu_new();
1017 /* create sub items. for the menu item activation callback we pass the
1018 * index of label_colors[] as data parameter. for the None color we
1019 * pass an invalid (high) value. also we attach a data pointer so we
1020 * can always get back the Mainwindow pointer. */
1022 item = gtk_check_menu_item_new_with_label(_("None"));
1023 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1024 g_signal_connect(G_OBJECT(item), "activate",
1025 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1026 GUINT_TO_POINTER(0));
1027 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1028 gtk_widget_show(item);
1030 gtk_widget_add_accelerator(item, "activate",
1031 mainwin->menu_factory->accel_group,
1032 GDK_0, GDK_CONTROL_MASK,
1033 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1035 item = gtk_menu_item_new();
1036 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1037 gtk_widget_show(item);
1039 /* create pixmap/label menu items */
1040 for (i = 0; i < N_COLOR_LABELS; i++) {
1041 item = colorlabel_create_check_color_menu_item(
1042 i, refresh, MAINWIN_COLORMENU);
1043 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1044 g_signal_connect(G_OBJECT(item), "activate",
1045 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1046 GUINT_TO_POINTER(i + 1));
1047 g_object_set_data(G_OBJECT(item), "mainwin",
1049 gtk_widget_show(item);
1051 gtk_widget_add_accelerator(item, "activate",
1052 mainwin->menu_factory->accel_group,
1053 GDK_1+i, GDK_CONTROL_MASK,
1054 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1056 gtk_widget_show(menu);
1057 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1058 mainwin->colorlabel_menu = menu;
1061 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1062 MainWindow *mainwindow)
1064 if (evt && evt->button == 1) {
1065 log_window_show_error(mainwindow->logwin);
1066 gtk_widget_hide(mainwindow->warning_btn);
1071 static gboolean warning_visi_notify(GtkWidget *widget,
1072 GdkEventVisibility *event,
1073 MainWindow *mainwindow)
1075 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1079 static gboolean warning_leave_notify(GtkWidget *widget,
1080 GdkEventCrossing *event,
1081 MainWindow *mainwindow)
1083 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1087 static gboolean warning_enter_notify(GtkWidget *widget,
1088 GdkEventCrossing *event,
1089 MainWindow *mainwindow)
1091 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1095 void mainwindow_show_error(void)
1097 MainWindow *mainwin = mainwindow_get_mainwindow();
1098 gtk_widget_show(mainwin->warning_btn);
1101 void mainwindow_clear_error(MainWindow *mainwin)
1103 gtk_widget_hide(mainwin->warning_btn);
1106 MainWindow *main_window_create()
1108 MainWindow *mainwin;
1112 GtkWidget *handlebox;
1113 GtkWidget *vbox_body;
1114 GtkWidget *hbox_stat;
1115 GtkWidget *statusbar;
1116 GtkWidget *progressbar;
1117 GtkWidget *statuslabel;
1118 GtkWidget *ac_button;
1119 GtkWidget *ac_label;
1120 GtkWidget *online_pixmap;
1121 GtkWidget *offline_pixmap;
1122 GtkWidget *online_switch;
1123 GtkWidget *offline_switch;
1125 GtkWidget *warning_icon;
1126 GtkWidget *warning_btn;
1128 FolderView *folderview;
1129 SummaryView *summaryview;
1130 MessageView *messageview;
1131 GdkColormap *colormap;
1133 gboolean success[4];
1134 GtkItemFactory *ifactory;
1136 GtkWidget *menuitem;
1138 guint n_menu_entries;
1140 static GdkGeometry geometry;
1142 debug_print("Creating main window...\n");
1143 mainwin = g_new0(MainWindow, 1);
1146 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
1147 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1148 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1150 if (!geometry.min_height) {
1151 geometry.min_width = 320;
1152 geometry.min_height = 200;
1154 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1157 g_signal_connect(G_OBJECT(window), "delete_event",
1158 G_CALLBACK(main_window_close_cb), mainwin);
1159 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1160 g_signal_connect(G_OBJECT(window), "focus_in_event",
1161 G_CALLBACK(mainwindow_focus_in_event),
1163 g_signal_connect(G_OBJECT(window), "key_press_event",
1164 G_CALLBACK(mainwindow_key_pressed), mainwin);
1166 gtk_widget_realize(window);
1167 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1170 gtkut_widget_set_app_icon(window);
1172 vbox = gtk_vbox_new(FALSE, 0);
1173 gtk_widget_show(vbox);
1174 gtk_container_add(GTK_CONTAINER(window), vbox);
1177 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1178 menubar = menubar_create(window, mainwin_entries,
1179 n_menu_entries, "<Main>", mainwin);
1180 gtk_widget_show(menubar);
1181 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1182 ifactory = gtk_item_factory_from_widget(menubar);
1184 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1185 main_create_mailing_list_menu (mainwin, NULL); */
1187 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1189 if (prefs_common.toolbar_detachable) {
1190 handlebox = gtk_handle_box_new();
1191 gtk_widget_show(handlebox);
1192 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1193 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1194 G_CALLBACK(toolbar_child_attached), mainwin);
1195 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1196 G_CALLBACK(toolbar_child_detached), mainwin);
1198 handlebox = gtk_hbox_new(FALSE, 0);
1199 gtk_widget_show(handlebox);
1200 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1202 /* link window to mainwin->window to avoid gdk warnings */
1203 mainwin->window = window;
1205 /* create toolbar */
1206 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1209 toolbar_set_learn_button
1213 /* vbox that contains body */
1214 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1215 gtk_widget_show(vbox_body);
1216 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1217 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1219 hbox_stat = gtk_hbox_new(FALSE, 2);
1220 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1222 tips = gtk_tooltips_new();
1224 warning_icon = gtk_image_new_from_stock
1225 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1226 warning_btn = gtk_event_box_new();
1227 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1229 mainwin->warning_btn = warning_btn;
1231 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1232 G_CALLBACK(warning_icon_pressed),
1233 (gpointer) mainwin);
1234 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1235 G_CALLBACK(warning_visi_notify), mainwin);
1236 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1237 G_CALLBACK(warning_visi_notify), mainwin);
1238 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1239 G_CALLBACK(warning_leave_notify), mainwin);
1240 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1241 G_CALLBACK(warning_enter_notify), mainwin);
1243 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1245 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1246 _("Some error(s) happened. Click here to view log."), NULL);
1247 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1249 statusbar = statusbar_create();
1250 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1252 progressbar = gtk_progress_bar_new();
1253 gtk_widget_set_size_request(progressbar, 120, 1);
1254 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1256 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1257 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1258 online_switch = gtk_button_new ();
1259 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1260 _("You are online. Click the icon to go offline"), NULL);
1261 offline_switch = gtk_button_new ();
1262 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1263 _("You are offline. Click the icon to go online"),
1265 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1266 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1267 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1268 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1269 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1270 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1271 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1272 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1274 statuslabel = gtk_label_new("");
1275 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1277 ac_button = gtk_button_new();
1278 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1279 ac_button, _("Select account"), NULL);
1280 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1281 gtk_widget_set_size_request(ac_button, -1, 0);
1282 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1283 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1284 G_CALLBACK(ac_label_button_pressed), mainwin);
1286 ac_label = gtk_label_new("");
1287 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1289 gtk_widget_show_all(hbox_stat);
1291 gtk_widget_hide(offline_switch);
1292 gtk_widget_hide(warning_btn);
1295 mainwin->folderview = folderview = folderview_create();
1296 mainwin->summaryview = summaryview = summary_create();
1297 mainwin->messageview = messageview = messageview_create(mainwin);
1299 /* init log instances data before creating log views */
1300 set_log_title(LOG_PROTOCOL, _("Protocol log"));
1301 set_log_prefs(LOG_PROTOCOL,
1302 &prefs_common.logwin_width,
1303 &prefs_common.logwin_height);
1304 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1305 set_log_prefs(LOG_DEBUG_FILTERING,
1306 &prefs_common.filtering_debugwin_width,
1307 &prefs_common.filtering_debugwin_height);
1309 /* setup log windows */
1310 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1311 log_window_init(mainwin->logwin);
1313 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1314 log_window_set_clipping(mainwin->logwin,
1315 prefs_common.cliplog,
1316 prefs_common.loglength);
1318 log_window_init(mainwin->filtering_debugwin);
1319 log_window_set_clipping(mainwin->filtering_debugwin,
1320 prefs_common.filtering_debug_cliplog,
1321 prefs_common.filtering_debug_loglength);
1322 if (prefs_common.enable_filtering_debug)
1323 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1325 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1327 folderview->mainwin = mainwin;
1328 folderview->summaryview = summaryview;
1330 summaryview->mainwin = mainwin;
1331 summaryview->folderview = folderview;
1332 summaryview->messageview = messageview;
1333 summaryview->window = window;
1335 messageview->statusbar = statusbar;
1336 mainwin->vbox = vbox;
1337 mainwin->menubar = menubar;
1338 mainwin->menu_factory = ifactory;
1339 mainwin->handlebox = handlebox;
1340 mainwin->vbox_body = vbox_body;
1341 mainwin->hbox_stat = hbox_stat;
1342 mainwin->statusbar = statusbar;
1343 mainwin->progressbar = progressbar;
1344 mainwin->statuslabel = statuslabel;
1345 mainwin->online_switch = online_switch;
1346 mainwin->online_pixmap = online_pixmap;
1347 mainwin->offline_pixmap = offline_pixmap;
1348 mainwin->ac_button = ac_button;
1349 mainwin->ac_label = ac_label;
1350 mainwin->offline_switch = offline_switch;
1352 /* set context IDs for status bar */
1353 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1354 (GTK_STATUSBAR(statusbar), "Main Window");
1355 mainwin->folderview_cid = gtk_statusbar_get_context_id
1356 (GTK_STATUSBAR(statusbar), "Folder View");
1357 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1358 (GTK_STATUSBAR(statusbar), "Summary View");
1359 mainwin->messageview_cid = gtk_statusbar_get_context_id
1360 (GTK_STATUSBAR(statusbar), "Message View");
1362 messageview->statusbar_cid = mainwin->messageview_cid;
1364 /* allocate colors for summary view and folder view */
1365 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1366 summaryview->color_marked.blue = (guint16)65535;
1368 summaryview->color_dim.red = summaryview->color_dim.green =
1369 summaryview->color_dim.blue = COLOR_DIM;
1371 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1372 &folderview->color_new);
1374 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1375 &folderview->color_op);
1377 summaryview->color_important.red = 0;
1378 summaryview->color_important.green = 0;
1379 summaryview->color_important.blue = (guint16)65535;
1381 color[0] = summaryview->color_marked;
1382 color[1] = summaryview->color_dim;
1383 color[2] = folderview->color_new;
1384 color[3] = folderview->color_op;
1386 colormap = gdk_drawable_get_colormap(window->window);
1387 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1388 for (i = 0; i < 4; i++) {
1389 if (success[i] == FALSE)
1390 g_warning("MainWindow: color allocation %d failed\n", i);
1393 debug_print("done.\n");
1395 messageview->visible = prefs_common.msgview_visible;
1397 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1399 g_signal_connect(G_OBJECT(window), "size_allocate",
1400 G_CALLBACK(main_window_size_allocate_cb),
1403 /* set menu items */
1404 menuitem = gtk_item_factory_get_item
1405 (ifactory, "/View/Character encoding/Auto detect");
1406 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1408 switch (prefs_common.toolbar_style) {
1410 menuitem = gtk_item_factory_get_item
1411 (ifactory, "/View/Show or hide/Toolbar/Hide");
1414 menuitem = gtk_item_factory_get_item
1415 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1418 menuitem = gtk_item_factory_get_item
1419 (ifactory, "/View/Show or hide/Toolbar/Text only");
1422 menuitem = gtk_item_factory_get_item
1423 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1425 case TOOLBAR_BOTH_HORIZ:
1426 menuitem = gtk_item_factory_get_item
1428 "/View/Show or hide/Toolbar/Text beside icons");
1430 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1432 gtk_widget_hide(mainwin->hbox_stat);
1433 menuitem = gtk_item_factory_get_item
1434 (ifactory, "/View/Show or hide/Status bar");
1435 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1436 prefs_common.show_statusbar);
1438 /* set account selection menu */
1439 ac_menu = gtk_item_factory_get_widget
1440 (ifactory, "/Configuration/Change current account");
1441 mainwin->ac_menu = ac_menu;
1443 toolbar_main_set_sensitive(mainwin);
1445 /* create actions menu */
1446 main_window_update_actions_menu(mainwin);
1448 main_create_mailing_list_menu (mainwin, NULL);
1450 /* attach accel groups to main window */
1451 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1452 gtk_window_add_accel_group \
1454 gtk_item_factory_from_widget(menu)->accel_group); \
1455 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1457 G_CALLBACK(main_window_accel_activate), mainwin);
1460 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1462 /* connect the accelerators for equivalent
1463 menu items in different menus */
1464 menu_connect_identical_items();
1466 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1468 g_signal_connect(G_OBJECT(window), "window_state_event",
1469 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1470 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1471 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1472 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1474 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1475 prefs_common.layout_mode == SMALL_LAYOUT) {
1476 summary_relayout(mainwin->summaryview);
1478 summary_update_unread(mainwin->summaryview, NULL);
1480 gtk_widget_show(mainwin->window);
1482 /* initialize views */
1483 folderview_init(folderview);
1484 summary_init(summaryview);
1485 messageview_init(messageview);
1487 sslcertwindow_register_hook();
1489 mainwin->lock_count = 0;
1490 mainwin->menu_lock_count = 0;
1491 mainwin->cursor_count = 0;
1493 mainwin->progressindicator_hook =
1494 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1497 watch_cursor = gdk_cursor_new(GDK_WATCH);
1499 hand_cursor = gdk_cursor_new(GDK_HAND2);
1501 mainwin_list = g_list_append(mainwin_list, mainwin);
1503 /* init work_offline */
1504 if (prefs_common.work_offline)
1505 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1507 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1512 void main_window_destroy(MainWindow *mainwin)
1514 /* TODO : destroy other component */
1515 messageview_destroy(mainwin->messageview);
1516 mainwin->messageview = NULL;
1519 void main_window_update_actions_menu(MainWindow *mainwin)
1521 GtkItemFactory *ifactory;
1523 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1524 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1527 void main_window_cursor_wait(MainWindow *mainwin)
1530 if (mainwin->cursor_count == 0) {
1531 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1532 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1535 mainwin->cursor_count++;
1540 void main_window_cursor_normal(MainWindow *mainwin)
1542 if (mainwin->cursor_count)
1543 mainwin->cursor_count--;
1545 if (mainwin->cursor_count == 0) {
1546 gdk_window_set_cursor(mainwin->window->window, NULL);
1547 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1552 /* lock / unlock the user-interface */
1553 void main_window_lock(MainWindow *mainwin)
1555 if (mainwin->lock_count == 0)
1556 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1558 mainwin->lock_count++;
1560 main_window_set_menu_sensitive(mainwin);
1561 toolbar_main_set_sensitive(mainwin);
1564 void main_window_unlock(MainWindow *mainwin)
1566 if (mainwin->lock_count)
1567 mainwin->lock_count--;
1569 main_window_set_menu_sensitive(mainwin);
1570 toolbar_main_set_sensitive(mainwin);
1572 if (mainwin->lock_count == 0)
1573 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1576 static void main_window_menu_callback_block(MainWindow *mainwin)
1578 mainwin->menu_lock_count++;
1581 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1583 if (mainwin->menu_lock_count)
1584 mainwin->menu_lock_count--;
1587 static guint prefs_tag = 0;
1589 void main_window_reflect_prefs_all(void)
1591 main_window_reflect_prefs_all_real(FALSE);
1594 static gboolean reflect_prefs_timeout_cb(gpointer data)
1596 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1598 MainWindow *mainwin;
1601 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1602 mainwin = (MainWindow *)cur->data;
1604 main_window_show_cur_account(mainwin);
1605 main_window_set_menu_sensitive(mainwin);
1606 toolbar_main_set_sensitive(mainwin);
1609 if (pixmap_theme_changed) {
1610 toolbar_update(TOOLBAR_MAIN, mainwin);
1611 messageview_reflect_prefs_pixmap_theme();
1612 compose_reflect_prefs_pixmap_theme();
1613 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1614 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1616 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1617 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1618 mainwin->online_pixmap);
1619 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1620 gtk_widget_show(pixmap);
1621 mainwin->online_pixmap = pixmap;
1622 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1623 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1624 mainwin->offline_pixmap);
1625 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1626 gtk_widget_show(pixmap);
1627 mainwin->offline_pixmap = pixmap;
1630 headerview_set_font(mainwin->messageview->headerview);
1631 headerview_set_visibility(mainwin->messageview->headerview,
1632 prefs_common.display_header_pane);
1633 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1634 folderview_reflect_prefs();
1635 summary_reflect_prefs();
1636 summary_redisplay_msg(mainwin->summaryview);
1642 void main_window_reflect_prefs_all_now(void)
1644 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1647 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1652 /* re-create colorlabel submenu */
1653 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1654 g_return_if_fail(menu != NULL);
1656 /* clear items. get item pointers. */
1657 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1658 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1660 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1661 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1665 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1667 if (prefs_tag == 0 || pixmap_theme_changed) {
1668 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1669 GINT_TO_POINTER(pixmap_theme_changed));
1673 void main_window_set_summary_column(void)
1676 MainWindow *mainwin;
1678 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1679 mainwin = (MainWindow *)cur->data;
1680 summary_set_column_order(mainwin->summaryview);
1684 void main_window_set_folder_column(void)
1687 MainWindow *mainwin;
1689 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1690 mainwin = (MainWindow *)cur->data;
1691 folderview_set_column_order(mainwin->folderview);
1695 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1696 GList *account_list)
1698 GList *cur_ac, *cur_item;
1699 GtkWidget *menuitem;
1700 PrefsAccount *ac_prefs;
1702 /* destroy all previous menu item */
1703 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1704 while (cur_item != NULL) {
1705 GList *next = cur_item->next;
1706 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1710 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1711 ac_prefs = (PrefsAccount *)cur_ac->data;
1713 menuitem = gtk_menu_item_new_with_label
1714 (ac_prefs->account_name
1715 ? ac_prefs->account_name : _("Untitled"));
1716 gtk_widget_show(menuitem);
1717 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1718 g_signal_connect(G_OBJECT(menuitem), "activate",
1719 G_CALLBACK(account_selector_menu_cb),
1724 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1725 GList *account_list)
1727 GList *cur_ac, *cur_item;
1729 GtkWidget *menuitem;
1730 PrefsAccount *ac_prefs;
1732 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1733 "/Message/Receive");
1735 /* search for separator */
1736 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1737 cur_item = cur_item->next) {
1738 if (GTK_BIN(cur_item->data)->child == NULL) {
1739 cur_item = cur_item->next;
1744 /* destroy all previous menu item */
1745 while (cur_item != NULL) {
1746 GList *next = cur_item->next;
1747 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1751 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1752 ac_prefs = (PrefsAccount *)cur_ac->data;
1754 menuitem = gtk_menu_item_new_with_label
1755 (ac_prefs->account_name ? ac_prefs->account_name
1757 gtk_widget_show(menuitem);
1758 gtk_menu_append(GTK_MENU(menu), menuitem);
1759 g_signal_connect(G_OBJECT(menuitem), "activate",
1760 G_CALLBACK(account_receive_menu_cb),
1765 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1766 GList *account_list)
1768 GList *cur_ac, *cur_item;
1769 GtkWidget *menuitem;
1770 PrefsAccount *ac_prefs;
1771 GtkWidget *menu = NULL;
1773 if (mainwin->toolbar->getall_btn == NULL
1774 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1777 menu = mainwin->toolbar->getall_combo->menu;
1779 /* destroy all previous menu item */
1780 cur_item = GTK_MENU_SHELL(menu)->children;
1781 while (cur_item != NULL) {
1782 GList *next = cur_item->next;
1783 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1787 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1788 ac_prefs = (PrefsAccount *)cur_ac->data;
1790 menuitem = gtk_menu_item_new_with_label
1791 (ac_prefs->account_name
1792 ? ac_prefs->account_name : _("Untitled"));
1793 gtk_widget_show(menuitem);
1794 gtk_menu_append(GTK_MENU(menu), menuitem);
1795 g_signal_connect(G_OBJECT(menuitem), "activate",
1796 G_CALLBACK(account_receive_menu_cb),
1801 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1802 GList *account_list)
1804 GList *cur_ac, *cur_item;
1805 GtkWidget *menuitem;
1806 PrefsAccount *ac_prefs;
1807 GtkWidget *menu = NULL;
1809 if (mainwin->toolbar->compose_mail_btn == NULL
1810 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1813 menu = mainwin->toolbar->compose_combo->menu;
1815 /* destroy all previous menu item */
1816 cur_item = GTK_MENU_SHELL(menu)->children;
1817 while (cur_item != NULL) {
1818 GList *next = cur_item->next;
1819 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1823 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1824 ac_prefs = (PrefsAccount *)cur_ac->data;
1826 menuitem = gtk_menu_item_new_with_label
1827 (ac_prefs->account_name
1828 ? ac_prefs->account_name : _("Untitled"));
1829 gtk_widget_show(menuitem);
1830 gtk_menu_append(GTK_MENU(menu), menuitem);
1831 g_signal_connect(G_OBJECT(menuitem), "activate",
1832 G_CALLBACK(account_compose_menu_cb),
1837 void main_window_set_account_menu(GList *account_list)
1840 MainWindow *mainwin;
1842 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1843 mainwin = (MainWindow *)cur->data;
1844 main_window_set_account_selector_menu(mainwin, account_list);
1845 main_window_set_account_receive_menu(mainwin, account_list);
1846 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1847 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1849 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
1852 void main_window_set_account_menu_only_toolbar(GList *account_list)
1855 MainWindow *mainwin;
1857 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1858 mainwin = (MainWindow *)cur->data;
1859 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1860 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1864 static void main_window_show_cur_account(MainWindow *mainwin)
1869 ac_name = g_strdup(cur_account
1870 ? (cur_account->account_name
1871 ? cur_account->account_name : _("Untitled"))
1875 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1877 buf = g_strdup(PROG_VERSION);
1878 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1881 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1882 gtk_widget_queue_resize(mainwin->ac_button);
1887 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
1889 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1890 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1891 GtkWidget *message_wid = mainwin->messageview->vbox;
1893 if (layout_mode == prefs_common.layout_mode)
1896 debug_print("Changing window separation type from %d to %d\n",
1897 prefs_common.layout_mode, layout_mode);
1899 /* remove widgets from those containers */
1900 gtk_widget_ref(folder_wid);
1901 gtk_widget_ref(summary_wid);
1902 gtk_widget_ref(message_wid);
1903 gtkut_container_remove
1904 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1905 gtkut_container_remove
1906 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1907 gtkut_container_remove
1908 (GTK_CONTAINER(message_wid->parent), message_wid);
1910 gtk_widget_hide(mainwin->window);
1911 main_window_set_widgets(mainwin, layout_mode);
1912 gtk_widget_show(mainwin->window);
1914 gtk_widget_unref(folder_wid);
1915 gtk_widget_unref(summary_wid);
1916 gtk_widget_unref(message_wid);
1919 void mainwindow_reset_paned(GtkPaned *paned)
1923 if (gtk_paned_get_child1(GTK_PANED(paned)))
1924 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
1925 if (gtk_paned_get_child2(GTK_PANED(paned)))
1926 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
1929 g_object_get (G_OBJECT(paned),
1932 g_object_get (G_OBJECT(paned),
1936 gtk_paned_set_position(GTK_PANED(paned), mid);
1939 static void mainwin_paned_show_first(GtkPaned *paned)
1942 g_object_get (G_OBJECT(paned),
1946 if (gtk_paned_get_child1(GTK_PANED(paned)))
1947 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
1948 if (gtk_paned_get_child2(GTK_PANED(paned)))
1949 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
1950 gtk_paned_set_position(GTK_PANED(paned), max);
1953 static void mainwin_paned_show_last(GtkPaned *paned)
1956 g_object_get (G_OBJECT(paned),
1960 if (gtk_paned_get_child1(GTK_PANED(paned)))
1961 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
1962 if (gtk_paned_get_child2(GTK_PANED(paned)))
1963 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
1964 gtk_paned_set_position(GTK_PANED(paned), min);
1967 void main_window_toggle_message_view(MainWindow *mainwin)
1969 SummaryView *summaryview = mainwin->summaryview;
1970 GtkWidget *ppaned = NULL;
1971 GtkWidget *container = NULL;
1973 switch (prefs_common.layout_mode) {
1975 case VERTICAL_LAYOUT:
1977 ppaned = mainwin->vpaned;
1978 container = mainwin->hpaned;
1979 if (ppaned->parent != NULL) {
1980 mainwin->messageview->visible = FALSE;
1981 summaryview->displayed = NULL;
1982 gtk_widget_ref(ppaned);
1983 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
1984 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1986 mainwin->messageview->visible = TRUE;
1987 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
1988 gtk_container_add(GTK_CONTAINER(container), ppaned);
1989 gtk_widget_unref(ppaned);
1993 ppaned = mainwin->hpaned;
1994 container = mainwin->vpaned;
1995 if (mainwin->messageview->vbox->parent != NULL) {
1996 mainwin->messageview->visible = FALSE;
1997 summaryview->displayed = NULL;
1998 gtk_widget_ref(mainwin->messageview->vbox);
1999 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2001 mainwin->messageview->visible = TRUE;
2002 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2003 gtk_widget_unref(mainwin->messageview->vbox);
2006 case WIDE_MSGLIST_LAYOUT:
2007 g_warning("can't hide messageview in this wide msglist layout");
2011 if (messageview_is_visible(mainwin->messageview))
2012 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2013 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2015 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2016 GTK_ARROW_UP, GTK_SHADOW_OUT);
2018 if (mainwin->messageview->visible == FALSE)
2019 messageview_clear(mainwin->messageview);
2021 main_window_set_menu_sensitive(mainwin);
2023 prefs_common.msgview_visible = mainwin->messageview->visible;
2025 if (messageview_is_visible(mainwin->messageview)) {
2026 gtk_widget_queue_resize(mainwin->hpaned);
2027 gtk_widget_queue_resize(mainwin->vpaned);
2029 summary_grab_focus(summaryview);
2032 void main_window_get_size(MainWindow *mainwin)
2034 GtkAllocation *allocation;
2036 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2037 debug_print("called after messageview "
2038 "has been deallocated!\n");
2042 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2044 if (allocation->width > 1 && allocation->height > 1) {
2045 prefs_common.summaryview_width = allocation->width;
2047 if (messageview_is_visible(mainwin->messageview))
2048 prefs_common.summaryview_height = allocation->height;
2050 prefs_common.mainview_width = allocation->width;
2053 allocation = &mainwin->window->allocation;
2054 if (allocation->width > 1 && allocation->height > 1) {
2055 prefs_common.mainview_height = allocation->height;
2056 prefs_common.mainwin_width = allocation->width;
2057 prefs_common.mainwin_height = allocation->height;
2060 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2061 if (allocation->width > 1 && allocation->height > 1) {
2062 prefs_common.folderview_width = allocation->width;
2063 prefs_common.folderview_height = allocation->height;
2066 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2067 if (allocation->width > 1 && allocation->height > 1) {
2068 prefs_common.msgview_width = allocation->width;
2069 prefs_common.msgview_height = allocation->height;
2072 /* debug_print("summaryview size: %d x %d\n",
2073 prefs_common.summaryview_width,
2074 prefs_common.summaryview_height);
2075 debug_print("folderview size: %d x %d\n",
2076 prefs_common.folderview_width,
2077 prefs_common.folderview_height);
2078 debug_print("messageview size: %d x %d\n",
2079 prefs_common.msgview_width,
2080 prefs_common.msgview_height); */
2083 void main_window_get_position(MainWindow *mainwin)
2087 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2089 prefs_common.mainview_x = x;
2090 prefs_common.mainview_y = y;
2091 prefs_common.mainwin_x = x;
2092 prefs_common.mainwin_y = y;
2094 debug_print("main window position: %d, %d\n", x, y);
2097 void main_window_progress_on(MainWindow *mainwin)
2099 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2102 void main_window_progress_off(MainWindow *mainwin)
2104 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2105 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2108 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2112 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2113 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2114 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2115 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2118 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2120 if (confirm && procmsg_have_trashed_mails_fast()) {
2121 if (alertpanel(_("Empty trash"),
2122 _("Delete all messages in trash folders?"),
2123 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2124 != G_ALERTALTERNATE)
2126 manage_window_focus_in(mainwin->window, NULL, NULL);
2129 procmsg_empty_all_trash();
2131 if (mainwin->summaryview->folder_item &&
2132 mainwin->summaryview->folder_item->stype == F_TRASH)
2133 gtk_widget_grab_focus(mainwin->folderview->ctree);
2136 void main_window_add_mailbox(MainWindow *mainwin)
2141 path = input_dialog(_("Add mailbox"),
2142 _("Input the location of mailbox.\n"
2143 "If an existing mailbox is specified, it will be\n"
2144 "scanned automatically."),
2147 if (folder_find_from_path(path)) {
2148 alertpanel_error(_("The mailbox '%s' already exists."), path);
2152 folder = folder_new(folder_get_class_from_string("mh"),
2153 !strcmp(path, "Mail") ? _("Mailbox") :
2154 g_path_get_basename(path), path);
2157 if (folder->klass->create_tree(folder) < 0) {
2158 alertpanel_error(_("Creation of the mailbox failed.\n"
2159 "Maybe some files already exist, or you don't have the permission to write there."));
2160 folder_destroy(folder);
2165 folder_set_ui_func(folder, scan_tree_func, mainwin);
2166 folder_scan_tree(folder, TRUE);
2167 folder_set_ui_func(folder, NULL, NULL);
2170 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2172 SensitiveCond state = 0;
2173 SummarySelection selection;
2174 FolderItem *item = mainwin->summaryview->folder_item;
2175 GList *account_list = account_get_list();
2177 selection = summary_get_selection_type(mainwin->summaryview);
2179 if (mainwin->lock_count == 0)
2180 state |= M_UNLOCKED;
2181 if (selection != SUMMARY_NONE)
2182 state |= M_MSG_EXIST;
2183 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2185 /* if (item->folder->type != F_NEWS) */
2186 state |= M_ALLOW_DELETE;
2188 if (prefs_common.immediate_exec == 0
2189 && mainwin->lock_count == 0)
2190 state |= M_DELAY_EXEC;
2192 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2193 || selection != SUMMARY_NONE)
2194 state |= M_HIDE_READ_MSG;
2196 if (mainwin->summaryview->threaded)
2197 state |= M_THREADED;
2199 state |= M_UNTHREADED;
2200 if (selection == SUMMARY_SELECTED_SINGLE ||
2201 selection == SUMMARY_SELECTED_MULTIPLE)
2202 state |= M_TARGET_EXIST;
2203 if (selection == SUMMARY_SELECTED_SINGLE)
2204 state |= M_SINGLE_TARGET_EXIST;
2205 if (mainwin->summaryview->folder_item &&
2206 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2209 state |= M_NOT_NEWS;
2210 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2211 state |= M_ACTIONS_EXIST;
2213 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2214 state |= M_HAVE_QUEUED_MAILS;
2216 if (selection == SUMMARY_SELECTED_SINGLE &&
2218 (folder_has_parent_of_type(item, F_DRAFT) ||
2219 folder_has_parent_of_type(item, F_OUTBOX) ||
2220 folder_has_parent_of_type(item, F_QUEUE))))
2221 state |= M_ALLOW_REEDIT;
2223 state |= M_HAVE_ACCOUNT;
2225 if (any_folder_want_synchronise())
2226 state |= M_WANT_SYNC;
2228 for ( ; account_list != NULL; account_list = account_list->next) {
2229 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2230 state |= M_HAVE_NEWS_ACCOUNT;
2235 if (procmsg_spam_can_learn() &&
2236 (mainwin->summaryview->folder_item &&
2237 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2238 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2239 state |= M_CAN_LEARN_SPAM;
2242 if (inc_is_active())
2243 state |= M_INC_ACTIVE;
2244 if (imap_cancel_all_enabled())
2245 state |= M_INC_ACTIVE;
2247 if (mainwin->summaryview->deleted > 0 ||
2248 mainwin->summaryview->moved > 0 ||
2249 mainwin->summaryview->copied > 0)
2250 state |= M_DELAY_EXEC;
2257 void main_window_set_menu_sensitive(MainWindow *mainwin)
2259 GtkItemFactory *ifactory = mainwin->menu_factory;
2260 SensitiveCond state;
2263 GtkWidget *menuitem;
2264 SummaryView *summaryview;
2269 static const struct {
2273 {"/File/Save as...", M_TARGET_EXIST},
2274 {"/File/Print..." , M_TARGET_EXIST},
2275 {"/File/Synchronise folders", M_WANT_SYNC},
2276 {"/File/Exit" , M_UNLOCKED},
2278 {"/Edit/Select thread" , M_TARGET_EXIST},
2279 {"/Edit/Delete thread" , M_TARGET_EXIST},
2280 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2282 {"/View/Set displayed columns/in Folder list..."
2284 {"/View/Sort" , M_EXEC},
2285 {"/View/Thread view" , M_EXEC},
2286 {"/View/Expand all threads" , M_MSG_EXIST},
2287 {"/View/Collapse all threads" , M_MSG_EXIST},
2288 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2289 {"/View/Go to/Previous message" , M_MSG_EXIST},
2290 {"/View/Go to/Next message" , M_MSG_EXIST},
2291 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2292 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2293 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2294 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2295 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2296 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2297 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2298 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2299 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2300 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2301 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2303 {"/Message/Receive/Get from current account"
2304 , M_HAVE_ACCOUNT|M_UNLOCKED},
2305 {"/Message/Receive/Get from all accounts"
2306 , M_HAVE_ACCOUNT|M_UNLOCKED},
2307 {"/Message/Receive/Cancel receiving"
2309 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2310 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2311 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2312 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2313 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2314 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2315 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2316 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2317 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2318 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2319 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2320 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2321 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2322 {"/Message/Mark" , M_TARGET_EXIST},
2323 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2324 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2325 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2326 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2327 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2328 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2329 {"/Message/Color label" , M_TARGET_EXIST},
2330 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2332 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2333 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2334 {"/Tools/Harvest addresses/from Messages..."
2336 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2337 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2338 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2339 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2340 {"/Tools/List URLs..." , M_TARGET_EXIST},
2341 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2342 {"/Tools/Execute" , M_DELAY_EXEC},
2343 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2345 {"/Configuration", M_UNLOCKED},
2346 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2347 {"/Configuration/Create new account...", M_UNLOCKED},
2348 {"/Configuration/Edit accounts...", M_UNLOCKED},
2353 state = main_window_get_current_state(mainwin);
2355 for (i = 0; entry[i].entry != NULL; i++) {
2356 sensitive = ((entry[i].cond & state) == entry[i].cond);
2357 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2360 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2362 /* search for separator */
2363 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2364 cur_item = cur_item->next) {
2365 if (GTK_BIN(cur_item->data)->child == NULL) {
2366 cur_item = cur_item->next;
2371 for (; cur_item != NULL; cur_item = cur_item->next) {
2372 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2373 (M_UNLOCKED & state) != 0);
2376 main_window_menu_callback_block(mainwin);
2378 #define SET_CHECK_MENU_ACTIVE(path, active) \
2380 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2381 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2384 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2385 messageview_is_visible(mainwin->messageview));
2387 summaryview = mainwin->summaryview;
2388 menu_path = "/View/Sort/Don't sort";
2390 switch (summaryview->sort_key) {
2391 case SORT_BY_NUMBER:
2392 menu_path = "/View/Sort/by number"; break;
2394 menu_path = "/View/Sort/by Size"; break;
2396 menu_path = "/View/Sort/by Date"; break;
2398 menu_path = "/View/Sort/by From"; break;
2400 menu_path = "/View/Sort/by To"; break;
2401 case SORT_BY_SUBJECT:
2402 menu_path = "/View/Sort/by Subject"; break;
2404 menu_path = "/View/Sort/by color label"; break;
2406 menu_path = "/View/Sort/by mark"; break;
2407 case SORT_BY_STATUS:
2408 menu_path = "/View/Sort/by status"; break;
2410 menu_path = "/View/Sort/by attachment"; break;
2412 menu_path = "/View/Sort/by score"; break;
2413 case SORT_BY_LOCKED:
2414 menu_path = "/View/Sort/by locked"; break;
2417 menu_path = "/View/Sort/Don't sort"; break;
2419 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2421 if (summaryview->sort_type == SORT_ASCENDING) {
2422 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2424 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2427 if (summaryview->sort_key != SORT_BY_NONE) {
2428 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2429 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2431 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2432 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2435 if (mainwin->messageview
2436 && mainwin->messageview->mimeview
2437 && mainwin->messageview->mimeview->textview)
2438 SET_CHECK_MENU_ACTIVE("/View/All headers",
2439 mainwin->messageview->mimeview->textview->show_all_headers);
2440 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2441 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2442 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2443 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2444 if (prefs_common.hide_quotes == 1)
2445 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2446 if (prefs_common.hide_quotes == 2)
2447 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2448 if (prefs_common.hide_quotes == 3)
2449 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2451 #undef SET_CHECK_MENU_ACTIVE
2453 main_window_menu_callback_unblock(mainwin);
2456 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2458 GtkItemFactory *ifactory;
2460 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2463 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2465 gtk_widget_set_sensitive (gtk_item_factory_get_item
2466 (ifactory,"/Message/Mailing-List"), TRUE);
2468 gtk_widget_set_sensitive (gtk_item_factory_get_item
2469 (ifactory,"/Message/Mailing-List"), FALSE);
2472 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2475 GtkWidget *menuitem;
2477 if (!msginfo || !msginfo->extradata) {
2478 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2479 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2480 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2481 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2482 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2483 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2487 /* Mailing list post */
2488 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2489 g_free(msginfo->extradata->list_post);
2490 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2492 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2494 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2496 /* Mailing list help */
2497 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2499 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2501 /* Mailing list subscribe */
2502 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2504 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2506 /* Mailing list unsubscribe */
2507 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2509 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2511 /* Mailing list view archive */
2512 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2514 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2516 /* Mailing list contact owner */
2517 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2519 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2524 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2526 GtkWidget *item, *menu;
2527 const gchar *url_pt ;
2528 gchar url_decoded[BUFFSIZE];
2529 GList *amenu, *alist;
2532 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2534 /* First delete old submenu */
2535 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2536 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2537 alist = amenu->next;
2538 item = GTK_WIDGET (amenu->data);
2539 gtk_widget_destroy (item);
2543 for (url_pt = list_header; url_pt && *url_pt;) {
2544 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2546 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2547 item = gtk_menu_item_new_with_label ((url_decoded));
2548 g_signal_connect(G_OBJECT(item), "activate",
2549 G_CALLBACK(mailing_list_compose),
2552 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2553 !g_strncasecmp (url_decoded, "https:",6)) {
2555 item = gtk_menu_item_new_with_label ((url_decoded));
2556 g_signal_connect(G_OBJECT(item), "activate",
2557 G_CALLBACK(mailing_list_open_uri),
2561 gtk_menu_append (GTK_MENU(menu), item);
2562 gtk_widget_show (item);
2568 gtk_widget_set_sensitive (menuitem, TRUE);
2570 gtk_widget_set_sensitive (menuitem, FALSE);
2576 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2578 gchar tmp[BUFFSIZE];
2582 gboolean with_plus = TRUE;
2585 *url_decoded = '\0';
2589 /* Ignore spaces, comments and tabs () */
2590 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2592 for (;*buf != ')' && *buf != 0x00; buf++);
2594 /* First non space and non comment must be a < */
2597 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2599 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2604 *url_decoded = '\0';
2609 *url_decoded = '\0';
2615 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2617 /* Prepare the work for the next url in the list */
2618 /* after the closing bracket >, ignore space, comments and tabs */
2619 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2621 for (;*buf != ')' && *buf != 0x00; buf++);
2623 if (!buf || !*buf) {
2628 /* now first non space, non comment must be a comma */
2630 for (;*buf != 0x00; buf++);
2636 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2640 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2641 compose_new(NULL, mailto+7, NULL);
2644 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2649 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2650 open_uri (mailto, prefs_common.uri_cmd);
2653 void main_window_popup(MainWindow *mainwin)
2655 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2656 main_window_show(mainwin);
2658 gtkut_window_popup(mainwin->window);
2659 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2660 if (mainwin->in_folder) {
2661 mainwindow_enter_folder(mainwin);
2663 mainwindow_exit_folder(mainwin);
2668 void main_window_show(MainWindow *mainwin)
2670 gtk_widget_show(mainwin->window);
2671 gtk_widget_show(mainwin->vbox_body);
2673 gtk_widget_set_uposition(mainwin->window,
2674 prefs_common.mainwin_x,
2675 prefs_common.mainwin_y);
2677 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2678 prefs_common.folderview_width,
2679 prefs_common.folderview_height);
2680 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2681 prefs_common.summaryview_width,
2682 prefs_common.summaryview_height);
2683 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2684 prefs_common.msgview_width,
2685 prefs_common.msgview_height);
2688 void main_window_hide(MainWindow *mainwin)
2690 main_window_get_size(mainwin);
2691 main_window_get_position(mainwin);
2693 gtk_widget_hide(mainwin->window);
2694 gtk_widget_hide(mainwin->vbox_body);
2697 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2699 GtkWidget *folderwin = NULL;
2700 GtkWidget *messagewin = NULL;
2703 GtkWidget *vbox_body = mainwin->vbox_body;
2704 GtkItemFactory *ifactory = mainwin->menu_factory;
2705 GtkWidget *menuitem;
2706 gboolean first_set = (mainwin->hpaned == NULL);
2707 debug_print("Setting widgets... ");
2709 if (layout_mode == SMALL_LAYOUT && first_set) {
2710 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2711 prefs_common.folderview_width,
2712 prefs_common.folderview_height);
2713 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2715 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2718 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2719 prefs_common.folderview_width,
2720 prefs_common.folderview_height);
2721 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2722 prefs_common.summaryview_width,
2723 prefs_common.summaryview_height);
2724 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2725 prefs_common.msgview_width,
2726 prefs_common.msgview_height);
2729 mainwin->messageview->statusbar = mainwin->statusbar;
2730 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2732 /* clean top-most container */
2733 if (mainwin->hpaned) {
2734 if (mainwin->hpaned->parent == mainwin->vpaned)
2735 gtk_widget_destroy(mainwin->vpaned);
2737 gtk_widget_destroy(mainwin->hpaned);
2740 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
2741 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
2742 switch (layout_mode) {
2743 case VERTICAL_LAYOUT:
2746 hpaned = gtk_hpaned_new();
2747 if (layout_mode == VERTICAL_LAYOUT)
2748 vpaned = gtk_hpaned_new();
2750 vpaned = gtk_vpaned_new();
2751 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2752 gtk_paned_add1(GTK_PANED(hpaned),
2753 GTK_WIDGET_PTR(mainwin->folderview));
2754 gtk_widget_show(hpaned);
2755 gtk_widget_queue_resize(hpaned);
2757 if (messageview_is_visible(mainwin->messageview)) {
2758 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2759 gtk_paned_add1(GTK_PANED(vpaned),
2760 GTK_WIDGET_PTR(mainwin->summaryview));
2762 gtk_paned_add2(GTK_PANED(hpaned),
2763 GTK_WIDGET_PTR(mainwin->summaryview));
2764 gtk_widget_ref(vpaned);
2766 gtk_paned_add2(GTK_PANED(vpaned),
2767 GTK_WIDGET_PTR(mainwin->messageview));
2768 gtk_widget_show(vpaned);
2769 if (layout_mode == SMALL_LAYOUT && first_set) {
2770 mainwin_paned_show_first(GTK_PANED(hpaned));
2772 gtk_widget_queue_resize(vpaned);
2775 vpaned = gtk_vpaned_new();
2776 hpaned = gtk_hpaned_new();
2777 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2778 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
2780 gtk_paned_add1(GTK_PANED(hpaned),
2781 GTK_WIDGET_PTR(mainwin->folderview));
2782 gtk_paned_add2(GTK_PANED(hpaned),
2783 GTK_WIDGET_PTR(mainwin->summaryview));
2785 gtk_widget_show(hpaned);
2786 gtk_widget_queue_resize(hpaned);
2788 if (messageview_is_visible(mainwin->messageview)) {
2789 gtk_paned_add2(GTK_PANED(vpaned),
2790 GTK_WIDGET_PTR(mainwin->messageview));
2792 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
2794 gtk_widget_show(vpaned);
2795 gtk_widget_queue_resize(vpaned);
2797 case WIDE_MSGLIST_LAYOUT:
2798 vpaned = gtk_vpaned_new();
2799 hpaned = gtk_hpaned_new();
2800 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2802 gtk_paned_add1(GTK_PANED(vpaned),
2803 GTK_WIDGET_PTR(mainwin->summaryview));
2804 gtk_paned_add1(GTK_PANED(hpaned),
2805 GTK_WIDGET_PTR(mainwin->folderview));
2807 gtk_widget_show(hpaned);
2808 gtk_widget_queue_resize(hpaned);
2810 if (messageview_is_visible(mainwin->messageview)) {
2811 gtk_paned_add2(GTK_PANED(hpaned),
2812 GTK_WIDGET_PTR(mainwin->messageview));
2814 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
2816 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
2818 gtk_widget_show(vpaned);
2819 gtk_widget_queue_resize(vpaned);
2822 g_warning("Unknown layout");
2826 mainwin->hpaned = hpaned;
2827 mainwin->vpaned = vpaned;
2829 if (layout_mode == SMALL_LAYOUT) {
2830 if (mainwin->messageview->visible)
2831 main_window_toggle_message_view(mainwin);
2834 if (layout_mode == SMALL_LAYOUT && first_set) {
2835 gtk_widget_realize(mainwin->window);
2836 gtk_widget_realize(mainwin->folderview->ctree);
2837 gtk_widget_realize(mainwin->summaryview->hbox);
2838 gtk_widget_realize(mainwin->summaryview->hbox_l);
2839 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2840 prefs_common.folderview_width,
2841 prefs_common.folderview_height);
2842 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2844 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2846 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
2847 prefs_common.mainwin_width,
2848 prefs_common.mainwin_height);
2849 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
2851 /* remove headerview if not in prefs */
2852 headerview_set_visibility(mainwin->messageview->headerview,
2853 prefs_common.display_header_pane);
2855 if (messageview_is_visible(mainwin->messageview))
2856 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2857 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2859 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2860 GTK_ARROW_UP, GTK_SHADOW_OUT);
2862 gtk_window_move(GTK_WINDOW(mainwin->window),
2863 prefs_common.mainwin_x,
2864 prefs_common.mainwin_y);
2866 gtk_widget_queue_resize(vbox_body);
2867 gtk_widget_queue_resize(mainwin->vbox);
2868 gtk_widget_queue_resize(mainwin->window);
2869 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2870 * and mimeview icon list/ctree lose track of their visibility states */
2871 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2872 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2873 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2874 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2875 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2876 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2878 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2880 prefs_common.layout_mode = layout_mode;
2882 menuitem = gtk_item_factory_get_item
2883 (ifactory, "/View/Show or hide/Message view");
2884 gtk_check_menu_item_set_active
2885 (GTK_CHECK_MENU_ITEM(menuitem),
2886 messageview_is_visible(mainwin->messageview));
2888 #define SET_CHECK_MENU_ACTIVE(path, active) \
2890 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2891 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2894 switch (prefs_common.layout_mode) {
2896 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
2898 case VERTICAL_LAYOUT:
2899 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
2902 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
2904 case WIDE_MSGLIST_LAYOUT:
2905 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
2908 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
2911 #undef SET_CHECK_MENU_ACTIVE
2915 (G_OBJECT(folderwin), "size_allocate",
2916 G_CALLBACK(folder_window_size_allocate_cb),
2921 (G_OBJECT(messagewin), "size_allocate",
2922 G_CALLBACK(message_window_size_allocate_cb),
2926 debug_print("done.\n");
2929 void main_window_destroy_all(void)
2931 while (mainwin_list != NULL) {
2932 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2934 /* free toolbar stuff */
2935 toolbar_clear_list(TOOLBAR_MAIN);
2936 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2937 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2939 mainwin->folderview->mainwin = NULL;
2940 mainwin->summaryview->mainwin = NULL;
2941 mainwin->messageview->mainwin = NULL;
2943 g_free(mainwin->toolbar);
2946 mainwin_list = g_list_remove(mainwin_list, mainwin);
2948 g_list_free(mainwin_list);
2949 mainwin_list = NULL;
2952 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2955 gtk_widget_set_size_request(child, 1, -1);
2958 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2961 gtk_widget_set_size_request(child, -1, -1);
2964 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2967 MainWindow *mainwin = (MainWindow *)data;
2969 if (!event) return FALSE;
2971 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2972 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2975 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2976 menu_button_position, widget,
2977 event->button, event->time);
2982 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2985 MainWindow *mainwin = (MainWindow *)data;
2986 gboolean close_allowed = TRUE;
2988 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
2990 if (close_allowed && mainwin->lock_count == 0)
2991 app_exit_cb(data, 0, widget);
2996 static void main_window_size_allocate_cb(GtkWidget *widget,
2997 GtkAllocation *allocation,
3000 MainWindow *mainwin = (MainWindow *)data;
3001 main_window_get_size(mainwin);
3004 static void folder_window_size_allocate_cb(GtkWidget *widget,
3005 GtkAllocation *allocation,
3008 MainWindow *mainwin = (MainWindow *)data;
3010 main_window_get_size(mainwin);
3013 static void message_window_size_allocate_cb(GtkWidget *widget,
3014 GtkAllocation *allocation,
3017 MainWindow *mainwin = (MainWindow *)data;
3019 main_window_get_size(mainwin);
3022 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3025 main_window_add_mailbox(mainwin);
3028 static void update_folderview_cb(MainWindow *mainwin, guint action,
3031 summary_show(mainwin->summaryview, NULL);
3032 folderview_check_new_all();
3035 static void foldersort_cb(MainWindow *mainwin, guint action,
3041 static void import_mbox_cb(MainWindow *mainwin, guint action,
3044 /* only notify if import has failed */
3045 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3046 alertpanel_error(_("Mbox import has failed."));
3050 static void export_mbox_cb(MainWindow *mainwin, guint action,
3053 /* only notify if export has failed */
3054 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3055 alertpanel_error(_("Export to mbox has failed."));
3059 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3062 /* only notify if export has failed */
3063 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3064 alertpanel_error(_("Export to mbox has failed."));
3068 static void empty_trash_cb(MainWindow *mainwin, guint action,
3071 main_window_empty_trash(mainwin, TRUE);
3074 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3076 summary_save_as(mainwin->summaryview);
3079 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3081 summary_print(mainwin->summaryview);
3084 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3086 if (prefs_common.confirm_on_exit) {
3087 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3088 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3089 != G_ALERTALTERNATE)
3091 manage_window_focus_in(mainwin->window, NULL, NULL);
3094 app_will_exit(widget, mainwin);
3097 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3100 summary_search(mainwin->summaryview);
3102 message_search(mainwin->messageview);
3105 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3107 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3110 static void toggle_message_cb(MainWindow *mainwin, guint action,
3115 active = GTK_CHECK_MENU_ITEM(widget)->active;
3117 if (active != messageview_is_visible(mainwin->messageview))
3118 summary_toggle_view(mainwin->summaryview);
3121 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3124 toolbar_toggle(action, mainwin);
3127 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3130 MessageView *msgview = (MessageView*)mainwin->messageview;
3131 GSList *msginfo_list = NULL;
3133 g_return_if_fail(msgview != NULL);
3135 msginfo_list = summary_get_selection(mainwin->summaryview);
3136 g_return_if_fail(msginfo_list != NULL);
3137 compose_reply_from_messageview(msgview, msginfo_list, action);
3138 g_slist_free(msginfo_list);
3142 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3145 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3146 gtk_widget_show(mainwin->hbox_stat);
3147 prefs_common.show_statusbar = TRUE;
3149 gtk_widget_hide(mainwin->hbox_stat);
3150 prefs_common.show_statusbar = FALSE;
3154 static void set_layout_cb(MainWindow *mainwin, guint action,
3157 LayoutType layout_mode = action;
3158 LayoutType old_layout_mode = prefs_common.layout_mode;
3159 if (mainwin->menu_lock_count) {
3162 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3166 if (layout_mode == prefs_common.layout_mode) {
3170 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3171 main_window_toggle_message_view(mainwin);
3172 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3173 main_window_toggle_message_view(mainwin);
3175 main_window_separation_change(mainwin, layout_mode);
3176 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3177 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3178 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3180 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3181 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3182 mainwindow_exit_folder(mainwin);
3184 summary_relayout(mainwin->summaryview);
3185 summary_update_unread(mainwin->summaryview, NULL);
3188 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3191 offline_ask_sync = ask_sync;
3193 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3195 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3196 offline_ask_sync = TRUE;
3199 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3201 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3204 static gboolean any_folder_want_synchronise(void)
3206 GList *folderlist = folder_get_list();
3208 /* see if there are synchronised folders */
3209 for (; folderlist; folderlist = folderlist->next) {
3210 Folder *folder = (Folder *)folderlist->data;
3211 if (folder_want_synchronise(folder)) {
3219 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3222 if (!any_folder_want_synchronise())
3225 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3226 _("Do you want to synchronise your folders now?"),
3227 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3230 if (offline_ask_sync)
3231 folder_synchronise(NULL);
3234 static void online_switch_clicked (GtkButton *btn, gpointer data)
3236 MainWindow *mainwin;
3237 GtkItemFactory *ifactory;
3238 GtkCheckMenuItem *menuitem;
3240 mainwin = (MainWindow *) data;
3242 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3243 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3245 g_return_if_fail(mainwin != NULL);
3246 g_return_if_fail(menuitem != NULL);
3248 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3249 gtk_widget_hide (mainwin->online_switch);
3250 gtk_widget_show (mainwin->offline_switch);
3251 menuitem->active = TRUE;
3252 inc_autocheck_timer_remove();
3255 if (prefs_common.work_offline)
3257 mainwindow_check_synchronise(mainwin, TRUE);
3258 prefs_common.work_offline = TRUE;
3259 imap_disconnect_all();
3260 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3263 if (!prefs_common.work_offline)
3265 gtk_widget_hide (mainwin->offline_switch);
3266 gtk_widget_show (mainwin->online_switch);
3267 menuitem->active = FALSE;
3268 prefs_common.work_offline = FALSE;
3269 inc_autocheck_timer_set();
3270 refresh_resolvers();
3271 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3275 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3278 addressbook_open(NULL);
3281 static void log_window_show_cb(MainWindow *mainwin, guint action,
3284 log_window_show(mainwin->logwin);
3287 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3290 log_window_show(mainwin->filtering_debugwin);
3293 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3299 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3301 summary_move_to(mainwin->summaryview);
3304 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3306 summary_copy_to(mainwin->summaryview);
3309 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3311 summary_delete(mainwin->summaryview);
3314 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3316 summary_delete_trash(mainwin->summaryview);
3319 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3321 summary_cancel(mainwin->summaryview);
3324 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3326 summary_open_msg(mainwin->summaryview);
3329 static void view_source_cb(MainWindow *mainwin, guint action,
3332 summary_view_source(mainwin->summaryview);
3335 static void show_all_header_cb(MainWindow *mainwin, guint action,
3338 if (mainwin->menu_lock_count) return;
3339 mainwin->summaryview->messageview->all_headers =
3340 GTK_CHECK_MENU_ITEM(widget)->active;
3341 summary_display_msg_selected(mainwin->summaryview,
3342 GTK_CHECK_MENU_ITEM(widget)->active);
3345 #define SET_CHECK_MENU_ACTIVE(path, active) \
3347 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3348 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3351 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3354 GtkWidget *menuitem;
3355 GtkItemFactory *ifactory = mainwin->menu_factory;
3357 if (mainwin->menu_lock_count) return;
3359 prefs_common.hide_quotes =
3360 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3362 mainwin->menu_lock_count++;
3363 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3364 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3365 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3366 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3367 mainwin->menu_lock_count--;
3369 summary_redisplay_msg(mainwin->summaryview);
3372 #undef SET_CHECK_MENU_ACTIVE
3373 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3375 summary_mark(mainwin->summaryview);
3378 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3380 summary_unmark(mainwin->summaryview);
3383 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3386 summary_mark_as_unread(mainwin->summaryview);
3389 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3392 summary_mark_as_read(mainwin->summaryview);
3395 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3398 summary_mark_all_read(mainwin->summaryview);
3401 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3404 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3407 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3410 summary_ignore_thread(mainwin->summaryview);
3413 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3416 summary_unignore_thread(mainwin->summaryview);
3419 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3422 summary_msgs_lock(mainwin->summaryview);
3425 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3428 summary_msgs_unlock(mainwin->summaryview);
3432 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3434 summary_reedit(mainwin->summaryview);
3437 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3439 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3440 summary_display_msg_selected(mainwin->summaryview,
3441 mainwin->messageview->mimeview->textview->show_all_headers);
3443 messageview_list_urls(mainwin->messageview);
3446 static void add_address_cb(MainWindow *mainwin, guint action,
3449 summary_add_address(mainwin->summaryview);
3452 static void set_charset_cb(MainWindow *mainwin, guint action,
3457 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3458 str = conv_get_charset_str((CharSet)action);
3460 g_free(mainwin->messageview->forced_charset);
3461 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3462 procmime_force_charset(str);
3464 summary_redisplay_msg(mainwin->summaryview);
3466 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3470 static void set_decode_cb(MainWindow *mainwin, guint action,
3473 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3474 mainwin->messageview->forced_encoding = (EncodingType)action;
3476 summary_redisplay_msg(mainwin->summaryview);
3478 debug_print("forced encoding: %d\n", action);
3482 static void hide_read_messages (MainWindow *mainwin, guint action,
3485 if (!mainwin->summaryview->folder_item
3486 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3488 summary_toggle_show_read_messages(mainwin->summaryview);
3491 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3493 gboolean threaded = FALSE;
3494 if (mainwin->menu_lock_count) return;
3495 if (!mainwin->summaryview->folder_item) return;
3497 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3499 mainwin->summaryview->folder_item->threaded = threaded;
3501 mainwin->summaryview->threaded = threaded;
3503 summary_show(mainwin->summaryview,
3504 mainwin->summaryview->folder_item);
3507 static void expand_threads_cb(MainWindow *mainwin, guint action,
3510 summary_expand_threads(mainwin->summaryview);
3513 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3516 summary_collapse_threads(mainwin->summaryview);
3519 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3522 prefs_summary_column_open();
3525 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3528 prefs_folder_column_open();
3531 static void sort_summary_cb(MainWindow *mainwin, guint action,
3534 FolderItem *item = mainwin->summaryview->folder_item;
3535 GtkWidget *menuitem;
3537 if (mainwin->menu_lock_count) return;
3539 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3540 menuitem = gtk_item_factory_get_item
3541 (mainwin->menu_factory, "/View/Sort/Ascending");
3542 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3543 GTK_CHECK_MENU_ITEM(menuitem)->active
3544 ? SORT_ASCENDING : SORT_DESCENDING);
3545 item->sort_key = action;
3549 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3552 FolderItem *item = mainwin->summaryview->folder_item;
3554 if (mainwin->menu_lock_count) return;
3556 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3557 summary_sort(mainwin->summaryview,
3558 item->sort_key, (FolderSortType)action);
3561 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3564 summary_attract_by_subject(mainwin->summaryview);
3567 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3572 item = folderview_get_selected_item(mainwin->folderview);
3574 main_window_cursor_wait(mainwin);
3575 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3577 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3578 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3580 STATUSBAR_POP(mainwin);
3581 main_window_cursor_normal(mainwin);
3591 static void deldup_all(FolderItem *item, gpointer _data)
3593 struct DelDupsData *data = _data;
3596 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3598 data->dups += result;
3603 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3606 struct DelDupsData data = {0, 0};
3608 main_window_cursor_wait(mainwin);
3609 folder_func_to_all_folders(deldup_all, &data);
3610 main_window_cursor_normal(mainwin);
3612 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3613 "Deleted %d duplicate messages in %d folders.\n",
3615 data.dups, data.folders);
3618 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3620 summary_filter(mainwin->summaryview, (gboolean)action);
3623 static void execute_summary_cb(MainWindow *mainwin, guint action,
3626 summary_execute(mainwin->summaryview);
3629 static void update_summary_cb(MainWindow *mainwin, guint action,
3633 FolderView *folderview = mainwin->folderview;
3635 if (!mainwin->summaryview->folder_item) return;
3636 if (!folderview->opened) return;
3638 folder_update_op_count();
3640 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3641 folderview->opened);
3644 folder_item_scan(fitem);
3645 summary_show(mainwin->summaryview, fitem);
3648 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3650 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3653 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3655 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3658 static void prev_unread_cb(MainWindow *mainwin, guint action,
3661 summary_select_prev_unread(mainwin->summaryview);
3664 static void next_unread_cb(MainWindow *mainwin, guint action,
3667 summary_select_next_unread(mainwin->summaryview);
3670 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3672 summary_select_prev_new(mainwin->summaryview);
3675 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3677 summary_select_next_new(mainwin->summaryview);
3680 static void prev_marked_cb(MainWindow *mainwin, guint action,
3683 summary_select_prev_marked(mainwin->summaryview);
3686 static void next_marked_cb(MainWindow *mainwin, guint action,
3689 summary_select_next_marked(mainwin->summaryview);
3692 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3695 summary_select_prev_labeled(mainwin->summaryview);
3698 static void next_labeled_cb(MainWindow *mainwin, guint action,
3701 summary_select_next_labeled(mainwin->summaryview);
3704 static void last_read_cb(MainWindow *mainwin, guint action,
3707 summary_select_last_read(mainwin->summaryview);
3710 static void parent_cb(MainWindow *mainwin, guint action,
3713 summary_select_parent(mainwin->summaryview);
3716 static void goto_folder_cb(MainWindow *mainwin, guint action,
3719 FolderItem *to_folder;
3721 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3724 folderview_select(mainwin->folderview, to_folder);
3727 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3730 folderview_select_next_unread(mainwin->folderview, FALSE);
3733 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3735 messageview_copy_clipboard(mainwin->messageview);
3738 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3740 MessageView *msgview = mainwin->messageview;
3742 if (messageview_is_visible(msgview) &&
3743 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3744 messageview_select_all(mainwin->messageview);
3746 summary_select_all(mainwin->summaryview);
3749 static void select_thread_cb(MainWindow *mainwin, guint action,
3752 summary_select_thread(mainwin->summaryview, FALSE);
3755 static void delete_thread_cb(MainWindow *mainwin, guint action,
3758 summary_select_thread(mainwin->summaryview, TRUE);
3761 static void create_filter_cb(MainWindow *mainwin, guint action,
3764 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3767 static void create_processing_cb(MainWindow *mainwin, guint action,
3770 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3773 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3776 prefs_filtering_open(&pre_global_processing,
3777 _("Processing rules to apply before folder rules"),
3778 MANUAL_ANCHOR_PROCESSING,
3782 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3785 prefs_filtering_open(&post_global_processing,
3786 _("Processing rules to apply after folder rules"),
3787 MANUAL_ANCHOR_PROCESSING,
3791 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3794 prefs_filtering_open(&filtering_rules,
3795 _("Filtering configuration"),
3796 MANUAL_ANCHOR_FILTERING,
3800 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3803 prefs_template_open();
3806 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3809 prefs_actions_open(mainwin);
3812 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3815 ssl_manager_open(mainwin);
3818 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3822 new_account_cb(mainwin, 0, widget);
3824 account_open(cur_account);
3828 static void new_account_cb(MainWindow *mainwin, guint action,
3831 account_edit_open();
3832 if (!compose_get_compose_list()) account_add();
3835 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3837 FolderItem *item = NULL;
3838 cur_account = (PrefsAccount *)data;
3840 if (!mainwindow_get_mainwindow())
3842 main_window_show_cur_account(mainwindow_get_mainwindow());
3843 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3844 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3845 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3846 item = folderview_get_selected_item(
3847 mainwindow_get_mainwindow()->folderview);
3849 toolbar_set_compose_button
3850 (mainwindow_get_mainwindow()->toolbar,
3851 FOLDER_TYPE(item->folder) == F_NEWS ?
3852 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3856 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3858 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3859 PrefsAccount *account = (PrefsAccount *)data;
3861 inc_account_mail(mainwin, account);
3864 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3866 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3867 PrefsAccount *account = (PrefsAccount *)data;
3868 FolderItem *item = mainwin->summaryview->folder_item;
3870 compose_new_with_folderitem(account, item, NULL);
3873 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3878 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3880 pluginwindow_create();
3883 static void manual_open_cb(MainWindow *mainwin, guint action,
3886 manual_open((ManualType)action, NULL);
3889 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3894 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3896 MainWindow *mainwin = (MainWindow *)data;
3900 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3901 LOCAL_FOLDER(folder)->rootpath,
3905 str = g_strdup_printf(_("Scanning folder %s ..."),
3906 LOCAL_FOLDER(folder)->rootpath);
3908 STATUSBAR_PUSH(mainwin, str);
3909 STATUSBAR_POP(mainwin);
3913 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3916 SummaryView *summary;
3918 g_return_val_if_fail(data, FALSE);
3919 if (!g_list_find(mainwin_list, data))
3921 summary = ((MainWindow *)data)->summaryview;
3922 g_return_val_if_fail(summary, FALSE);
3924 if (GTK_CLIST(summary->ctree)->selection &&
3925 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3931 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
3934 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
3938 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
3941 if (!claws_is_starting()
3942 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
3943 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
3945 if (iconified_count > 0)
3946 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
3949 if (state->new_window_state == 0)
3950 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
3954 gboolean mainwindow_is_obscured(void)
3959 #define BREAK_ON_MODIFIER_KEY() \
3960 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3962 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3965 MainWindow *mainwin = (MainWindow*) data;
3967 if (!mainwin || !event)
3970 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3972 lastkey = event->keyval;
3976 switch (event->keyval) {
3977 case GDK_Q: /* Quit */
3978 BREAK_ON_MODIFIER_KEY();
3980 app_exit_cb(mainwin, 0, NULL);
3983 if (mainwin->folderview && mainwin->summaryview
3984 && ((!mainwin->summaryview->displayed
3985 && !mainwin->summaryview->selected)
3986 || (mainwin->summaryview->folder_item
3987 && mainwin->summaryview->folder_item->total_msgs == 0))) {
3988 g_signal_stop_emission_by_name(G_OBJECT(widget),
3990 folderview_select_next_unread(mainwin->folderview, TRUE);
3995 if (maemo_mainwindow_is_fullscreen(widget)) {
3996 gtk_window_unfullscreen(GTK_WINDOW(widget));
3998 gtk_window_fullscreen(GTK_WINDOW(widget));
4008 #undef BREAK_ON_MODIFIER_KEY
4011 * Harvest addresses for selected folder.
4013 static void addr_harvest_cb( MainWindow *mainwin,
4017 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4021 * Harvest addresses for selected messages in summary view.
4023 static void addr_harvest_msg_cb( MainWindow *mainwin,
4027 summary_harvest_address( mainwin->summaryview );
4031 *\brief get a MainWindow
4033 *\return MainWindow * The first mainwindow in the mainwin_list
4035 MainWindow *mainwindow_get_mainwindow(void)
4037 if (mainwin_list && mainwin_list->data)
4038 return (MainWindow *)(mainwin_list->data);
4043 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4045 ProgressData *data = (ProgressData *) source;
4046 MainWindow *mainwin = (MainWindow *) userdata;
4048 switch (data->cmd) {
4049 case PROGRESS_COMMAND_START:
4050 case PROGRESS_COMMAND_STOP:
4051 gtk_progress_bar_set_fraction
4052 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4054 case PROGRESS_COMMAND_SET_PERCENTAGE:
4055 gtk_progress_bar_set_fraction
4056 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4059 while (gtk_events_pending()) gtk_main_iteration ();
4064 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4066 mainwindow_check_synchronise(mainwin, FALSE);
4069 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4071 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4074 void mainwindow_jump_to(const gchar *target)
4078 FolderItem *item = NULL;
4080 MainWindow *mainwin = mainwindow_get_mainwindow();
4086 printf("not initialized\n");
4090 tmp = g_strdup(target);
4092 if ((p = strstr(tmp, "\r")) != NULL)
4094 if ((p = strstr(tmp, "\n")) != NULL)
4097 if ((item = folder_find_item_from_identifier(tmp))) {
4098 printf("selecting folder '%s'\n", tmp);
4099 folderview_select(mainwin->folderview, item);
4100 main_window_popup(mainwin);
4105 msg = strrchr(tmp, G_DIR_SEPARATOR);
4108 if ((item = folder_find_item_from_identifier(tmp))) {
4109 printf("selecting folder '%s'\n", tmp);
4110 folderview_select(mainwin->folderview, item);
4112 printf("'%s' not found\n", tmp);
4114 if (item && msg && atoi(msg)) {
4115 printf("selecting message %d\n", atoi(msg));
4116 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4117 summary_display_msg_selected(mainwin->summaryview, FALSE);
4118 main_window_popup(mainwin);
4121 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4122 MsgInfo *msginfo = NULL;
4124 msg[strlen(msg)-1] = '\0';
4125 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4127 printf("selecting message %s\n", msg);
4128 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4129 summary_display_msg_selected(mainwin->summaryview, FALSE);
4130 main_window_popup(mainwin);
4132 procmsg_msginfo_free(msginfo);
4135 printf("'%s' not found\n", msg);
4138 printf("'%s' not found\n", msg);
4141 printf("'%s' not found\n", tmp);
4147 void mainwindow_exit_folder(MainWindow *mainwin) {
4148 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4149 folderview_close_opened(mainwin->folderview);
4150 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4152 mainwin->in_folder = FALSE;
4155 void mainwindow_enter_folder(MainWindow *mainwin) {
4156 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4157 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4159 mainwin->in_folder = TRUE;
4163 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4166 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4170 void maemo_window_full_screen_if_needed (GtkWindow *window)
4172 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4173 gtk_window_fullscreen(GTK_WINDOW(window));
4177 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4179 g_signal_connect(G_OBJECT(window), "key_press_event",
4180 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());