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"
65 #include "prefs_common.h"
66 #include "prefs_actions.h"
67 #include "prefs_filtering.h"
68 #include "prefs_account.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_folder_column.h"
71 #include "prefs_template.h"
74 #include "addressbook.h"
75 #include "logwindow.h"
76 #include "manage_window.h"
77 #include "alertpanel.h"
78 #include "statusbar.h"
79 #include "inputdialog.h"
86 #include "ssl_manager.h"
87 #include "sslcertwindow.h"
88 #include "prefs_gtk.h"
89 #include "pluginwindow.h"
91 #include "progressindicator.h"
92 #include "localfolder.h"
93 #include "filtering.h"
94 #include "folderutils.h"
95 #include "foldersort.h"
96 #include "icon_legend.h"
97 #include "colorlabel.h"
103 #define AC_LABEL_WIDTH 240
105 /* list of all instantiated MainWindow */
106 static GList *mainwin_list = NULL;
108 static GdkCursor *watch_cursor = NULL;
109 static GdkCursor *hand_cursor = NULL;
111 static gint iconified_count = 0;
113 static void main_window_menu_callback_block (MainWindow *mainwin);
114 static void main_window_menu_callback_unblock (MainWindow *mainwin);
116 static void main_window_show_cur_account (MainWindow *mainwin);
118 static void main_window_separation_change (MainWindow *mainwin,
119 LayoutType layout_mode);
121 static void main_window_set_widgets (MainWindow *mainwin,
122 LayoutType layout_mode);
124 static void toolbar_child_attached (GtkWidget *widget,
127 static void toolbar_child_detached (GtkWidget *widget,
131 static gboolean ac_label_button_pressed (GtkWidget *widget,
132 GdkEventButton *event,
135 static gint main_window_close_cb (GtkWidget *widget,
139 static void main_window_size_allocate_cb (GtkWidget *widget,
140 GtkAllocation *allocation,
142 static void folder_window_size_allocate_cb (GtkWidget *widget,
143 GtkAllocation *allocation,
145 static void message_window_size_allocate_cb (GtkWidget *widget,
146 GtkAllocation *allocation,
149 static void update_folderview_cb (MainWindow *mainwin,
152 static void add_mailbox_cb (MainWindow *mainwin,
155 static void foldersort_cb (MainWindow *mainwin,
158 static void import_mbox_cb (MainWindow *mainwin,
161 static void export_mbox_cb (MainWindow *mainwin,
164 static void export_list_mbox_cb (MainWindow *mainwin,
167 static void empty_trash_cb (MainWindow *mainwin,
171 static void save_as_cb (MainWindow *mainwin,
174 static void print_cb (MainWindow *mainwin,
177 static void app_exit_cb (MainWindow *mainwin,
181 static void search_cb (MainWindow *mainwin,
185 static void toggle_message_cb (MainWindow *mainwin,
188 static void toggle_toolbar_cb (MainWindow *mainwin,
191 static void toggle_statusbar_cb (MainWindow *mainwin,
194 static void set_layout_cb (MainWindow *mainwin,
198 static void addressbook_open_cb (MainWindow *mainwin,
201 static void log_window_show_cb (MainWindow *mainwin,
204 static void filtering_debug_window_show_cb (MainWindow *mainwin,
208 static void inc_cancel_cb (MainWindow *mainwin,
212 static void open_msg_cb (MainWindow *mainwin,
216 static void view_source_cb (MainWindow *mainwin,
220 static void show_all_header_cb (MainWindow *mainwin,
224 static void hide_quotes_cb(MainWindow *mainwin,
228 static void move_to_cb (MainWindow *mainwin,
231 static void copy_to_cb (MainWindow *mainwin,
234 static void delete_cb (MainWindow *mainwin,
237 static void delete_trash_cb (MainWindow *mainwin,
241 static void cancel_cb (MainWindow *mainwin,
245 static void mark_cb (MainWindow *mainwin,
248 static void unmark_cb (MainWindow *mainwin,
252 static void mark_as_unread_cb (MainWindow *mainwin,
255 static void mark_as_read_cb (MainWindow *mainwin,
258 static void mark_all_read_cb (MainWindow *mainwin,
261 static void mark_as_spam_cb (MainWindow *mainwin,
265 static void ignore_thread_cb (MainWindow *mainwin,
268 static void unignore_thread_cb (MainWindow *mainwin,
271 static void lock_msgs_cb (MainWindow *mainwin,
274 static void unlock_msgs_cb (MainWindow *mainwin,
278 static void reedit_cb (MainWindow *mainwin,
282 static void add_address_cb (MainWindow *mainwin,
286 static void set_charset_cb (MainWindow *mainwin,
290 static void set_decode_cb (MainWindow *mainwin,
294 static void hide_read_messages (MainWindow *mainwin,
298 static void thread_cb (MainWindow *mainwin,
301 static void expand_threads_cb (MainWindow *mainwin,
304 static void collapse_threads_cb (MainWindow *mainwin,
308 static void set_summary_display_item_cb (MainWindow *mainwin,
311 static void set_folder_display_item_cb (MainWindow *mainwin,
314 static void sort_summary_cb (MainWindow *mainwin,
317 static void sort_summary_type_cb (MainWindow *mainwin,
320 static void attract_by_subject_cb(MainWindow *mainwin,
324 static void delete_duplicated_cb (MainWindow *mainwin,
327 static void delete_duplicated_all_cb (MainWindow *mainwin,
330 static void filter_cb (MainWindow *mainwin,
333 static void execute_summary_cb (MainWindow *mainwin,
336 static void update_summary_cb (MainWindow *mainwin,
340 static void prev_cb (MainWindow *mainwin,
343 static void next_cb (MainWindow *mainwin,
346 static void next_unread_cb (MainWindow *mainwin,
349 static void prev_unread_cb (MainWindow *mainwin,
353 static void prev_new_cb (MainWindow *mainwin,
356 static void next_new_cb (MainWindow *mainwin,
359 static void prev_marked_cb (MainWindow *mainwin,
362 static void next_marked_cb (MainWindow *mainwin,
365 static void prev_labeled_cb (MainWindow *mainwin,
368 static void next_labeled_cb (MainWindow *mainwin,
371 static void last_read_cb (MainWindow *mainwin,
374 static void parent_cb (MainWindow *mainwin,
378 static void goto_folder_cb (MainWindow *mainwin,
381 static void goto_unread_folder_cb(MainWindow *mainwin,
385 static void copy_cb (MainWindow *mainwin,
388 static void allsel_cb (MainWindow *mainwin,
391 static void select_thread_cb (MainWindow *mainwin,
394 static void delete_thread_cb (MainWindow *mainwin,
398 static void create_filter_cb (MainWindow *mainwin,
401 static void create_processing_cb (MainWindow *mainwin,
404 static void open_urls_cb (MainWindow *mainwin,
408 static void prefs_template_open_cb (MainWindow *mainwin,
411 static void prefs_actions_open_cb (MainWindow *mainwin,
414 static void prefs_tags_open_cb (MainWindow *mainwin,
417 static void prefs_account_open_cb (MainWindow *mainwin,
421 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
425 static void prefs_post_processing_open_cb (MainWindow *mainwin,
429 static void prefs_filtering_open_cb (MainWindow *mainwin,
433 static void ssl_manager_open_cb (MainWindow *mainwin,
437 static void new_account_cb (MainWindow *mainwin,
441 static void account_selector_menu_cb (GtkMenuItem *menuitem,
443 static void account_receive_menu_cb (GtkMenuItem *menuitem,
445 static void account_compose_menu_cb (GtkMenuItem *menuitem,
448 static void prefs_open_cb (GtkMenuItem *menuitem,
450 static void plugins_open_cb (GtkMenuItem *menuitem,
453 static void online_switch_clicked(GtkButton *btn,
456 static void manual_open_cb (MainWindow *mainwin,
460 static void legend_open_cb (GtkMenuItem *menuitem,
463 static void scan_tree_func (Folder *folder,
467 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
469 static void addr_harvest_cb ( MainWindow *mainwin,
473 static void addr_harvest_msg_cb ( MainWindow *mainwin,
476 static void sync_cb ( MainWindow *mainwin,
480 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
481 GdkEventFocus *focus,
483 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
484 GdkEventVisibility *state,
486 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
487 GdkEventWindowState *state,
489 static void main_window_reply_cb (MainWindow *mainwin,
492 static gboolean mainwindow_progressindicator_hook (gpointer source,
495 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
498 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
500 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
502 static void mailing_list_compose(GtkWidget *w, gpointer *data);
504 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
505 #define SEPARATE_ACTION 500
506 static void mainwindow_quicksearch (MainWindow *mainwin,
509 static gboolean any_folder_want_synchronise(void);
511 static GtkItemFactoryEntry mainwin_entries[] =
513 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
514 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
516 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
517 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
518 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
520 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
521 {N_("/_File/Exp_ort selected to mbox file..."),
522 NULL, export_list_mbox_cb, 0, NULL},
523 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
525 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
527 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
528 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
530 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
531 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
532 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
533 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
535 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
536 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
537 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
538 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
539 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
540 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_Edit/_Find in current message..."),
542 "<control>F", search_cb, 0, NULL},
543 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
544 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
545 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
547 {N_("/_View/Show or hi_de/_Message view"),
548 "V", toggle_message_cb, 0, "<ToggleItem>"},
549 {N_("/_View/Show or hi_de/_Toolbar"),
550 NULL, NULL, 0, "<Branch>"},
551 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
552 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
553 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
554 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
555 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
556 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
557 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
558 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
559 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
560 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
561 {N_("/_View/Show or hi_de/Status _bar"),
562 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
563 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
564 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
565 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
567 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
568 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
569 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
570 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
571 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
572 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
573 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
574 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
576 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
577 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
578 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
580 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
581 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
582 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
583 {N_("/_View/_Sort/by _color label"),
584 NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
585 {N_("/_View/_Sort/by tag"),
586 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
587 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
588 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
589 {N_("/_View/_Sort/by a_ttachment"),
590 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
591 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
592 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
593 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
594 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
596 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
597 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_View/_Sort/_Attract by subject"),
599 NULL, attract_by_subject_cb, 0, NULL},
600 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
601 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
602 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
603 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
605 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
607 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
608 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/P_revious unread message"),
611 "<shift>P", prev_unread_cb, 0, NULL},
612 {N_("/_View/_Go to/N_ext unread message"),
613 "<shift>N", next_unread_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
616 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
617 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_View/_Go to/Previous _marked message"),
619 NULL, prev_marked_cb, 0, NULL},
620 {N_("/_View/_Go to/Next m_arked message"),
621 NULL, next_marked_cb, 0, NULL},
622 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_View/_Go to/Previous _labeled message"),
624 NULL, prev_labeled_cb, 0, NULL},
625 {N_("/_View/_Go to/Next la_beled message"),
626 NULL, next_labeled_cb, 0, NULL},
627 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_View/_Go to/Last read message"),
629 NULL, last_read_cb, 0, NULL},
630 {N_("/_View/_Go to/Parent message"),
631 "<control>Up", parent_cb, 0, NULL},
632 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
633 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
634 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
635 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
637 #define ENC_SEPARATOR \
638 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
639 #define ENC_ACTION(action) \
640 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
642 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
643 {N_("/_View/Character _encoding/_Auto detect"),
644 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
645 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
646 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
647 ENC_ACTION(C_US_ASCII)},
648 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
649 ENC_ACTION(C_UTF_8)},
652 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
653 ENC_ACTION(C_ISO_8859_1)},
654 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
655 ENC_ACTION(C_ISO_8859_15)},
656 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
657 ENC_ACTION(C_WINDOWS_1252)},
660 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
661 ENC_ACTION(C_ISO_8859_2)},
664 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
665 ENC_ACTION(C_ISO_8859_13)},
666 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
667 ENC_ACTION(C_ISO_8859_4)},
670 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
671 ENC_ACTION(C_ISO_8859_7)},
674 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
675 ENC_ACTION(C_ISO_8859_8)},
676 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
677 ENC_ACTION(C_CP1255)},
680 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
681 ENC_ACTION(C_ISO_8859_6)},
682 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
683 ENC_ACTION(C_CP1256)},
686 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
687 ENC_ACTION(C_ISO_8859_9)},
690 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
691 ENC_ACTION(C_ISO_8859_5)},
692 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
693 ENC_ACTION(C_KOI8_R)},
694 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
695 ENC_ACTION(C_KOI8_U)},
696 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
697 ENC_ACTION(C_CP1251)},
700 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
701 ENC_ACTION(C_ISO_2022_JP)},
702 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
703 ENC_ACTION(C_ISO_2022_JP_2)},
704 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
705 ENC_ACTION(C_EUC_JP)},
706 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
707 ENC_ACTION(C_SHIFT_JIS)},
710 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
711 ENC_ACTION(C_GB2312)},
712 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
714 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
716 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
717 ENC_ACTION(C_EUC_TW)},
718 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
719 ENC_ACTION(C_ISO_2022_CN)},
722 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
723 ENC_ACTION(C_EUC_KR)},
724 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
725 ENC_ACTION(C_ISO_2022_KR)},
728 {N_("/_View/Character _encoding/Thai (TIS-620)"),
729 ENC_ACTION(C_TIS_620)},
730 {N_("/_View/Character _encoding/Thai (Windows-874)"),
731 ENC_ACTION(C_WINDOWS_874)},
736 #define DEC_SEPARATOR \
737 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
738 #define DEC_ACTION(action) \
739 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
740 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
741 {N_("/_View/Decode/_Auto detect"),
742 NULL, set_decode_cb, 0, "<RadioItem>"},
743 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
744 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
745 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
746 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
747 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
752 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
753 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
754 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
755 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
756 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
758 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
759 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
760 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
763 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
764 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
765 {N_("/_Message/Recei_ve/Get from _current account"),
766 "<control>I", inc_mail_cb, 0, NULL},
767 {N_("/_Message/Recei_ve/Get from _all accounts"),
768 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
769 {N_("/_Message/Recei_ve/Cancel receivin_g"),
770 NULL, inc_cancel_cb, 0, NULL},
771 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
772 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
773 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
774 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
775 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
776 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
777 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
778 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
779 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
780 {N_("/_Message/Repl_y to/mailing _list"),
781 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
782 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
783 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
784 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
785 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
786 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
788 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
789 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
790 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
791 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
792 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
793 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
794 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
796 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
797 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
798 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
799 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
800 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
801 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
802 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
803 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
804 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
805 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
806 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
807 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
808 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
809 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
810 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
811 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
812 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
813 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
814 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
815 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
816 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
817 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
818 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
819 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
820 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
821 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
823 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
824 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
825 {N_("/_Tools/Add sender to address boo_k"),
826 NULL, add_address_cb, 0, NULL},
827 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
828 {N_("/_Tools/_Harvest addresses/from _Folder..."),
829 NULL, addr_harvest_cb, 0, NULL},
830 {N_("/_Tools/_Harvest addresses/from _Messages..."),
831 NULL, addr_harvest_msg_cb, 0, NULL},
832 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
833 {N_("/_Tools/_Filter all messages in folder"),
834 NULL, filter_cb, 0, NULL},
835 {N_("/_Tools/Filter _selected messages"),
836 NULL, filter_cb, 1, NULL},
837 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
838 {N_("/_Tools/_Create filter rule/_Automatically"),
839 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
840 {N_("/_Tools/_Create filter rule/by _From"),
841 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
842 {N_("/_Tools/_Create filter rule/by _To"),
843 NULL, create_filter_cb, FILTER_BY_TO, NULL},
844 {N_("/_Tools/_Create filter rule/by _Subject"),
845 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
846 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
847 {N_("/_Tools/C_reate processing rule/_Automatically"),
848 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
849 {N_("/_Tools/C_reate processing rule/by _From"),
850 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
851 {N_("/_Tools/C_reate processing rule/by _To"),
852 NULL, create_processing_cb, FILTER_BY_TO, NULL},
853 {N_("/_Tools/C_reate processing rule/by _Subject"),
854 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
855 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
856 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
857 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
858 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
859 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
860 {N_("/_Tools/Ch_eck for new messages in all folders"),
861 NULL, update_folderview_cb, 0, NULL},
862 {N_("/_Tools/Delete du_plicated messages"),
863 NULL, NULL, 0, "<Branch>"},
864 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
865 NULL, delete_duplicated_cb, 0, NULL},
866 {N_("/_Tools/Delete du_plicated messages/In all folders"),
867 NULL, delete_duplicated_all_cb, 0, NULL},
868 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
869 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
871 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
872 {N_("/_Tools/SSL cer_tificates..."),
873 NULL, ssl_manager_open_cb, 0, NULL},
875 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
876 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
877 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
879 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
880 {N_("/_Configuration/C_hange current account"),
881 NULL, NULL, 0, "<Branch>"},
882 {N_("/_Configuration/_Preferences for current account..."),
883 NULL, prefs_account_open_cb, 0, NULL},
884 {N_("/_Configuration/Create _new account..."),
885 NULL, new_account_cb, 0, NULL},
886 {N_("/_Configuration/_Edit accounts..."),
887 NULL, account_edit_open, 0, NULL},
888 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
889 {N_("/_Configuration/P_references..."),
890 NULL, prefs_open_cb, 0, NULL},
891 {N_("/_Configuration/Pre-pr_ocessing..."),
892 NULL, prefs_pre_processing_open_cb, 0, NULL},
893 {N_("/_Configuration/Post-pro_cessing..."),
894 NULL, prefs_post_processing_open_cb, 0, NULL},
895 {N_("/_Configuration/_Filtering..."),
896 NULL, prefs_filtering_open_cb, 0, NULL},
897 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
898 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
899 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
900 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
901 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
903 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
904 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
905 {N_("/_Help/_Online User-contributed FAQ"),
906 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
907 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
908 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
909 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
912 static gboolean offline_ask_sync = TRUE;
913 static guint lastkey;
914 static gboolean is_obscured = FALSE;
916 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
922 MainWindow *mainwin = (MainWindow *)user_data;
924 if (mainwin->summaryview &&
925 mainwin->summaryview->quicksearch &&
926 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
927 (mod == 0 || mod == GDK_SHIFT_MASK)) {
928 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
934 #define N_COLOR_LABELS colorlabel_get_color_count()
936 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
941 GtkCheckMenuItem **items;
946 mainwin = (MainWindow *)data;
947 g_return_if_fail(mainwin != NULL);
949 sel = summary_get_selection(mainwin->summaryview);
952 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
953 g_return_if_fail(menu != NULL);
955 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
957 /* NOTE: don't return prematurely because we set the "dont_toggle"
958 * state for check menu items */
959 g_object_set_data(G_OBJECT(menu), "dont_toggle",
962 /* clear items. get item pointers. */
963 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
964 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
965 gtk_check_menu_item_set_active
966 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
967 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
972 if (n == (N_COLOR_LABELS + 1)) {
973 /* iterate all messages and set the state of the appropriate
975 for (; sel != NULL; sel = sel->next) {
979 msginfo = (MsgInfo *)sel->data;
981 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
982 if (!items[clabel]->active)
983 gtk_check_menu_item_set_active
984 (items[clabel], TRUE);
988 g_warning("invalid number of color elements (%d)\n", n);
991 /* reset "dont_toggle" state */
992 g_object_set_data(G_OBJECT(menu), "dont_toggle",
996 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
999 guint color = GPOINTER_TO_UINT(data);
1000 MainWindow *mainwin;
1002 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1003 g_return_if_fail(mainwin != NULL);
1005 /* "dont_toggle" state set? */
1006 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1010 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1013 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1016 MainWindow *mainwin;
1020 GHashTable *menu_table = g_hash_table_new_full(
1025 mainwin = (MainWindow *)data;
1026 g_return_if_fail(mainwin != NULL);
1028 sel = summary_get_selection(mainwin->summaryview);
1031 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1032 g_return_if_fail(menu != NULL);
1034 /* NOTE: don't return prematurely because we set the "dont_toggle"
1035 * state for check menu items */
1036 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1037 GINT_TO_POINTER(1));
1039 /* clear items. get item pointers. */
1040 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1041 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1042 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1044 gtk_check_menu_item_set_active
1045 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1047 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1051 /* iterate all messages and set the state of the appropriate
1053 for (; sel != NULL; sel = sel->next) {
1055 GSList *tags = NULL;
1057 GtkCheckMenuItem *item;
1058 msginfo = (MsgInfo *)sel->data;
1060 tags = msginfo->tags;
1064 for (; tags; tags = tags->next) {
1065 id = GPOINTER_TO_INT(tags->data);
1066 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1067 if (item && !item->active)
1068 gtk_check_menu_item_set_active
1075 g_hash_table_destroy(menu_table);
1076 /* reset "dont_toggle" state */
1077 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1078 GINT_TO_POINTER(0));
1081 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1084 gint id = GPOINTER_TO_INT(data);
1085 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1086 MainWindow *mainwin;
1088 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1089 g_return_if_fail(mainwin != NULL);
1091 /* "dont_toggle" state set? */
1092 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1098 summary_set_tag(mainwin->summaryview, id, NULL);
1101 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1103 GtkWidget *label_menuitem;
1108 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1109 "/Message/Color label");
1110 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1111 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1113 gtk_widget_show(label_menuitem);
1115 menu = gtk_menu_new();
1117 /* create sub items. for the menu item activation callback we pass the
1118 * index of label_colors[] as data parameter. for the None color we
1119 * pass an invalid (high) value. also we attach a data pointer so we
1120 * can always get back the Mainwindow pointer. */
1122 item = gtk_check_menu_item_new_with_label(_("None"));
1123 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1124 g_signal_connect(G_OBJECT(item), "activate",
1125 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1126 GUINT_TO_POINTER(0));
1127 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1128 gtk_widget_show(item);
1130 gtk_widget_add_accelerator(item, "activate",
1131 mainwin->menu_factory->accel_group,
1132 GDK_0, GDK_CONTROL_MASK,
1133 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1135 item = gtk_menu_item_new();
1136 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1137 gtk_widget_show(item);
1139 /* create pixmap/label menu items */
1140 for (i = 0; i < N_COLOR_LABELS; i++) {
1141 item = colorlabel_create_check_color_menu_item(
1142 i, refresh, MAINWIN_COLORMENU);
1143 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1144 g_signal_connect(G_OBJECT(item), "activate",
1145 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1146 GUINT_TO_POINTER(i + 1));
1147 g_object_set_data(G_OBJECT(item), "mainwin",
1149 gtk_widget_show(item);
1151 gtk_widget_add_accelerator(item, "activate",
1152 mainwin->menu_factory->accel_group,
1153 GDK_1+i, GDK_CONTROL_MASK,
1154 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1156 gtk_widget_show(menu);
1157 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1158 mainwin->colorlabel_menu = menu;
1161 static void mainwindow_tags_menu_item_new_tag_activate_cb(GtkWidget *widget,
1164 MainWindow *mainwin;
1166 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1167 g_return_if_fail(mainwin != NULL);
1169 /* "dont_toggle" state set? */
1170 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1174 id = prefs_tags_create_new(mainwin);
1176 summary_set_tag(mainwin->summaryview, id, NULL);
1177 main_window_reflect_tags_changes(mainwindow_get_mainwindow());
1181 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1183 GtkWidget *label_menuitem;
1186 GSList *cur = tags_get_list();
1188 gboolean existing_tags = FALSE;
1190 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1192 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1193 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1196 gtk_widget_show(label_menuitem);
1198 menu = gtk_menu_new();
1200 /* create tags menu items */
1201 for (; cur; cur = cur->next) {
1202 gint id = GPOINTER_TO_INT(cur->data);
1203 const gchar *tag = tags_get_tag(id);
1205 item = gtk_check_menu_item_new_with_label(tag);
1206 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1207 g_signal_connect(G_OBJECT(item), "activate",
1208 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1209 GINT_TO_POINTER(id));
1210 g_object_set_data(G_OBJECT(item), "mainwin",
1212 g_object_set_data(G_OBJECT(item), "tag_id",
1213 GINT_TO_POINTER(id));
1214 gtk_widget_show(item);
1215 existing_tags = TRUE;
1217 if (existing_tags) {
1219 item = gtk_menu_item_new();
1220 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1221 gtk_widget_show(item);
1223 item = gtk_menu_item_new_with_label(_("New tag..."));
1224 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1225 g_signal_connect(G_OBJECT(item), "activate",
1226 G_CALLBACK(mainwindow_tags_menu_item_new_tag_activate_cb),
1228 g_object_set_data(G_OBJECT(item), "mainwin",
1230 gtk_widget_show(item);
1232 gtk_widget_show(menu);
1233 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1234 mainwin->tags_menu = menu;
1237 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1238 MainWindow *mainwindow)
1240 if (evt && evt->button == 1) {
1241 log_window_show_error(mainwindow->logwin);
1242 gtk_widget_hide(mainwindow->warning_btn);
1247 static gboolean warning_visi_notify(GtkWidget *widget,
1248 GdkEventVisibility *event,
1249 MainWindow *mainwindow)
1251 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1255 static gboolean warning_leave_notify(GtkWidget *widget,
1256 GdkEventCrossing *event,
1257 MainWindow *mainwindow)
1259 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1263 static gboolean warning_enter_notify(GtkWidget *widget,
1264 GdkEventCrossing *event,
1265 MainWindow *mainwindow)
1267 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1271 void mainwindow_show_error(void)
1273 MainWindow *mainwin = mainwindow_get_mainwindow();
1274 gtk_widget_show(mainwin->warning_btn);
1277 void mainwindow_clear_error(MainWindow *mainwin)
1279 gtk_widget_hide(mainwin->warning_btn);
1282 MainWindow *main_window_create()
1284 MainWindow *mainwin;
1288 GtkWidget *handlebox;
1289 GtkWidget *vbox_body;
1290 GtkWidget *hbox_stat;
1291 GtkWidget *statusbar;
1292 GtkWidget *progressbar;
1293 GtkWidget *statuslabel;
1294 GtkWidget *ac_button;
1295 GtkWidget *ac_label;
1296 GtkWidget *online_pixmap;
1297 GtkWidget *offline_pixmap;
1298 GtkWidget *online_switch;
1299 GtkWidget *offline_switch;
1301 GtkWidget *warning_icon;
1302 GtkWidget *warning_btn;
1304 FolderView *folderview;
1305 SummaryView *summaryview;
1306 MessageView *messageview;
1307 GdkColormap *colormap;
1309 gboolean success[4];
1310 GtkItemFactory *ifactory;
1312 GtkWidget *menuitem;
1314 guint n_menu_entries;
1316 static GdkGeometry geometry;
1318 debug_print("Creating main window...\n");
1319 mainwin = g_new0(MainWindow, 1);
1322 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
1323 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1324 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1326 if (!geometry.min_height) {
1327 geometry.min_width = 320;
1328 geometry.min_height = 200;
1330 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1333 g_signal_connect(G_OBJECT(window), "delete_event",
1334 G_CALLBACK(main_window_close_cb), mainwin);
1335 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1336 g_signal_connect(G_OBJECT(window), "focus_in_event",
1337 G_CALLBACK(mainwindow_focus_in_event),
1339 g_signal_connect(G_OBJECT(window), "key_press_event",
1340 G_CALLBACK(mainwindow_key_pressed), mainwin);
1342 gtk_widget_realize(window);
1343 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1346 gtkut_widget_set_app_icon(window);
1348 vbox = gtk_vbox_new(FALSE, 0);
1349 gtk_widget_show(vbox);
1350 gtk_container_add(GTK_CONTAINER(window), vbox);
1353 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1354 menubar = menubar_create(window, mainwin_entries,
1355 n_menu_entries, "<Main>", mainwin);
1356 gtk_widget_show(menubar);
1357 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1358 ifactory = gtk_item_factory_from_widget(menubar);
1360 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1361 main_create_mailing_list_menu (mainwin, NULL); */
1363 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1365 if (prefs_common.toolbar_detachable) {
1366 handlebox = gtk_handle_box_new();
1367 gtk_widget_show(handlebox);
1368 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1369 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1370 G_CALLBACK(toolbar_child_attached), mainwin);
1371 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1372 G_CALLBACK(toolbar_child_detached), mainwin);
1374 handlebox = gtk_hbox_new(FALSE, 0);
1375 gtk_widget_show(handlebox);
1376 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1378 /* link window to mainwin->window to avoid gdk warnings */
1379 mainwin->window = window;
1381 /* create toolbar */
1382 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1385 toolbar_set_learn_button
1389 /* vbox that contains body */
1390 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1391 gtk_widget_show(vbox_body);
1392 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1393 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1395 hbox_stat = gtk_hbox_new(FALSE, 2);
1396 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1398 tips = gtk_tooltips_new();
1400 warning_icon = gtk_image_new_from_stock
1401 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1402 warning_btn = gtk_event_box_new();
1403 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1405 mainwin->warning_btn = warning_btn;
1407 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1408 G_CALLBACK(warning_icon_pressed),
1409 (gpointer) mainwin);
1410 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1411 G_CALLBACK(warning_visi_notify), mainwin);
1412 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1413 G_CALLBACK(warning_visi_notify), mainwin);
1414 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1415 G_CALLBACK(warning_leave_notify), mainwin);
1416 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1417 G_CALLBACK(warning_enter_notify), mainwin);
1419 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1421 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1422 _("Some error(s) happened. Click here to view log."), NULL);
1423 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1425 statusbar = statusbar_create();
1426 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1428 progressbar = gtk_progress_bar_new();
1429 gtk_widget_set_size_request(progressbar, 120, 1);
1430 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1432 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1433 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1434 online_switch = gtk_button_new ();
1435 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1436 _("You are online. Click the icon to go offline"), NULL);
1437 offline_switch = gtk_button_new ();
1438 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1439 _("You are offline. Click the icon to go online"),
1441 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1442 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1443 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1444 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1445 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1446 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1447 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1448 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1450 statuslabel = gtk_label_new("");
1451 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1453 ac_button = gtk_button_new();
1454 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1455 ac_button, _("Select account"), NULL);
1456 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1457 gtk_widget_set_size_request(ac_button, -1, 0);
1458 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1459 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1460 G_CALLBACK(ac_label_button_pressed), mainwin);
1462 ac_label = gtk_label_new("");
1463 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1465 gtk_widget_show_all(hbox_stat);
1467 gtk_widget_hide(offline_switch);
1468 gtk_widget_hide(warning_btn);
1471 mainwin->folderview = folderview = folderview_create();
1472 mainwin->summaryview = summaryview = summary_create();
1473 mainwin->messageview = messageview = messageview_create(mainwin);
1475 /* init log instances data before creating log views */
1476 set_log_title(LOG_PROTOCOL, _("Network log"));
1477 set_log_prefs(LOG_PROTOCOL,
1478 &prefs_common.logwin_width,
1479 &prefs_common.logwin_height);
1480 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1481 set_log_prefs(LOG_DEBUG_FILTERING,
1482 &prefs_common.filtering_debugwin_width,
1483 &prefs_common.filtering_debugwin_height);
1485 /* setup log windows */
1486 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1487 log_window_init(mainwin->logwin);
1489 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1490 log_window_set_clipping(mainwin->logwin,
1491 prefs_common.cliplog,
1492 prefs_common.loglength);
1494 log_window_init(mainwin->filtering_debugwin);
1495 log_window_set_clipping(mainwin->filtering_debugwin,
1496 prefs_common.filtering_debug_cliplog,
1497 prefs_common.filtering_debug_loglength);
1498 if (prefs_common.enable_filtering_debug)
1499 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1501 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1503 folderview->mainwin = mainwin;
1504 folderview->summaryview = summaryview;
1506 summaryview->mainwin = mainwin;
1507 summaryview->folderview = folderview;
1508 summaryview->messageview = messageview;
1509 summaryview->window = window;
1511 messageview->statusbar = statusbar;
1512 mainwin->vbox = vbox;
1513 mainwin->menubar = menubar;
1514 mainwin->menu_factory = ifactory;
1515 mainwin->handlebox = handlebox;
1516 mainwin->vbox_body = vbox_body;
1517 mainwin->hbox_stat = hbox_stat;
1518 mainwin->statusbar = statusbar;
1519 mainwin->progressbar = progressbar;
1520 mainwin->statuslabel = statuslabel;
1521 mainwin->online_switch = online_switch;
1522 mainwin->online_pixmap = online_pixmap;
1523 mainwin->offline_pixmap = offline_pixmap;
1524 mainwin->ac_button = ac_button;
1525 mainwin->ac_label = ac_label;
1526 mainwin->offline_switch = offline_switch;
1528 /* set context IDs for status bar */
1529 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1530 (GTK_STATUSBAR(statusbar), "Main Window");
1531 mainwin->folderview_cid = gtk_statusbar_get_context_id
1532 (GTK_STATUSBAR(statusbar), "Folder View");
1533 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1534 (GTK_STATUSBAR(statusbar), "Summary View");
1535 mainwin->messageview_cid = gtk_statusbar_get_context_id
1536 (GTK_STATUSBAR(statusbar), "Message View");
1538 messageview->statusbar_cid = mainwin->messageview_cid;
1540 /* allocate colors for summary view and folder view */
1541 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1542 summaryview->color_marked.blue = (guint16)65535;
1544 summaryview->color_dim.red = summaryview->color_dim.green =
1545 summaryview->color_dim.blue = COLOR_DIM;
1547 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1548 &folderview->color_new);
1550 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1551 &folderview->color_op);
1553 summaryview->color_important.red = 0;
1554 summaryview->color_important.green = 0;
1555 summaryview->color_important.blue = (guint16)65535;
1557 color[0] = summaryview->color_marked;
1558 color[1] = summaryview->color_dim;
1559 color[2] = folderview->color_new;
1560 color[3] = folderview->color_op;
1562 colormap = gdk_drawable_get_colormap(window->window);
1563 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1564 for (i = 0; i < 4; i++) {
1565 if (success[i] == FALSE)
1566 g_warning("MainWindow: color allocation %d failed\n", i);
1569 debug_print("done.\n");
1571 messageview->visible = prefs_common.msgview_visible;
1573 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1575 g_signal_connect(G_OBJECT(window), "size_allocate",
1576 G_CALLBACK(main_window_size_allocate_cb),
1579 /* set menu items */
1580 menuitem = gtk_item_factory_get_item
1581 (ifactory, "/View/Character encoding/Auto detect");
1582 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1584 switch (prefs_common.toolbar_style) {
1586 menuitem = gtk_item_factory_get_item
1587 (ifactory, "/View/Show or hide/Toolbar/Hide");
1590 menuitem = gtk_item_factory_get_item
1591 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1594 menuitem = gtk_item_factory_get_item
1595 (ifactory, "/View/Show or hide/Toolbar/Text only");
1598 menuitem = gtk_item_factory_get_item
1599 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1601 case TOOLBAR_BOTH_HORIZ:
1602 menuitem = gtk_item_factory_get_item
1604 "/View/Show or hide/Toolbar/Text beside icons");
1606 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1608 gtk_widget_hide(mainwin->hbox_stat);
1609 menuitem = gtk_item_factory_get_item
1610 (ifactory, "/View/Show or hide/Status bar");
1611 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1612 prefs_common.show_statusbar);
1614 /* set account selection menu */
1615 ac_menu = gtk_item_factory_get_widget
1616 (ifactory, "/Configuration/Change current account");
1617 mainwin->ac_menu = ac_menu;
1619 toolbar_main_set_sensitive(mainwin);
1621 /* create actions menu */
1622 main_window_update_actions_menu(mainwin);
1624 main_create_mailing_list_menu (mainwin, NULL);
1626 /* attach accel groups to main window */
1627 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1628 gtk_window_add_accel_group \
1630 gtk_item_factory_from_widget(menu)->accel_group); \
1631 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1633 G_CALLBACK(main_window_accel_activate), mainwin);
1636 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1638 /* connect the accelerators for equivalent
1639 menu items in different menus */
1640 menu_connect_identical_items();
1642 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1644 g_signal_connect(G_OBJECT(window), "window_state_event",
1645 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1646 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1647 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1648 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1650 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1651 prefs_common.layout_mode == SMALL_LAYOUT) {
1652 summary_relayout(mainwin->summaryview);
1654 summary_update_unread(mainwin->summaryview, NULL);
1656 gtk_widget_show(mainwin->window);
1658 /* initialize views */
1659 folderview_init(folderview);
1660 summary_init(summaryview);
1661 messageview_init(messageview);
1663 sslcertwindow_register_hook();
1665 mainwin->lock_count = 0;
1666 mainwin->menu_lock_count = 0;
1667 mainwin->cursor_count = 0;
1669 mainwin->progressindicator_hook =
1670 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1673 watch_cursor = gdk_cursor_new(GDK_WATCH);
1675 hand_cursor = gdk_cursor_new(GDK_HAND2);
1677 mainwin_list = g_list_append(mainwin_list, mainwin);
1679 /* init work_offline */
1680 if (prefs_common.work_offline)
1681 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1683 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1684 mainwindow_tags_menu_create(mainwin, FALSE);
1689 void main_window_destroy(MainWindow *mainwin)
1691 /* TODO : destroy other component */
1692 messageview_destroy(mainwin->messageview);
1693 mainwin->messageview = NULL;
1696 void main_window_update_actions_menu(MainWindow *mainwin)
1698 GtkItemFactory *ifactory;
1700 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1701 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1704 void main_window_cursor_wait(MainWindow *mainwin)
1707 if (mainwin->cursor_count == 0) {
1708 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1709 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1712 mainwin->cursor_count++;
1717 void main_window_cursor_normal(MainWindow *mainwin)
1719 if (mainwin->cursor_count)
1720 mainwin->cursor_count--;
1722 if (mainwin->cursor_count == 0) {
1723 gdk_window_set_cursor(mainwin->window->window, NULL);
1724 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1729 /* lock / unlock the user-interface */
1730 void main_window_lock(MainWindow *mainwin)
1732 if (mainwin->lock_count == 0)
1733 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1735 mainwin->lock_count++;
1737 main_window_set_menu_sensitive(mainwin);
1738 toolbar_main_set_sensitive(mainwin);
1741 void main_window_unlock(MainWindow *mainwin)
1743 if (mainwin->lock_count)
1744 mainwin->lock_count--;
1746 main_window_set_menu_sensitive(mainwin);
1747 toolbar_main_set_sensitive(mainwin);
1749 if (mainwin->lock_count == 0)
1750 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1753 static void main_window_menu_callback_block(MainWindow *mainwin)
1755 mainwin->menu_lock_count++;
1758 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1760 if (mainwin->menu_lock_count)
1761 mainwin->menu_lock_count--;
1764 static guint prefs_tag = 0;
1766 void main_window_reflect_prefs_all(void)
1768 main_window_reflect_prefs_all_real(FALSE);
1771 static gboolean reflect_prefs_timeout_cb(gpointer data)
1773 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1775 MainWindow *mainwin;
1778 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1779 mainwin = (MainWindow *)cur->data;
1781 main_window_show_cur_account(mainwin);
1782 main_window_set_menu_sensitive(mainwin);
1783 toolbar_main_set_sensitive(mainwin);
1786 if (pixmap_theme_changed) {
1787 toolbar_update(TOOLBAR_MAIN, mainwin);
1788 messageview_reflect_prefs_pixmap_theme();
1789 compose_reflect_prefs_pixmap_theme();
1790 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1791 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1793 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1794 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1795 mainwin->online_pixmap);
1796 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1797 gtk_widget_show(pixmap);
1798 mainwin->online_pixmap = pixmap;
1799 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1800 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1801 mainwin->offline_pixmap);
1802 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1803 gtk_widget_show(pixmap);
1804 mainwin->offline_pixmap = pixmap;
1807 headerview_set_font(mainwin->messageview->headerview);
1808 headerview_set_visibility(mainwin->messageview->headerview,
1809 prefs_common.display_header_pane);
1810 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1811 folderview_reflect_prefs();
1812 summary_reflect_prefs();
1813 summary_redisplay_msg(mainwin->summaryview);
1819 void main_window_reflect_prefs_all_now(void)
1821 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1824 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1829 /* re-create colorlabel submenu */
1830 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1831 g_return_if_fail(menu != NULL);
1833 /* clear items. get item pointers. */
1834 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1835 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1837 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1838 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1842 void main_window_reflect_tags_changes(MainWindow *mainwin)
1847 /* re-create tags submenu */
1848 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1849 g_return_if_fail(menu != NULL);
1851 /* clear items. get item pointers. */
1852 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1853 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1855 mainwindow_tags_menu_create(mainwin, TRUE);
1856 summary_reflect_tags_changes(mainwin->summaryview);
1860 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1862 if (prefs_tag == 0 || pixmap_theme_changed) {
1863 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1864 GINT_TO_POINTER(pixmap_theme_changed));
1868 void main_window_set_summary_column(void)
1871 MainWindow *mainwin;
1873 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1874 mainwin = (MainWindow *)cur->data;
1875 summary_set_column_order(mainwin->summaryview);
1879 void main_window_set_folder_column(void)
1882 MainWindow *mainwin;
1884 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1885 mainwin = (MainWindow *)cur->data;
1886 folderview_set_column_order(mainwin->folderview);
1890 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1891 GList *account_list)
1893 GList *cur_ac, *cur_item;
1894 GtkWidget *menuitem;
1895 PrefsAccount *ac_prefs;
1897 /* destroy all previous menu item */
1898 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1899 while (cur_item != NULL) {
1900 GList *next = cur_item->next;
1901 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1905 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1906 ac_prefs = (PrefsAccount *)cur_ac->data;
1908 menuitem = gtk_menu_item_new_with_label
1909 (ac_prefs->account_name
1910 ? ac_prefs->account_name : _("Untitled"));
1911 gtk_widget_show(menuitem);
1912 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1913 g_signal_connect(G_OBJECT(menuitem), "activate",
1914 G_CALLBACK(account_selector_menu_cb),
1919 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1920 GList *account_list)
1922 GList *cur_ac, *cur_item;
1924 GtkWidget *menuitem;
1925 PrefsAccount *ac_prefs;
1927 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1928 "/Message/Receive");
1930 /* search for separator */
1931 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1932 cur_item = cur_item->next) {
1933 if (GTK_BIN(cur_item->data)->child == NULL) {
1934 cur_item = cur_item->next;
1939 /* destroy all previous menu item */
1940 while (cur_item != NULL) {
1941 GList *next = cur_item->next;
1942 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1946 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1947 ac_prefs = (PrefsAccount *)cur_ac->data;
1949 menuitem = gtk_menu_item_new_with_label
1950 (ac_prefs->account_name ? ac_prefs->account_name
1952 gtk_widget_show(menuitem);
1953 gtk_menu_append(GTK_MENU(menu), menuitem);
1954 g_signal_connect(G_OBJECT(menuitem), "activate",
1955 G_CALLBACK(account_receive_menu_cb),
1960 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1961 GList *account_list)
1963 GList *cur_ac, *cur_item;
1964 GtkWidget *menuitem;
1965 PrefsAccount *ac_prefs;
1966 GtkWidget *menu = NULL;
1968 if (mainwin->toolbar->getall_btn == NULL
1969 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1972 menu = mainwin->toolbar->getall_combo->menu;
1974 /* destroy all previous menu item */
1975 cur_item = GTK_MENU_SHELL(menu)->children;
1976 while (cur_item != NULL) {
1977 GList *next = cur_item->next;
1978 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1982 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1983 ac_prefs = (PrefsAccount *)cur_ac->data;
1985 menuitem = gtk_menu_item_new_with_label
1986 (ac_prefs->account_name
1987 ? ac_prefs->account_name : _("Untitled"));
1988 gtk_widget_show(menuitem);
1989 gtk_menu_append(GTK_MENU(menu), menuitem);
1990 g_signal_connect(G_OBJECT(menuitem), "activate",
1991 G_CALLBACK(account_receive_menu_cb),
1996 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1997 GList *account_list)
1999 GList *cur_ac, *cur_item;
2000 GtkWidget *menuitem;
2001 PrefsAccount *ac_prefs;
2002 GtkWidget *menu = NULL;
2004 if (mainwin->toolbar->compose_mail_btn == NULL
2005 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
2008 menu = mainwin->toolbar->compose_combo->menu;
2010 /* destroy all previous menu item */
2011 cur_item = GTK_MENU_SHELL(menu)->children;
2012 while (cur_item != NULL) {
2013 GList *next = cur_item->next;
2014 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2018 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2019 ac_prefs = (PrefsAccount *)cur_ac->data;
2021 menuitem = gtk_menu_item_new_with_label
2022 (ac_prefs->account_name
2023 ? ac_prefs->account_name : _("Untitled"));
2024 gtk_widget_show(menuitem);
2025 gtk_menu_append(GTK_MENU(menu), menuitem);
2026 g_signal_connect(G_OBJECT(menuitem), "activate",
2027 G_CALLBACK(account_compose_menu_cb),
2032 void main_window_set_account_menu(GList *account_list)
2035 MainWindow *mainwin;
2037 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2038 mainwin = (MainWindow *)cur->data;
2039 main_window_set_account_selector_menu(mainwin, account_list);
2040 main_window_set_account_receive_menu(mainwin, account_list);
2041 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2042 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2044 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2047 void main_window_set_account_menu_only_toolbar(GList *account_list)
2050 MainWindow *mainwin;
2052 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2053 mainwin = (MainWindow *)cur->data;
2054 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2055 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2059 static void main_window_show_cur_account(MainWindow *mainwin)
2064 ac_name = g_strdup(cur_account
2065 ? (cur_account->account_name
2066 ? cur_account->account_name : _("Untitled"))
2070 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2072 buf = g_strdup(PROG_VERSION);
2073 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2076 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2077 gtk_widget_queue_resize(mainwin->ac_button);
2082 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2084 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2085 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2086 GtkWidget *message_wid = mainwin->messageview->vbox;
2088 if (layout_mode == prefs_common.layout_mode)
2091 debug_print("Changing window separation type from %d to %d\n",
2092 prefs_common.layout_mode, layout_mode);
2094 /* remove widgets from those containers */
2095 gtk_widget_ref(folder_wid);
2096 gtk_widget_ref(summary_wid);
2097 gtk_widget_ref(message_wid);
2098 gtkut_container_remove
2099 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2100 gtkut_container_remove
2101 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2102 gtkut_container_remove
2103 (GTK_CONTAINER(message_wid->parent), message_wid);
2105 gtk_widget_hide(mainwin->window);
2106 main_window_set_widgets(mainwin, layout_mode);
2107 gtk_widget_show(mainwin->window);
2109 gtk_widget_unref(folder_wid);
2110 gtk_widget_unref(summary_wid);
2111 gtk_widget_unref(message_wid);
2114 void mainwindow_reset_paned(GtkPaned *paned)
2118 if (gtk_paned_get_child1(GTK_PANED(paned)))
2119 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2120 if (gtk_paned_get_child2(GTK_PANED(paned)))
2121 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2124 g_object_get (G_OBJECT(paned),
2127 g_object_get (G_OBJECT(paned),
2131 gtk_paned_set_position(GTK_PANED(paned), mid);
2134 static void mainwin_paned_show_first(GtkPaned *paned)
2137 g_object_get (G_OBJECT(paned),
2141 if (gtk_paned_get_child1(GTK_PANED(paned)))
2142 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2143 if (gtk_paned_get_child2(GTK_PANED(paned)))
2144 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2145 gtk_paned_set_position(GTK_PANED(paned), max);
2148 static void mainwin_paned_show_last(GtkPaned *paned)
2151 g_object_get (G_OBJECT(paned),
2155 if (gtk_paned_get_child1(GTK_PANED(paned)))
2156 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2157 if (gtk_paned_get_child2(GTK_PANED(paned)))
2158 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2159 gtk_paned_set_position(GTK_PANED(paned), min);
2162 void main_window_toggle_message_view(MainWindow *mainwin)
2164 SummaryView *summaryview = mainwin->summaryview;
2165 GtkWidget *ppaned = NULL;
2166 GtkWidget *container = NULL;
2168 switch (prefs_common.layout_mode) {
2170 case VERTICAL_LAYOUT:
2172 ppaned = mainwin->vpaned;
2173 container = mainwin->hpaned;
2174 if (ppaned->parent != NULL) {
2175 mainwin->messageview->visible = FALSE;
2176 summaryview->displayed = NULL;
2177 gtk_widget_ref(ppaned);
2178 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2179 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2181 mainwin->messageview->visible = TRUE;
2182 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2183 gtk_container_add(GTK_CONTAINER(container), ppaned);
2184 gtk_widget_unref(ppaned);
2188 ppaned = mainwin->hpaned;
2189 container = mainwin->vpaned;
2190 if (mainwin->messageview->vbox->parent != NULL) {
2191 mainwin->messageview->visible = FALSE;
2192 summaryview->displayed = NULL;
2193 gtk_widget_ref(mainwin->messageview->vbox);
2194 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2196 mainwin->messageview->visible = TRUE;
2197 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2198 gtk_widget_unref(mainwin->messageview->vbox);
2201 case WIDE_MSGLIST_LAYOUT:
2202 g_warning("can't hide messageview in this wide msglist layout");
2206 if (messageview_is_visible(mainwin->messageview))
2207 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2208 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2210 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2211 GTK_ARROW_UP, GTK_SHADOW_OUT);
2213 if (mainwin->messageview->visible == FALSE)
2214 messageview_clear(mainwin->messageview);
2216 main_window_set_menu_sensitive(mainwin);
2218 prefs_common.msgview_visible = mainwin->messageview->visible;
2220 if (messageview_is_visible(mainwin->messageview)) {
2221 gtk_widget_queue_resize(mainwin->hpaned);
2222 gtk_widget_queue_resize(mainwin->vpaned);
2224 summary_grab_focus(summaryview);
2227 void main_window_get_size(MainWindow *mainwin)
2229 GtkAllocation *allocation;
2231 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2232 debug_print("called after messageview "
2233 "has been deallocated!\n");
2237 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2239 if (allocation->width > 1 && allocation->height > 1) {
2240 prefs_common.summaryview_width = allocation->width;
2242 if (messageview_is_visible(mainwin->messageview))
2243 prefs_common.summaryview_height = allocation->height;
2245 prefs_common.mainview_width = allocation->width;
2248 allocation = &mainwin->window->allocation;
2249 if (allocation->width > 1 && allocation->height > 1) {
2250 prefs_common.mainview_height = allocation->height;
2251 prefs_common.mainwin_width = allocation->width;
2252 prefs_common.mainwin_height = allocation->height;
2255 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2256 if (allocation->width > 1 && allocation->height > 1) {
2257 prefs_common.folderview_width = allocation->width;
2258 prefs_common.folderview_height = allocation->height;
2261 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2262 if (allocation->width > 1 && allocation->height > 1) {
2263 prefs_common.msgview_width = allocation->width;
2264 prefs_common.msgview_height = allocation->height;
2267 /* debug_print("summaryview size: %d x %d\n",
2268 prefs_common.summaryview_width,
2269 prefs_common.summaryview_height);
2270 debug_print("folderview size: %d x %d\n",
2271 prefs_common.folderview_width,
2272 prefs_common.folderview_height);
2273 debug_print("messageview size: %d x %d\n",
2274 prefs_common.msgview_width,
2275 prefs_common.msgview_height); */
2278 void main_window_get_position(MainWindow *mainwin)
2282 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2284 prefs_common.mainview_x = x;
2285 prefs_common.mainview_y = y;
2286 prefs_common.mainwin_x = x;
2287 prefs_common.mainwin_y = y;
2289 debug_print("main window position: %d, %d\n", x, y);
2292 void main_window_progress_on(MainWindow *mainwin)
2294 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2297 void main_window_progress_off(MainWindow *mainwin)
2299 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2300 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2303 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2307 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2308 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2309 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2310 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2313 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2315 if (confirm && procmsg_have_trashed_mails_fast()) {
2316 if (alertpanel(_("Empty trash"),
2317 _("Delete all messages in trash folders?"),
2318 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2319 != G_ALERTALTERNATE)
2321 manage_window_focus_in(mainwin->window, NULL, NULL);
2324 procmsg_empty_all_trash();
2326 if (mainwin->summaryview->folder_item &&
2327 mainwin->summaryview->folder_item->stype == F_TRASH)
2328 gtk_widget_grab_focus(mainwin->folderview->ctree);
2331 void main_window_add_mailbox(MainWindow *mainwin)
2336 path = input_dialog(_("Add mailbox"),
2337 _("Input the location of mailbox.\n"
2338 "If an existing mailbox is specified, it will be\n"
2339 "scanned automatically."),
2342 if (folder_find_from_path(path)) {
2343 alertpanel_error(_("The mailbox '%s' already exists."), path);
2347 folder = folder_new(folder_get_class_from_string("mh"),
2348 !strcmp(path, "Mail") ? _("Mailbox") :
2349 g_path_get_basename(path), path);
2352 if (folder->klass->create_tree(folder) < 0) {
2353 alertpanel_error(_("Creation of the mailbox failed.\n"
2354 "Maybe some files already exist, or you don't have the permission to write there."));
2355 folder_destroy(folder);
2360 folder_set_ui_func(folder, scan_tree_func, mainwin);
2361 folder_scan_tree(folder, TRUE);
2362 folder_set_ui_func(folder, NULL, NULL);
2365 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2367 SensitiveCond state = 0;
2368 SummarySelection selection;
2369 FolderItem *item = mainwin->summaryview->folder_item;
2370 GList *account_list = account_get_list();
2373 selection = summary_get_selection_type(mainwin->summaryview);
2375 if (mainwin->lock_count == 0)
2376 state |= M_UNLOCKED;
2377 if (selection != SUMMARY_NONE)
2378 state |= M_MSG_EXIST;
2379 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2381 /* if (item->folder->type != F_NEWS) */
2382 state |= M_ALLOW_DELETE;
2384 if (prefs_common.immediate_exec == 0
2385 && mainwin->lock_count == 0)
2386 state |= M_DELAY_EXEC;
2388 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2389 || selection != SUMMARY_NONE)
2390 state |= M_HIDE_READ_MSG;
2392 if (mainwin->summaryview->threaded)
2393 state |= M_THREADED;
2395 state |= M_UNTHREADED;
2396 if (selection == SUMMARY_SELECTED_SINGLE ||
2397 selection == SUMMARY_SELECTED_MULTIPLE)
2398 state |= M_TARGET_EXIST;
2399 if (selection == SUMMARY_SELECTED_SINGLE)
2400 state |= M_SINGLE_TARGET_EXIST;
2401 if (mainwin->summaryview->folder_item &&
2402 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2405 state |= M_NOT_NEWS;
2406 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2407 state |= M_ACTIONS_EXIST;
2409 tmp = tags_get_list();
2410 if (tmp && g_slist_length(tmp))
2411 state |= M_TAGS_EXIST;
2414 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2415 state |= M_HAVE_QUEUED_MAILS;
2417 if (selection == SUMMARY_SELECTED_SINGLE &&
2419 (folder_has_parent_of_type(item, F_DRAFT) ||
2420 folder_has_parent_of_type(item, F_OUTBOX) ||
2421 folder_has_parent_of_type(item, F_QUEUE))))
2422 state |= M_ALLOW_REEDIT;
2424 state |= M_HAVE_ACCOUNT;
2426 if (any_folder_want_synchronise())
2427 state |= M_WANT_SYNC;
2429 for ( ; account_list != NULL; account_list = account_list->next) {
2430 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2431 state |= M_HAVE_NEWS_ACCOUNT;
2436 if (procmsg_spam_can_learn() &&
2437 (mainwin->summaryview->folder_item &&
2438 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2439 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2440 state |= M_CAN_LEARN_SPAM;
2443 if (inc_is_active())
2444 state |= M_INC_ACTIVE;
2445 if (imap_cancel_all_enabled())
2446 state |= M_INC_ACTIVE;
2448 if (mainwin->summaryview->deleted > 0 ||
2449 mainwin->summaryview->moved > 0 ||
2450 mainwin->summaryview->copied > 0)
2451 state |= M_DELAY_EXEC;
2458 void main_window_set_menu_sensitive(MainWindow *mainwin)
2460 GtkItemFactory *ifactory = mainwin->menu_factory;
2461 SensitiveCond state;
2464 GtkWidget *menuitem;
2465 SummaryView *summaryview;
2470 static const struct {
2474 {"/File/Save as...", M_TARGET_EXIST},
2475 {"/File/Print..." , M_TARGET_EXIST},
2476 {"/File/Synchronise folders", M_WANT_SYNC},
2477 {"/File/Exit" , M_UNLOCKED},
2479 {"/Edit/Select thread" , M_TARGET_EXIST},
2480 {"/Edit/Delete thread" , M_TARGET_EXIST},
2481 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2483 {"/View/Set displayed columns/in Folder list..."
2485 {"/View/Sort" , M_EXEC},
2486 {"/View/Thread view" , M_EXEC},
2487 {"/View/Expand all threads" , M_MSG_EXIST},
2488 {"/View/Collapse all threads" , M_MSG_EXIST},
2489 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2490 {"/View/Go to/Previous message" , M_MSG_EXIST},
2491 {"/View/Go to/Next message" , M_MSG_EXIST},
2492 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2493 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2494 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2495 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2496 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2497 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2498 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2499 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2500 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2501 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2502 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2504 {"/Message/Receive/Get from current account"
2505 , M_HAVE_ACCOUNT|M_UNLOCKED},
2506 {"/Message/Receive/Get from all accounts"
2507 , M_HAVE_ACCOUNT|M_UNLOCKED},
2508 {"/Message/Receive/Cancel receiving"
2510 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2511 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2512 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2513 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2514 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2515 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2516 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2517 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2518 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2519 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2520 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2521 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2522 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2523 {"/Message/Mark" , M_TARGET_EXIST},
2524 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2525 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2526 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2527 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2528 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2529 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2530 {"/Message/Color label" , M_TARGET_EXIST},
2531 {"/Message/Tags" , M_TARGET_EXIST},
2532 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2534 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2535 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2536 {"/Tools/Harvest addresses/from Messages..."
2538 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2539 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2540 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2541 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2542 {"/Tools/List URLs..." , M_TARGET_EXIST},
2543 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2544 {"/Tools/Execute" , M_DELAY_EXEC},
2545 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2547 {"/Configuration", M_UNLOCKED},
2548 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2549 {"/Configuration/Create new account...", M_UNLOCKED},
2550 {"/Configuration/Edit accounts...", M_UNLOCKED},
2555 state = main_window_get_current_state(mainwin);
2557 for (i = 0; entry[i].entry != NULL; i++) {
2558 sensitive = ((entry[i].cond & state) == entry[i].cond);
2559 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2562 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2564 /* search for separator */
2565 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2566 cur_item = cur_item->next) {
2567 if (GTK_BIN(cur_item->data)->child == NULL) {
2568 cur_item = cur_item->next;
2573 for (; cur_item != NULL; cur_item = cur_item->next) {
2574 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2575 (M_UNLOCKED & state) != 0);
2578 main_window_menu_callback_block(mainwin);
2580 #define SET_CHECK_MENU_ACTIVE(path, active) \
2582 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2583 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2586 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2587 messageview_is_visible(mainwin->messageview));
2589 summaryview = mainwin->summaryview;
2590 menu_path = "/View/Sort/Don't sort";
2592 switch (summaryview->sort_key) {
2593 case SORT_BY_NUMBER:
2594 menu_path = "/View/Sort/by number"; break;
2596 menu_path = "/View/Sort/by Size"; break;
2598 menu_path = "/View/Sort/by Date"; break;
2599 case SORT_BY_THREAD_DATE:
2600 menu_path = "/View/Sort/by Thread date"; break;
2602 menu_path = "/View/Sort/by From"; break;
2604 menu_path = "/View/Sort/by To"; break;
2605 case SORT_BY_SUBJECT:
2606 menu_path = "/View/Sort/by Subject"; break;
2608 menu_path = "/View/Sort/by color label"; break;
2610 menu_path = "/View/Sort/by mark"; break;
2611 case SORT_BY_STATUS:
2612 menu_path = "/View/Sort/by status"; break;
2614 menu_path = "/View/Sort/by attachment"; break;
2616 menu_path = "/View/Sort/by score"; break;
2617 case SORT_BY_LOCKED:
2618 menu_path = "/View/Sort/by locked"; break;
2620 menu_path = "/View/Sort/by tag"; break;
2623 menu_path = "/View/Sort/Don't sort"; break;
2625 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2627 if (summaryview->sort_type == SORT_ASCENDING) {
2628 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2630 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2633 if (summaryview->sort_key != SORT_BY_NONE) {
2634 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2635 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2637 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2638 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2641 if (mainwin->messageview
2642 && mainwin->messageview->mimeview
2643 && mainwin->messageview->mimeview->textview)
2644 SET_CHECK_MENU_ACTIVE("/View/All headers",
2645 mainwin->messageview->mimeview->textview->show_all_headers);
2646 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2647 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2648 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2649 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2650 if (prefs_common.hide_quotes == 1)
2651 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2652 if (prefs_common.hide_quotes == 2)
2653 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2654 if (prefs_common.hide_quotes == 3)
2655 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2657 #undef SET_CHECK_MENU_ACTIVE
2659 main_window_menu_callback_unblock(mainwin);
2662 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2664 GtkItemFactory *ifactory;
2666 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2669 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2671 gtk_widget_set_sensitive (gtk_item_factory_get_item
2672 (ifactory,"/Message/Mailing-List"), TRUE);
2674 gtk_widget_set_sensitive (gtk_item_factory_get_item
2675 (ifactory,"/Message/Mailing-List"), FALSE);
2678 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2681 GtkWidget *menuitem;
2683 if (!msginfo || !msginfo->extradata) {
2684 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2685 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2686 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2687 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2688 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2689 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2693 /* Mailing list post */
2694 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2695 g_free(msginfo->extradata->list_post);
2696 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2698 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2700 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2702 /* Mailing list help */
2703 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2705 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2707 /* Mailing list subscribe */
2708 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2710 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2712 /* Mailing list unsubscribe */
2713 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2715 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2717 /* Mailing list view archive */
2718 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2720 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2722 /* Mailing list contact owner */
2723 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2725 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2730 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2732 GtkWidget *item, *menu;
2733 const gchar *url_pt ;
2734 gchar url_decoded[BUFFSIZE];
2735 GList *amenu, *alist;
2738 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2740 /* First delete old submenu */
2741 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2742 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2743 alist = amenu->next;
2744 item = GTK_WIDGET (amenu->data);
2745 gtk_widget_destroy (item);
2749 for (url_pt = list_header; url_pt && *url_pt;) {
2750 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2752 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2753 item = gtk_menu_item_new_with_label ((url_decoded));
2754 g_signal_connect(G_OBJECT(item), "activate",
2755 G_CALLBACK(mailing_list_compose),
2758 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2759 !g_strncasecmp (url_decoded, "https:",6)) {
2761 item = gtk_menu_item_new_with_label ((url_decoded));
2762 g_signal_connect(G_OBJECT(item), "activate",
2763 G_CALLBACK(mailing_list_open_uri),
2767 gtk_menu_append (GTK_MENU(menu), item);
2768 gtk_widget_show (item);
2774 gtk_widget_set_sensitive (menuitem, TRUE);
2776 gtk_widget_set_sensitive (menuitem, FALSE);
2782 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2784 gchar tmp[BUFFSIZE];
2788 gboolean with_plus = TRUE;
2791 *url_decoded = '\0';
2795 /* Ignore spaces, comments and tabs () */
2796 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2798 for (;*buf != ')' && *buf != 0x00; buf++);
2800 /* First non space and non comment must be a < */
2803 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2805 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2810 *url_decoded = '\0';
2815 *url_decoded = '\0';
2821 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2823 /* Prepare the work for the next url in the list */
2824 /* after the closing bracket >, ignore space, comments and tabs */
2825 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2827 for (;*buf != ')' && *buf != 0x00; buf++);
2829 if (!buf || !*buf) {
2834 /* now first non space, non comment must be a comma */
2836 for (;*buf != 0x00; buf++);
2842 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2846 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2847 compose_new(NULL, mailto+7, NULL);
2850 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2855 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2856 open_uri (mailto, prefs_common.uri_cmd);
2859 void main_window_popup(MainWindow *mainwin)
2861 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2862 main_window_show(mainwin);
2864 gtkut_window_popup(mainwin->window);
2865 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2866 if (mainwin->in_folder) {
2867 mainwindow_enter_folder(mainwin);
2869 mainwindow_exit_folder(mainwin);
2874 void main_window_show(MainWindow *mainwin)
2876 gtk_widget_show(mainwin->window);
2877 gtk_widget_show(mainwin->vbox_body);
2879 gtk_widget_set_uposition(mainwin->window,
2880 prefs_common.mainwin_x,
2881 prefs_common.mainwin_y);
2883 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2884 prefs_common.folderview_width,
2885 prefs_common.folderview_height);
2886 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2887 prefs_common.summaryview_width,
2888 prefs_common.summaryview_height);
2889 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2890 prefs_common.msgview_width,
2891 prefs_common.msgview_height);
2894 void main_window_hide(MainWindow *mainwin)
2896 main_window_get_size(mainwin);
2897 main_window_get_position(mainwin);
2899 gtk_widget_hide(mainwin->window);
2900 gtk_widget_hide(mainwin->vbox_body);
2903 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2905 GtkWidget *folderwin = NULL;
2906 GtkWidget *messagewin = NULL;
2909 GtkWidget *vbox_body = mainwin->vbox_body;
2910 GtkItemFactory *ifactory = mainwin->menu_factory;
2911 GtkWidget *menuitem;
2912 gboolean first_set = (mainwin->hpaned == NULL);
2913 debug_print("Setting widgets... ");
2915 if (layout_mode == SMALL_LAYOUT && first_set) {
2916 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2917 prefs_common.folderview_width,
2918 prefs_common.folderview_height);
2919 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2921 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2924 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2925 prefs_common.folderview_width,
2926 prefs_common.folderview_height);
2927 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2928 prefs_common.summaryview_width,
2929 prefs_common.summaryview_height);
2930 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2931 prefs_common.msgview_width,
2932 prefs_common.msgview_height);
2935 mainwin->messageview->statusbar = mainwin->statusbar;
2936 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2938 /* clean top-most container */
2939 if (mainwin->hpaned) {
2940 if (mainwin->hpaned->parent == mainwin->vpaned)
2941 gtk_widget_destroy(mainwin->vpaned);
2943 gtk_widget_destroy(mainwin->hpaned);
2946 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
2947 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
2948 switch (layout_mode) {
2949 case VERTICAL_LAYOUT:
2952 hpaned = gtk_hpaned_new();
2953 if (layout_mode == VERTICAL_LAYOUT)
2954 vpaned = gtk_hpaned_new();
2956 vpaned = gtk_vpaned_new();
2957 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2958 gtk_paned_add1(GTK_PANED(hpaned),
2959 GTK_WIDGET_PTR(mainwin->folderview));
2960 gtk_widget_show(hpaned);
2961 gtk_widget_queue_resize(hpaned);
2963 if (messageview_is_visible(mainwin->messageview)) {
2964 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2965 gtk_paned_add1(GTK_PANED(vpaned),
2966 GTK_WIDGET_PTR(mainwin->summaryview));
2968 gtk_paned_add2(GTK_PANED(hpaned),
2969 GTK_WIDGET_PTR(mainwin->summaryview));
2970 gtk_widget_ref(vpaned);
2972 gtk_paned_add2(GTK_PANED(vpaned),
2973 GTK_WIDGET_PTR(mainwin->messageview));
2974 gtk_widget_show(vpaned);
2975 if (layout_mode == SMALL_LAYOUT && first_set) {
2976 mainwin_paned_show_first(GTK_PANED(hpaned));
2978 gtk_widget_queue_resize(vpaned);
2981 vpaned = gtk_vpaned_new();
2982 hpaned = gtk_hpaned_new();
2983 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2984 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
2986 gtk_paned_add1(GTK_PANED(hpaned),
2987 GTK_WIDGET_PTR(mainwin->folderview));
2988 gtk_paned_add2(GTK_PANED(hpaned),
2989 GTK_WIDGET_PTR(mainwin->summaryview));
2991 gtk_widget_show(hpaned);
2992 gtk_widget_queue_resize(hpaned);
2994 if (messageview_is_visible(mainwin->messageview)) {
2995 gtk_paned_add2(GTK_PANED(vpaned),
2996 GTK_WIDGET_PTR(mainwin->messageview));
2998 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3000 gtk_widget_show(vpaned);
3001 gtk_widget_queue_resize(vpaned);
3003 case WIDE_MSGLIST_LAYOUT:
3004 vpaned = gtk_vpaned_new();
3005 hpaned = gtk_hpaned_new();
3006 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3008 gtk_paned_add1(GTK_PANED(vpaned),
3009 GTK_WIDGET_PTR(mainwin->summaryview));
3010 gtk_paned_add1(GTK_PANED(hpaned),
3011 GTK_WIDGET_PTR(mainwin->folderview));
3013 gtk_widget_show(hpaned);
3014 gtk_widget_queue_resize(hpaned);
3016 if (messageview_is_visible(mainwin->messageview)) {
3017 gtk_paned_add2(GTK_PANED(hpaned),
3018 GTK_WIDGET_PTR(mainwin->messageview));
3020 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3022 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3024 gtk_widget_show(vpaned);
3025 gtk_widget_queue_resize(vpaned);
3028 g_warning("Unknown layout");
3032 mainwin->hpaned = hpaned;
3033 mainwin->vpaned = vpaned;
3035 if (layout_mode == SMALL_LAYOUT) {
3036 if (mainwin->messageview->visible)
3037 main_window_toggle_message_view(mainwin);
3040 if (layout_mode == SMALL_LAYOUT && first_set) {
3041 gtk_widget_realize(mainwin->window);
3042 gtk_widget_realize(mainwin->folderview->ctree);
3043 gtk_widget_realize(mainwin->summaryview->hbox);
3044 gtk_widget_realize(mainwin->summaryview->hbox_l);
3045 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3046 prefs_common.folderview_width,
3047 prefs_common.folderview_height);
3048 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3050 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3052 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3053 prefs_common.mainwin_width,
3054 prefs_common.mainwin_height);
3055 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3057 /* remove headerview if not in prefs */
3058 headerview_set_visibility(mainwin->messageview->headerview,
3059 prefs_common.display_header_pane);
3061 if (messageview_is_visible(mainwin->messageview))
3062 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3063 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3065 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3066 GTK_ARROW_UP, GTK_SHADOW_OUT);
3068 gtk_window_move(GTK_WINDOW(mainwin->window),
3069 prefs_common.mainwin_x,
3070 prefs_common.mainwin_y);
3072 gtk_widget_queue_resize(vbox_body);
3073 gtk_widget_queue_resize(mainwin->vbox);
3074 gtk_widget_queue_resize(mainwin->window);
3075 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3076 * and mimeview icon list/ctree lose track of their visibility states */
3077 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3078 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3079 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3080 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3081 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
3082 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3084 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3086 prefs_common.layout_mode = layout_mode;
3088 menuitem = gtk_item_factory_get_item
3089 (ifactory, "/View/Show or hide/Message view");
3090 gtk_check_menu_item_set_active
3091 (GTK_CHECK_MENU_ITEM(menuitem),
3092 messageview_is_visible(mainwin->messageview));
3094 #define SET_CHECK_MENU_ACTIVE(path, active) \
3096 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3097 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3100 switch (prefs_common.layout_mode) {
3102 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3104 case VERTICAL_LAYOUT:
3105 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3108 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3110 case WIDE_MSGLIST_LAYOUT:
3111 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
3114 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
3117 #undef SET_CHECK_MENU_ACTIVE
3121 (G_OBJECT(folderwin), "size_allocate",
3122 G_CALLBACK(folder_window_size_allocate_cb),
3127 (G_OBJECT(messagewin), "size_allocate",
3128 G_CALLBACK(message_window_size_allocate_cb),
3132 debug_print("done.\n");
3135 void main_window_destroy_all(void)
3137 while (mainwin_list != NULL) {
3138 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
3140 /* free toolbar stuff */
3141 toolbar_clear_list(TOOLBAR_MAIN);
3142 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
3143 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
3145 mainwin->folderview->mainwin = NULL;
3146 mainwin->summaryview->mainwin = NULL;
3147 mainwin->messageview->mainwin = NULL;
3149 g_free(mainwin->toolbar);
3152 mainwin_list = g_list_remove(mainwin_list, mainwin);
3154 g_list_free(mainwin_list);
3155 mainwin_list = NULL;
3158 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
3161 gtk_widget_set_size_request(child, 1, -1);
3164 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
3167 gtk_widget_set_size_request(child, -1, -1);
3170 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
3173 MainWindow *mainwin = (MainWindow *)data;
3175 if (!event) return FALSE;
3177 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3178 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
3181 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3182 menu_button_position, widget,
3183 event->button, event->time);
3188 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3191 MainWindow *mainwin = (MainWindow *)data;
3192 gboolean close_allowed = TRUE;
3194 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
3196 if (close_allowed && mainwin->lock_count == 0)
3197 app_exit_cb(data, 0, widget);
3202 static void main_window_size_allocate_cb(GtkWidget *widget,
3203 GtkAllocation *allocation,
3206 MainWindow *mainwin = (MainWindow *)data;
3207 main_window_get_size(mainwin);
3210 static void folder_window_size_allocate_cb(GtkWidget *widget,
3211 GtkAllocation *allocation,
3214 MainWindow *mainwin = (MainWindow *)data;
3216 main_window_get_size(mainwin);
3219 static void message_window_size_allocate_cb(GtkWidget *widget,
3220 GtkAllocation *allocation,
3223 MainWindow *mainwin = (MainWindow *)data;
3225 main_window_get_size(mainwin);
3228 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3231 main_window_add_mailbox(mainwin);
3234 static void update_folderview_cb(MainWindow *mainwin, guint action,
3237 summary_show(mainwin->summaryview, NULL);
3238 folderview_check_new_all();
3241 static void foldersort_cb(MainWindow *mainwin, guint action,
3247 static void import_mbox_cb(MainWindow *mainwin, guint action,
3250 /* only notify if import has failed */
3251 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3252 alertpanel_error(_("Mbox import has failed."));
3256 static void export_mbox_cb(MainWindow *mainwin, guint action,
3259 /* only notify if export has failed */
3260 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3261 alertpanel_error(_("Export to mbox has failed."));
3265 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3268 /* only notify if export has failed */
3269 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3270 alertpanel_error(_("Export to mbox has failed."));
3274 static void empty_trash_cb(MainWindow *mainwin, guint action,
3277 main_window_empty_trash(mainwin, TRUE);
3280 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3282 summary_save_as(mainwin->summaryview);
3285 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3287 summary_print(mainwin->summaryview);
3290 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3292 if (prefs_common.confirm_on_exit) {
3293 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3294 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3295 != G_ALERTALTERNATE)
3297 manage_window_focus_in(mainwin->window, NULL, NULL);
3300 app_will_exit(widget, mainwin);
3303 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3306 summary_search(mainwin->summaryview);
3308 message_search(mainwin->messageview);
3311 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3313 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3316 static void toggle_message_cb(MainWindow *mainwin, guint action,
3321 active = GTK_CHECK_MENU_ITEM(widget)->active;
3323 if (active != messageview_is_visible(mainwin->messageview))
3324 summary_toggle_view(mainwin->summaryview);
3327 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3330 toolbar_toggle(action, mainwin);
3333 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3336 MessageView *msgview = (MessageView*)mainwin->messageview;
3337 GSList *msginfo_list = NULL;
3339 g_return_if_fail(msgview != NULL);
3341 msginfo_list = summary_get_selection(mainwin->summaryview);
3342 g_return_if_fail(msginfo_list != NULL);
3343 compose_reply_from_messageview(msgview, msginfo_list, action);
3344 g_slist_free(msginfo_list);
3348 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3351 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3352 gtk_widget_show(mainwin->hbox_stat);
3353 prefs_common.show_statusbar = TRUE;
3355 gtk_widget_hide(mainwin->hbox_stat);
3356 prefs_common.show_statusbar = FALSE;
3360 static void set_layout_cb(MainWindow *mainwin, guint action,
3363 LayoutType layout_mode = action;
3364 LayoutType old_layout_mode = prefs_common.layout_mode;
3365 if (mainwin->menu_lock_count) {
3368 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3372 if (layout_mode == prefs_common.layout_mode) {
3376 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3377 main_window_toggle_message_view(mainwin);
3378 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3379 main_window_toggle_message_view(mainwin);
3381 main_window_separation_change(mainwin, layout_mode);
3382 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3383 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3384 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3386 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3387 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3388 mainwindow_exit_folder(mainwin);
3390 summary_relayout(mainwin->summaryview);
3391 summary_update_unread(mainwin->summaryview, NULL);
3394 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3397 offline_ask_sync = ask_sync;
3399 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3401 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3402 offline_ask_sync = TRUE;
3405 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3407 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3410 static gboolean any_folder_want_synchronise(void)
3412 GList *folderlist = folder_get_list();
3414 /* see if there are synchronised folders */
3415 for (; folderlist; folderlist = folderlist->next) {
3416 Folder *folder = (Folder *)folderlist->data;
3417 if (folder_want_synchronise(folder)) {
3425 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3428 if (!any_folder_want_synchronise())
3431 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3432 _("Do you want to synchronise your folders now?"),
3433 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3436 if (offline_ask_sync)
3437 folder_synchronise(NULL);
3440 static void online_switch_clicked (GtkButton *btn, gpointer data)
3442 MainWindow *mainwin;
3443 GtkItemFactory *ifactory;
3444 GtkCheckMenuItem *menuitem;
3446 mainwin = (MainWindow *) data;
3448 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3449 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3451 g_return_if_fail(mainwin != NULL);
3452 g_return_if_fail(menuitem != NULL);
3454 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3455 gtk_widget_hide (mainwin->online_switch);
3456 gtk_widget_show (mainwin->offline_switch);
3457 menuitem->active = TRUE;
3458 inc_autocheck_timer_remove();
3461 if (prefs_common.work_offline)
3463 mainwindow_check_synchronise(mainwin, TRUE);
3464 prefs_common.work_offline = TRUE;
3465 imap_disconnect_all();
3466 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3469 if (!prefs_common.work_offline)
3471 gtk_widget_hide (mainwin->offline_switch);
3472 gtk_widget_show (mainwin->online_switch);
3473 menuitem->active = FALSE;
3474 prefs_common.work_offline = FALSE;
3475 inc_autocheck_timer_set();
3476 refresh_resolvers();
3477 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3481 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3484 addressbook_open(NULL);
3487 static void log_window_show_cb(MainWindow *mainwin, guint action,
3490 log_window_show(mainwin->logwin);
3493 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3496 log_window_show(mainwin->filtering_debugwin);
3499 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3505 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3507 summary_move_to(mainwin->summaryview);
3510 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3512 summary_copy_to(mainwin->summaryview);
3515 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3517 summary_delete(mainwin->summaryview);
3520 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3522 summary_delete_trash(mainwin->summaryview);
3525 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3527 summary_cancel(mainwin->summaryview);
3530 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3532 summary_open_msg(mainwin->summaryview);
3535 static void view_source_cb(MainWindow *mainwin, guint action,
3538 summary_view_source(mainwin->summaryview);
3541 static void show_all_header_cb(MainWindow *mainwin, guint action,
3544 if (mainwin->menu_lock_count) return;
3545 mainwin->summaryview->messageview->all_headers =
3546 GTK_CHECK_MENU_ITEM(widget)->active;
3547 summary_display_msg_selected(mainwin->summaryview,
3548 GTK_CHECK_MENU_ITEM(widget)->active);
3551 #define SET_CHECK_MENU_ACTIVE(path, active) \
3553 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3554 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3557 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3560 GtkWidget *menuitem;
3561 GtkItemFactory *ifactory = mainwin->menu_factory;
3563 if (mainwin->menu_lock_count) return;
3565 prefs_common.hide_quotes =
3566 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3568 mainwin->menu_lock_count++;
3569 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3570 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3571 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3572 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3573 mainwin->menu_lock_count--;
3575 summary_redisplay_msg(mainwin->summaryview);
3578 #undef SET_CHECK_MENU_ACTIVE
3579 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3581 summary_mark(mainwin->summaryview);
3584 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3586 summary_unmark(mainwin->summaryview);
3589 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3592 summary_mark_as_unread(mainwin->summaryview);
3595 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3598 summary_mark_as_read(mainwin->summaryview);
3601 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3604 summary_mark_all_read(mainwin->summaryview);
3607 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3610 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3613 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3616 summary_ignore_thread(mainwin->summaryview);
3619 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3622 summary_unignore_thread(mainwin->summaryview);
3625 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3628 summary_msgs_lock(mainwin->summaryview);
3631 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3634 summary_msgs_unlock(mainwin->summaryview);
3638 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3640 summary_reedit(mainwin->summaryview);
3643 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3645 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3646 summary_display_msg_selected(mainwin->summaryview,
3647 mainwin->messageview->mimeview->textview->show_all_headers);
3649 messageview_list_urls(mainwin->messageview);
3652 static void add_address_cb(MainWindow *mainwin, guint action,
3655 summary_add_address(mainwin->summaryview);
3658 static void set_charset_cb(MainWindow *mainwin, guint action,
3663 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3664 str = conv_get_charset_str((CharSet)action);
3666 g_free(mainwin->messageview->forced_charset);
3667 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3668 procmime_force_charset(str);
3670 summary_redisplay_msg(mainwin->summaryview);
3672 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3676 static void set_decode_cb(MainWindow *mainwin, guint action,
3679 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3680 mainwin->messageview->forced_encoding = (EncodingType)action;
3682 summary_redisplay_msg(mainwin->summaryview);
3684 debug_print("forced encoding: %d\n", action);
3688 static void hide_read_messages (MainWindow *mainwin, guint action,
3691 if (!mainwin->summaryview->folder_item
3692 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3694 summary_toggle_show_read_messages(mainwin->summaryview);
3697 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3699 gboolean threaded = FALSE;
3700 if (mainwin->menu_lock_count) return;
3701 if (!mainwin->summaryview->folder_item) return;
3703 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3705 mainwin->summaryview->folder_item->threaded = threaded;
3707 mainwin->summaryview->threaded = threaded;
3709 summary_show(mainwin->summaryview,
3710 mainwin->summaryview->folder_item);
3713 static void expand_threads_cb(MainWindow *mainwin, guint action,
3716 summary_expand_threads(mainwin->summaryview);
3719 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3722 summary_collapse_threads(mainwin->summaryview);
3725 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3728 prefs_summary_column_open();
3731 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3734 prefs_folder_column_open();
3737 static void sort_summary_cb(MainWindow *mainwin, guint action,
3740 FolderItem *item = mainwin->summaryview->folder_item;
3741 GtkWidget *menuitem;
3743 if (mainwin->menu_lock_count) return;
3745 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3746 menuitem = gtk_item_factory_get_item
3747 (mainwin->menu_factory, "/View/Sort/Ascending");
3748 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3749 GTK_CHECK_MENU_ITEM(menuitem)->active
3750 ? SORT_ASCENDING : SORT_DESCENDING);
3751 item->sort_key = action;
3755 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3758 FolderItem *item = mainwin->summaryview->folder_item;
3760 if (mainwin->menu_lock_count) return;
3762 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3763 summary_sort(mainwin->summaryview,
3764 item->sort_key, (FolderSortType)action);
3767 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3770 summary_attract_by_subject(mainwin->summaryview);
3773 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3778 item = folderview_get_selected_item(mainwin->folderview);
3780 main_window_cursor_wait(mainwin);
3781 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3783 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3784 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3786 STATUSBAR_POP(mainwin);
3787 main_window_cursor_normal(mainwin);
3797 static void deldup_all(FolderItem *item, gpointer _data)
3799 struct DelDupsData *data = _data;
3802 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3804 data->dups += result;
3809 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3812 struct DelDupsData data = {0, 0};
3814 main_window_cursor_wait(mainwin);
3815 folder_func_to_all_folders(deldup_all, &data);
3816 main_window_cursor_normal(mainwin);
3818 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3819 "Deleted %d duplicate messages in %d folders.\n",
3821 data.dups, data.folders);
3824 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3826 summary_filter(mainwin->summaryview, (gboolean)action);
3829 static void execute_summary_cb(MainWindow *mainwin, guint action,
3832 summary_execute(mainwin->summaryview);
3835 static void update_summary_cb(MainWindow *mainwin, guint action,
3839 FolderView *folderview = mainwin->folderview;
3841 if (!mainwin->summaryview->folder_item) return;
3842 if (!folderview->opened) return;
3844 folder_update_op_count();
3846 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3847 folderview->opened);
3850 folder_item_scan(fitem);
3851 summary_show(mainwin->summaryview, fitem);
3854 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3856 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3859 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3861 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3864 static void prev_unread_cb(MainWindow *mainwin, guint action,
3867 summary_select_prev_unread(mainwin->summaryview);
3870 static void next_unread_cb(MainWindow *mainwin, guint action,
3873 summary_select_next_unread(mainwin->summaryview);
3876 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3878 summary_select_prev_new(mainwin->summaryview);
3881 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3883 summary_select_next_new(mainwin->summaryview);
3886 static void prev_marked_cb(MainWindow *mainwin, guint action,
3889 summary_select_prev_marked(mainwin->summaryview);
3892 static void next_marked_cb(MainWindow *mainwin, guint action,
3895 summary_select_next_marked(mainwin->summaryview);
3898 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3901 summary_select_prev_labeled(mainwin->summaryview);
3904 static void next_labeled_cb(MainWindow *mainwin, guint action,
3907 summary_select_next_labeled(mainwin->summaryview);
3910 static void last_read_cb(MainWindow *mainwin, guint action,
3913 summary_select_last_read(mainwin->summaryview);
3916 static void parent_cb(MainWindow *mainwin, guint action,
3919 summary_select_parent(mainwin->summaryview);
3922 static void goto_folder_cb(MainWindow *mainwin, guint action,
3925 FolderItem *to_folder;
3927 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3930 folderview_select(mainwin->folderview, to_folder);
3933 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3936 folderview_select_next_unread(mainwin->folderview, FALSE);
3939 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3941 messageview_copy_clipboard(mainwin->messageview);
3944 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3946 MessageView *msgview = mainwin->messageview;
3948 if (messageview_is_visible(msgview) &&
3949 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3950 messageview_select_all(mainwin->messageview);
3952 summary_select_all(mainwin->summaryview);
3955 static void select_thread_cb(MainWindow *mainwin, guint action,
3958 summary_select_thread(mainwin->summaryview, FALSE);
3961 static void delete_thread_cb(MainWindow *mainwin, guint action,
3964 summary_select_thread(mainwin->summaryview, TRUE);
3967 static void create_filter_cb(MainWindow *mainwin, guint action,
3970 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3973 static void create_processing_cb(MainWindow *mainwin, guint action,
3976 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3979 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3982 prefs_filtering_open(&pre_global_processing,
3983 _("Processing rules to apply before folder rules"),
3984 MANUAL_ANCHOR_PROCESSING,
3988 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3991 prefs_filtering_open(&post_global_processing,
3992 _("Processing rules to apply after folder rules"),
3993 MANUAL_ANCHOR_PROCESSING,
3997 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
4000 prefs_filtering_open(&filtering_rules,
4001 _("Filtering configuration"),
4002 MANUAL_ANCHOR_FILTERING,
4006 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
4009 prefs_template_open();
4012 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
4015 prefs_actions_open(mainwin);
4018 static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
4021 prefs_tags_open(mainwin);
4024 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
4027 ssl_manager_open(mainwin);
4030 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
4034 new_account_cb(mainwin, 0, widget);
4036 account_open(cur_account);
4040 static void new_account_cb(MainWindow *mainwin, guint action,
4043 account_edit_open();
4044 if (!compose_get_compose_list()) account_add();
4047 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
4049 FolderItem *item = NULL;
4050 cur_account = (PrefsAccount *)data;
4052 if (!mainwindow_get_mainwindow())
4054 main_window_show_cur_account(mainwindow_get_mainwindow());
4055 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
4056 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
4057 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
4058 item = folderview_get_selected_item(
4059 mainwindow_get_mainwindow()->folderview);
4061 toolbar_set_compose_button
4062 (mainwindow_get_mainwindow()->toolbar,
4063 FOLDER_TYPE(item->folder) == F_NEWS ?
4064 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
4068 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
4070 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4071 PrefsAccount *account = (PrefsAccount *)data;
4073 inc_account_mail(mainwin, account);
4076 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
4078 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4079 PrefsAccount *account = (PrefsAccount *)data;
4080 FolderItem *item = mainwin->summaryview->folder_item;
4082 compose_new_with_folderitem(account, item, NULL);
4085 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
4090 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
4092 pluginwindow_create();
4095 static void manual_open_cb(MainWindow *mainwin, guint action,
4098 manual_open((ManualType)action, NULL);
4101 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
4106 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
4108 MainWindow *mainwin = (MainWindow *)data;
4112 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
4113 LOCAL_FOLDER(folder)->rootpath,
4117 str = g_strdup_printf(_("Scanning folder %s ..."),
4118 LOCAL_FOLDER(folder)->rootpath);
4120 STATUSBAR_PUSH(mainwin, str);
4121 STATUSBAR_POP(mainwin);
4125 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
4128 SummaryView *summary;
4130 g_return_val_if_fail(data, FALSE);
4131 if (!g_list_find(mainwin_list, data))
4133 summary = ((MainWindow *)data)->summaryview;
4134 g_return_val_if_fail(summary, FALSE);
4136 if (GTK_CLIST(summary->ctree)->selection &&
4137 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
4143 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
4146 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
4150 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
4153 if (!claws_is_starting()
4154 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
4155 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
4157 if (iconified_count > 0)
4158 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
4161 if (state->new_window_state == 0)
4162 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
4166 gboolean mainwindow_is_obscured(void)
4171 #define BREAK_ON_MODIFIER_KEY() \
4172 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
4174 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
4177 MainWindow *mainwin = (MainWindow*) data;
4179 if (!mainwin || !event)
4182 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
4184 lastkey = event->keyval;
4188 switch (event->keyval) {
4189 case GDK_Q: /* Quit */
4190 BREAK_ON_MODIFIER_KEY();
4192 app_exit_cb(mainwin, 0, NULL);
4195 if (mainwin->folderview && mainwin->summaryview
4196 && ((!mainwin->summaryview->displayed
4197 && !mainwin->summaryview->selected)
4198 || (mainwin->summaryview->folder_item
4199 && mainwin->summaryview->folder_item->total_msgs == 0))) {
4200 g_signal_stop_emission_by_name(G_OBJECT(widget),
4202 folderview_select_next_unread(mainwin->folderview, TRUE);
4207 if (maemo_mainwindow_is_fullscreen(widget)) {
4208 gtk_window_unfullscreen(GTK_WINDOW(widget));
4210 gtk_window_fullscreen(GTK_WINDOW(widget));
4220 #undef BREAK_ON_MODIFIER_KEY
4223 * Harvest addresses for selected folder.
4225 static void addr_harvest_cb( MainWindow *mainwin,
4229 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4233 * Harvest addresses for selected messages in summary view.
4235 static void addr_harvest_msg_cb( MainWindow *mainwin,
4239 summary_harvest_address( mainwin->summaryview );
4243 *\brief get a MainWindow
4245 *\return MainWindow * The first mainwindow in the mainwin_list
4247 MainWindow *mainwindow_get_mainwindow(void)
4249 if (mainwin_list && mainwin_list->data)
4250 return (MainWindow *)(mainwin_list->data);
4255 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4257 ProgressData *data = (ProgressData *) source;
4258 MainWindow *mainwin = (MainWindow *) userdata;
4260 switch (data->cmd) {
4261 case PROGRESS_COMMAND_START:
4262 case PROGRESS_COMMAND_STOP:
4263 gtk_progress_bar_set_fraction
4264 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4266 case PROGRESS_COMMAND_SET_PERCENTAGE:
4267 gtk_progress_bar_set_fraction
4268 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4271 while (gtk_events_pending()) gtk_main_iteration ();
4276 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4278 mainwindow_check_synchronise(mainwin, FALSE);
4281 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4283 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4286 void mainwindow_jump_to(const gchar *target, gboolean popup)
4290 FolderItem *item = NULL;
4292 MainWindow *mainwin = mainwindow_get_mainwindow();
4298 printf("not initialized\n");
4302 tmp = g_strdup(target);
4304 if ((p = strstr(tmp, "\r")) != NULL)
4306 if ((p = strstr(tmp, "\n")) != NULL)
4309 if ((item = folder_find_item_from_identifier(tmp))) {
4310 printf("selecting folder '%s'\n", tmp);
4311 folderview_select(mainwin->folderview, item);
4313 main_window_popup(mainwin);
4318 msg = strrchr(tmp, G_DIR_SEPARATOR);
4321 if ((item = folder_find_item_from_identifier(tmp))) {
4322 printf("selecting folder '%s'\n", tmp);
4323 folderview_select(mainwin->folderview, item);
4325 printf("'%s' not found\n", tmp);
4327 if (item && msg && atoi(msg)) {
4328 printf("selecting message %d\n", atoi(msg));
4329 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4330 summary_display_msg_selected(mainwin->summaryview, FALSE);
4332 main_window_popup(mainwin);
4335 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4336 MsgInfo *msginfo = NULL;
4338 msg[strlen(msg)-1] = '\0';
4339 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4341 printf("selecting message %s\n", msg);
4342 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4343 summary_display_msg_selected(mainwin->summaryview, FALSE);
4345 main_window_popup(mainwin);
4347 procmsg_msginfo_free(msginfo);
4350 printf("'%s' not found\n", msg);
4353 printf("'%s' not found\n", msg);
4356 printf("'%s' not found\n", tmp);
4362 void mainwindow_exit_folder(MainWindow *mainwin) {
4363 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4364 folderview_close_opened(mainwin->folderview);
4365 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4367 mainwin->in_folder = FALSE;
4370 void mainwindow_enter_folder(MainWindow *mainwin) {
4371 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4372 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4374 mainwin->in_folder = TRUE;
4378 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4381 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4385 void maemo_window_full_screen_if_needed (GtkWindow *window)
4387 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4388 gtk_window_fullscreen(GTK_WINDOW(window));
4392 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4394 g_signal_connect(G_OBJECT(window), "key_press_event",
4395 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());