2 Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 Copyright (C) 1999-2008 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 3 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, see <http://www.gnu.org/licenses/>.
22 #include <glib/gi18n.h>
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
42 #include <gtk/gtktooltips.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
64 #include "prefs_common.h"
65 #include "prefs_actions.h"
66 #include "prefs_filtering.h"
67 #include "prefs_account.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_folder_column.h"
70 #include "prefs_template.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.h"
87 #include "prefs_gtk.h"
88 #include "pluginwindow.h"
90 #include "progressindicator.h"
91 #include "localfolder.h"
92 #include "filtering.h"
93 #include "folderutils.h"
94 #include "foldersort.h"
95 #include "icon_legend.h"
96 #include "colorlabel.h"
101 #include "printing.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 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
175 static void page_setup_cb (MainWindow *mainwin,
180 static void print_cb (MainWindow *mainwin,
183 static void app_exit_cb (MainWindow *mainwin,
187 static void search_cb (MainWindow *mainwin,
191 static void toggle_message_cb (MainWindow *mainwin,
194 static void toggle_toolbar_cb (MainWindow *mainwin,
197 static void toggle_col_headers_cb(MainWindow *mainwin,
201 static void toggle_statusbar_cb (MainWindow *mainwin,
204 static void set_layout_cb (MainWindow *mainwin,
208 static void addressbook_open_cb (MainWindow *mainwin,
211 static void log_window_show_cb (MainWindow *mainwin,
214 static void filtering_debug_window_show_cb (MainWindow *mainwin,
218 static void inc_cancel_cb (MainWindow *mainwin,
222 static void open_msg_cb (MainWindow *mainwin,
226 static void view_source_cb (MainWindow *mainwin,
230 static void show_all_header_cb (MainWindow *mainwin,
234 static void hide_quotes_cb(MainWindow *mainwin,
238 static void move_to_cb (MainWindow *mainwin,
241 static void copy_to_cb (MainWindow *mainwin,
244 static void delete_cb (MainWindow *mainwin,
247 static void delete_trash_cb (MainWindow *mainwin,
251 static void cancel_cb (MainWindow *mainwin,
255 static void mark_cb (MainWindow *mainwin,
258 static void unmark_cb (MainWindow *mainwin,
262 static void mark_as_unread_cb (MainWindow *mainwin,
265 static void mark_as_read_cb (MainWindow *mainwin,
268 static void mark_all_read_cb (MainWindow *mainwin,
271 static void mark_as_spam_cb (MainWindow *mainwin,
275 static void ignore_thread_cb (MainWindow *mainwin,
278 static void unignore_thread_cb (MainWindow *mainwin,
281 static void watch_thread_cb (MainWindow *mainwin,
284 static void unwatch_thread_cb (MainWindow *mainwin,
287 static void lock_msgs_cb (MainWindow *mainwin,
290 static void unlock_msgs_cb (MainWindow *mainwin,
294 static void reedit_cb (MainWindow *mainwin,
298 static void add_address_cb (MainWindow *mainwin,
302 static void set_charset_cb (MainWindow *mainwin,
306 static void set_decode_cb (MainWindow *mainwin,
310 static void hide_read_messages (MainWindow *mainwin,
314 static void thread_cb (MainWindow *mainwin,
317 static void expand_threads_cb (MainWindow *mainwin,
320 static void collapse_threads_cb (MainWindow *mainwin,
324 static void set_summary_display_item_cb (MainWindow *mainwin,
327 static void set_folder_display_item_cb (MainWindow *mainwin,
330 static void sort_summary_cb (MainWindow *mainwin,
333 static void sort_summary_type_cb (MainWindow *mainwin,
336 static void attract_by_subject_cb(MainWindow *mainwin,
340 static void delete_duplicated_cb (MainWindow *mainwin,
343 static void delete_duplicated_all_cb (MainWindow *mainwin,
346 static void filter_cb (MainWindow *mainwin,
349 static void process_cb (MainWindow *mainwin,
352 static void execute_summary_cb (MainWindow *mainwin,
355 static void update_summary_cb (MainWindow *mainwin,
359 static void prev_cb (MainWindow *mainwin,
362 static void next_cb (MainWindow *mainwin,
365 static void next_unread_cb (MainWindow *mainwin,
368 static void prev_unread_cb (MainWindow *mainwin,
372 static void prev_new_cb (MainWindow *mainwin,
375 static void next_new_cb (MainWindow *mainwin,
378 static void prev_marked_cb (MainWindow *mainwin,
381 static void next_marked_cb (MainWindow *mainwin,
384 static void prev_labeled_cb (MainWindow *mainwin,
387 static void next_labeled_cb (MainWindow *mainwin,
390 static void last_read_cb (MainWindow *mainwin,
393 static void parent_cb (MainWindow *mainwin,
397 static void goto_folder_cb (MainWindow *mainwin,
400 static void goto_unread_folder_cb(MainWindow *mainwin,
404 static void copy_cb (MainWindow *mainwin,
407 static void allsel_cb (MainWindow *mainwin,
410 static void select_thread_cb (MainWindow *mainwin,
413 static void delete_thread_cb (MainWindow *mainwin,
417 static void create_filter_cb (MainWindow *mainwin,
420 static void create_processing_cb (MainWindow *mainwin,
423 static void open_urls_cb (MainWindow *mainwin,
427 static void prefs_template_open_cb (MainWindow *mainwin,
430 static void prefs_actions_open_cb (MainWindow *mainwin,
433 static void prefs_tags_open_cb (MainWindow *mainwin,
436 static void prefs_account_open_cb (MainWindow *mainwin,
440 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
444 static void prefs_post_processing_open_cb (MainWindow *mainwin,
448 static void prefs_filtering_open_cb (MainWindow *mainwin,
451 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
452 static void ssl_manager_open_cb (MainWindow *mainwin,
456 static void new_account_cb (MainWindow *mainwin,
460 static void account_selector_menu_cb (GtkMenuItem *menuitem,
462 static void account_receive_menu_cb (GtkMenuItem *menuitem,
465 static void account_compose_menu_cb (GtkMenuItem *menuitem,
468 static void prefs_open_cb (GtkMenuItem *menuitem,
470 static void plugins_open_cb (GtkMenuItem *menuitem,
473 static void online_switch_clicked(GtkButton *btn,
476 static void manual_open_cb (MainWindow *mainwin,
480 static void legend_open_cb (GtkMenuItem *menuitem,
483 static void scan_tree_func (Folder *folder,
487 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
489 static void addr_harvest_cb ( MainWindow *mainwin,
493 static void addr_harvest_msg_cb ( MainWindow *mainwin,
496 static void sync_cb ( MainWindow *mainwin,
500 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
501 GdkEventFocus *focus,
503 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
504 GdkEventVisibility *state,
506 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
507 GdkEventWindowState *state,
509 static void main_window_reply_cb (MainWindow *mainwin,
512 static gboolean mainwindow_progressindicator_hook (gpointer source,
515 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
518 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
520 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
522 static void mailing_list_compose(GtkWidget *w, gpointer *data);
524 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
525 #define SEPARATE_ACTION 500
526 static void mainwindow_quicksearch (MainWindow *mainwin,
529 static gboolean any_folder_want_synchronise(void);
531 static GtkItemFactoryEntry mainwin_entries[] =
533 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
534 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
536 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
537 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
538 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
540 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
541 {N_("/_File/Exp_ort selected to mbox file..."),
542 NULL, export_list_mbox_cb, 0, NULL},
543 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
545 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
546 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
547 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
548 {N_("/_File/Page setup..."), NULL, page_setup_cb, 0, NULL},
550 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
551 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
553 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
554 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
555 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
556 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
558 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
559 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
560 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
561 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
562 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
563 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
564 {N_("/_Edit/_Find in current message..."),
565 "<control>F", search_cb, 0, NULL},
566 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
567 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
568 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
569 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
570 {N_("/_View/Show or hi_de/_Toolbar"),
571 NULL, NULL, 0, "<Branch>"},
572 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
573 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
574 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
575 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
576 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
577 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
578 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
579 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
581 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
582 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
584 {N_("/_View/Show or hi_de/_Message view"),
585 "V", toggle_message_cb, 0, "<ToggleItem>"},
587 {N_("/_View/Show or hi_de/Status _bar"),
588 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
590 {N_("/_View/Show or hi_de/Column headers"),
591 NULL, toggle_col_headers_cb, 0, "<ToggleItem>"},
592 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
593 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
594 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
596 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
599 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
600 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
601 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
602 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
603 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
604 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
607 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
608 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
609 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
610 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
611 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
612 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
613 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
614 {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
615 {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
616 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
617 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
618 {N_("/_View/_Sort/by a_ttachment"),
619 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
620 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
621 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
622 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
623 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
625 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
626 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_View/_Sort/_Attract by subject"),
628 NULL, attract_by_subject_cb, 0, NULL},
629 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
630 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
631 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
632 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
634 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
636 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
637 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
638 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_View/_Go to/P_revious unread message"),
640 "<shift>P", prev_unread_cb, 0, NULL},
641 {N_("/_View/_Go to/N_ext unread message"),
642 "<shift>N", next_unread_cb, 0, NULL},
643 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
645 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
646 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
647 {N_("/_View/_Go to/Previous _marked message"),
648 NULL, prev_marked_cb, 0, NULL},
649 {N_("/_View/_Go to/Next m_arked message"),
650 NULL, next_marked_cb, 0, NULL},
651 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_View/_Go to/Previous _labeled message"),
653 NULL, prev_labeled_cb, 0, NULL},
654 {N_("/_View/_Go to/Next la_beled message"),
655 NULL, next_labeled_cb, 0, NULL},
656 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_View/_Go to/Last read message"),
658 NULL, last_read_cb, 0, NULL},
659 {N_("/_View/_Go to/Parent message"),
660 "<control>Up", parent_cb, 0, NULL},
661 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
663 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
664 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
666 #define ENC_SEPARATOR \
667 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
668 #define ENC_ACTION(action) \
669 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
671 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
672 {N_("/_View/Character _encoding/_Auto detect"),
673 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
676 {N_("/_View/Character _encoding/7bit ASCII (US-ASC_II)"),
677 ENC_ACTION(C_US_ASCII)},
678 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
679 ENC_ACTION(C_UTF_8)},
682 {N_("/_View/Character _encoding/Western European"),NULL, NULL, 0, "<Branch>"},
683 {N_("/_View/Character _encoding/Western European/ISO-8859-_1"),
684 ENC_ACTION(C_ISO_8859_1)},
685 {N_("/_View/Character _encoding/Western European/ISO-8859-15"),
686 ENC_ACTION(C_ISO_8859_15)},
687 {N_("/_View/Character _encoding/Western European/Windows-1252"),
688 ENC_ACTION(C_WINDOWS_1252)},
690 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
691 ENC_ACTION(C_ISO_8859_2)},
693 {N_("/_View/Character _encoding/Baltic"), NULL, NULL, 0, "<Branch>"},
694 {N_("/_View/Character _encoding/Baltic/ISO-8859-13"),
695 ENC_ACTION(C_ISO_8859_13)},
696 {N_("/_View/Character _encoding/Baltic/ISO-8859-_4"),
697 ENC_ACTION(C_ISO_8859_4)},
699 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
700 ENC_ACTION(C_ISO_8859_7)},
702 {N_("/_View/Character _encoding/Hebrew"), NULL, NULL, 0, "<Branch>"},
703 {N_("/_View/Character _encoding/Hebrew/ISO-8859-_8"),
704 ENC_ACTION(C_ISO_8859_8)},
705 {N_("/_View/Character _encoding/Hebrew/Windows-1255"),
706 ENC_ACTION(C_CP1255)},
708 {N_("/_View/Character _encoding/Arabic"), NULL, NULL, 0, "<Branch>"},
709 {N_("/_View/Character _encoding/Arabic/ISO-8859-_6"),
710 ENC_ACTION(C_ISO_8859_6)},
711 {N_("/_View/Character _encoding/Arabic/Windows-1256"),
712 ENC_ACTION(C_CP1256)},
714 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
715 ENC_ACTION(C_ISO_8859_9)},
717 {N_("/_View/Character _encoding/Cyrillic"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_View/Character _encoding/Cyrillic/ISO-8859-_5"),
719 ENC_ACTION(C_ISO_8859_5)},
720 {N_("/_View/Character _encoding/Cyrillic/KOI8-_R"),
721 ENC_ACTION(C_KOI8_R)},
722 {N_("/_View/Character _encoding/Cyrillic/KOI8-U"),
723 ENC_ACTION(C_KOI8_U)},
724 {N_("/_View/Character _encoding/Cyrillic/Windows-1251"),
725 ENC_ACTION(C_CP1251)},
727 {N_("/_View/Character _encoding/Japanese"), NULL, NULL, 0, "<Branch>"},
728 {N_("/_View/Character _encoding/Japanese/ISO-2022-_JP"),
729 ENC_ACTION(C_ISO_2022_JP)},
730 {N_("/_View/Character _encoding/Japanese/ISO-2022-JP-2"),
731 ENC_ACTION(C_ISO_2022_JP_2)},
732 {N_("/_View/Character _encoding/Japanese/_EUC-JP"),
733 ENC_ACTION(C_EUC_JP)},
734 {N_("/_View/Character _encoding/Japanese/_Shift__JIS"),
735 ENC_ACTION(C_SHIFT_JIS)},
737 {N_("/_View/Character _encoding/Chinese"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_View/Character _encoding/Chinese/Simplified (_GB2312)"),
739 ENC_ACTION(C_GB2312)},
740 {N_("/_View/Character _encoding/Chinese/Simplified (GBK)"),
742 {N_("/_View/Character _encoding/Chinese/Traditional (_Big5)"),
744 {N_("/_View/Character _encoding/Chinese/Traditional (EUC-_TW)"),
745 ENC_ACTION(C_EUC_TW)},
746 {N_("/_View/Character _encoding/Chinese/ISO-2022-_CN"),
747 ENC_ACTION(C_ISO_2022_CN)},
749 {N_("/_View/Character _encoding/Korean"), NULL, NULL, 0, "<Branch>"},
750 {N_("/_View/Character _encoding/Korean/EUC-_KR"),
751 ENC_ACTION(C_EUC_KR)},
752 {N_("/_View/Character _encoding/Korean/ISO-2022-KR"),
753 ENC_ACTION(C_ISO_2022_KR)},
755 {N_("/_View/Character _encoding/Thai"), NULL, NULL, 0, "<Branch>"},
756 {N_("/_View/Character _encoding/Thai/TIS-620"),
757 ENC_ACTION(C_TIS_620)},
758 {N_("/_View/Character _encoding/Thai/Windows-874"),
759 ENC_ACTION(C_WINDOWS_874)},
764 #define DEC_SEPARATOR \
765 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
766 #define DEC_ACTION(action) \
767 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
768 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
769 {N_("/_View/Decode/_Auto detect"),
770 NULL, set_decode_cb, 0, "<RadioItem>"},
771 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
772 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
773 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
774 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
775 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
780 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
781 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
782 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
783 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
784 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
785 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
786 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
787 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
788 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
789 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
791 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
792 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
793 {N_("/_Message/Recei_ve/Get from _current account"),
794 "<control>I", inc_mail_cb, 0, NULL},
795 {N_("/_Message/Recei_ve/Get from _all accounts"),
796 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
797 {N_("/_Message/Recei_ve/Cancel receivin_g"),
798 NULL, inc_cancel_cb, 0, NULL},
799 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
800 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
801 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
802 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
803 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
804 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
805 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
806 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
807 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
808 {N_("/_Message/Repl_y to/mailing _list"),
809 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
810 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
811 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
812 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
813 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
814 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
816 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
817 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
818 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
819 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
820 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
821 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
822 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
824 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
825 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
826 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
827 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
828 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
829 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
830 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
831 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
832 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
833 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
834 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
835 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
836 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
837 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
838 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
839 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
840 {N_("/_Message/_Mark/Watch thread"), NULL, watch_thread_cb, 0, NULL},
841 {N_("/_Message/_Mark/Unwatch thread"), NULL, unwatch_thread_cb, 0, NULL},
842 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
843 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
844 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
845 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
846 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
847 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
848 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
849 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
850 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
851 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
853 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
854 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
855 {N_("/_Tools/Add sender to address boo_k"),
856 NULL, add_address_cb, 0, NULL},
857 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
858 {N_("/_Tools/_Harvest addresses/from _Folder..."),
859 NULL, addr_harvest_cb, 0, NULL},
860 {N_("/_Tools/_Harvest addresses/from _Messages..."),
861 NULL, addr_harvest_msg_cb, 0, NULL},
862 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
863 {N_("/_Tools/_Filter all messages in folder"),
864 NULL, filter_cb, 0, NULL},
865 {N_("/_Tools/Filter _selected messages"),
866 NULL, filter_cb, 1, NULL},
867 {N_("/_Tools/Run folder processing rules"),
868 NULL, process_cb, 0, NULL},
869 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
870 {N_("/_Tools/_Create filter rule/_Automatically"),
871 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
872 {N_("/_Tools/_Create filter rule/by _From"),
873 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
874 {N_("/_Tools/_Create filter rule/by _To"),
875 NULL, create_filter_cb, FILTER_BY_TO, NULL},
876 {N_("/_Tools/_Create filter rule/by _Subject"),
877 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
878 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
879 {N_("/_Tools/C_reate processing rule/_Automatically"),
880 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
881 {N_("/_Tools/C_reate processing rule/by _From"),
882 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
883 {N_("/_Tools/C_reate processing rule/by _To"),
884 NULL, create_processing_cb, FILTER_BY_TO, NULL},
885 {N_("/_Tools/C_reate processing rule/by _Subject"),
886 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
887 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
888 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
889 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
890 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
891 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
892 {N_("/_Tools/Ch_eck for new messages in all folders"),
893 NULL, update_folderview_cb, 0, NULL},
894 {N_("/_Tools/Delete du_plicated messages"),
895 NULL, NULL, 0, "<Branch>"},
896 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
897 NULL, delete_duplicated_cb, 0, NULL},
898 {N_("/_Tools/Delete du_plicated messages/In all folders"),
899 NULL, delete_duplicated_all_cb, 0, NULL},
900 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
901 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
902 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
903 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
904 {N_("/_Tools/SSL cer_tificates..."),
905 NULL, ssl_manager_open_cb, 0, NULL},
907 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
908 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
909 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
911 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
912 {N_("/_Configuration/C_hange current account"),
913 NULL, NULL, 0, "<Branch>"},
914 {N_("/_Configuration/_Preferences for current account..."),
915 NULL, prefs_account_open_cb, 0, NULL},
916 {N_("/_Configuration/Create _new account..."),
917 NULL, new_account_cb, 0, NULL},
918 {N_("/_Configuration/_Edit accounts..."),
919 NULL, account_edit_open, 0, NULL},
920 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
921 {N_("/_Configuration/P_references..."),
922 NULL, prefs_open_cb, 0, NULL},
923 {N_("/_Configuration/Pre-pr_ocessing..."),
924 NULL, prefs_pre_processing_open_cb, 0, NULL},
925 {N_("/_Configuration/Post-pro_cessing..."),
926 NULL, prefs_post_processing_open_cb, 0, NULL},
927 {N_("/_Configuration/_Filtering..."),
928 NULL, prefs_filtering_open_cb, 0, NULL},
929 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
930 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
931 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
932 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
933 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
935 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
936 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_CLAWS, NULL},
937 {N_("/_Help/_Online User-contributed FAQ"),
938 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
939 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
940 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
941 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
944 static gboolean offline_ask_sync = TRUE;
945 static guint lastkey;
946 static gboolean is_obscured = FALSE;
948 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
954 MainWindow *mainwin = (MainWindow *)user_data;
956 if (mainwin->summaryview &&
957 mainwin->summaryview->quicksearch &&
958 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
959 (mod == 0 || mod == GDK_SHIFT_MASK)) {
960 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
966 #define N_COLOR_LABELS colorlabel_get_color_count()
968 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
973 GtkCheckMenuItem **items;
978 mainwin = (MainWindow *)data;
979 g_return_if_fail(mainwin != NULL);
981 sel = summary_get_selection(mainwin->summaryview);
984 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
985 g_return_if_fail(menu != NULL);
987 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
989 /* NOTE: don't return prematurely because we set the "dont_toggle"
990 * state for check menu items */
991 g_object_set_data(G_OBJECT(menu), "dont_toggle",
994 /* clear items. get item pointers. */
995 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
996 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
997 gtk_check_menu_item_set_active
998 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
999 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
1004 if (n == (N_COLOR_LABELS + 1)) {
1005 /* iterate all messages and set the state of the appropriate
1007 for (; sel != NULL; sel = sel->next) {
1011 msginfo = (MsgInfo *)sel->data;
1013 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
1014 if (!items[clabel]->active)
1015 gtk_check_menu_item_set_active
1016 (items[clabel], TRUE);
1020 g_warning("invalid number of color elements (%d)\n", n);
1023 /* reset "dont_toggle" state */
1024 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1025 GINT_TO_POINTER(0));
1028 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
1031 guint color = GPOINTER_TO_UINT(data);
1032 MainWindow *mainwin;
1034 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1035 g_return_if_fail(mainwin != NULL);
1037 /* "dont_toggle" state set? */
1038 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1042 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1045 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1048 MainWindow *mainwin;
1052 GHashTable *menu_table = g_hash_table_new_full(
1056 GHashTable *menu_allsel_table = g_hash_table_new_full(
1061 mainwin = (MainWindow *)data;
1062 g_return_if_fail(mainwin != NULL);
1064 sel = summary_get_selection(mainwin->summaryview);
1067 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1068 g_return_if_fail(menu != NULL);
1070 /* NOTE: don't return prematurely because we set the "dont_toggle"
1071 * state for check menu items */
1072 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1073 GINT_TO_POINTER(1));
1075 /* clear items. get item pointers. */
1076 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1077 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1078 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1080 gtk_check_menu_item_set_active
1081 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1083 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1084 g_hash_table_insert(menu_allsel_table, GINT_TO_POINTER(id), GINT_TO_POINTER(0));
1088 /* iterate all messages and set the state of the appropriate
1091 for (; sel != NULL; sel = sel->next) {
1093 GSList *tags = NULL;
1095 GtkCheckMenuItem *item;
1096 msginfo = (MsgInfo *)sel->data;
1099 tags = msginfo->tags;
1103 for (; tags; tags = tags->next) {
1104 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
1105 id = GPOINTER_TO_INT(tags->data);
1106 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1107 if (item && !item->active) {
1108 gtk_check_menu_item_set_active
1112 g_hash_table_replace(menu_allsel_table, tags->data, GINT_TO_POINTER(num_checked));
1117 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1118 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1119 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1121 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, GINT_TO_POINTER(id)));
1122 if (num_checked < sel_len && num_checked > 0)
1123 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), TRUE);
1125 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1129 g_hash_table_destroy(menu_table);
1130 g_hash_table_destroy(menu_allsel_table);
1131 /* reset "dont_toggle" state */
1132 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1133 GINT_TO_POINTER(0));
1136 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1139 gint id = GPOINTER_TO_INT(data);
1140 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1141 MainWindow *mainwin;
1143 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1144 g_return_if_fail(mainwin != NULL);
1146 /* "dont_toggle" state set? */
1147 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1153 summary_set_tag(mainwin->summaryview, id, NULL);
1156 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1158 GtkWidget *label_menuitem;
1163 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1164 "/Message/Color label");
1165 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1166 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1168 gtk_widget_show(label_menuitem);
1170 menu = gtk_menu_new();
1172 /* create sub items. for the menu item activation callback we pass the
1173 * index of label_colors[] as data parameter. for the None color we
1174 * pass an invalid (high) value. also we attach a data pointer so we
1175 * can always get back the Mainwindow pointer. */
1177 item = gtk_check_menu_item_new_with_label(_("None"));
1178 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1179 g_signal_connect(G_OBJECT(item), "activate",
1180 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1181 GUINT_TO_POINTER(0));
1182 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1183 gtk_widget_show(item);
1185 gtk_widget_add_accelerator(item, "activate",
1186 mainwin->menu_factory->accel_group,
1187 GDK_0, GDK_CONTROL_MASK,
1188 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1190 item = gtk_menu_item_new();
1191 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1192 gtk_widget_show(item);
1194 /* create pixmap/label menu items */
1195 for (i = 0; i < N_COLOR_LABELS; i++) {
1196 item = colorlabel_create_check_color_menu_item(
1197 i, refresh, MAINWIN_COLORMENU);
1198 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1199 g_signal_connect(G_OBJECT(item), "activate",
1200 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1201 GUINT_TO_POINTER(i + 1));
1202 g_object_set_data(G_OBJECT(item), "mainwin",
1204 gtk_widget_show(item);
1206 gtk_widget_add_accelerator(item, "activate",
1207 mainwin->menu_factory->accel_group,
1208 GDK_1+i, GDK_CONTROL_MASK,
1209 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1211 gtk_widget_show(menu);
1212 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1213 mainwin->colorlabel_menu = menu;
1216 static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
1219 MainWindow *mainwin;
1221 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1222 g_return_if_fail(mainwin != NULL);
1224 /* "dont_toggle" state set? */
1225 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1229 tag_apply_open(summary_get_selection(mainwin->summaryview));
1232 static gint mainwin_tag_cmp_list(gconstpointer a, gconstpointer b)
1234 gint id_a = GPOINTER_TO_INT(a);
1235 gint id_b = GPOINTER_TO_INT(b);
1236 const gchar *tag_a = tags_get_tag(id_a);
1237 const gchar *tag_b = tags_get_tag(id_b);
1241 return tag_b == NULL ? 0:1;
1244 return tag_a == NULL ? 0:1;
1246 return g_utf8_collate(tag_a, tag_b);
1249 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1251 GtkWidget *label_menuitem;
1254 GSList *cur = tags_get_list();
1255 GSList *orig = NULL;
1256 gboolean existing_tags = FALSE;
1258 cur = orig = g_slist_sort(cur, mainwin_tag_cmp_list);
1260 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1262 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1263 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1266 gtk_widget_show(label_menuitem);
1268 menu = gtk_menu_new();
1270 /* create tags menu items */
1271 for (; cur; cur = cur->next) {
1272 gint id = GPOINTER_TO_INT(cur->data);
1273 const gchar *tag = tags_get_tag(id);
1275 item = gtk_check_menu_item_new_with_label(tag);
1276 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1277 g_signal_connect(G_OBJECT(item), "activate",
1278 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1279 GINT_TO_POINTER(id));
1280 g_object_set_data(G_OBJECT(item), "mainwin",
1282 g_object_set_data(G_OBJECT(item), "tag_id",
1283 GINT_TO_POINTER(id));
1284 gtk_widget_show(item);
1285 existing_tags = TRUE;
1287 if (existing_tags) {
1289 item = gtk_menu_item_new();
1290 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1291 gtk_widget_show(item);
1294 item = gtk_menu_item_new_with_label(_("Apply tags..."));
1295 gtk_widget_add_accelerator(item, "activate",
1296 mainwin->menu_factory->accel_group,
1297 GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
1298 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1299 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1300 g_signal_connect(G_OBJECT(item), "activate",
1301 G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
1303 g_object_set_data(G_OBJECT(item), "mainwin",
1305 gtk_widget_show(item);
1308 gtk_widget_show(menu);
1309 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1310 mainwin->tags_menu = menu;
1312 #ifndef GENERIC_UMPC
1313 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1314 MainWindow *mainwindow)
1316 if (evt && evt->button == 1) {
1317 log_window_show_error(mainwindow->logwin);
1318 gtk_widget_hide(mainwindow->warning_btn);
1323 static gboolean warning_visi_notify(GtkWidget *widget,
1324 GdkEventVisibility *event,
1325 MainWindow *mainwindow)
1327 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1331 static gboolean warning_leave_notify(GtkWidget *widget,
1332 GdkEventCrossing *event,
1333 MainWindow *mainwindow)
1335 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1339 static gboolean warning_enter_notify(GtkWidget *widget,
1340 GdkEventCrossing *event,
1341 MainWindow *mainwindow)
1343 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1347 void mainwindow_show_error(void)
1349 MainWindow *mainwin = mainwindow_get_mainwindow();
1350 gtk_widget_show(mainwin->warning_btn);
1353 void mainwindow_clear_error(MainWindow *mainwin)
1355 gtk_widget_hide(mainwin->warning_btn);
1358 #define BREAK_ON_MODIFIER_KEY() \
1359 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
1361 static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
1364 MainWindow *mainwin = (MainWindow*) data;
1366 if (!mainwin || !event)
1369 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
1371 lastkey = event->keyval;
1375 switch (event->keyval) {
1376 case GDK_Q: /* Quit */
1377 BREAK_ON_MODIFIER_KEY();
1379 app_exit_cb(mainwin, 0, NULL);
1382 if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
1383 if (mainwin->folderview && mainwin->summaryview
1384 && ((!mainwin->summaryview->displayed
1385 && !mainwin->summaryview->selected)
1386 || (mainwin->summaryview->folder_item
1387 && mainwin->summaryview->folder_item->total_msgs == 0))) {
1388 g_signal_stop_emission_by_name(G_OBJECT(widget),
1390 folderview_select_next_unread(mainwin->folderview, TRUE);
1396 if (maemo_mainwindow_is_fullscreen(widget)) {
1397 gtk_window_unfullscreen(GTK_WINDOW(widget));
1399 gtk_window_fullscreen(GTK_WINDOW(widget));
1403 if (mainwin->summaryview &&
1404 mainwin->summaryview->ext_messageview &&
1405 mainwin->summaryview->ext_messageview->window &&
1406 widget == mainwin->summaryview->ext_messageview->window) {
1407 messageview_destroy(mainwin->summaryview->ext_messageview);
1417 #undef BREAK_ON_MODIFIER_KEY
1420 void mainwindow_maemo_led_set(gboolean state) {
1421 static gint last_state = -1;
1422 if (last_state == state)
1424 last_state = (gint)state;
1425 if (prefs_common.maemo_show_led) {
1427 execute_command_line("/usr/bin/dbus-send --system --type=method_call "
1428 "--dest=com.nokia.mce "
1429 "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_activate "
1430 "string:PatternCommunicationEvent", TRUE);
1431 execute_command_line("/usr/bin/dbus-send --system --type=method_call "
1432 "--dest=com.nokia.mce "
1433 "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_activate "
1434 "string:PatternCommunicationEmail", TRUE);
1436 execute_command_line("/usr/bin/dbus-send --system --type=method_call "
1437 "--dest=com.nokia.mce "
1438 "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_deactivate "
1439 "string:PatternCommunicationEvent", TRUE);
1440 execute_command_line("/usr/bin/dbus-send --system --type=method_call "
1441 "--dest=com.nokia.mce "
1442 "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_deactivate "
1443 "string:PatternCommunicationEmail", TRUE);
1448 static void led_update(FolderItem *removed_item)
1450 guint new, unread, unreadmarked, marked, total, replied;
1451 guint forwarded, locked, ignored, watched;
1453 folder_count_total_msgs(&new, &unread, &unreadmarked, &marked, &total,
1454 &replied, &forwarded, &locked, &ignored,
1457 total -= removed_item->total_msgs;
1458 new -= removed_item->new_msgs;
1459 unread -= removed_item->unread_msgs;
1463 mainwindow_maemo_led_set(TRUE);
1465 mainwindow_maemo_led_set(FALSE);
1468 static gboolean maemo_folder_item_update_hook(gpointer source, gpointer data)
1475 static gboolean maemo_folder_update_hook(gpointer source, gpointer data)
1477 FolderUpdateData *hookdata;
1479 if (hookdata->update_flags & FOLDER_REMOVE_FOLDERITEM)
1480 led_update(hookdata->item);
1487 static void main_window_install_maemo_hooks(MainWindow *mainwin)
1489 gint maemo_item_hook_id, maemo_folder_hook_id;
1491 maemo_item_hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, maemo_folder_item_update_hook, NULL);
1492 if (maemo_item_hook_id == -1) {
1496 maemo_folder_hook_id = hooks_register_hook (FOLDER_UPDATE_HOOKLIST, maemo_folder_update_hook, NULL);
1497 if (maemo_folder_hook_id == -1) {
1498 goto err_out_folder;
1504 hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, maemo_item_hook_id);
1510 MainWindow *main_window_create()
1512 MainWindow *mainwin;
1516 GtkWidget *handlebox;
1517 GtkWidget *vbox_body;
1518 #ifndef GENERIC_UMPC
1519 GtkWidget *hbox_stat;
1520 GtkWidget *statusbar;
1521 GtkWidget *progressbar;
1522 GtkWidget *statuslabel;
1523 GtkWidget *ac_button;
1524 GtkWidget *ac_label;
1525 GtkWidget *online_pixmap;
1526 GtkWidget *offline_pixmap;
1528 GtkWidget *warning_icon;
1529 GtkWidget *warning_btn;
1531 GtkWidget *online_switch;
1532 GtkWidget *offline_switch;
1533 FolderView *folderview;
1534 SummaryView *summaryview;
1535 MessageView *messageview;
1536 GdkColormap *colormap;
1538 gboolean success[4];
1539 GtkItemFactory *ifactory;
1541 GtkWidget *menuitem;
1543 guint n_menu_entries;
1545 static GdkGeometry geometry;
1547 debug_print("Creating main window...\n");
1548 mainwin = g_new0(MainWindow, 1);
1551 window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
1552 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1553 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1555 prefs_common.layout_mode = SMALL_LAYOUT;
1557 if (!geometry.min_height) {
1558 geometry.min_width = 320;
1559 geometry.min_height = 200;
1561 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1564 g_signal_connect(G_OBJECT(window), "delete_event",
1565 G_CALLBACK(main_window_close_cb), mainwin);
1566 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1567 g_signal_connect(G_OBJECT(window), "focus_in_event",
1568 G_CALLBACK(mainwindow_focus_in_event),
1570 g_signal_connect(G_OBJECT(window), "key_press_event",
1571 G_CALLBACK(mainwindow_key_pressed), mainwin);
1573 gtk_widget_realize(window);
1574 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1577 gtkut_widget_set_app_icon(window);
1579 vbox = gtk_vbox_new(FALSE, 0);
1580 gtk_widget_show(vbox);
1581 gtk_container_add(GTK_CONTAINER(window), vbox);
1584 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1585 menubar = menubar_create(window, mainwin_entries,
1586 n_menu_entries, "<Main>", mainwin);
1587 gtk_widget_show(menubar);
1590 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1593 ifactory = gtk_item_factory_from_widget(menubar);
1595 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1596 main_create_mailing_list_menu (mainwin, NULL); */
1598 if (prefs_common.toolbar_detachable) {
1599 handlebox = gtk_handle_box_new();
1600 gtk_widget_show(handlebox);
1601 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1602 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1603 G_CALLBACK(toolbar_child_attached), mainwin);
1604 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1605 G_CALLBACK(toolbar_child_detached), mainwin);
1607 handlebox = gtk_hbox_new(FALSE, 0);
1608 gtk_widget_show(handlebox);
1609 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1611 /* link window to mainwin->window to avoid gdk warnings */
1612 mainwin->window = window;
1613 mainwin_list = g_list_append(mainwin_list, mainwin);
1616 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1620 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1624 toolbar_set_learn_button
1628 /* vbox that contains body */
1629 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1630 gtk_widget_show(vbox_body);
1631 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1632 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1634 #ifndef GENERIC_UMPC
1635 hbox_stat = gtk_hbox_new(FALSE, 2);
1636 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1638 tips = gtk_tooltips_new();
1640 warning_icon = gtk_image_new_from_stock
1641 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1642 warning_btn = gtk_event_box_new();
1643 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1645 mainwin->warning_btn = warning_btn;
1647 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1648 G_CALLBACK(warning_icon_pressed),
1649 (gpointer) mainwin);
1650 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1651 G_CALLBACK(warning_visi_notify), mainwin);
1652 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1653 G_CALLBACK(warning_visi_notify), mainwin);
1654 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1655 G_CALLBACK(warning_leave_notify), mainwin);
1656 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1657 G_CALLBACK(warning_enter_notify), mainwin);
1659 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1661 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1662 _("Some error(s) happened. Click here to view log."), NULL);
1663 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1665 statusbar = statusbar_create();
1666 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1668 progressbar = gtk_progress_bar_new();
1669 gtk_widget_set_size_request(progressbar, 120, 1);
1670 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1672 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1673 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1674 online_switch = gtk_button_new ();
1675 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1676 _("You are online. Click the icon to go offline"), NULL);
1677 offline_switch = gtk_button_new ();
1678 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1679 _("You are offline. Click the icon to go online"),
1681 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1682 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1683 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1684 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1685 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1686 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1687 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1688 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1690 statuslabel = gtk_label_new("");
1691 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1693 ac_button = gtk_button_new();
1694 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1695 ac_button, _("Select account"), NULL);
1696 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1697 gtk_widget_set_size_request(ac_button, -1, 0);
1698 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1699 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1700 G_CALLBACK(ac_label_button_pressed), mainwin);
1702 ac_label = gtk_label_new("");
1703 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1705 gtk_widget_show_all(hbox_stat);
1707 gtk_widget_hide(offline_switch);
1708 gtk_widget_hide(warning_btn);
1710 online_switch = gtk_button_new ();
1711 offline_switch = gtk_button_new ();
1712 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1713 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1716 mainwin->folderview = folderview = folderview_create();
1717 mainwin->summaryview = summaryview = summary_create();
1718 mainwin->messageview = messageview = messageview_create(mainwin);
1720 /* init log instances data before creating log views */
1721 set_log_title(LOG_PROTOCOL, _("Network log"));
1722 set_log_prefs(LOG_PROTOCOL,
1723 &prefs_common.logwin_width,
1724 &prefs_common.logwin_height);
1725 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1726 set_log_prefs(LOG_DEBUG_FILTERING,
1727 &prefs_common.filtering_debugwin_width,
1728 &prefs_common.filtering_debugwin_height);
1730 /* setup log windows */
1731 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1732 log_window_init(mainwin->logwin);
1734 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1735 log_window_set_clipping(mainwin->logwin,
1736 prefs_common.cliplog,
1737 prefs_common.loglength);
1739 log_window_init(mainwin->filtering_debugwin);
1740 log_window_set_clipping(mainwin->filtering_debugwin,
1741 prefs_common.filtering_debug_cliplog,
1742 prefs_common.filtering_debug_loglength);
1743 if (prefs_common.enable_filtering_debug)
1744 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1746 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1748 folderview->mainwin = mainwin;
1749 folderview->summaryview = summaryview;
1751 summaryview->mainwin = mainwin;
1752 summaryview->folderview = folderview;
1753 summaryview->messageview = messageview;
1754 summaryview->window = window;
1756 mainwin->vbox = vbox;
1757 mainwin->menubar = menubar;
1758 mainwin->menu_factory = ifactory;
1759 mainwin->handlebox = handlebox;
1760 mainwin->vbox_body = vbox_body;
1761 mainwin->online_switch = online_switch;
1762 mainwin->offline_switch = offline_switch;
1763 #ifndef GENERIC_UMPC
1764 messageview->statusbar = statusbar;
1765 mainwin->statusbar = statusbar;
1766 mainwin->hbox_stat = hbox_stat;
1767 mainwin->progressbar = progressbar;
1768 mainwin->statuslabel = statuslabel;
1769 mainwin->online_pixmap = online_pixmap;
1770 mainwin->offline_pixmap = offline_pixmap;
1771 mainwin->ac_button = ac_button;
1772 mainwin->ac_label = ac_label;
1773 /* set context IDs for status bar */
1774 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1775 (GTK_STATUSBAR(statusbar), "Main Window");
1776 mainwin->folderview_cid = gtk_statusbar_get_context_id
1777 (GTK_STATUSBAR(statusbar), "Folder View");
1778 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1779 (GTK_STATUSBAR(statusbar), "Summary View");
1780 mainwin->messageview_cid = gtk_statusbar_get_context_id
1781 (GTK_STATUSBAR(statusbar), "Message View");
1782 messageview->statusbar_cid = mainwin->messageview_cid;
1785 messageview->statusbar = NULL;
1786 mainwin->statusbar = NULL;
1787 mainwin->hbox_stat = NULL;
1788 /* mainwin->progressbar is set in toolbar.c */
1789 mainwin->statuslabel = NULL;
1790 mainwin->online_pixmap = NULL;
1791 mainwin->offline_pixmap = NULL;
1792 mainwin->ac_button = NULL;
1793 mainwin->ac_label = NULL;
1796 /* allocate colors for summary view and folder view */
1797 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1798 summaryview->color_marked.blue = (guint16)65535;
1800 summaryview->color_dim.red = summaryview->color_dim.green =
1801 summaryview->color_dim.blue = COLOR_DIM;
1803 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1804 &folderview->color_new);
1806 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1807 &folderview->color_op);
1809 summaryview->color_important.red = 0;
1810 summaryview->color_important.green = 0;
1811 summaryview->color_important.blue = (guint16)65535;
1813 color[0] = summaryview->color_marked;
1814 color[1] = summaryview->color_dim;
1815 color[2] = folderview->color_new;
1816 color[3] = folderview->color_op;
1818 colormap = gdk_drawable_get_colormap(window->window);
1819 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1820 for (i = 0; i < 4; i++) {
1821 if (success[i] == FALSE)
1822 g_warning("MainWindow: color allocation %d failed\n", i);
1825 debug_print("done.\n");
1827 messageview->visible = prefs_common.msgview_visible;
1829 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1831 g_signal_connect(G_OBJECT(window), "size_allocate",
1832 G_CALLBACK(main_window_size_allocate_cb),
1835 /* set menu items */
1836 menuitem = gtk_item_factory_get_item
1837 (ifactory, "/View/Character encoding/Auto detect");
1838 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1840 switch (prefs_common.toolbar_style) {
1842 menuitem = gtk_item_factory_get_item
1843 (ifactory, "/View/Show or hide/Toolbar/Hide");
1846 menuitem = gtk_item_factory_get_item
1847 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1850 menuitem = gtk_item_factory_get_item
1851 (ifactory, "/View/Show or hide/Toolbar/Text only");
1854 menuitem = gtk_item_factory_get_item
1855 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1857 case TOOLBAR_BOTH_HORIZ:
1858 menuitem = gtk_item_factory_get_item
1860 "/View/Show or hide/Toolbar/Text beside icons");
1862 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1864 #ifndef GENERIC_UMPC
1865 gtk_widget_hide(mainwin->hbox_stat);
1866 menuitem = gtk_item_factory_get_item
1867 (ifactory, "/View/Show or hide/Status bar");
1868 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1869 prefs_common.show_statusbar);
1871 menuitem = gtk_item_factory_get_item
1872 (ifactory, "/View/Show or hide/Column headers");
1873 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1874 prefs_common.show_col_headers);
1875 /* set account selection menu */
1876 ac_menu = gtk_item_factory_get_widget
1877 (ifactory, "/Configuration/Change current account");
1878 mainwin->ac_menu = ac_menu;
1880 toolbar_main_set_sensitive(mainwin);
1882 /* create actions menu */
1883 main_window_update_actions_menu(mainwin);
1885 main_create_mailing_list_menu (mainwin, NULL);
1887 /* attach accel groups to main window */
1888 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1889 gtk_window_add_accel_group \
1891 gtk_item_factory_from_widget(menu)->accel_group); \
1892 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1894 G_CALLBACK(main_window_accel_activate), mainwin);
1897 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1899 /* connect the accelerators for equivalent
1900 menu items in different menus */
1901 menu_connect_identical_items();
1903 #ifndef GENERIC_UMPC
1904 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1907 g_signal_connect(G_OBJECT(window), "window_state_event",
1908 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1909 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1910 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1911 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1913 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1914 prefs_common.layout_mode == SMALL_LAYOUT) {
1915 summary_relayout(mainwin->summaryview);
1917 summary_update_unread(mainwin->summaryview, NULL);
1919 gtk_widget_show(mainwin->window);
1921 /* initialize views */
1922 folderview_init(folderview);
1923 summary_init(summaryview);
1924 messageview_init(messageview);
1925 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1926 sslcertwindow_register_hook();
1928 mainwin->lock_count = 0;
1929 mainwin->menu_lock_count = 0;
1930 mainwin->cursor_count = 0;
1932 mainwin->progressindicator_hook =
1933 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1936 watch_cursor = gdk_cursor_new(GDK_WATCH);
1938 hand_cursor = gdk_cursor_new(GDK_HAND2);
1940 /* init work_offline */
1941 if (prefs_common.work_offline)
1942 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1944 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1945 mainwindow_tags_menu_create(mainwin, FALSE);
1948 main_window_install_maemo_hooks(mainwin);
1953 void main_window_update_actions_menu(MainWindow *mainwin)
1955 GtkItemFactory *ifactory;
1957 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1958 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1961 void main_window_cursor_wait(MainWindow *mainwin)
1964 if (mainwin->cursor_count == 0) {
1965 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1966 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1969 mainwin->cursor_count++;
1974 void main_window_cursor_normal(MainWindow *mainwin)
1976 if (mainwin->cursor_count)
1977 mainwin->cursor_count--;
1979 if (mainwin->cursor_count == 0) {
1980 gdk_window_set_cursor(mainwin->window->window, NULL);
1981 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1986 /* lock / unlock the user-interface */
1987 void main_window_lock(MainWindow *mainwin)
1989 if (mainwin->lock_count == 0 && mainwin->ac_button)
1990 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1992 mainwin->lock_count++;
1994 main_window_set_menu_sensitive(mainwin);
1995 toolbar_main_set_sensitive(mainwin);
1998 void main_window_unlock(MainWindow *mainwin)
2000 if (mainwin->lock_count)
2001 mainwin->lock_count--;
2003 main_window_set_menu_sensitive(mainwin);
2004 toolbar_main_set_sensitive(mainwin);
2006 if (mainwin->lock_count == 0 && mainwin->ac_button)
2007 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
2010 static void main_window_menu_callback_block(MainWindow *mainwin)
2012 mainwin->menu_lock_count++;
2015 static void main_window_menu_callback_unblock(MainWindow *mainwin)
2017 if (mainwin->menu_lock_count)
2018 mainwin->menu_lock_count--;
2021 static guint prefs_tag = 0;
2023 void main_window_reflect_prefs_all(void)
2025 main_window_reflect_prefs_all_real(FALSE);
2028 static gboolean reflect_prefs_timeout_cb(gpointer data)
2030 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
2032 MainWindow *mainwin;
2033 #ifndef GENERIC_UMPC
2036 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2037 mainwin = (MainWindow *)cur->data;
2039 main_window_show_cur_account(mainwin);
2040 main_window_set_menu_sensitive(mainwin);
2041 toolbar_main_set_sensitive(mainwin);
2044 if (pixmap_theme_changed) {
2045 toolbar_update(TOOLBAR_MAIN, mainwin);
2046 messageview_reflect_prefs_pixmap_theme();
2047 compose_reflect_prefs_pixmap_theme();
2048 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
2049 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
2050 #ifndef GENERIC_UMPC
2051 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
2052 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
2053 mainwin->online_pixmap);
2054 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
2055 gtk_widget_show(pixmap);
2056 mainwin->online_pixmap = pixmap;
2057 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
2058 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
2059 mainwin->offline_pixmap);
2060 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
2061 gtk_widget_show(pixmap);
2062 mainwin->offline_pixmap = pixmap;
2066 headerview_set_font(mainwin->messageview->headerview);
2067 headerview_set_visibility(mainwin->messageview->headerview,
2068 prefs_common.display_header_pane);
2069 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
2070 folderview_reflect_prefs();
2071 summary_reflect_prefs();
2072 #ifndef GENERIC_UMPC
2073 summary_redisplay_msg(mainwin->summaryview);
2075 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2076 if (mainwin->in_folder) {
2077 mainwindow_enter_folder(mainwin);
2079 mainwindow_exit_folder(mainwin);
2087 void main_window_reflect_prefs_all_now(void)
2089 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
2092 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
2097 /* re-create colorlabel submenu */
2098 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
2099 g_return_if_fail(menu != NULL);
2101 /* clear items. get item pointers. */
2102 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
2103 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
2105 mainwindow_colorlabel_menu_create(mainwin, TRUE);
2106 summary_reflect_prefs_custom_colors(mainwin->summaryview);
2110 static gint tags_tag = 0;
2111 static gboolean main_window_reflect_tags_changes_real(gpointer data)
2115 MainWindow *mainwin = (MainWindow *)data;
2117 if (summary_is_locked(mainwin->summaryview)) {
2121 /* re-create tags submenu */
2122 menu = GTK_MENU_SHELL(mainwin->tags_menu);
2123 g_return_val_if_fail(menu != NULL, FALSE);
2125 /* clear items. get item pointers. */
2126 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
2127 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
2129 mainwindow_tags_menu_create(mainwin, TRUE);
2130 summary_reflect_tags_changes(mainwin->summaryview);
2136 void main_window_reflect_tags_changes(MainWindow *mainwin)
2138 if (tags_tag == 0) {
2139 tags_tag = g_timeout_add(100, main_window_reflect_tags_changes_real,
2144 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
2146 if (prefs_tag == 0 || pixmap_theme_changed) {
2147 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
2148 GINT_TO_POINTER(pixmap_theme_changed));
2152 void main_window_set_summary_column(void)
2155 MainWindow *mainwin;
2157 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2158 mainwin = (MainWindow *)cur->data;
2159 summary_set_column_order(mainwin->summaryview);
2163 void main_window_set_folder_column(void)
2166 MainWindow *mainwin;
2168 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2169 mainwin = (MainWindow *)cur->data;
2170 folderview_set_column_order(mainwin->folderview);
2174 static void main_window_set_account_selector_menu(MainWindow *mainwin,
2175 GList *account_list)
2177 GList *cur_ac, *cur_item;
2178 GtkWidget *menuitem;
2179 PrefsAccount *ac_prefs;
2181 /* destroy all previous menu item */
2182 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
2183 while (cur_item != NULL) {
2184 GList *next = cur_item->next;
2185 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2189 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2190 ac_prefs = (PrefsAccount *)cur_ac->data;
2192 menuitem = gtk_menu_item_new_with_label
2193 (ac_prefs->account_name
2194 ? ac_prefs->account_name : _("Untitled"));
2195 gtk_widget_show(menuitem);
2196 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
2197 g_signal_connect(G_OBJECT(menuitem), "activate",
2198 G_CALLBACK(account_selector_menu_cb),
2203 static void main_window_set_account_receive_menu(MainWindow *mainwin,
2204 GList *account_list)
2206 GList *cur_ac, *cur_item;
2208 GtkWidget *menuitem;
2209 PrefsAccount *ac_prefs;
2211 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
2212 "/Message/Receive");
2214 /* search for separator */
2215 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2216 cur_item = cur_item->next) {
2217 if (GTK_BIN(cur_item->data)->child == NULL) {
2218 cur_item = cur_item->next;
2223 /* destroy all previous menu item */
2224 while (cur_item != NULL) {
2225 GList *next = cur_item->next;
2226 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2230 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2231 ac_prefs = (PrefsAccount *)cur_ac->data;
2233 if (ac_prefs->protocol == A_NONE)
2236 menuitem = gtk_menu_item_new_with_label
2237 (ac_prefs->account_name ? ac_prefs->account_name
2239 gtk_widget_show(menuitem);
2240 gtk_menu_append(GTK_MENU(menu), menuitem);
2241 g_signal_connect(G_OBJECT(menuitem), "activate",
2242 G_CALLBACK(account_receive_menu_cb),
2247 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
2248 GList *account_list)
2251 GtkWidget *menuitem;
2252 PrefsAccount *ac_prefs;
2253 GtkWidget *menu = NULL;
2255 if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
2258 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
2260 gtk_widget_destroy(menu);
2261 menu = gtk_menu_new();
2263 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2264 ac_prefs = (PrefsAccount *)cur_ac->data;
2266 if (ac_prefs->protocol == A_NONE)
2269 menuitem = gtk_menu_item_new_with_label
2270 (ac_prefs->account_name
2271 ? ac_prefs->account_name : _("Untitled"));
2272 gtk_widget_show(menuitem);
2273 gtk_menu_append(GTK_MENU(menu), menuitem);
2274 g_signal_connect(G_OBJECT(menuitem), "activate",
2275 G_CALLBACK(account_receive_menu_cb),
2278 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
2281 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
2282 GList *account_list)
2284 #ifndef GENERIC_UMPC
2286 GtkWidget *menuitem;
2287 PrefsAccount *ac_prefs;
2288 GtkWidget *menu = NULL;
2290 if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
2293 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
2295 gtk_widget_destroy(menu);
2296 menu = gtk_menu_new();
2298 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2299 ac_prefs = (PrefsAccount *)cur_ac->data;
2301 menuitem = gtk_menu_item_new_with_label
2302 (ac_prefs->account_name
2303 ? ac_prefs->account_name : _("Untitled"));
2304 gtk_widget_show(menuitem);
2305 gtk_menu_append(GTK_MENU(menu), menuitem);
2306 g_signal_connect(G_OBJECT(menuitem), "activate",
2307 G_CALLBACK(account_compose_menu_cb),
2310 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
2314 void main_window_set_account_menu(GList *account_list)
2317 MainWindow *mainwin;
2319 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2320 mainwin = (MainWindow *)cur->data;
2321 main_window_set_account_selector_menu(mainwin, account_list);
2322 main_window_set_account_receive_menu(mainwin, account_list);
2323 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2324 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2326 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2329 void main_window_set_account_menu_only_toolbar(GList *account_list)
2332 MainWindow *mainwin;
2334 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2335 mainwin = (MainWindow *)cur->data;
2336 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2337 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2341 static void main_window_show_cur_account(MainWindow *mainwin)
2346 ac_name = g_strdup(cur_account
2347 ? (cur_account->account_name
2348 ? cur_account->account_name : _("Untitled"))
2352 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2354 buf = g_strdup(PROG_VERSION);
2355 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2358 if (mainwin->ac_label)
2359 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2360 if (mainwin->ac_button)
2361 gtk_widget_queue_resize(mainwin->ac_button);
2365 #ifndef GENERIC_UMPC
2366 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2368 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2369 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2370 GtkWidget *message_wid = mainwin->messageview->vbox;
2372 if (layout_mode == prefs_common.layout_mode)
2375 debug_print("Changing window separation type from %d to %d\n",
2376 prefs_common.layout_mode, layout_mode);
2378 /* remove widgets from those containers */
2379 gtk_widget_ref(folder_wid);
2380 gtk_widget_ref(summary_wid);
2381 gtk_widget_ref(message_wid);
2382 gtkut_container_remove
2383 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2384 gtkut_container_remove
2385 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2386 gtkut_container_remove
2387 (GTK_CONTAINER(message_wid->parent), message_wid);
2389 gtk_widget_hide(mainwin->window);
2390 main_window_set_widgets(mainwin, layout_mode);
2391 gtk_widget_show(mainwin->window);
2393 gtk_widget_unref(folder_wid);
2394 gtk_widget_unref(summary_wid);
2395 gtk_widget_unref(message_wid);
2398 void mainwindow_reset_paned(GtkPaned *paned)
2402 if (gtk_paned_get_child1(GTK_PANED(paned)))
2403 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2404 if (gtk_paned_get_child2(GTK_PANED(paned)))
2405 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2408 g_object_get (G_OBJECT(paned),
2411 g_object_get (G_OBJECT(paned),
2415 gtk_paned_set_position(GTK_PANED(paned), mid);
2418 static void mainwin_paned_show_first(GtkPaned *paned)
2421 g_object_get (G_OBJECT(paned),
2425 if (gtk_paned_get_child1(GTK_PANED(paned)))
2426 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2427 if (gtk_paned_get_child2(GTK_PANED(paned)))
2428 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2429 gtk_paned_set_position(GTK_PANED(paned), max);
2432 static void mainwin_paned_show_last(GtkPaned *paned)
2435 g_object_get (G_OBJECT(paned),
2439 if (gtk_paned_get_child1(GTK_PANED(paned)))
2440 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2441 if (gtk_paned_get_child2(GTK_PANED(paned)))
2442 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2443 gtk_paned_set_position(GTK_PANED(paned), min);
2446 void main_window_toggle_message_view(MainWindow *mainwin)
2448 SummaryView *summaryview = mainwin->summaryview;
2449 GtkWidget *ppaned = NULL;
2450 GtkWidget *container = NULL;
2452 switch (prefs_common.layout_mode) {
2454 case VERTICAL_LAYOUT:
2456 ppaned = mainwin->vpaned;
2457 container = mainwin->hpaned;
2458 if (ppaned->parent != NULL) {
2459 mainwin->messageview->visible = FALSE;
2460 summaryview->displayed = NULL;
2461 gtk_widget_ref(ppaned);
2462 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2463 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2465 mainwin->messageview->visible = TRUE;
2466 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2467 gtk_container_add(GTK_CONTAINER(container), ppaned);
2468 gtk_widget_unref(ppaned);
2472 ppaned = mainwin->hpaned;
2473 container = mainwin->vpaned;
2474 if (mainwin->messageview->vbox->parent != NULL) {
2475 mainwin->messageview->visible = FALSE;
2476 summaryview->displayed = NULL;
2477 gtk_widget_ref(mainwin->messageview->vbox);
2478 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2480 mainwin->messageview->visible = TRUE;
2481 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2482 gtk_widget_unref(mainwin->messageview->vbox);
2485 case WIDE_MSGLIST_LAYOUT:
2486 g_warning("can't hide messageview in this wide msglist layout");
2490 if (messageview_is_visible(mainwin->messageview))
2491 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2492 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2494 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2495 GTK_ARROW_UP, GTK_SHADOW_OUT);
2497 if (mainwin->messageview->visible == FALSE)
2498 messageview_clear(mainwin->messageview);
2500 main_window_set_menu_sensitive(mainwin);
2502 prefs_common.msgview_visible = mainwin->messageview->visible;
2504 if (messageview_is_visible(mainwin->messageview)) {
2505 gtk_widget_queue_resize(mainwin->hpaned);
2506 gtk_widget_queue_resize(mainwin->vpaned);
2508 summary_grab_focus(summaryview);
2509 if (!summary_is_list(summaryview)) {
2510 summary_show(summaryview, summaryview->folder_item);
2514 void main_window_get_size(MainWindow *mainwin)
2516 GtkAllocation *allocation;
2518 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2519 debug_print("called after messageview "
2520 "has been deallocated!\n");
2524 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2526 if (allocation->width > 1 && allocation->height > 1) {
2527 prefs_common.summaryview_width = allocation->width;
2529 if (messageview_is_visible(mainwin->messageview))
2530 prefs_common.summaryview_height = allocation->height;
2532 prefs_common.mainview_width = allocation->width;
2535 allocation = &mainwin->window->allocation;
2536 if (allocation->width > 1 && allocation->height > 1 &&
2537 !prefs_common.mainwin_maximised) {
2538 prefs_common.mainview_height = allocation->height;
2539 prefs_common.mainwin_width = allocation->width;
2540 prefs_common.mainwin_height = allocation->height;
2543 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2544 if (allocation->width > 1 && allocation->height > 1) {
2545 prefs_common.folderview_width = allocation->width;
2546 prefs_common.folderview_height = allocation->height;
2549 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2550 if (allocation->width > 1 && allocation->height > 1) {
2551 prefs_common.msgview_width = allocation->width;
2552 prefs_common.msgview_height = allocation->height;
2555 /* debug_print("summaryview size: %d x %d\n",
2556 prefs_common.summaryview_width,
2557 prefs_common.summaryview_height);
2558 debug_print("folderview size: %d x %d\n",
2559 prefs_common.folderview_width,
2560 prefs_common.folderview_height);
2561 debug_print("messageview size: %d x %d\n",
2562 prefs_common.msgview_width,
2563 prefs_common.msgview_height); */
2566 void main_window_get_position(MainWindow *mainwin)
2570 if (prefs_common.mainwin_maximised)
2573 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2575 prefs_common.mainview_x = x;
2576 prefs_common.mainview_y = y;
2577 prefs_common.mainwin_x = x;
2578 prefs_common.mainwin_y = y;
2580 debug_print("main window position: %d, %d\n", x, y);
2583 void main_window_progress_on(MainWindow *mainwin)
2585 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2588 void main_window_progress_off(MainWindow *mainwin)
2590 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2591 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2594 static gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean for_quit)
2596 if (confirm && procmsg_have_trashed_mails_fast()) {
2600 val = alertpanel(_("Empty trash"),
2601 _("Delete all messages in trash folders?"),
2602 GTK_STOCK_NO, "+" GTK_STOCK_YES, _("Don't quit"));
2604 val = alertpanel(_("Empty trash"),
2605 _("Delete all messages in trash folders?"),
2606 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL);
2607 if (val == G_ALERTALTERNATE) {
2608 debug_print("will empty trash\n");
2609 } else if (val == G_ALERTDEFAULT) {
2610 debug_print("will not empty trash\n");
2613 return FALSE; /* cancel exit */
2615 manage_window_focus_in(mainwin->window, NULL, NULL);
2618 procmsg_empty_all_trash();
2620 if (mainwin->summaryview->folder_item &&
2621 mainwin->summaryview->folder_item->stype == F_TRASH)
2622 gtk_widget_grab_focus(mainwin->folderview->ctree);
2626 static void main_window_add_mailbox(MainWindow *mainwin)
2631 path = input_dialog(_("Add mailbox"),
2632 _("Input the location of mailbox.\n"
2633 "If an existing mailbox is specified, it will be\n"
2634 "scanned automatically."),
2637 if (folder_find_from_path(path)) {
2638 alertpanel_error(_("The mailbox '%s' already exists."), path);
2642 folder = folder_new(folder_get_class_from_string("mh"),
2643 !strcmp(path, "Mail") ? _("Mailbox") :
2644 g_path_get_basename(path), path);
2647 if (folder->klass->create_tree(folder) < 0) {
2648 alertpanel_error(_("Creation of the mailbox failed.\n"
2649 "Maybe some files already exist, or you don't have the permission to write there."));
2650 folder_destroy(folder);
2655 folder_set_ui_func(folder, scan_tree_func, mainwin);
2656 folder_scan_tree(folder, TRUE);
2657 folder_set_ui_func(folder, NULL, NULL);
2660 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2662 SensitiveCond state = 0;
2663 SummarySelection selection;
2664 FolderItem *item = mainwin->summaryview->folder_item;
2665 GList *account_list = account_get_list();
2668 selection = summary_get_selection_type(mainwin->summaryview);
2670 if (mainwin->lock_count == 0 && !claws_is_starting())
2671 state |= M_UNLOCKED;
2672 if (selection != SUMMARY_NONE)
2673 state |= M_MSG_EXIST;
2674 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2676 /* if (item->folder->type != F_NEWS) */
2677 state |= M_ALLOW_DELETE;
2679 if (prefs_common.immediate_exec == 0
2680 && mainwin->lock_count == 0)
2681 state |= M_DELAY_EXEC;
2683 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2684 || selection != SUMMARY_NONE)
2685 state |= M_HIDE_READ_MSG;
2687 if (mainwin->summaryview->threaded)
2688 state |= M_THREADED;
2690 state |= M_UNTHREADED;
2691 if (selection == SUMMARY_SELECTED_SINGLE ||
2692 selection == SUMMARY_SELECTED_MULTIPLE)
2693 state |= M_TARGET_EXIST;
2694 if (selection == SUMMARY_SELECTED_SINGLE)
2695 state |= M_SINGLE_TARGET_EXIST;
2696 if (mainwin->summaryview->folder_item &&
2697 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2700 state |= M_NOT_NEWS;
2701 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2702 state |= M_ACTIONS_EXIST;
2704 tmp = tags_get_list();
2705 if (tmp && g_slist_length(tmp))
2706 state |= M_TAGS_EXIST;
2709 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2710 state |= M_HAVE_QUEUED_MAILS;
2712 if (selection == SUMMARY_SELECTED_SINGLE &&
2714 (folder_has_parent_of_type(item, F_DRAFT) ||
2715 folder_has_parent_of_type(item, F_OUTBOX) ||
2716 folder_has_parent_of_type(item, F_QUEUE))))
2717 state |= M_ALLOW_REEDIT;
2719 state |= M_HAVE_ACCOUNT;
2721 if (any_folder_want_synchronise())
2722 state |= M_WANT_SYNC;
2724 if (item && item->prefs->processing && selection != SUMMARY_NONE)
2725 state |= M_HAVE_PROCESSING;
2727 for ( ; account_list != NULL; account_list = account_list->next) {
2728 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2729 state |= M_HAVE_NEWS_ACCOUNT;
2734 if (procmsg_spam_can_learn() &&
2735 (mainwin->summaryview->folder_item &&
2736 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2737 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2738 state |= M_CAN_LEARN_SPAM;
2741 if (inc_is_active())
2742 state |= M_INC_ACTIVE;
2743 if (imap_cancel_all_enabled())
2744 state |= M_INC_ACTIVE;
2746 if (mainwin->summaryview->deleted > 0 ||
2747 mainwin->summaryview->moved > 0 ||
2748 mainwin->summaryview->copied > 0)
2749 state |= M_DELAY_EXEC;
2751 if (summary_is_list(mainwin->summaryview))
2752 state |= M_SUMMARY_ISLIST;
2759 void main_window_set_menu_sensitive(MainWindow *mainwin)
2761 GtkItemFactory *ifactory = mainwin->menu_factory;
2762 SensitiveCond state;
2765 GtkWidget *menuitem;
2766 SummaryView *summaryview;
2771 static const struct {
2775 {"/File/Save as...", M_TARGET_EXIST},
2776 {"/File/Print..." , M_TARGET_EXIST},
2777 {"/File/Synchronise folders", M_WANT_SYNC},
2778 {"/File/Exit" , M_UNLOCKED},
2780 {"/Edit/Select thread" , M_TARGET_EXIST|M_SUMMARY_ISLIST},
2781 {"/Edit/Delete thread" , M_TARGET_EXIST|M_SUMMARY_ISLIST},
2782 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2784 {"/View/Set displayed columns/in Folder list..."
2785 , M_UNLOCKED|M_SUMMARY_ISLIST},
2786 {"/View/Sort" , M_EXEC|M_SUMMARY_ISLIST},
2787 {"/View/Thread view" , M_EXEC|M_SUMMARY_ISLIST},
2788 {"/View/Expand all threads" , M_MSG_EXIST|M_SUMMARY_ISLIST},
2789 {"/View/Collapse all threads" , M_MSG_EXIST|M_SUMMARY_ISLIST},
2790 {"/View/Hide read messages" , M_HIDE_READ_MSG|M_SUMMARY_ISLIST},
2791 {"/View/Go to/Previous message" , M_MSG_EXIST},
2792 {"/View/Go to/Next message" , M_MSG_EXIST},
2793 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2794 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2795 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2796 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2797 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2798 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2799 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2800 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2801 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2802 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2803 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2805 {"/Message/Receive/Get from current account"
2806 , M_HAVE_ACCOUNT|M_UNLOCKED},
2807 {"/Message/Receive/Get from all accounts"
2808 , M_HAVE_ACCOUNT|M_UNLOCKED},
2809 {"/Message/Receive/Cancel receiving"
2811 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2812 {"/Message/Compose an email message", M_HAVE_ACCOUNT},
2813 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2814 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
2815 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
2816 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS|M_SUMMARY_ISLIST},
2817 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
2818 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
2819 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
2820 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2821 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2822 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2823 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2824 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2825 {"/Message/Mark" , M_TARGET_EXIST|M_SUMMARY_ISLIST},
2826 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2827 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2828 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2829 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2830 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2831 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2832 {"/Message/Color label" , M_TARGET_EXIST},
2833 {"/Message/Tags" , M_TARGET_EXIST},
2834 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2836 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2837 {"/Tools/Harvest addresses" , M_MSG_EXIST|M_SUMMARY_ISLIST},
2838 {"/Tools/Harvest addresses/from Messages..."
2840 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2841 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2842 {"/Tools/Run folder processing rules" , M_HAVE_PROCESSING},
2843 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2844 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2845 {"/Tools/List URLs..." , M_TARGET_EXIST},
2846 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2847 {"/Tools/Execute" , M_DELAY_EXEC},
2848 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2850 {"/Configuration", M_UNLOCKED},
2851 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2852 {"/Configuration/Create new account...", M_UNLOCKED},
2853 {"/Configuration/Edit accounts...", M_UNLOCKED},
2858 state = main_window_get_current_state(mainwin);
2860 for (i = 0; entry[i].entry != NULL; i++) {
2861 sensitive = ((entry[i].cond & state) == entry[i].cond);
2862 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2865 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2867 /* search for separator */
2868 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2869 cur_item = cur_item->next) {
2870 if (GTK_BIN(cur_item->data)->child == NULL) {
2871 cur_item = cur_item->next;
2876 for (; cur_item != NULL; cur_item = cur_item->next) {
2877 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2878 (M_UNLOCKED & state) != 0);
2881 main_window_menu_callback_block(mainwin);
2883 #define SET_CHECK_MENU_ACTIVE(path, active) \
2885 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2886 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2889 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2890 messageview_is_visible(mainwin->messageview));
2892 summaryview = mainwin->summaryview;
2893 menu_path = "/View/Sort/Don't sort";
2895 switch (summaryview->sort_key) {
2896 case SORT_BY_NUMBER:
2897 menu_path = "/View/Sort/by number"; break;
2899 menu_path = "/View/Sort/by Size"; break;
2901 menu_path = "/View/Sort/by Date"; break;
2902 case SORT_BY_THREAD_DATE:
2903 menu_path = "/View/Sort/by Thread date"; break;
2905 menu_path = "/View/Sort/by From"; break;
2907 menu_path = "/View/Sort/by To"; break;
2908 case SORT_BY_SUBJECT:
2909 menu_path = "/View/Sort/by Subject"; break;
2911 menu_path = "/View/Sort/by color label"; break;
2913 menu_path = "/View/Sort/by mark"; break;
2914 case SORT_BY_STATUS:
2915 menu_path = "/View/Sort/by status"; break;
2917 menu_path = "/View/Sort/by attachment"; break;
2919 menu_path = "/View/Sort/by score"; break;
2920 case SORT_BY_LOCKED:
2921 menu_path = "/View/Sort/by locked"; break;
2923 menu_path = "/View/Sort/by tag"; break;
2926 menu_path = "/View/Sort/Don't sort"; break;
2928 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2930 if (summaryview->sort_type == SORT_ASCENDING) {
2931 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2933 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2936 if (summaryview->sort_key != SORT_BY_NONE) {
2937 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2938 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2940 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2941 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2944 if (mainwin->messageview
2945 && mainwin->messageview->mimeview
2946 && mainwin->messageview->mimeview->textview)
2947 SET_CHECK_MENU_ACTIVE("/View/All headers",
2948 mainwin->messageview->mimeview->textview->show_all_headers);
2949 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2950 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2951 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2952 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2953 if (prefs_common.hide_quotes == 1)
2954 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2955 if (prefs_common.hide_quotes == 2)
2956 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2957 if (prefs_common.hide_quotes == 3)
2958 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2960 #undef SET_CHECK_MENU_ACTIVE
2962 main_window_menu_callback_unblock(mainwin);
2965 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2967 GtkItemFactory *ifactory;
2969 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2972 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2974 gtk_widget_set_sensitive (gtk_item_factory_get_item
2975 (ifactory,"/Message/Mailing-List"), TRUE);
2977 gtk_widget_set_sensitive (gtk_item_factory_get_item
2978 (ifactory,"/Message/Mailing-List"), FALSE);
2981 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2984 GtkWidget *menuitem;
2986 if (!msginfo || !msginfo->extradata) {
2987 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2988 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2989 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2990 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2991 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2992 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2996 /* Mailing list post */
2997 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2998 g_free(msginfo->extradata->list_post);
2999 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
3001 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
3003 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
3005 /* Mailing list help */
3006 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
3008 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
3010 /* Mailing list subscribe */
3011 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
3013 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
3015 /* Mailing list unsubscribe */
3016 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
3018 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
3020 /* Mailing list view archive */
3021 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
3023 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
3025 /* Mailing list contact owner */
3026 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
3028 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
3033 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
3035 GtkWidget *item, *menu;
3036 const gchar *url_pt ;
3037 gchar url_decoded[BUFFSIZE];
3038 GList *amenu, *alist;
3041 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
3043 /* First delete old submenu */
3044 /* FIXME: we can optimize this, and only change/add/delete necessary items */
3045 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
3046 alist = amenu->next;
3047 item = GTK_WIDGET (amenu->data);
3048 gtk_widget_destroy (item);
3052 for (url_pt = list_header; url_pt && *url_pt;) {
3053 get_url_part (&url_pt, url_decoded, BUFFSIZE);
3055 if (!g_ascii_strncasecmp(url_decoded, "mailto:", 7)) {
3056 item = gtk_menu_item_new_with_label ((url_decoded));
3057 g_signal_connect(G_OBJECT(item), "activate",
3058 G_CALLBACK(mailing_list_compose),
3061 else if (!g_ascii_strncasecmp(url_decoded, "http:", 5) ||
3062 !g_ascii_strncasecmp(url_decoded, "https:",6)) {
3064 item = gtk_menu_item_new_with_label ((url_decoded));
3065 g_signal_connect(G_OBJECT(item), "activate",
3066 G_CALLBACK(mailing_list_open_uri),
3070 gtk_menu_append (GTK_MENU(menu), item);
3071 gtk_widget_show (item);
3077 gtk_widget_set_sensitive (menuitem, TRUE);
3079 gtk_widget_set_sensitive (menuitem, FALSE);
3085 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
3087 gchar tmp[BUFFSIZE];
3091 gboolean with_plus = TRUE;
3094 *url_decoded = '\0';
3098 /* Ignore spaces, comments and tabs () */
3099 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
3101 for (;*buf != ')' && *buf != 0x00; buf++);
3103 /* First non space and non comment must be a < */
3106 if (!strncmp(buf, "mailto:", strlen("mailto:")))
3108 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
3113 *url_decoded = '\0';
3118 *url_decoded = '\0';
3124 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
3126 /* Prepare the work for the next url in the list */
3127 /* after the closing bracket >, ignore space, comments and tabs */
3128 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
3130 for (;*buf != ')' && *buf != 0x00; buf++);
3132 if (!buf || !*buf) {
3137 /* now first non space, non comment must be a comma */
3139 for (;*buf != 0x00; buf++);
3145 static void mailing_list_compose (GtkWidget *w, gpointer *data)
3149 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
3150 compose_new(NULL, mailto+7, NULL);
3153 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
3158 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
3159 open_uri (mailto, prefs_common_get_uri_cmd());
3162 void main_window_popup(MainWindow *mainwin)
3164 static gboolean first_start = TRUE;
3166 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
3167 main_window_show(mainwin);
3169 if (prefs_common.mainwin_maximised)
3170 gtk_window_maximize(GTK_WINDOW(mainwin->window));
3173 gtk_window_deiconify(GTK_WINDOW(mainwin->window));
3174 first_start = FALSE;
3176 gtkut_window_popup(mainwin->window);
3178 if (prefs_common.layout_mode == SMALL_LAYOUT) {
3179 if (mainwin->in_folder) {
3180 mainwindow_enter_folder(mainwin);
3182 mainwindow_exit_folder(mainwin);
3187 void main_window_show(MainWindow *mainwin)
3189 gtk_widget_show(mainwin->window);
3190 gtk_widget_show(mainwin->vbox_body);
3191 #ifndef GENERIC_UMPC
3192 gtk_widget_set_uposition(mainwin->window,
3193 prefs_common.mainwin_x,
3194 prefs_common.mainwin_y);
3196 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3197 prefs_common.folderview_width,
3198 prefs_common.folderview_height);
3199 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3200 prefs_common.summaryview_width,
3201 prefs_common.summaryview_height);
3202 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3203 prefs_common.msgview_width,
3204 prefs_common.msgview_height);
3208 void main_window_hide(MainWindow *mainwin)
3210 main_window_get_size(mainwin);
3211 main_window_get_position(mainwin);
3213 gtk_widget_hide(mainwin->window);
3214 gtk_widget_hide(mainwin->vbox_body);
3217 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
3219 GtkWidget *folderwin = NULL;
3220 GtkWidget *messagewin = NULL;
3223 GtkWidget *vbox_body = mainwin->vbox_body;
3224 GtkItemFactory *ifactory = mainwin->menu_factory;
3225 GtkWidget *menuitem;
3226 gboolean first_set = (mainwin->hpaned == NULL);
3227 debug_print("Setting widgets... ");
3229 if (layout_mode == SMALL_LAYOUT && first_set) {
3230 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3231 prefs_common.folderview_width,
3232 prefs_common.folderview_height);
3233 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3235 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3238 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3239 prefs_common.folderview_width,
3240 prefs_common.folderview_height);
3241 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3242 prefs_common.summaryview_width,
3243 prefs_common.summaryview_height);
3244 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3245 prefs_common.msgview_width,
3246 prefs_common.msgview_height);
3249 #ifndef GENERIC_UMPC
3250 mainwin->messageview->statusbar = mainwin->statusbar;
3251 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3253 /* clean top-most container */
3254 if (mainwin->hpaned) {
3255 if (mainwin->hpaned->parent == mainwin->vpaned)
3256 gtk_widget_destroy(mainwin->vpaned);
3258 gtk_widget_destroy(mainwin->hpaned);
3261 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
3262 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
3263 switch (layout_mode) {
3264 case VERTICAL_LAYOUT:
3267 hpaned = gtk_hpaned_new();
3268 if (layout_mode == VERTICAL_LAYOUT)
3269 vpaned = gtk_hpaned_new();
3271 vpaned = gtk_vpaned_new();
3272 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
3273 gtk_paned_add1(GTK_PANED(hpaned),
3274 GTK_WIDGET_PTR(mainwin->folderview));
3275 gtk_widget_show(hpaned);
3276 gtk_widget_queue_resize(hpaned);
3278 if (messageview_is_visible(mainwin->messageview)) {
3279 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
3280 gtk_paned_add1(GTK_PANED(vpaned),
3281 GTK_WIDGET_PTR(mainwin->summaryview));
3283 gtk_paned_add2(GTK_PANED(hpaned),
3284 GTK_WIDGET_PTR(mainwin->summaryview));
3285 gtk_widget_ref(vpaned);
3287 gtk_paned_add2(GTK_PANED(vpaned),
3288 GTK_WIDGET_PTR(mainwin->messageview));
3289 gtk_widget_show(vpaned);
3290 if (layout_mode == SMALL_LAYOUT && first_set) {
3291 mainwin_paned_show_first(GTK_PANED(hpaned));
3293 gtk_widget_queue_resize(vpaned);
3296 vpaned = gtk_vpaned_new();
3297 hpaned = gtk_hpaned_new();
3298 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3299 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
3301 gtk_paned_add1(GTK_PANED(hpaned),
3302 GTK_WIDGET_PTR(mainwin->folderview));
3303 gtk_paned_add2(GTK_PANED(hpaned),
3304 GTK_WIDGET_PTR(mainwin->summaryview));
3306 gtk_widget_show(hpaned);
3307 gtk_widget_queue_resize(hpaned);
3309 if (messageview_is_visible(mainwin->messageview)) {
3310 gtk_paned_add2(GTK_PANED(vpaned),
3311 GTK_WIDGET_PTR(mainwin->messageview));
3313 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3315 gtk_widget_show(vpaned);
3316 gtk_widget_queue_resize(vpaned);
3318 case WIDE_MSGLIST_LAYOUT:
3319 vpaned = gtk_vpaned_new();
3320 hpaned = gtk_hpaned_new();
3321 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3323 gtk_paned_add1(GTK_PANED(vpaned),
3324 GTK_WIDGET_PTR(mainwin->summaryview));
3325 gtk_paned_add1(GTK_PANED(hpaned),
3326 GTK_WIDGET_PTR(mainwin->folderview));
3328 gtk_widget_show(hpaned);
3329 gtk_widget_queue_resize(hpaned);
3331 if (messageview_is_visible(mainwin->messageview)) {
3332 gtk_paned_add2(GTK_PANED(hpaned),
3333 GTK_WIDGET_PTR(mainwin->messageview));
3335 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3337 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3339 gtk_widget_show(vpaned);
3340 gtk_widget_queue_resize(vpaned);
3343 g_warning("Unknown layout");
3347 mainwin->hpaned = hpaned;
3348 mainwin->vpaned = vpaned;
3350 if (layout_mode == SMALL_LAYOUT) {
3351 if (mainwin->messageview->visible)
3352 main_window_toggle_message_view(mainwin);
3355 if (layout_mode == SMALL_LAYOUT && first_set) {
3356 gtk_widget_realize(mainwin->window);
3357 gtk_widget_realize(mainwin->folderview->ctree);
3358 gtk_widget_realize(mainwin->summaryview->hbox);
3359 gtk_widget_realize(mainwin->summaryview->hbox_l);
3360 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3361 prefs_common.folderview_width,
3362 prefs_common.folderview_height);
3363 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3365 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3367 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3368 prefs_common.mainwin_width,
3369 prefs_common.mainwin_height);
3370 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3372 /* remove headerview if not in prefs */
3373 headerview_set_visibility(mainwin->messageview->headerview,
3374 prefs_common.display_header_pane);
3376 if (messageview_is_visible(mainwin->messageview))
3377 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3378 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3380 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3381 GTK_ARROW_UP, GTK_SHADOW_OUT);
3383 gtk_window_move(GTK_WINDOW(mainwin->window),
3384 prefs_common.mainwin_x,
3385 prefs_common.mainwin_y);
3387 gtk_widget_queue_resize(vbox_body);
3388 gtk_widget_queue_resize(mainwin->vbox);
3389 gtk_widget_queue_resize(mainwin->window);
3390 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3391 * and mimeview icon list/ctree lose track of their visibility states */
3392 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3393 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3394 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3395 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3396 if (mainwin->messageview->mimeview->ctree_mode)
3397 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3399 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3401 prefs_common.layout_mode = layout_mode;
3403 menuitem = gtk_item_factory_get_item
3404 (ifactory, "/View/Show or hide/Message view");
3405 gtk_check_menu_item_set_active
3406 (GTK_CHECK_MENU_ITEM(menuitem),
3407 messageview_is_visible(mainwin->messageview));
3409 #define SET_CHECK_MENU_ACTIVE(path, active) \
3411 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3412 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3415 #ifndef GENERIC_UMPC
3416 switch (prefs_common.layout_mode) {
3418 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3420 case VERTICAL_LAYOUT:
3421 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3424 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3426 case WIDE_MSGLIST_LAYOUT:
3427 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
3430 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
3434 #undef SET_CHECK_MENU_ACTIVE
3438 (G_OBJECT(folderwin), "size_allocate",
3439 G_CALLBACK(folder_window_size_allocate_cb),
3444 (G_OBJECT(messagewin), "size_allocate",
3445 G_CALLBACK(message_window_size_allocate_cb),
3449 debug_print("done.\n");
3452 void main_window_destroy_all(void)
3454 while (mainwin_list != NULL) {
3455 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
3457 /* free toolbar stuff */
3458 toolbar_clear_list(TOOLBAR_MAIN);
3459 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
3460 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
3462 summaryview_destroy(mainwin->summaryview);
3463 mainwin->folderview->mainwin = NULL;
3464 mainwin->summaryview->mainwin = NULL;
3465 mainwin->messageview->mainwin = NULL;
3467 g_free(mainwin->toolbar);
3470 mainwin_list = g_list_remove(mainwin_list, mainwin);
3472 g_list_free(mainwin_list);
3473 mainwin_list = NULL;
3476 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
3479 gtk_widget_set_size_request(child, 1, -1);
3482 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
3485 gtk_widget_set_size_request(child, -1, -1);
3487 #ifndef GENERIC_UMPC
3488 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
3491 MainWindow *mainwin = (MainWindow *)data;
3493 if (!event) return FALSE;
3495 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3496 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
3499 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3500 menu_button_position, widget,
3501 event->button, event->time);
3506 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3509 MainWindow *mainwin = (MainWindow *)data;
3510 gboolean close_allowed = TRUE;
3512 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
3514 if (close_allowed && mainwin->lock_count == 0)
3515 app_exit_cb(data, 0, widget);
3520 static void main_window_size_allocate_cb(GtkWidget *widget,
3521 GtkAllocation *allocation,
3524 MainWindow *mainwin = (MainWindow *)data;
3525 main_window_get_size(mainwin);
3528 static void folder_window_size_allocate_cb(GtkWidget *widget,
3529 GtkAllocation *allocation,
3532 MainWindow *mainwin = (MainWindow *)data;
3534 main_window_get_size(mainwin);
3537 static void message_window_size_allocate_cb(GtkWidget *widget,
3538 GtkAllocation *allocation,
3541 MainWindow *mainwin = (MainWindow *)data;
3543 main_window_get_size(mainwin);
3546 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3549 main_window_add_mailbox(mainwin);
3552 static void update_folderview_cb(MainWindow *mainwin, guint action,
3555 summary_show(mainwin->summaryview, NULL);
3556 folderview_check_new_all();
3559 static void foldersort_cb(MainWindow *mainwin, guint action,
3565 static void import_mbox_cb(MainWindow *mainwin, guint action,
3568 /* only notify if import has failed */
3569 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3570 alertpanel_error(_("Mbox import has failed."));
3574 static void export_mbox_cb(MainWindow *mainwin, guint action,
3577 /* only notify if export has failed */
3578 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3579 alertpanel_error(_("Export to mbox has failed."));
3583 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3586 /* only notify if export has failed */
3587 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3588 alertpanel_error(_("Export to mbox has failed."));
3592 static void empty_trash_cb(MainWindow *mainwin, guint action,
3595 main_window_empty_trash(mainwin, TRUE, FALSE);
3598 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3600 summary_save_as(mainwin->summaryview);
3603 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3605 summary_print(mainwin->summaryview);
3608 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
3609 static void page_setup_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3611 MainWindow *mainwindow;
3614 mainwindow = mainwindow_get_mainwindow();
3615 win = (mainwindow ? GTK_WINDOW(mainwindow->window) : NULL);
3617 printing_page_setup(win);
3621 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3623 if (prefs_common.clean_on_exit) {
3624 if (!main_window_empty_trash(mainwin, prefs_common.ask_on_clean, TRUE))
3628 if (prefs_common.confirm_on_exit) {
3629 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3630 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3631 != G_ALERTALTERNATE)
3633 manage_window_focus_in(mainwin->window, NULL, NULL);
3636 app_will_exit(widget, mainwin);
3639 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3642 summary_search(mainwin->summaryview);
3644 message_search(mainwin->messageview);
3647 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3649 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3652 static void toggle_message_cb(MainWindow *mainwin, guint action,
3657 active = GTK_CHECK_MENU_ITEM(widget)->active;
3659 if (active != messageview_is_visible(mainwin->messageview))
3660 summary_toggle_view(mainwin->summaryview);
3663 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3666 toolbar_toggle(action, mainwin);
3669 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3672 MessageView *msgview = (MessageView*)mainwin->messageview;
3673 GSList *msginfo_list = NULL;
3675 g_return_if_fail(msgview != NULL);
3677 msginfo_list = summary_get_selection(mainwin->summaryview);
3678 g_return_if_fail(msginfo_list != NULL);
3679 compose_reply_from_messageview(msgview, msginfo_list, action);
3680 g_slist_free(msginfo_list);
3683 static void toggle_col_headers_cb(MainWindow *mainwin, guint action,
3686 FolderView *folderview = mainwin->folderview;
3687 SummaryView *summaryview = mainwin->summaryview;
3689 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3690 gtk_clist_column_titles_show(GTK_CLIST(folderview->ctree));
3691 gtk_clist_column_titles_show(GTK_CLIST(summaryview->ctree));
3692 prefs_common.show_col_headers = TRUE;
3694 gtk_clist_column_titles_hide(GTK_CLIST(folderview->ctree));
3695 gtk_clist_column_titles_hide(GTK_CLIST(summaryview->ctree));
3696 prefs_common.show_col_headers = FALSE;
3700 #ifndef GENERIC_UMPC
3701 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3704 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3705 gtk_widget_show(mainwin->hbox_stat);
3706 prefs_common.show_statusbar = TRUE;
3708 gtk_widget_hide(mainwin->hbox_stat);
3709 prefs_common.show_statusbar = FALSE;
3713 static void set_layout_cb(MainWindow *mainwin, guint action,
3716 LayoutType layout_mode = action;
3717 LayoutType old_layout_mode = prefs_common.layout_mode;
3718 if (mainwin->menu_lock_count) {
3721 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3725 if (layout_mode == prefs_common.layout_mode) {
3729 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3730 main_window_toggle_message_view(mainwin);
3731 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3732 main_window_toggle_message_view(mainwin);
3734 main_window_separation_change(mainwin, layout_mode);
3735 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3736 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3737 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3739 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3740 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3741 mainwindow_exit_folder(mainwin);
3743 summary_relayout(mainwin->summaryview);
3744 summary_update_unread(mainwin->summaryview, NULL);
3748 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3751 offline_ask_sync = ask_sync;
3753 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3755 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3756 offline_ask_sync = TRUE;
3759 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3761 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3764 static gboolean any_folder_want_synchronise(void)
3766 GList *folderlist = folder_get_list();
3768 /* see if there are synchronised folders */
3769 for (; folderlist; folderlist = folderlist->next) {
3770 Folder *folder = (Folder *)folderlist->data;
3771 if (folder_want_synchronise(folder)) {
3779 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3782 if (!any_folder_want_synchronise())
3785 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3786 _("Do you want to synchronise your folders now?"),
3787 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3790 if (offline_ask_sync)
3791 folder_synchronise(NULL);
3794 static void online_switch_clicked (GtkButton *btn, gpointer data)
3796 MainWindow *mainwin;
3797 GtkItemFactory *ifactory;
3798 GtkCheckMenuItem *menuitem;
3799 gboolean have_connectivity;
3801 #ifdef HAVE_NETWORKMANAGER
3802 have_connectivity = networkmanager_is_online(NULL);
3804 have_connectivity = TRUE;
3807 mainwin = (MainWindow *) data;
3809 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3810 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3812 g_return_if_fail(mainwin != NULL);
3813 g_return_if_fail(menuitem != NULL);
3815 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3816 #ifndef GENERIC_UMPC
3817 gtk_widget_hide (mainwin->online_switch);
3818 gtk_widget_show (mainwin->offline_switch);
3820 menuitem->active = TRUE;
3821 inc_autocheck_timer_remove();
3824 if (prefs_common.work_offline)
3827 if(have_connectivity)
3828 mainwindow_check_synchronise(mainwin, TRUE);
3829 prefs_common.work_offline = TRUE;
3830 imap_disconnect_all();
3831 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3834 if (!prefs_common.work_offline)
3836 #ifndef GENERIC_UMPC
3837 gtk_widget_hide (mainwin->offline_switch);
3838 gtk_widget_show (mainwin->online_switch);
3840 menuitem->active = FALSE;
3841 prefs_common.work_offline = FALSE;
3842 inc_autocheck_timer_set();
3843 refresh_resolvers();
3844 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3848 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3851 addressbook_open(NULL);
3854 static void log_window_show_cb(MainWindow *mainwin, guint action,
3857 log_window_show(mainwin->logwin);
3860 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3863 log_window_show(mainwin->filtering_debugwin);
3866 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3872 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3874 summary_move_to(mainwin->summaryview);
3877 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3879 summary_copy_to(mainwin->summaryview);
3882 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3884 summary_delete(mainwin->summaryview);
3887 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3889 summary_delete_trash(mainwin->summaryview);
3892 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3894 summary_cancel(mainwin->summaryview);
3897 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3899 summary_open_msg(mainwin->summaryview);
3902 static void view_source_cb(MainWindow *mainwin, guint action,
3905 summary_view_source(mainwin->summaryview);
3908 static void show_all_header_cb(MainWindow *mainwin, guint action,
3911 if (mainwin->menu_lock_count) return;
3912 mainwin->summaryview->messageview->all_headers =
3913 GTK_CHECK_MENU_ITEM(widget)->active;
3914 summary_display_msg_selected(mainwin->summaryview,
3915 GTK_CHECK_MENU_ITEM(widget)->active);
3918 #define SET_CHECK_MENU_ACTIVE(path, active) \
3920 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3921 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3924 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3927 GtkWidget *menuitem;
3928 GtkItemFactory *ifactory = mainwin->menu_factory;
3930 if (mainwin->menu_lock_count) return;
3932 prefs_common.hide_quotes =
3933 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3935 mainwin->menu_lock_count++;
3936 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3937 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3938 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3939 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3940 mainwin->menu_lock_count--;
3942 summary_redisplay_msg(mainwin->summaryview);
3945 #undef SET_CHECK_MENU_ACTIVE
3946 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3948 summary_mark(mainwin->summaryview);
3951 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3953 summary_unmark(mainwin->summaryview);
3956 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3959 summary_mark_as_unread(mainwin->summaryview);
3962 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3965 summary_mark_as_read(mainwin->summaryview);
3968 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3971 summary_mark_all_read(mainwin->summaryview);
3974 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3977 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3980 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3983 summary_ignore_thread(mainwin->summaryview);
3986 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3989 summary_unignore_thread(mainwin->summaryview);
3992 static void watch_thread_cb(MainWindow *mainwin, guint action,
3995 summary_watch_thread(mainwin->summaryview);
3998 static void unwatch_thread_cb(MainWindow *mainwin, guint action,
4001 summary_unwatch_thread(mainwin->summaryview);
4004 static void lock_msgs_cb(MainWindow *mainwin, guint action,
4007 summary_msgs_lock(mainwin->summaryview);
4010 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
4013 summary_msgs_unlock(mainwin->summaryview);
4017 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4019 summary_reedit(mainwin->summaryview);
4022 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4024 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
4025 summary_display_msg_selected(mainwin->summaryview,
4026 mainwin->messageview->mimeview->textview->show_all_headers);
4028 messageview_list_urls(mainwin->messageview);
4031 static void add_address_cb(MainWindow *mainwin, guint action,
4034 summary_add_address(mainwin->summaryview);
4037 static void set_charset_cb(MainWindow *mainwin, guint action,
4042 if (GTK_CHECK_MENU_ITEM(widget)->active) {
4043 str = conv_get_charset_str((CharSet)action);
4045 g_free(mainwin->messageview->forced_charset);
4046 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
4047 procmime_force_charset(str);
4049 summary_redisplay_msg(mainwin->summaryview);
4051 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
4055 static void set_decode_cb(MainWindow *mainwin, guint action,
4058 if (GTK_CHECK_MENU_ITEM(widget)->active) {
4059 mainwin->messageview->forced_encoding = (EncodingType)action;
4061 summary_redisplay_msg(mainwin->summaryview);
4063 debug_print("forced encoding: %d\n", action);
4067 static void hide_read_messages (MainWindow *mainwin, guint action,
4070 if (!mainwin->summaryview->folder_item
4071 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
4073 summary_toggle_show_read_messages(mainwin->summaryview);
4076 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4078 gboolean threaded = FALSE;
4079 if (mainwin->menu_lock_count) return;
4080 if (!mainwin->summaryview->folder_item) return;
4082 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
4084 mainwin->summaryview->folder_item->threaded = threaded;
4086 mainwin->summaryview->threaded = threaded;
4088 summary_show(mainwin->summaryview,
4089 mainwin->summaryview->folder_item);
4092 static void expand_threads_cb(MainWindow *mainwin, guint action,
4095 summary_expand_threads(mainwin->summaryview);
4098 static void collapse_threads_cb(MainWindow *mainwin, guint action,
4101 summary_collapse_threads(mainwin->summaryview);
4104 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
4107 prefs_summary_column_open();
4110 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
4113 prefs_folder_column_open();
4116 static void sort_summary_cb(MainWindow *mainwin, guint action,
4119 FolderItem *item = mainwin->summaryview->folder_item;
4120 GtkWidget *menuitem;
4122 if (mainwin->menu_lock_count) return;
4124 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
4125 menuitem = gtk_item_factory_get_item
4126 (mainwin->menu_factory, "/View/Sort/Ascending");
4127 summary_sort(mainwin->summaryview, (FolderSortKey)action,
4128 GTK_CHECK_MENU_ITEM(menuitem)->active
4129 ? SORT_ASCENDING : SORT_DESCENDING);
4130 item->sort_key = action;
4134 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
4137 FolderItem *item = mainwin->summaryview->folder_item;
4139 if (mainwin->menu_lock_count) return;
4141 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
4142 summary_sort(mainwin->summaryview,
4143 item->sort_key, (FolderSortType)action);
4146 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
4149 summary_attract_by_subject(mainwin->summaryview);
4152 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
4157 item = folderview_get_selected_item(mainwin->folderview);
4159 main_window_cursor_wait(mainwin);
4160 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
4162 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
4163 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
4165 STATUSBAR_POP(mainwin);
4166 main_window_cursor_normal(mainwin);
4176 static void deldup_all(FolderItem *item, gpointer _data)
4178 struct DelDupsData *data = _data;
4181 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
4183 data->dups += result;
4188 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
4191 struct DelDupsData data = {0, 0};
4193 main_window_cursor_wait(mainwin);
4194 folder_func_to_all_folders(deldup_all, &data);
4195 main_window_cursor_normal(mainwin);
4197 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
4198 "Deleted %d duplicate messages in %d folders.\n",
4200 data.dups, data.folders);
4203 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4205 summary_filter(mainwin->summaryview, (gboolean)action);
4208 static void process_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4210 FolderItem *item = mainwin->summaryview->folder_item;
4211 g_return_if_fail(item != NULL);
4213 item->processing_pending = TRUE;
4214 folder_item_apply_processing(item);
4215 item->processing_pending = FALSE;
4218 static void execute_summary_cb(MainWindow *mainwin, guint action,
4221 summary_execute(mainwin->summaryview);
4224 static void update_summary_cb(MainWindow *mainwin, guint action,
4228 FolderView *folderview = mainwin->folderview;
4230 if (!mainwin->summaryview->folder_item) return;
4231 if (!folderview->opened) return;
4233 folder_update_op_count();
4235 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
4236 folderview->opened);
4239 folder_item_scan(fitem);
4240 summary_show(mainwin->summaryview, fitem);
4243 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4245 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
4248 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4250 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
4253 static void prev_unread_cb(MainWindow *mainwin, guint action,
4256 summary_select_prev_unread(mainwin->summaryview);
4259 static void next_unread_cb(MainWindow *mainwin, guint action,
4262 summary_select_next_unread(mainwin->summaryview);
4265 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4267 summary_select_prev_new(mainwin->summaryview);
4270 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4272 summary_select_next_new(mainwin->summaryview);
4275 static void prev_marked_cb(MainWindow *mainwin, guint action,
4278 summary_select_prev_marked(mainwin->summaryview);
4281 static void next_marked_cb(MainWindow *mainwin, guint action,
4284 summary_select_next_marked(mainwin->summaryview);
4287 static void prev_labeled_cb(MainWindow *mainwin, guint action,
4290 summary_select_prev_labeled(mainwin->summaryview);
4293 static void next_labeled_cb(MainWindow *mainwin, guint action,
4296 summary_select_next_labeled(mainwin->summaryview);
4299 static void last_read_cb(MainWindow *mainwin, guint action,
4302 summary_select_last_read(mainwin->summaryview);
4305 static void parent_cb(MainWindow *mainwin, guint action,
4308 summary_select_parent(mainwin->summaryview);
4311 static void goto_folder_cb(MainWindow *mainwin, guint action,
4314 FolderItem *to_folder;
4316 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL, FALSE);
4319 folderview_select(mainwin->folderview, to_folder);
4322 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
4325 folderview_select_next_unread(mainwin->folderview, FALSE);
4328 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4330 messageview_copy_clipboard(mainwin->messageview);
4333 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4335 MessageView *msgview = mainwin->messageview;
4337 if (messageview_is_visible(msgview) &&
4338 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
4339 messageview_select_all(mainwin->messageview);
4341 summary_select_all(mainwin->summaryview);
4344 static void select_thread_cb(MainWindow *mainwin, guint action,
4347 summary_select_thread(mainwin->summaryview, FALSE);
4350 static void delete_thread_cb(MainWindow *mainwin, guint action,
4353 summary_select_thread(mainwin->summaryview, TRUE);
4356 static void create_filter_cb(MainWindow *mainwin, guint action,
4359 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
4362 static void create_processing_cb(MainWindow *mainwin, guint action,
4365 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
4368 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
4371 prefs_filtering_open(&pre_global_processing,
4372 _("Processing rules to apply before folder rules"),
4373 MANUAL_ANCHOR_PROCESSING,
4377 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
4380 prefs_filtering_open(&post_global_processing,
4381 _("Processing rules to apply after folder rules"),
4382 MANUAL_ANCHOR_PROCESSING,
4386 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
4389 prefs_filtering_open(&filtering_rules,
4390 _("Filtering configuration"),
4391 MANUAL_ANCHOR_FILTERING,
4395 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
4398 prefs_template_open();
4401 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
4404 prefs_actions_open(mainwin);
4407 static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
4410 GSList * list = summary_get_selected_msg_list(mainwin->summaryview);
4411 tag_apply_open(list);
4413 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
4414 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
4417 ssl_manager_open(mainwin);
4420 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
4424 new_account_cb(mainwin, 0, widget);
4426 account_open(cur_account);
4430 static void new_account_cb(MainWindow *mainwin, guint action,
4433 account_edit_open();
4434 if (!compose_get_compose_list()) account_add();
4437 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
4439 FolderItem *item = NULL;
4440 cur_account = (PrefsAccount *)data;
4442 if (!mainwindow_get_mainwindow())
4444 main_window_show_cur_account(mainwindow_get_mainwindow());
4445 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
4446 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
4447 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
4448 item = folderview_get_selected_item(
4449 mainwindow_get_mainwindow()->folderview);
4451 toolbar_set_compose_button
4452 (mainwindow_get_mainwindow()->toolbar,
4453 FOLDER_TYPE(item->folder) == F_NEWS ?
4454 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
4458 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
4460 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4461 PrefsAccount *account = (PrefsAccount *)data;
4463 inc_account_mail(mainwin, account);
4465 #ifndef GENERIC_UMPC
4466 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
4468 PrefsAccount *account = (PrefsAccount *)data;
4470 compose_new_with_folderitem(account, NULL, NULL);
4473 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
4478 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
4480 pluginwindow_create();
4483 static void manual_open_cb(MainWindow *mainwin, guint action,
4486 manual_open((ManualType)action, NULL);
4489 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
4494 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
4496 MainWindow *mainwin = (MainWindow *)data;
4500 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
4501 LOCAL_FOLDER(folder)->rootpath,
4505 str = g_strdup_printf(_("Scanning folder %s ..."),
4506 LOCAL_FOLDER(folder)->rootpath);
4508 STATUSBAR_PUSH(mainwin, str);
4509 STATUSBAR_POP(mainwin);
4513 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
4516 SummaryView *summary;
4518 g_return_val_if_fail(data, FALSE);
4519 if (!g_list_find(mainwin_list, data))
4521 summary = ((MainWindow *)data)->summaryview;
4522 g_return_val_if_fail(summary, FALSE);
4524 if (GTK_CLIST(summary->ctree)->selection &&
4525 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
4531 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
4534 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
4538 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
4541 if (!claws_is_starting()
4542 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
4543 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
4545 if (iconified_count > 0)
4546 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
4548 } else if (!claws_is_starting()) {
4549 prefs_common.mainwin_maximised =
4550 ((state->new_window_state&GDK_WINDOW_STATE_MAXIMIZED) != 0);
4552 if (state->new_window_state == 0)
4553 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
4557 gboolean mainwindow_is_obscured(void)
4563 * Harvest addresses for selected folder.
4565 static void addr_harvest_cb( MainWindow *mainwin,
4569 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4573 * Harvest addresses for selected messages in summary view.
4575 static void addr_harvest_msg_cb( MainWindow *mainwin,
4579 summary_harvest_address( mainwin->summaryview );
4583 *\brief get a MainWindow
4585 *\return MainWindow * The first mainwindow in the mainwin_list
4587 MainWindow *mainwindow_get_mainwindow(void)
4589 if (mainwin_list && mainwin_list->data)
4590 return (MainWindow *)(mainwin_list->data);
4595 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4597 ProgressData *data = (ProgressData *) source;
4598 MainWindow *mainwin = (MainWindow *) userdata;
4600 switch (data->cmd) {
4601 case PROGRESS_COMMAND_START:
4602 case PROGRESS_COMMAND_STOP:
4603 gtk_progress_bar_set_fraction
4604 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4606 case PROGRESS_COMMAND_SET_PERCENTAGE:
4607 gtk_progress_bar_set_fraction
4608 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4611 while (gtk_events_pending()) gtk_main_iteration ();
4616 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4618 mainwindow_check_synchronise(mainwin, FALSE);
4621 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4623 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4626 void mainwindow_jump_to(const gchar *target, gboolean popup)
4630 FolderItem *item = NULL;
4632 MainWindow *mainwin = mainwindow_get_mainwindow();
4633 gchar *from_uri = NULL;
4638 g_print("not initialized\n");
4642 if ((from_uri = g_filename_from_uri(target, NULL, NULL)) != NULL)
4645 tmp = g_strdup(target);
4647 if ((p = strstr(tmp, "\r")) != NULL)
4649 if ((p = strstr(tmp, "\n")) != NULL)
4652 if ((item = folder_find_item_from_identifier(tmp))) {
4653 g_print("selecting folder '%s'\n", tmp);
4654 folderview_select(mainwin->folderview, item);
4656 main_window_popup(mainwin);
4661 msg = strrchr(tmp, G_DIR_SEPARATOR);
4664 if ((item = folder_find_item_from_identifier(tmp))) {
4665 g_print("selecting folder '%s'\n", tmp);
4666 folderview_select(mainwin->folderview, item);
4667 } else if ((item = folder_find_item_from_real_path(tmp))) {
4668 g_print("selecting folder '%s'\n", tmp);
4669 folderview_select(mainwin->folderview, item);
4671 g_print("'%s' not found\n", tmp);
4673 if (item && msg && atoi(msg)) {
4674 g_print("selecting message %d\n", atoi(msg));
4675 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4676 summary_display_msg_selected(mainwin->summaryview, FALSE);
4678 main_window_popup(mainwin);
4681 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4682 MsgInfo *msginfo = NULL;
4684 msg[strlen(msg)-1] = '\0';
4685 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4687 g_print("selecting message %s\n", msg);
4688 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4689 summary_display_msg_selected(mainwin->summaryview, FALSE);
4691 main_window_popup(mainwin);
4693 procmsg_msginfo_free(msginfo);
4696 g_print("'%s' not found\n", msg);
4699 g_print("'%s' not found\n", msg);
4702 g_print("'%s' not found\n", tmp);
4708 void mainwindow_exit_folder(MainWindow *mainwin) {
4709 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4710 folderview_close_opened(mainwin->folderview);
4711 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4712 gtk_widget_grab_focus(mainwin->folderview->ctree);
4714 mainwin->in_folder = FALSE;
4717 void mainwindow_enter_folder(MainWindow *mainwin) {
4718 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4719 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4721 mainwin->in_folder = TRUE;
4725 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4728 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4732 void maemo_window_full_screen_if_needed (GtkWindow *window)
4734 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4735 gtk_window_fullscreen(GTK_WINDOW(window));
4739 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4741 g_signal_connect(G_OBJECT(window), "key_press_event",
4742 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());