talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

mainwindow.c (167252B)


      1 /*
      2  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
      3  * Copyright (C) 1999-2025 the Claws Mail team and Hiroyuki Yamamoto
      4  *
      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.
      9  *
     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.
     14  *
     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/>.
     17  */
     18 
     19 #include "defs.h"
     20 
     21 #include <glib.h>
     22 #include <glib/gi18n.h>
     23 #include <gdk/gdkkeysyms.h>
     24 #include <gtk/gtk.h>
     25 #include <string.h>
     26 #include <stdarg.h>
     27 
     28 #include "main.h"
     29 #include "mainwindow.h"
     30 #include "folderview.h"
     31 #include "folder_item_prefs.h"
     32 #include "foldersel.h"
     33 #include "summaryview.h"
     34 #include "messageview.h"
     35 #include "mimeview.h"
     36 #include "message_search.h"
     37 #include "menu.h"
     38 #include "stock_pixmap.h"
     39 #include "folder.h"
     40 #include "inc.h"
     41 #include "log.h"
     42 #include "compose.h"
     43 #include "procmsg.h"
     44 #include "password.h"
     45 #include "prefs_common.h"
     46 #include "prefs_actions.h"
     47 #include "prefs_account.h"
     48 #include "prefs_summary_column.h"
     49 #include "prefs_folder_column.h"
     50 #include "action.h"
     51 #include "account.h"
     52 #include "addressbook.h"
     53 #include "logwindow.h"
     54 #include "manage_window.h"
     55 #include "alertpanel.h"
     56 #include "statusbar.h"
     57 #include "inputdialog.h"
     58 #include "utils.h"
     59 #include "gtkutils.h"
     60 #include "codeconv.h"
     61 #include "manual.h"
     62 #include "version.h"
     63 #include "prefs_gtk.h"
     64 #include "hooks.h"
     65 #include "progressindicator.h"
     66 #include "localfolder.h"
     67 #include "folderutils.h"
     68 #include "foldersort.h"
     69 #include "icon_legend.h"
     70 #include "textview.h"
     71 #include "imap.h"
     72 #include "socket.h"
     73 #include "send_message.h"
     74 
     75 /*
     76  * longer labels crash the X Window System with error:
     77  * 'BadAlloc (insufficient resources for operation)'
     78  */
     79 #define MAX_MENU_LABEL_LENGTH		5453
     80 
     81 /* list of all instantiated MainWindow */
     82 static GList *mainwin_list = NULL;
     83 
     84 static GdkCursor *watch_cursor = NULL;
     85 static GdkCursor *hand_cursor = NULL;
     86 
     87 static gint iconified_count = 0;
     88 
     89 static void main_window_menu_callback_block	(MainWindow	*mainwin);
     90 static void main_window_menu_callback_unblock	(MainWindow	*mainwin);
     91 
     92 static void main_window_show_cur_account	(MainWindow	*mainwin);
     93 
     94 static void main_window_separation_change	(MainWindow	*mainwin,
     95 						 LayoutType	 layout_mode);
     96 
     97 static void main_window_set_widgets		(MainWindow	*mainwin,
     98 						 LayoutType	 layout_mode);
     99 
    100 static gboolean ac_label_button_pressed		(GtkWidget	*widget,
    101 						 GdkEventButton	*event,
    102 						 gpointer	 data);
    103 
    104 static gint main_window_close_cb		(GtkWidget	*widget,
    105 						 GdkEventAny	*event,
    106 						 gpointer	 data);
    107 
    108 static void main_window_size_allocate_cb	(GtkWidget	*widget,
    109 						 GtkAllocation	*allocation,
    110 						 gpointer	 data);
    111 static void folder_window_size_allocate_cb	(GtkWidget	*widget,
    112 						 GtkAllocation	*allocation,
    113 						 gpointer	 data);
    114 static void message_window_size_allocate_cb	(GtkWidget	*widget,
    115 						 GtkAllocation	*allocation,
    116 						 gpointer	 data);
    117 
    118 static void update_folderview_cb (GtkAction	*action,
    119 				  gpointer	 data);
    120 static void add_mailbox_cb	 (GtkAction	*action,
    121 				  gpointer	 data);
    122 static void foldersort_cb	 (GtkAction	*action,
    123 				  gpointer	 data);
    124 static void empty_trash_cb	 (GtkAction	*action,
    125 				  gpointer	 data);
    126 static void save_as_cb		 (GtkAction	*action,
    127 				  gpointer	 data);
    128 static void app_exit_cb		 (GtkAction	*action,
    129 				  gpointer	 data);
    130 
    131 
    132 static void search_cb		 (GtkAction	*action,
    133 				  gpointer	 data);
    134 
    135 static void toggle_message_cb	 (GtkAction	*action,
    136 				  gpointer	 data);
    137 static void toggle_toolbar_cb	 (GtkAction *action, GtkRadioAction *current, gpointer data);
    138 static void toggle_col_headers_cb(GtkAction	*action,
    139 				  gpointer	 data);
    140 
    141 static void toggle_statusbar_cb	 (GtkAction	*action,
    142 				  gpointer	 data);
    143 static void set_layout_cb	 (GtkAction *action, GtkRadioAction *current, gpointer data);
    144 
    145 static void addressbook_open_cb	(GtkAction	*action,
    146 				  gpointer	 data);
    147 static void log_window_show_cb	(GtkAction	*action,
    148 				  gpointer	 data);
    149 
    150 static void inc_cancel_cb		(GtkAction	*action,
    151 				  gpointer	 data);
    152 static void send_cancel_cb		(GtkAction	*action,
    153 				  gpointer	 data);
    154 
    155 static void open_msg_cb			(GtkAction	*action,
    156 				  gpointer	 data);
    157 
    158 static void view_source_cb		(GtkAction	*action,
    159 				  gpointer	 data);
    160 
    161 static void show_all_header_cb		(GtkAction	*action,
    162 				  gpointer	 data);
    163 static void toggle_fullscreen_cb	(GtkAction	*action,
    164 				  gpointer	 data);
    165 static void toggle_menubar_cb	(GtkAction	*action,
    166 				  gpointer	 data);
    167 
    168 static void hide_quotes_cb(GtkAction	*action,
    169 				  gpointer	 data);
    170 
    171 static void move_to_cb			(GtkAction	*action,
    172 				  gpointer	 data);
    173 static void copy_to_cb			(GtkAction	*action,
    174 				  gpointer	 data);
    175 static void delete_cb			(GtkAction	*action,
    176 				  gpointer	 data);
    177 static void delete_trash_cb			(GtkAction	*action,
    178 				  gpointer	 data);
    179 
    180 static void cancel_cb                   (GtkAction	*action,
    181 				  gpointer	 data);
    182 
    183 static void mark_cb			(GtkAction	*action,
    184 				  gpointer	 data);
    185 static void unmark_cb			(GtkAction	*action,
    186 				  gpointer	 data);
    187 
    188 static void mark_as_unread_cb		(GtkAction	*action,
    189 				  gpointer	 data);
    190 static void mark_as_read_cb		(GtkAction	*action,
    191 				  gpointer	 data);
    192 static void mark_all_read_cb		(GtkAction	*action,
    193 				  gpointer	 data);
    194 static void mark_all_unread_cb		(GtkAction	*action,
    195 				  gpointer	 data);
    196 
    197 static void ignore_thread_cb		(GtkAction	*action,
    198 				  gpointer	 data);
    199 static void unignore_thread_cb		(GtkAction	*action,
    200 				  gpointer	 data);
    201 static void watch_thread_cb		(GtkAction	*action,
    202 				  gpointer	 data);
    203 static void unwatch_thread_cb		(GtkAction	*action,
    204 				  gpointer	 data);
    205 static void lock_msgs_cb		(GtkAction	*action,
    206 				  gpointer	 data);
    207 static void unlock_msgs_cb		(GtkAction	*action,
    208 				  gpointer	 data);
    209 
    210 static void reedit_cb			(GtkAction	*action,
    211 				  gpointer	 data);
    212 
    213 static void add_address_cb		(GtkAction	*action,
    214 				  gpointer	 data);
    215 
    216 static void set_charset_cb		(GtkAction *action, GtkRadioAction *current, gpointer data);
    217 
    218 static void set_decode_cb		(GtkAction *action, GtkRadioAction *current, gpointer data);
    219 
    220 static void hide_read_messages   (GtkAction	*action,
    221 				  gpointer	 data);
    222 static void hide_read_threads   (GtkAction	*action,
    223 				  gpointer	 data);
    224 static void hide_del_messages   (GtkAction	*action,
    225 				  gpointer	 data);
    226 
    227 static void thread_cb		 (GtkAction	*action,
    228 				  gpointer	 data);
    229 static void expand_threads_cb	 (GtkAction	*action,
    230 				  gpointer	 data);
    231 static void collapse_threads_cb	 (GtkAction	*action,
    232 				  gpointer	 data);
    233 
    234 static void set_summary_display_item_cb	 (GtkAction	*action,
    235 				  gpointer	 data);
    236 static void set_folder_display_item_cb	 (GtkAction	*action,
    237 				  gpointer	 data);
    238 static void sort_summary_cb	 (GtkAction *action, GtkRadioAction *current, gpointer data);
    239 static void sort_summary_type_cb (GtkAction *action, GtkRadioAction *current, gpointer data);
    240 static void attract_by_subject_cb(GtkAction	*action,
    241 				  gpointer	 data);
    242 
    243 static void delete_duplicated_cb (GtkAction	*action,
    244 				  gpointer	 data);
    245 static void delete_duplicated_all_cb (GtkAction	*action,
    246 				  gpointer	 data);
    247 static void execute_summary_cb	 (GtkAction	*action,
    248 				  gpointer	 data);
    249 static void expunge_summary_cb	 (GtkAction	*action,
    250 				  gpointer	 data);
    251 static void update_summary_cb	 (GtkAction	*action,
    252 				  gpointer	 data);
    253 
    254 static void prev_cb		 (GtkAction	*action,
    255 				  gpointer	 data);
    256 static void next_cb		 (GtkAction	*action,
    257 				  gpointer	 data);
    258 static void next_unread_cb	 (GtkAction	*action,
    259 				  gpointer	 data);
    260 static void prev_unread_cb	 (GtkAction	*action,
    261 				  gpointer	 data);
    262 
    263 static void prev_new_cb		 (GtkAction	*action,
    264 				  gpointer	 data);
    265 static void next_new_cb		 (GtkAction	*action,
    266 				  gpointer	 data);
    267 static void prev_marked_cb	 (GtkAction	*action,
    268 				  gpointer	 data);
    269 static void next_marked_cb	 (GtkAction	*action,
    270 				  gpointer	 data);
    271 static void prev_labeled_cb	 (GtkAction	*action,
    272 				  gpointer	 data);
    273 static void next_labeled_cb	 (GtkAction	*action,
    274 				  gpointer	 data);
    275 static void prev_history_cb	 (GtkAction	*action,
    276 				  gpointer	 data);
    277 static void next_history_cb	 (GtkAction	*action,
    278 				  gpointer	 data);
    279 static void parent_cb		 (GtkAction	*action,
    280 				  gpointer	 data);
    281 
    282 static void goto_folder_cb	 (GtkAction	*action,
    283 				  gpointer	 data);
    284 static void goto_unread_folder_cb(GtkAction	*action,
    285 				  gpointer	 data);
    286 
    287 static void copy_cb		 (GtkAction	*action,
    288 				  gpointer	 data);
    289 static void allsel_cb		 (GtkAction	*action,
    290 				  gpointer	 data);
    291 static void select_thread_cb	 (GtkAction	*action,
    292 				  gpointer	 data);
    293 static void trash_thread_cb	 (GtkAction	*action,
    294 				  gpointer	 data);
    295 static void delete_thread_cb	 (GtkAction	*action,
    296 				  gpointer	 data);
    297 
    298 static void prefs_actions_open_cb	(GtkAction	*action,
    299 				  gpointer	 data);
    300 static void prefs_account_open_cb	(GtkAction	*action,
    301 				  gpointer	 data);
    302 
    303 static void new_account_cb	 (GtkAction	*action,
    304 				  gpointer	 data);
    305 
    306 static void account_selector_menu_cb	 (GtkMenuItem	*menuitem,
    307 					  gpointer	 data);
    308 static void account_receive_menu_cb	 (GtkMenuItem	*menuitem,
    309 					  gpointer	 data);
    310 
    311 static void account_compose_menu_cb	 (GtkMenuItem	*menuitem,
    312 					  gpointer	 data);
    313 
    314 static void prefs_open_cb	(GtkAction	*action,
    315 				  gpointer	 data);
    316 
    317 static void online_switch_clicked(GtkButton     *btn,
    318 				  gpointer data);
    319 
    320 static void manual_open_cb	 (GtkAction	*action,
    321 				  gpointer	 data);
    322 static void manual_faq_open_cb	 (GtkAction	*action,
    323 				  gpointer	 data);
    324 
    325 static void legend_open_cb	 (GtkAction	*action,
    326 				  gpointer	 data);
    327 
    328 static void scan_tree_func	 (Folder	*folder,
    329 				  FolderItem	*item,
    330 				  gpointer	 data);
    331 
    332 static void toggle_work_offline_cb(GtkAction	*action,
    333 				  gpointer	 data);
    334 
    335 static void sync_cb		 ( GtkAction	*action,
    336 				  gpointer	 data );
    337 
    338 static gboolean mainwindow_focus_in_event	(GtkWidget	*widget,
    339 						 GdkEventFocus	*focus,
    340 						 gpointer	 data);
    341 static gboolean mainwindow_visibility_event_cb	(GtkWidget	*widget,
    342 						 GdkEventVisibility	*state,
    343 						 gpointer	 data);
    344 static gboolean mainwindow_state_event_cb	(GtkWidget	*widget,
    345 						 GdkEventWindowState	*state,
    346 						 gpointer	 data);
    347 static void main_window_reply_cb			(GtkAction	*action,
    348 				  gpointer	 data);
    349 static gboolean mainwindow_progressindicator_hook	(gpointer 	 source,
    350 						 gpointer 	 userdata);
    351 
    352 static gint mailing_list_create_submenu(MainWindow *mainwindow,
    353 				       MsgInfo *msginfo);
    354 
    355 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
    356 
    357 static void get_url_part(const gchar **buf, gchar *url_decoded);
    358 
    359 static void mailing_list_compose(GtkWidget *w, gpointer *data);
    360 
    361 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
    362 
    363 static gboolean any_folder_want_synchronise(void);
    364 
    365 static void save_part_as_cb(GtkAction *action, gpointer data);
    366 static void view_part_as_text_cb(GtkAction *action, gpointer data);
    367 static void open_part_cb(GtkAction *action, gpointer data);
    368 static void open_part_with_cb(GtkAction *action, gpointer data);
    369 static void goto_next_part_cb(GtkAction *action, gpointer data);
    370 static void goto_prev_part_cb(GtkAction *action, gpointer data);
    371 #define DO_ACTION(name, act)	{ if (!strcmp(a_name, name)) action = act; }
    372 
    373 static void mainwindow_nothing_cb	   (GtkAction *action, gpointer data)
    374 {
    375 
    376 }
    377 
    378 static void about_cb(GtkAction *gaction, gpointer data)
    379 {
    380 	char path[PATH_MAX];
    381 	strlcpy(path, getenv("HOME"), sizeof(path));
    382 	strlcat(path, "/.local/share/talons/about.ui", sizeof(path));
    383 
    384 	GtkBuilder *builder = gtk_builder_new_from_file(path);
    385 	GtkWidget *about = GTK_WIDGET(gtk_builder_get_object(builder, "about"));
    386 	gtk_widget_show(about);
    387 }
    388 
    389 static void	mw_inc_mail_cb			(GtkAction *gaction, gpointer data)
    390 {
    391 	inc_mail_cb(data, 0, NULL);
    392 }
    393 static void 	mw_inc_all_account_mail_cb		(GtkAction *gaction, gpointer data)
    394 {
    395 	inc_all_account_mail_cb(data, 0, NULL);
    396 }
    397 static void 	mw_send_queue_cb			(GtkAction *gaction, gpointer data)
    398 {
    399 	send_queue_cb(data, 0, NULL);
    400 }
    401 static void 	mw_compose_mail_cb			(GtkAction *gaction, gpointer data)
    402 {
    403 	compose_mail_cb(data, 0, NULL);
    404 }
    405 
    406 /* make sure to keep the tables below in sync with the default_menurc[] in prefs_other.c */
    407 static GtkActionEntry mainwin_entries[] =
    408 {
    409 	{"Menu",                        NULL, "Menu", NULL, NULL, NULL },
    410 /* menus */
    411 	{"File",                        NULL, N_("_File"), NULL, NULL, NULL },
    412 	{"Edit",                        NULL, N_("_Edit"), NULL, NULL, NULL },
    413 	{"View",                        NULL, N_("_View"), NULL, NULL, NULL },
    414 	{"Message",                     NULL, N_("_Message"), NULL, NULL, NULL },
    415 	{"Tools",                       NULL, N_("_Tools"), NULL, NULL, NULL },
    416 	{"Configuration",               NULL, N_("_Configuration"), NULL, NULL, NULL },
    417 	{"Help",                        NULL, N_("_Help"), NULL, NULL, NULL },
    418 
    419 /* File menu */
    420 	{"File/AddMailbox",             NULL, N_("_Add mailbox"), NULL, NULL, NULL },
    421 	{"File/AddMailbox/MH",          NULL, N_("MH..."), NULL, NULL, G_CALLBACK(add_mailbox_cb) },
    422 	{"File/---",                    NULL, "---", NULL, NULL, NULL },
    423 
    424 	{"File/SortMailboxes",          NULL, N_("Change mailbox order..."), NULL, NULL, G_CALLBACK(foldersort_cb) },
    425 
    426 	{"File/EmptyTrashes",           NULL, N_("Empty all _Trash folders"), "<shift>D", NULL, G_CALLBACK(empty_trash_cb) },
    427 	/* {"File/---",                 NULL, "---", NULL, NULL, NULL }, */
    428 
    429 	{"File/SaveAs",                 NULL, N_("_Save email as..."), "<control>S", NULL, G_CALLBACK(save_as_cb) },
    430 	{"File/SavePartAs",             NULL, N_("_Save part as..."), "Y", NULL, G_CALLBACK(save_part_as_cb) },
    431 	/* {"File/---",                 NULL, "---", NULL, NULL, NULL }, */
    432 
    433 	/* {"File/---",                 NULL, "---", NULL, NULL, NULL }, */
    434 	{"File/SynchroniseFolders",     NULL, N_("Synchronise folders"), "<shift><control>S", NULL, G_CALLBACK(sync_cb) },
    435 	/* {"File/---",                 NULL, "---", NULL, NULL, NULL }, */
    436 	{"File/Exit",                   NULL, N_("E_xit"), "<control>Q", NULL, G_CALLBACK(app_exit_cb) },
    437 
    438 /* Edit menu */
    439 	{"Edit/Copy",                   NULL, N_("_Copy"), "<control>C", NULL, G_CALLBACK(copy_cb) },
    440 	{"Edit/SelectAll",              NULL, N_("Select _all"), "<control>A", NULL, G_CALLBACK(allsel_cb) },
    441 	{"Edit/SelectThread",           NULL, N_("Select _thread"), NULL, NULL, G_CALLBACK(select_thread_cb) },
    442 	{"Edit/---",                    NULL, "---", NULL, NULL, NULL },
    443 	{"Edit/Find",                   NULL, N_("_Find in current message..."), "<control>F", NULL, G_CALLBACK(search_cb) },
    444 
    445 	{"View/ShowHide",               NULL, N_("Show or hi_de"), NULL, NULL, NULL },
    446 	{"View/ShowHide/Toolbar",       NULL, N_("_Toolbar"), NULL, NULL, NULL },
    447 
    448 	{"View/SetColumns",             NULL, N_("Set displayed _columns"), NULL, NULL, NULL },
    449 	{"View/SetColumns/Folderlist",  NULL, N_("In _folder list..."), NULL, NULL, G_CALLBACK(set_folder_display_item_cb) },
    450 	{"View/SetColumns/Messagelist", NULL, N_("In _message list..."), NULL, NULL, G_CALLBACK(set_summary_display_item_cb) },
    451 	{"View/---",                    NULL, "---", NULL, NULL, NULL },
    452 
    453 	{"View/Layout",                 NULL, N_("La_yout"), NULL, NULL, NULL },
    454 	{"View/Sort",                   NULL, N_("_Sort"), NULL, NULL, NULL },
    455 	{"View/Sort/---",               NULL, "---", NULL, NULL, NULL },
    456 	{"View/Sort/AttractSubj",		NULL, N_("_Attract by subject"), NULL, NULL, G_CALLBACK(attract_by_subject_cb) },
    457 
    458 	{"View/ExpandThreads",			NULL, N_("E_xpand all threads"), NULL, NULL, G_CALLBACK(expand_threads_cb) },
    459 	{"View/CollapseThreads",		NULL, N_("Co_llapse all threads"), NULL, NULL, G_CALLBACK(collapse_threads_cb) },
    460 
    461 	{"View/Goto",                   NULL, N_("_Go to"), NULL, NULL, NULL },
    462 	{"View/Goto/Prev",              NULL, N_("_Previous message"), "P", NULL, G_CALLBACK(prev_cb) },
    463 	{"View/Goto/Next",              NULL, N_("_Next message"), "N", NULL, G_CALLBACK(next_cb) },
    464 	{"View/Goto/---",               NULL, "---", NULL, NULL, NULL },
    465 	{"View/Goto/PrevUnread",        NULL, N_("P_revious unread message"), "<shift>P", NULL, G_CALLBACK(prev_unread_cb) },
    466 	{"View/Goto/NextUnread",        NULL, N_("N_ext unread message"), "<shift>N", NULL, G_CALLBACK(next_unread_cb) },
    467 	/* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
    468 	{"View/Goto/PrevNew",           NULL, N_("Previous ne_w message"), NULL, NULL, G_CALLBACK(prev_new_cb) },
    469 	{"View/Goto/NextNew",           NULL, N_("Ne_xt new message"), NULL, NULL, G_CALLBACK(next_new_cb) },
    470 	/* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
    471 	{"View/Goto/PrevMarked",        NULL, N_("Previous _marked message"), NULL, NULL, G_CALLBACK(prev_marked_cb) },
    472 	{"View/Goto/NextMarked",        NULL, N_("Next m_arked message"), NULL, NULL, G_CALLBACK(next_marked_cb) },
    473 	/* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
    474 	{"View/Goto/PrevLabeled",       NULL, N_("Previous _labeled message"), NULL, NULL, G_CALLBACK(prev_labeled_cb) },
    475 	{"View/Goto/NextLabeled",       NULL, N_("Next la_beled message"), NULL, NULL, G_CALLBACK(next_labeled_cb) },
    476 	/* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
    477 	{"View/Goto/PrevHistory",       NULL, N_("Previously opened message"), "<alt>Left", NULL, G_CALLBACK(prev_history_cb) },
    478 	{"View/Goto/NextHistory",       NULL, N_("Next opened message"), "<alt>Right", NULL, G_CALLBACK(next_history_cb) },
    479 	/* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
    480 	{"View/Goto/ParentMessage",     NULL, N_("Parent message"), "<control>Up", NULL, G_CALLBACK(parent_cb) },
    481 	/* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
    482 	{"View/Goto/NextUnreadFolder",  NULL, N_("Next unread _folder"), "<shift>G", NULL, G_CALLBACK(goto_unread_folder_cb) },
    483 	{"View/Goto/Folder",            NULL, N_("F_older..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
    484 	/* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
    485 	{"View/Goto/NextPart",          NULL, N_("Next part"), "A", NULL, G_CALLBACK(goto_next_part_cb) },
    486 	{"View/Goto/PrevPart",          NULL, N_("Previous part"), "Z", NULL, G_CALLBACK(goto_prev_part_cb) },
    487 
    488 	/* {"View/---",                 NULL, "---", NULL, NULL, NULL }, */
    489 	{"View/Encoding",               NULL, N_("Character _encoding"), NULL, NULL, NULL }, /* set_charset_cb */
    490 	{"View/Encoding/---",           NULL, "---", NULL, NULL, NULL },
    491 #define ENC_ACTION(cs_char,c_char,string) \
    492 	{ "View/Encoding/" cs_char, NULL, N_(string), NULL, NULL, c_char }
    493 
    494 	{"View/Encoding/Western",       NULL, N_("Western European"), NULL, NULL, NULL },
    495 	{"View/Encoding/Baltic",        NULL, N_("Baltic"), NULL, NULL, NULL },
    496 	{"View/Encoding/Hebrew",        NULL, N_("Hebrew"), NULL, NULL, NULL },
    497 	{"View/Encoding/Arabic",        NULL, N_("Arabic"), NULL, NULL, NULL },
    498 	{"View/Encoding/Cyrillic",      NULL, N_("Cyrillic"), NULL, NULL, NULL },
    499 	{"View/Encoding/Japanese",      NULL, N_("Japanese"), NULL, NULL, NULL },
    500 	{"View/Encoding/Chinese",       NULL, N_("Chinese"), NULL, NULL, NULL },
    501 	{"View/Encoding/Korean",        NULL, N_("Korean"), NULL, NULL, NULL },
    502 	{"View/Encoding/Thai",          NULL, N_("Thai"), NULL, NULL, NULL },
    503 
    504 	{"View/Decode",                 NULL, N_("Decode"), NULL, NULL, NULL }, /* set_decode_cb */
    505 	{"View/Decode/---",             NULL, "---", NULL, NULL, NULL },
    506 
    507 #define DEC_ACTION(cs_type,c_type,string) \
    508 	{ "View/Decode/" cs_type, NULL, N_(string), NULL, NULL, c_type }
    509 
    510 	/* {"View/---",                 NULL, "---", NULL, NULL, NULL }, */
    511 	{"View/OpenNewWindow",          NULL, N_("Open in new _window"), "<control><alt>N", NULL, G_CALLBACK(open_msg_cb) },
    512 	{"View/MessageSource",          NULL, N_("Mess_age source"), "<control>U", NULL, G_CALLBACK(view_source_cb) },
    513 	/* {"View/---",                 NULL, "---", NULL, NULL, NULL }, */
    514 	{"View/Part",                   NULL, N_("Message part"), NULL, NULL, NULL },
    515 	{"View/Part/AsText",            NULL, N_("View as text"), "T", NULL, G_CALLBACK(view_part_as_text_cb) },
    516 	{"View/Part/Open",              NULL, N_("Open"), "L", NULL, G_CALLBACK(open_part_cb) },
    517 	{"View/Part/OpenWith",          NULL, N_("Open with..."), "O", NULL, G_CALLBACK(open_part_with_cb) },
    518 	/* {"View/---",                 NULL, "---", NULL, NULL, NULL }, */
    519 
    520 	{"View/Quotes",                 NULL, N_("Quotes"), NULL, NULL, NULL },
    521 	/* {"View/---",                 NULL, "---", NULL, NULL, NULL }, */
    522 	{"View/UpdateSummary",          NULL, N_("Refresh message list"), "<control><alt>U", NULL, G_CALLBACK(update_summary_cb) },
    523 
    524 /* Message menu */
    525 	{"Message/Receive",                              NULL, N_("Recei_ve"), NULL, NULL, NULL },
    526 	{"Message/Receive/CurrentAccount",               NULL, N_("Get from _current account"), "<control>I", NULL, G_CALLBACK(mw_inc_mail_cb) },
    527 	{"Message/Receive/AllAccounts",                  NULL, N_("Get from _all accounts"), "<shift><control>I", NULL, G_CALLBACK(mw_inc_all_account_mail_cb) },
    528 	{"Message/Receive/CancelReceiving",              NULL, N_("Cancel receivin_g"), NULL, NULL, G_CALLBACK(inc_cancel_cb) },
    529 	{"Message/Receive/---",                          NULL, "---", NULL, NULL, NULL },
    530 	{"Message/Receive/PlaceHolder",                  NULL, "PlaceHolder,", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    531 	{"Message/SendQueue",                            NULL, N_("_Send queued messages"), NULL, NULL, G_CALLBACK(mw_send_queue_cb) },
    532 	{"Message/CancelSending",                        NULL, N_("Cancel sending"), NULL, NULL, G_CALLBACK(send_cancel_cb) },
    533 
    534 	{"Message/---",                                  NULL, "---", NULL, NULL, NULL },
    535 
    536 	{"Message/ComposeEmail",                         NULL, N_("Write a_n email message"), "<control>M", NULL, G_CALLBACK(mw_compose_mail_cb) },
    537 
    538 	{"Message/Reply",                                NULL, N_("_Reply"), "<control>R", NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_REPLY */
    539 	{"Message/ReplyTo",                              NULL, N_("Repl_y to"), NULL, NULL, NULL },
    540 	{"Message/ReplyTo/All",                          NULL, N_("_All"), "<shift><control>R", NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_REPLY_TO_ALL */
    541 	{"Message/ReplyTo/Sender",                       NULL, N_("_Sender"), NULL, NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_REPLY_TO_SENDER */
    542 	{"Message/ReplyTo/List",                         NULL, N_("Mailing _list"), "<control>L", NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_REPLY_TO_LIST */
    543 	{"Message/FollowupReply",                        NULL, N_("Follow-up and reply to"), NULL, NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_FOLLOWUP_AND_REPLY_TO */
    544 	/* {"Message/---",                               NULL, "---", NULL, NULL, NULL }, */
    545 
    546 	{"Message/Forward",                              NULL, N_("_Forward"), "<control><alt>F", NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_FORWARD_INLINE */
    547 	{"Message/ForwardAtt",                           NULL, N_("For_ward as attachment"), NULL, NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_FORWARD_AS_ATTACH */
    548 	{"Message/Redirect",                             NULL, N_("Redirec_t"), NULL, NULL, G_CALLBACK(main_window_reply_cb) }, /* COMPOSE_REDIRECT */
    549 
    550 	{"Message/MailingList",                          NULL, N_("Mailing-_List"), NULL, NULL, NULL },
    551 	{"Message/MailingList/Post",                     NULL, N_("Post"), NULL, NULL, NULL },
    552 	{"Message/MailingList/Post/PlaceHolder",         NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    553 	{"Message/MailingList/Help",                     NULL, N_("Help"), NULL, NULL, NULL },
    554 	{"Message/MailingList/Help/PlaceHolder",         NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    555 	{"Message/MailingList/Subscribe",                NULL, N_("Subscribe"), NULL, NULL, NULL },
    556 	{"Message/MailingList/Subscribe/PlaceHolder",    NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    557 	{"Message/MailingList/Unsubscribe",              NULL, N_("Unsubscribe"), NULL, NULL, NULL },
    558 	{"Message/MailingList/Unsubscribe/PlaceHolder",  NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    559 	{"Message/MailingList/ViewArchive",              NULL, N_("View archive"), NULL, NULL, NULL },
    560 	{"Message/MailingList/ViewArchive/PlaceHolder",  NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    561 	{"Message/MailingList/ContactOwner",             NULL, N_("Contact owner"), NULL, NULL, NULL },
    562 	{"Message/MailingList/ContactOwner/PlaceHolder", NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    563 	/* separation */
    564 
    565 	{"Message/Move",                             NULL, N_("M_ove..."), "<control>O", NULL, G_CALLBACK(move_to_cb) },
    566 	{"Message/Copy",                             NULL, N_("_Copy..."), "<shift><control>O", NULL, G_CALLBACK(copy_to_cb) },
    567 	{"Message/Trash",                            NULL, N_("Move to _trash"), "<control>D", NULL, G_CALLBACK(delete_trash_cb) },
    568 	{"Message/Delete",                           NULL, N_("_Delete..."), NULL, NULL, G_CALLBACK(delete_cb) },
    569 	{"Message/TrashThread",                      NULL, N_("Move thread to tr_ash"), NULL, NULL, G_CALLBACK(trash_thread_cb) },
    570 	{"Message/DeleteThread",                     NULL, N_("Delete t_hread"), NULL, NULL, G_CALLBACK(delete_thread_cb) },
    571 	{"Message/CancelNews",                       NULL, N_("Cancel a news message"), NULL, NULL, G_CALLBACK(cancel_cb) },
    572 	/* separation */
    573 	{"Message/Marks",                            NULL, N_("_Marks"), NULL, NULL, NULL },
    574 	{"Message/Marks/Mark",                       NULL, N_("_Mark"), "<shift>asterisk", NULL, G_CALLBACK(mark_cb) },
    575 	{"Message/Marks/Unmark",                     NULL, N_("_Unmark"), "U", NULL, G_CALLBACK(unmark_cb) },
    576 	{"Message/Marks/---",                        NULL, "---", NULL, NULL, NULL },
    577 
    578 	{"Message/Marks/MarkRead",                   NULL, N_("Mark as rea_d"), NULL, NULL, G_CALLBACK(mark_as_read_cb) },
    579 	{"Message/Marks/MarkUnread",                 NULL, N_("Mark as unr_ead"), "<shift>exclam", NULL, G_CALLBACK(mark_as_unread_cb) },
    580 	/* separation */
    581 	{"Message/Marks/MarkAllRead",                NULL, N_("Mark all read in folder"), NULL, NULL, G_CALLBACK(mark_all_read_cb) },
    582 	{"Message/Marks/MarkAllUnread",              NULL, N_("Mark all unread in folder"), NULL, NULL, G_CALLBACK(mark_all_unread_cb) },
    583 	/* separation */
    584 	{"Message/Marks/IgnoreThread",               NULL, N_("Ignore thread"), NULL, NULL, G_CALLBACK(ignore_thread_cb) },
    585 	{"Message/Marks/UnignoreThread",             NULL, N_("Unignore thread"), NULL, NULL, G_CALLBACK(unignore_thread_cb) },
    586 	{"Message/Marks/WatchThread",                NULL, N_("Watch thread"), NULL, NULL, G_CALLBACK(watch_thread_cb) },
    587 	{"Message/Marks/UnwatchThread",              NULL, N_("Unwatch thread"), NULL, NULL, G_CALLBACK(unwatch_thread_cb) },
    588 
    589 	{"Message/Marks/Lock",                       NULL, N_("Lock"), NULL, NULL, G_CALLBACK(lock_msgs_cb) },
    590 	{"Message/Marks/Unlock",                     NULL, N_("Unlock"), NULL, NULL, G_CALLBACK(unlock_msgs_cb) },
    591 
    592 	{"Message/Reedit",                           NULL, N_("Re-_edit"), NULL, NULL, G_CALLBACK(reedit_cb) },
    593 	/*{"Message/---",                            NULL, "---", NULL, NULL, NULL },*/
    594 
    595 	{"Tools/AddressBook",                        NULL, N_("_Address book"), "<shift><control>A", NULL, G_CALLBACK(addressbook_open_cb) },
    596 	{"Tools/AddSenderToAB",                      NULL, N_("Add sender to address boo_k"), NULL, NULL, G_CALLBACK(add_address_cb) },
    597 
    598 	/* {"Tools/---",                             NULL, "---", NULL, NULL, NULL }, */
    599 	{"Tools/Actions",                            NULL, N_("Actio_ns"), NULL, NULL, NULL },
    600 	{"Tools/Actions/PlaceHolder",                NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    601 	/* {"Tools/---",                             NULL, "---", NULL, NULL, NULL }, */
    602 
    603 	{"Tools/CheckNewMessages",                   NULL, N_("Ch_eck for new messages in all folders"), NULL, NULL, G_CALLBACK(update_folderview_cb) },
    604 	{"Tools/DeleteDuplicates",                   NULL, N_("Delete du_plicated messages"), NULL, NULL, NULL },
    605 	{"Tools/DeleteDuplicates/SelFolder",         NULL, N_("In selected folder"), NULL, NULL, G_CALLBACK(delete_duplicated_cb) },
    606 	{"Tools/DeleteDuplicates/AllFolders",        NULL, N_("In all folders"), NULL, NULL, G_CALLBACK(delete_duplicated_all_cb) },
    607 	/* {"Tools/---",                             NULL, "---", NULL, NULL, NULL }, */
    608 
    609 	{"Tools/Execute",                            NULL, N_("E_xecute"), "X", NULL, G_CALLBACK(execute_summary_cb) },
    610 	{"Tools/Expunge",                            NULL, N_("Exp_unge"), "<control>E", NULL, G_CALLBACK(expunge_summary_cb) },
    611 	/* {"Tools/---",                             NULL, "---", NULL, NULL, NULL }, */
    612 	{"Tools/NetworkLog",                         NULL, N_("Network _Log"), "<shift><control>L", NULL, G_CALLBACK(log_window_show_cb) },
    613 
    614 /* Configuration menu */
    615 	{"Configuration/ChangeAccount",              NULL, N_("C_hange current account"), NULL, NULL, NULL },
    616 	{"Configuration/ChangeAccount/PlaceHolder",  NULL, "Placeholder", NULL, NULL, G_CALLBACK(mainwindow_nothing_cb) },
    617 	{"Configuration/AccountPrefs",               NULL, N_("_Preferences for current account..."), NULL, NULL, G_CALLBACK(prefs_account_open_cb) },
    618 	{"Configuration/CreateAccount",              NULL, N_("Create _new account..."), NULL, NULL, G_CALLBACK(new_account_cb) },
    619 	{"Configuration/EditAccounts",               NULL, N_("_Edit accounts..."), NULL, NULL, G_CALLBACK(account_edit_open) },
    620 	{"Configuration/---",                        NULL, "---", NULL, NULL, NULL },
    621 
    622 	{"Configuration/Preferences",                NULL, N_("P_references..."), NULL, NULL, G_CALLBACK(prefs_open_cb) },
    623 	{"Configuration/Actions",                    NULL, N_("_Actions..."), NULL, NULL, G_CALLBACK(prefs_actions_open_cb) },
    624 
    625 /* Help menu */
    626 	{"Help/Manual",                              NULL, N_("_Manual"), NULL, NULL, G_CALLBACK(manual_open_cb) },
    627 	{"Help/FAQ",                                 NULL, N_("_Online User-contributed FAQ"), NULL, NULL, G_CALLBACK(manual_faq_open_cb) },
    628 	{"Help/IconLegend",                          NULL, N_("Icon _Legend"), NULL, NULL, G_CALLBACK(legend_open_cb) },
    629 	{"Help/---",                                 NULL, "---", NULL, NULL, NULL },
    630 	{"Help/About",                               NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_cb) },
    631 };
    632 
    633 static GtkToggleActionEntry mainwin_toggle_entries[] = {
    634 	{"File/OfflineMode",                     NULL, N_("Offline _mode"), "<control>W", NULL, G_CALLBACK(toggle_work_offline_cb), FALSE }, /*toggle*/
    635 	{"View/ShowHide/MenuBar",                NULL, N_("Men_ubar"), "<control>F12", NULL, G_CALLBACK(toggle_menubar_cb), FALSE }, /* toggle */
    636 	{"View/ShowHide/MessageView",            NULL, N_("_Message view"), "V", NULL, G_CALLBACK(toggle_message_cb), FALSE }, /* toggle */
    637 	{"View/ShowHide/StatusBar",              NULL, N_("Status _bar"), NULL, NULL, G_CALLBACK(toggle_statusbar_cb), FALSE }, /* toggle */
    638 	{"View/ShowHide/ColumnHeaders",          NULL, N_("Column headers"), NULL, NULL, G_CALLBACK(toggle_col_headers_cb), FALSE }, /* toggle */
    639 	{"View/ThreadView",                      NULL, N_("Th_read view"), "<control>T", NULL, G_CALLBACK(thread_cb), FALSE }, /* toggle */
    640 	{"View/HideReadThreads",                 NULL, N_("Hide read threads"), NULL, NULL, G_CALLBACK(hide_read_threads), FALSE }, /* toggle */
    641 	{"View/HideReadMessages",                NULL, N_("_Hide read messages"), NULL, NULL, G_CALLBACK(hide_read_messages), FALSE }, /* toggle */
    642 	{"View/HideDelMessages",                 NULL, N_("Hide deleted messages"), NULL, NULL, G_CALLBACK(hide_del_messages), FALSE }, /* toggle */
    643 	{"View/FullScreen",                      NULL, N_("_Fullscreen"), "F11", NULL, G_CALLBACK(toggle_fullscreen_cb), FALSE }, /* toggle */
    644 	{"View/AllHeaders",                      NULL, N_("Show all _headers"), "<control>H", NULL, G_CALLBACK(show_all_header_cb), FALSE }, /* toggle */
    645 	{"View/Quotes/CollapseAll",              NULL, N_("_Collapse all"), "<shift><control>Q", NULL, G_CALLBACK(hide_quotes_cb), FALSE }, /* 1 toggle */
    646 	{"View/Quotes/Collapse2",                NULL, N_("Collapse from level _2"), NULL, NULL, G_CALLBACK(hide_quotes_cb), FALSE }, /* 2 toggle */
    647 	{"View/Quotes/Collapse3",                NULL, N_("Collapse from level _3"), NULL, NULL, G_CALLBACK(hide_quotes_cb), FALSE }, /* 3 toggle */
    648 };
    649 
    650 static GtkRadioActionEntry mainwin_showhide_radio_entries[] = { /* toggle_toolbar_cb */
    651 	{"View/ShowHide/Toolbar/TextBelowIcon",  NULL, N_("Text _below icons"), NULL, NULL, TOOLBAR_BOTH }, /* radio TOOLBAR_BOTH */
    652 	{"View/ShowHide/Toolbar/TextBesideIcon", NULL, N_("Text be_side icons"), NULL, NULL, TOOLBAR_BOTH_HORIZ }, /* radio TOOLBAR_BOTH_HORIZ */
    653 	{"View/ShowHide/Toolbar/IconOnly",       NULL, N_("_Icons only"), NULL, NULL, TOOLBAR_ICON }, /* radio TOOLBAR_ICON */
    654 	{"View/ShowHide/Toolbar/TextOnly",       NULL, N_("_Text only"), NULL, NULL, TOOLBAR_TEXT }, /* radio TOOLBAR_TEXT */
    655 	{"View/ShowHide/Toolbar/Hide",           NULL, N_("_Hide"), NULL, NULL, TOOLBAR_NONE }, /* radio TOOLBAR_NONE */
    656 };
    657 
    658 static GtkRadioActionEntry mainwin_layout_radio_entries[] = { /* set_layout_cb */
    659 	{"View/Layout/Standard",                 NULL, N_("_Standard"), NULL, NULL, NORMAL_LAYOUT }, /* radio NORMAL_LAYOUT */
    660 	{"View/Layout/ThreeColumns",             NULL, N_("_Three columns"), NULL, NULL, VERTICAL_LAYOUT }, /* radio VERTICAL_LAYOUT */
    661 };
    662 
    663 static GtkRadioActionEntry mainwin_sort_radio_entries[] = { /* sort_summary_cb */
    664 	{"View/Sort/Number",                     NULL, N_("By _number"), NULL, NULL, SORT_BY_NUMBER }, /* radio SORT_BY_NUMBER */
    665 	{"View/Sort/Size",                       NULL, N_("By s_ize"), NULL, NULL, SORT_BY_SIZE }, /* radio SORT_BY_SIZE */
    666 	{"View/Sort/Date",                       NULL, N_("By _date"), NULL, NULL, SORT_BY_DATE }, /* radio SORT_BY_DATE */
    667 	{"View/Sort/ThreadDate",                 NULL, N_("By thread date"), NULL, NULL, SORT_BY_THREAD_DATE }, /* radio SORT_BY_THREAD_DATE */
    668 	{"View/Sort/From",                       NULL, N_("By _From"), NULL, NULL, SORT_BY_FROM }, /* radio SORT_BY_FROM */
    669 	{"View/Sort/To",                         NULL, N_("By _To"), NULL, NULL, SORT_BY_TO }, /* radio SORT_BY_TO */
    670 	{"View/Sort/Subject",                    NULL, N_("By s_ubject"), NULL, NULL, SORT_BY_SUBJECT }, /* radio SORT_BY_SUBJECT */
    671 	{"View/Sort/Mark",                       NULL, N_("By _mark"), NULL, NULL, SORT_BY_MARK }, /* radio SORT_BY_MARK */
    672 	{"View/Sort/Status",                     NULL, N_("By _status"), NULL, NULL, SORT_BY_STATUS }, /* radio SORT_BY_STATUS */
    673 	{"View/Sort/Attachment",                 NULL, N_("By a_ttachment"), NULL, NULL, SORT_BY_MIME }, /* radio SORT_BY_MIME */
    674 	{"View/Sort/Score",                      NULL, N_("By score"), NULL, NULL, SORT_BY_SCORE }, /* radio SORT_BY_SCORE */
    675 	{"View/Sort/Locked",                     NULL, N_("By locked"), NULL, NULL, SORT_BY_LOCKED }, /* radio SORT_BY_LOCKED */
    676 	{"View/Sort/DontSort",                   NULL, N_("D_on't sort"), NULL, NULL, SORT_BY_NONE }, /* radio SORT_BY_NONE */
    677 };
    678 
    679 static GtkRadioActionEntry mainwin_sorttype_radio_entries[] = { /* sort_summary_type_cb */
    680 	{"View/Sort/Ascending",                  NULL, N_("Ascending"), NULL, NULL, SORT_ASCENDING }, /* radio SORT_ASCENDING */
    681 	{"View/Sort/Descending",                 NULL, N_("Descending"), NULL, NULL, SORT_DESCENDING }, /* radio SORT_DESCENDING */
    682 };
    683 
    684 static GtkRadioActionEntry mainwin_radio_enc_entries[] =
    685 {
    686 	ENC_ACTION(CS_AUTO, C_AUTO, N_("_Automatic")), /* RADIO set_charset_cb */
    687 	ENC_ACTION(CS_US_ASCII, C_US_ASCII, N_("7bit ASCII (US-ASC_II)")), /* RADIO set_charset_cb */
    688 	ENC_ACTION(CS_UTF_8, C_UTF_8, N_("Unicode (_UTF-8)")), /* RADIO set_charset_cb */
    689 	ENC_ACTION("Western/"CS_ISO_8859_1, C_ISO_8859_1, "ISO-8859-_1"), /* RADIO set_charset_cb */
    690 	ENC_ACTION("Western/"CS_ISO_8859_15, C_ISO_8859_15, "ISO-8859-15"), /* RADIO set_charset_cb */
    691 	ENC_ACTION("Western/"CS_WINDOWS_1252, C_WINDOWS_1252, "Windows-1252"), /* RADIO set_charset_cb */
    692 	ENC_ACTION(CS_ISO_8859_2, C_ISO_8859_2, N_("Central European (ISO-8859-_2)")), /* RADIO set_charset_cb */
    693 	ENC_ACTION("Baltic/"CS_ISO_8859_13, C_ISO_8859_13, "ISO-8859-13"), /* RADIO set_charset_cb */
    694 	ENC_ACTION("Baltic/"CS_ISO_8859_4, C_ISO_8859_14, "ISO-8859-_4"), /* RADIO set_charset_cb */
    695 	ENC_ACTION(CS_ISO_8859_7, C_ISO_8859_7, N_("Greek (ISO-8859-_7)")), /* RADIO set_charset_cb */
    696 	ENC_ACTION("Hebrew/"CS_ISO_8859_8, C_ISO_8859_8, "ISO-8859-_8"), /* RADIO set_charset_cb */
    697 	ENC_ACTION("Hebrew/"CS_WINDOWS_1255, C_WINDOWS_1255, "Windows-1255"), /* RADIO set_charset_cb */
    698 	ENC_ACTION("Arabic/"CS_ISO_8859_6, C_ISO_8859_6, "ISO-8859-_6"), /* RADIO set_charset_cb */
    699 	ENC_ACTION("Arabic/"CS_WINDOWS_1256, C_WINDOWS_1256, "Windows-1256"), /* RADIO set_charset_cb */
    700 	ENC_ACTION(CS_ISO_8859_9, C_ISO_8859_9, N_("Turkish (ISO-8859-_9)")), /* RADIO set_charset_cb */
    701 	ENC_ACTION("Cyrillic/"CS_ISO_8859_5, C_ISO_8859_5, "ISO-8859-_5"), /* RADIO set_charset_cb */
    702 	ENC_ACTION("Cyrillic/"CS_KOI8_R, C_KOI8_R, "KOI8-_R"), /* RADIO set_charset_cb */
    703 	ENC_ACTION("Cyrillic/"CS_MACCYR, C_MACCYR, "_Mac-Cyrillic"), /* RADIO set_charset_cb */
    704 	ENC_ACTION("Cyrillic/"CS_KOI8_U, C_KOI8_U, "KOI8-_U"), /* RADIO set_charset_cb */
    705 	ENC_ACTION("Cyrillic/"CS_WINDOWS_1251, C_WINDOWS_1251, "Windows-1251"), /* RADIO set_charset_cb */
    706 	ENC_ACTION("Japanese/"CS_ISO_2022_JP, C_ISO_2022_JP, "ISO-2022-_JP"), /* RADIO set_charset_cb */
    707 	ENC_ACTION("Japanese/"CS_ISO_2022_JP_2, C_ISO_2022_JP_2, "ISO-2022-JP-_2"), /* RADIO set_charset_cb */
    708 	ENC_ACTION("Japanese/"CS_EUC_JP, C_EUC_JP, "_EUC-JP"), /* RADIO set_charset_cb */
    709 	ENC_ACTION("Japanese/"CS_SHIFT_JIS, C_SHIFT_JIS, "_Shift-JIS"), /* RADIO set_charset_cb */
    710 	ENC_ACTION("Chinese/"CS_GB18030, C_GB18030, "_GB18030"), /* RADIO set_charset_cb */
    711 	ENC_ACTION("Chinese/"CS_GB2312, C_GB2312, "_GB2312"), /* RADIO set_charset_cb */
    712 	ENC_ACTION("Chinese/"CS_GBK, C_GBK, "GB_K"), /* RADIO set_charset_cb */
    713 	ENC_ACTION("Chinese/"CS_BIG5, C_BIG5, "_Big5-JP"), /* RADIO set_charset_cb */
    714 	ENC_ACTION("Chinese/"CS_EUC_TW, C_EUC_TW, "EUC-_TW"), /* RADIO set_charset_cb */
    715 	ENC_ACTION("Korean/"CS_EUC_KR, C_EUC_KR, "_EUC-KR"), /* RADIO set_charset_cb */
    716 	ENC_ACTION("Korean/"CS_ISO_2022_KR, C_ISO_2022_KR, "_ISO-2022-KR"), /* RADIO set_charset_cb */
    717 	ENC_ACTION("Thai/"CS_TIS_620, C_TIS_620, "_TIS-620-KR"), /* RADIO set_charset_cb */
    718 	ENC_ACTION("Thai/"CS_WINDOWS_874, C_WINDOWS_874, "_Windows-874"), /* RADIO set_charset_cb */
    719 };
    720 
    721 static GtkRadioActionEntry mainwin_radio_dec_entries[] =
    722 {
    723 	DEC_ACTION("AutoDetect", 0, N_("_Auto detect")),	/* set_decode_cb */
    724 	/* --- */
    725 	DEC_ACTION("8bit", ENC_8BIT, "_8bit"),
    726 	DEC_ACTION("QP", ENC_QUOTED_PRINTABLE, "_Quoted printable"),
    727 	DEC_ACTION("B64", ENC_BASE64, "_Base64"),
    728 	DEC_ACTION("Uuencode", ENC_X_UUENCODE, "_Uuencode"),
    729 };
    730 
    731 static gboolean offline_ask_sync = TRUE;
    732 static gboolean is_obscured = FALSE;
    733 
    734 void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModifierType modifier,
    735 				  GClosure *closure, GtkMenuItem *item)
    736 {
    737 	GList *closures = gtk_widget_list_accel_closures(GTK_WIDGET(item));
    738 	GList *cur;
    739 	for (cur = closures; cur; cur = cur->next) {
    740 		if (closure == cur->data) {
    741 			GtkLabel *label = g_object_get_data(G_OBJECT(item), "accel_label");
    742 			gchar *new_accel;
    743 
    744 			if (keyval == GDK_KEY_Delete) {
    745 				const gchar *accel_path;
    746 				accel_path = gtk_menu_item_get_accel_path(item);
    747 				keyval = 0; modifier = 0;
    748 				gtk_accel_map_change_entry (accel_path, keyval, modifier, TRUE);
    749 			}
    750 			new_accel = gtk_accelerator_get_label(keyval, modifier);
    751 			gtk_label_set_text(label, new_accel);
    752 			g_free(new_accel);
    753 		}
    754 	}
    755 	g_list_free(closures);
    756 }
    757 
    758 static void warning_btn_pressed(GtkButton *btn, gpointer data)
    759 {
    760 	MainWindow *mainwin = (MainWindow *)data;
    761 
    762 	log_window_show_error(mainwin->logwin);
    763 	gtk_widget_hide(mainwin->warning_btn);
    764 }
    765 
    766 static gboolean warning_visi_notify(GtkWidget *widget,
    767 				       GdkEventVisibility *event,
    768 				       MainWindow *mainwindow)
    769 {
    770 	gdk_window_set_cursor(gtk_widget_get_window(mainwindow->warning_btn), hand_cursor);
    771 	return FALSE;
    772 }
    773 
    774 static gboolean warning_leave_notify(GtkWidget *widget,
    775 				      GdkEventCrossing *event,
    776 				      MainWindow *mainwindow)
    777 {
    778 	gdk_window_set_cursor(gtk_widget_get_window(mainwindow->warning_btn), NULL);
    779 	return FALSE;
    780 }
    781 
    782 static gboolean warning_enter_notify(GtkWidget *widget,
    783 				      GdkEventCrossing *event,
    784 				      MainWindow *mainwindow)
    785 {
    786 	gdk_window_set_cursor(gtk_widget_get_window(mainwindow->warning_btn), hand_cursor);
    787 	return FALSE;
    788 }
    789 
    790 void mainwindow_show_error(void)
    791 {
    792 	MainWindow *mainwin = mainwindow_get_mainwindow();
    793 	gtk_widget_show(mainwin->warning_btn);
    794 }
    795 
    796 void mainwindow_clear_error(MainWindow *mainwin)
    797 {
    798 	gtk_widget_hide(mainwin->warning_btn);
    799 }
    800 
    801 #define BREAK_ON_MODIFIER_KEY() \
    802 	if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
    803 
    804 static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
    805 				    gpointer data)
    806 {
    807 	MainWindow *mainwin = (MainWindow*) data;
    808 
    809 	if (!mainwin || !event)
    810 		return FALSE;
    811 
    812 	switch (event->keyval) {
    813 	case GDK_KEY_Q:             /* Quit */
    814 		BREAK_ON_MODIFIER_KEY();
    815 
    816 		if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
    817 			app_exit_cb(NULL, mainwin);
    818 		}
    819 		return FALSE;
    820 	case GDK_KEY_space:
    821 		BREAK_ON_MODIFIER_KEY();
    822 		if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
    823 			if (mainwin->folderview != NULL && mainwin->summaryview != NULL
    824 			    && ((!mainwin->summaryview->displayed
    825 		        	&& !mainwin->summaryview->selected)
    826 				|| (mainwin->summaryview->folder_item
    827 				    && mainwin->summaryview->folder_item->total_msgs == 0))) {
    828 				g_signal_stop_emission_by_name(G_OBJECT(widget),
    829                                 	       "key_press_event");
    830 				folderview_select_next_with_flag(mainwin->folderview, MSG_UNREAD);
    831 			}
    832 		}
    833 		break;
    834 	default:
    835 		break;
    836 	}
    837 	return FALSE;
    838 }
    839 
    840 #undef BREAK_ON_MODIFIER_KEY
    841 
    842 MainWindow *main_window_create()
    843 {
    844 	MainWindow *mainwin;
    845 	GtkWidget *window;
    846 	GtkWidget *vbox;
    847 	GtkWidget *menubar;
    848 	GtkWidget *handlebox;
    849 	GtkWidget *vbox_body;
    850 	GtkWidget *menuitem;
    851 	GtkWidget *hbox_stat;
    852 	GtkWidget *statusbar;
    853 	GtkWidget *progressbar;
    854 	GtkWidget *statuslabel;
    855 	GtkWidget *ac_button;
    856 	GtkWidget *ac_label;
    857  	GtkWidget *online_pixmap;
    858 	GtkWidget *offline_pixmap;
    859 	GtkWidget *warning_btn;
    860 	GtkWidget *online_switch;
    861 	GtkWidget *offline_switch;
    862 	FolderView *folderview;
    863 	SummaryView *summaryview;
    864 	MessageView *messageview;
    865 	GtkWidget *ac_menu;
    866 	GdkScreen *screen;
    867 
    868 	static GdkGeometry geometry;
    869 
    870 	debug_print("Creating main window...\n");
    871 	mainwin = g_new0(MainWindow, 1);
    872 
    873 	/* main window */
    874 	window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
    875 	gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
    876 	gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
    877 	if (!geometry.min_height) {
    878 		geometry.min_width = 320;
    879 		geometry.min_height = 200;
    880 	}
    881 	gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
    882 				      GDK_HINT_MIN_SIZE);
    883 
    884 	g_signal_connect(G_OBJECT(window), "delete_event",
    885 			 G_CALLBACK(main_window_close_cb), mainwin);
    886 	MANAGE_WINDOW_SIGNALS_CONNECT(window);
    887 	g_signal_connect(G_OBJECT(window), "focus_in_event",
    888 			 G_CALLBACK(mainwindow_focus_in_event),
    889 			 mainwin);
    890 	g_signal_connect(G_OBJECT(window), "key_press_event",
    891 			 G_CALLBACK(mainwindow_key_pressed), mainwin);
    892 
    893 	screen = gdk_screen_get_default();
    894 	g_signal_connect(G_OBJECT(screen), "size_changed",
    895 			 G_CALLBACK(gtkut_gdk_screen_size_changed), NULL);
    896 	g_signal_emit_by_name(G_OBJECT(screen), "size_changed", NULL);
    897 
    898 	gtk_widget_realize(window);
    899 	gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
    900 
    901 
    902 	gtkut_widget_set_app_icon(window);
    903 
    904 	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    905 	gtk_widget_show(vbox);
    906 	gtk_container_add(GTK_CONTAINER(window), vbox);
    907 
    908 	/* menu bar */
    909 
    910 	mainwin->ui_manager = gtk_ui_manager_new();
    911 	mainwin->action_group = cm_menu_create_action_group_full(mainwin->ui_manager,"Menu", mainwin_entries,
    912 			G_N_ELEMENTS(mainwin_entries), (gpointer)mainwin);
    913 	gtk_action_group_add_toggle_actions(mainwin->action_group, mainwin_toggle_entries,
    914 			G_N_ELEMENTS(mainwin_toggle_entries), (gpointer)mainwin);
    915 	gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_showhide_radio_entries,
    916 			G_N_ELEMENTS(mainwin_showhide_radio_entries), C_AUTO, G_CALLBACK(toggle_toolbar_cb), (gpointer)mainwin);
    917 
    918 	gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_layout_radio_entries,
    919 			G_N_ELEMENTS(mainwin_layout_radio_entries), C_AUTO, G_CALLBACK(set_layout_cb), (gpointer)mainwin);
    920 
    921 	gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_sort_radio_entries,
    922 			G_N_ELEMENTS(mainwin_sort_radio_entries), C_AUTO, G_CALLBACK(sort_summary_cb), (gpointer)mainwin);
    923 	gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_sorttype_radio_entries,
    924 			G_N_ELEMENTS(mainwin_sorttype_radio_entries), C_AUTO, G_CALLBACK(sort_summary_type_cb), (gpointer)mainwin);
    925 	gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_radio_enc_entries,
    926 			G_N_ELEMENTS(mainwin_radio_enc_entries), C_AUTO, G_CALLBACK(set_charset_cb), (gpointer)mainwin);
    927 	gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_radio_dec_entries,
    928 			G_N_ELEMENTS(mainwin_radio_dec_entries), C_AUTO, G_CALLBACK(set_decode_cb), (gpointer)mainwin);
    929 
    930 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_MENUBAR)
    931 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "File", "File", GTK_UI_MANAGER_MENU)
    932 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU)
    933 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "View", "View", GTK_UI_MANAGER_MENU)
    934 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "Message", "Message", GTK_UI_MANAGER_MENU)
    935 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "Tools", "Tools", GTK_UI_MANAGER_MENU)
    936 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "Configuration", "Configuration", GTK_UI_MANAGER_MENU)
    937 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "Help", "Help", GTK_UI_MANAGER_MENU)
    938 
    939 /* File menu */
    940 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "AddMailbox", "File/AddMailbox", GTK_UI_MANAGER_MENU)
    941 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File/AddMailbox", "MH", "File/AddMailbox/MH", GTK_UI_MANAGER_MENUITEM)
    942 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator1", "File/---", GTK_UI_MANAGER_SEPARATOR)
    943 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SortMailboxes", "File/SortMailboxes", GTK_UI_MANAGER_MENUITEM)
    944 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator3", "File/---", GTK_UI_MANAGER_SEPARATOR)
    945 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "EmptyTrashes", "File/EmptyTrashes", GTK_UI_MANAGER_MENUITEM)
    946 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator4", "File/---", GTK_UI_MANAGER_SEPARATOR)
    947 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM)
    948 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SavePartAs", "File/SavePartAs", GTK_UI_MANAGER_MENUITEM)
    949 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator6", "File/---", GTK_UI_MANAGER_SEPARATOR)
    950 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "OfflineMode", "File/OfflineMode", GTK_UI_MANAGER_MENUITEM)
    951 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SynchroniseFolders", "File/SynchroniseFolders", GTK_UI_MANAGER_MENUITEM)
    952 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator7", "File/---", GTK_UI_MANAGER_SEPARATOR)
    953 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Exit", "File/Exit", GTK_UI_MANAGER_MENUITEM)
    954 
    955 /* Edit menu */
    956 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "Copy", "Edit/Copy", GTK_UI_MANAGER_MENUITEM)
    957 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "SelectAll", "Edit/SelectAll", GTK_UI_MANAGER_MENUITEM)
    958 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "SelectThread", "Edit/SelectThread", GTK_UI_MANAGER_MENUITEM)
    959 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "Separator1", "Edit/---", GTK_UI_MANAGER_SEPARATOR)
    960 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "Find", "Edit/Find", GTK_UI_MANAGER_MENUITEM)
    961 
    962 /* View menu */
    963 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ShowHide", "View/ShowHide", GTK_UI_MANAGER_MENU)
    964 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide", "MenuBar", "View/ShowHide/MenuBar", GTK_UI_MANAGER_MENUITEM)
    965 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide", "Toolbar", "View/ShowHide/Toolbar", GTK_UI_MANAGER_MENU)
    966 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar", "TextBelowIcon", "View/ShowHide/Toolbar/TextBelowIcon", GTK_UI_MANAGER_MENUITEM)
    967 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar", "TextBesideIcon", "View/ShowHide/Toolbar/TextBesideIcon", GTK_UI_MANAGER_MENUITEM)
    968 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar", "IconOnly", "View/ShowHide/Toolbar/IconOnly", GTK_UI_MANAGER_MENUITEM)
    969 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar", "TextOnly", "View/ShowHide/Toolbar/TextOnly", GTK_UI_MANAGER_MENUITEM)
    970 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar", "Hide", "View/ShowHide/Toolbar/Hide", GTK_UI_MANAGER_MENUITEM)
    971 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide", "MessageView", "View/ShowHide/MessageView", GTK_UI_MANAGER_MENUITEM)
    972 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide", "StatusBar", "View/ShowHide/StatusBar", GTK_UI_MANAGER_MENUITEM)
    973 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide", "ColumnHeaders", "View/ShowHide/ColumnHeaders", GTK_UI_MANAGER_MENUITEM)
    974 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "SetColumns", "View/SetColumns", GTK_UI_MANAGER_MENU)
    975 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/SetColumns", "Folderlist", "View/SetColumns/Folderlist", GTK_UI_MANAGER_MENUITEM)
    976 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/SetColumns", "Messagelist", "View/SetColumns/Messagelist", GTK_UI_MANAGER_MENUITEM)
    977 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator1", "View/---", GTK_UI_MANAGER_SEPARATOR)
    978 
    979 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "FullScreen", "View/FullScreen", GTK_UI_MANAGER_MENUITEM)
    980 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Layout", "View/Layout", GTK_UI_MANAGER_MENU)
    981 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Layout", "Standard", "View/Layout/Standard", GTK_UI_MANAGER_MENUITEM)
    982 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Layout", "ThreeColumns", "View/Layout/ThreeColumns", GTK_UI_MANAGER_MENUITEM)
    983 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator2", "View/---", GTK_UI_MANAGER_SEPARATOR)
    984 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Sort", "View/Sort", GTK_UI_MANAGER_MENU)
    985 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Number", "View/Sort/Number", GTK_UI_MANAGER_MENUITEM)
    986 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Size", "View/Sort/Size", GTK_UI_MANAGER_MENUITEM)
    987 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Date", "View/Sort/Date", GTK_UI_MANAGER_MENUITEM)
    988 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "ThreadDate", "View/Sort/ThreadDate", GTK_UI_MANAGER_MENUITEM)
    989 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "From", "View/Sort/From", GTK_UI_MANAGER_MENUITEM)
    990 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "To", "View/Sort/To", GTK_UI_MANAGER_MENUITEM)
    991 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Subject", "View/Sort/Subject", GTK_UI_MANAGER_MENUITEM)
    992 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Mark", "View/Sort/Mark", GTK_UI_MANAGER_MENUITEM)
    993 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Status", "View/Sort/Status", GTK_UI_MANAGER_MENUITEM)
    994 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Attachment", "View/Sort/Attachment", GTK_UI_MANAGER_MENUITEM)
    995 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Score", "View/Sort/Score", GTK_UI_MANAGER_MENUITEM)
    996 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Locked", "View/Sort/Locked", GTK_UI_MANAGER_MENUITEM)
    997 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "DontSort", "View/Sort/DontSort", GTK_UI_MANAGER_MENUITEM)
    998 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Separator1", "View/Sort/---", GTK_UI_MANAGER_SEPARATOR)
    999 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Ascending", "View/Sort/Ascending", GTK_UI_MANAGER_MENUITEM)
   1000 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Descending", "View/Sort/Descending", GTK_UI_MANAGER_MENUITEM)
   1001 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "Separator2", "View/Sort/---", GTK_UI_MANAGER_SEPARATOR)
   1002 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Sort", "AttractSubj", "View/Sort/AttractSubj", GTK_UI_MANAGER_MENUITEM)
   1003 
   1004 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ThreadView", "View/ThreadView", GTK_UI_MANAGER_MENUITEM)
   1005 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ExpandThreads", "View/ExpandThreads", GTK_UI_MANAGER_MENUITEM)
   1006 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "CollapseThreads", "View/CollapseThreads", GTK_UI_MANAGER_MENUITEM)
   1007 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideReadThreads", "View/HideReadThreads", GTK_UI_MANAGER_MENUITEM)
   1008 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideReadMessages", "View/HideReadMessages", GTK_UI_MANAGER_MENUITEM)
   1009 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideDelMessages", "View/HideDelMessages", GTK_UI_MANAGER_MENUITEM)
   1010 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator3", "View/---", GTK_UI_MANAGER_SEPARATOR)
   1011 
   1012 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Goto", "View/Goto", GTK_UI_MANAGER_MENU)
   1013 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Prev", "View/Goto/Prev", GTK_UI_MANAGER_MENUITEM)
   1014 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Next", "View/Goto/Next", GTK_UI_MANAGER_MENUITEM)
   1015 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator1", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1016 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevUnread", "View/Goto/PrevUnread", GTK_UI_MANAGER_MENUITEM)
   1017 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextUnread", "View/Goto/NextUnread", GTK_UI_MANAGER_MENUITEM)
   1018 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator2", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1019 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevNew", "View/Goto/PrevNew", GTK_UI_MANAGER_MENUITEM)
   1020 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextNew", "View/Goto/NextNew", GTK_UI_MANAGER_MENUITEM)
   1021 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator3", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1022 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevMarked", "View/Goto/PrevMarked", GTK_UI_MANAGER_MENUITEM)
   1023 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextMarked", "View/Goto/NextMarked", GTK_UI_MANAGER_MENUITEM)
   1024 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator4", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1025 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevLabeled", "View/Goto/PrevLabeled", GTK_UI_MANAGER_MENUITEM)
   1026 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextLabeled", "View/Goto/NextLabeled", GTK_UI_MANAGER_MENUITEM)
   1027 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator5", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1028 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevHistory", "View/Goto/PrevHistory", GTK_UI_MANAGER_MENUITEM)
   1029 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextHistory", "View/Goto/NextHistory", GTK_UI_MANAGER_MENUITEM)
   1030 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator6", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1031 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
   1032 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator7", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1033 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM)
   1034 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Folder", "View/Goto/Folder", GTK_UI_MANAGER_MENUITEM)
   1035 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator8", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
   1036 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextPart", "View/Goto/NextPart", GTK_UI_MANAGER_MENUITEM)
   1037 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevPart", "View/Goto/PrevPart", GTK_UI_MANAGER_MENUITEM)
   1038 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator4", "View/---", GTK_UI_MANAGER_SEPARATOR)
   1039 
   1040 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Encoding", "View/Encoding", GTK_UI_MANAGER_MENU)
   1041 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", CS_AUTO, "View/Encoding/"CS_AUTO, GTK_UI_MANAGER_MENUITEM)
   1042 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Separator1", "View/Encoding/---", GTK_UI_MANAGER_SEPARATOR)
   1043 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", CS_US_ASCII, "View/Encoding/"CS_US_ASCII, GTK_UI_MANAGER_MENUITEM)
   1044 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", CS_UTF_8, "View/Encoding/"CS_UTF_8, GTK_UI_MANAGER_MENUITEM)
   1045 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Separator2", "View/Encoding/---", GTK_UI_MANAGER_SEPARATOR)
   1046 
   1047 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Western", "View/Encoding/Western", GTK_UI_MANAGER_MENU)
   1048 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Western", CS_ISO_8859_1, "View/Encoding/Western/"CS_ISO_8859_1, GTK_UI_MANAGER_MENUITEM)
   1049 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Western", CS_ISO_8859_15, "View/Encoding/Western/"CS_ISO_8859_15, GTK_UI_MANAGER_MENUITEM)
   1050 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Western", CS_WINDOWS_1252, "View/Encoding/Western/"CS_WINDOWS_1252, GTK_UI_MANAGER_MENUITEM)
   1051 
   1052 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", CS_ISO_8859_2, "View/Encoding/"CS_ISO_8859_2, GTK_UI_MANAGER_MENUITEM)
   1053 
   1054 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Baltic", "View/Encoding/Baltic", GTK_UI_MANAGER_MENU)
   1055 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Baltic", CS_ISO_8859_13, "View/Encoding/Baltic/"CS_ISO_8859_13, GTK_UI_MANAGER_MENUITEM)
   1056 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Baltic", CS_ISO_8859_4, "View/Encoding/Baltic/"CS_ISO_8859_4, GTK_UI_MANAGER_MENUITEM)
   1057 
   1058 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", CS_ISO_8859_7, "View/Encoding/"CS_ISO_8859_7, GTK_UI_MANAGER_MENUITEM)
   1059 
   1060 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Hebrew", "View/Encoding/Hebrew", GTK_UI_MANAGER_MENU)
   1061 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Hebrew", CS_ISO_8859_8, "View/Encoding/Hebrew/"CS_ISO_8859_8, GTK_UI_MANAGER_MENUITEM)
   1062 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Hebrew", CS_WINDOWS_1255, "View/Encoding/Hebrew/"CS_WINDOWS_1255, GTK_UI_MANAGER_MENUITEM)
   1063 
   1064 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Arabic", "View/Encoding/Arabic", GTK_UI_MANAGER_MENU)
   1065 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Arabic", CS_ISO_8859_6, "View/Encoding/Arabic/"CS_ISO_8859_6, GTK_UI_MANAGER_MENUITEM)
   1066 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Arabic", CS_WINDOWS_1256, "View/Encoding/Arabic/"CS_WINDOWS_1256, GTK_UI_MANAGER_MENUITEM)
   1067 
   1068 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", CS_ISO_8859_9, "View/Encoding/"CS_ISO_8859_9, GTK_UI_MANAGER_MENUITEM)
   1069 
   1070 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Cyrillic", "View/Encoding/Cyrillic", GTK_UI_MANAGER_MENU)
   1071 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_ISO_8859_5, "View/Encoding/Cyrillic/"CS_ISO_8859_5, GTK_UI_MANAGER_MENUITEM)
   1072 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_KOI8_R, "View/Encoding/Cyrillic/"CS_KOI8_R, GTK_UI_MANAGER_MENUITEM)
   1073 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_MACCYR, "View/Encoding/Cyrillic/"CS_MACCYR, GTK_UI_MANAGER_MENUITEM)
   1074 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_KOI8_U, "View/Encoding/Cyrillic/"CS_KOI8_U, GTK_UI_MANAGER_MENUITEM)
   1075 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_WINDOWS_1251, "View/Encoding/Cyrillic/"CS_WINDOWS_1251, GTK_UI_MANAGER_MENUITEM)
   1076 
   1077 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Japanese", "View/Encoding/Japanese", GTK_UI_MANAGER_MENU)
   1078 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Japanese", CS_ISO_2022_JP, "View/Encoding/Japanese/"CS_ISO_2022_JP, GTK_UI_MANAGER_MENUITEM)
   1079 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Japanese", CS_ISO_2022_JP_2, "View/Encoding/Japanese/"CS_ISO_2022_JP_2, GTK_UI_MANAGER_MENUITEM)
   1080 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Japanese", CS_EUC_JP, "View/Encoding/Japanese/"CS_EUC_JP, GTK_UI_MANAGER_MENUITEM)
   1081 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Japanese", CS_SHIFT_JIS, "View/Encoding/Japanese/"CS_SHIFT_JIS, GTK_UI_MANAGER_MENUITEM)
   1082 
   1083 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Chinese", "View/Encoding/Chinese", GTK_UI_MANAGER_MENU)
   1084 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GB18030, "View/Encoding/Chinese/"CS_GB18030, GTK_UI_MANAGER_MENUITEM)
   1085 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GB2312, "View/Encoding/Chinese/"CS_GB2312, GTK_UI_MANAGER_MENUITEM)
   1086 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GBK, "View/Encoding/Chinese/"CS_GBK, GTK_UI_MANAGER_MENUITEM)
   1087 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_BIG5, "View/Encoding/Chinese/"CS_BIG5, GTK_UI_MANAGER_MENUITEM)
   1088 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_EUC_TW, "View/Encoding/Chinese/"CS_EUC_TW, GTK_UI_MANAGER_MENUITEM)
   1089 
   1090 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Korean", "View/Encoding/Korean", GTK_UI_MANAGER_MENU)
   1091 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Korean", CS_EUC_KR, "View/Encoding/Korean/"CS_EUC_KR, GTK_UI_MANAGER_MENUITEM)
   1092 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Korean", CS_ISO_2022_KR, "View/Encoding/Korean/"CS_ISO_2022_KR, GTK_UI_MANAGER_MENUITEM)
   1093 
   1094 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Thai", "View/Encoding/Thai", GTK_UI_MANAGER_MENU)
   1095 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Thai", CS_TIS_620, "View/Encoding/Thai/"CS_TIS_620, GTK_UI_MANAGER_MENUITEM)
   1096 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Thai", CS_WINDOWS_874, "View/Encoding/Thai/"CS_WINDOWS_874, GTK_UI_MANAGER_MENUITEM)
   1097 
   1098 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Decode", "View/Decode", GTK_UI_MANAGER_MENU)
   1099 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Decode", "AutoDetect", "View/Decode/AutoDetect", GTK_UI_MANAGER_MENUITEM)
   1100 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Decode", "Separator1", "View/Decode/---", GTK_UI_MANAGER_SEPARATOR)
   1101 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Decode", "8bit", "View/Decode/8bit", GTK_UI_MANAGER_MENUITEM)
   1102 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Decode", "QP", "View/Decode/QP", GTK_UI_MANAGER_MENUITEM)
   1103 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Decode", "B64", "View/Decode/B64", GTK_UI_MANAGER_MENUITEM)
   1104 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Decode", "Uuencode", "View/Decode/Uuencode", GTK_UI_MANAGER_MENUITEM)
   1105 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator5", "View/---", GTK_UI_MANAGER_SEPARATOR)
   1106 
   1107 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "OpenNewWindow", "View/OpenNewWindow", GTK_UI_MANAGER_MENUITEM)
   1108 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "MessageSource", "View/MessageSource", GTK_UI_MANAGER_MENUITEM)
   1109 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "AllHeaders", "View/AllHeaders", GTK_UI_MANAGER_MENUITEM)
   1110 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Quotes", "View/Quotes", GTK_UI_MANAGER_MENU)
   1111 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "CollapseAll", "View/Quotes/CollapseAll", GTK_UI_MANAGER_MENUITEM)
   1112 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "Collapse2", "View/Quotes/Collapse2", GTK_UI_MANAGER_MENUITEM)
   1113 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "Collapse3", "View/Quotes/Collapse3", GTK_UI_MANAGER_MENUITEM)
   1114 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Part", "View/Part", GTK_UI_MANAGER_MENU)
   1115 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Part", "AsText", "View/Part/AsText", GTK_UI_MANAGER_MENUITEM)
   1116 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Part", "Open", "View/Part/Open", GTK_UI_MANAGER_MENUITEM)
   1117 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Part", "OpenWith", "View/Part/OpenWith", GTK_UI_MANAGER_MENUITEM)
   1118 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator8", "View/---", GTK_UI_MANAGER_SEPARATOR)
   1119 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "UpdateSummary", "View/UpdateSummary", GTK_UI_MANAGER_MENUITEM)
   1120 
   1121 /* Message menu */
   1122 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Receive", "Message/Receive", GTK_UI_MANAGER_MENU)
   1123 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Receive", "CurrentAccount", "Message/Receive/CurrentAccount", GTK_UI_MANAGER_MENUITEM)
   1124 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Receive", "AllAccounts", "Message/Receive/AllAccounts", GTK_UI_MANAGER_MENUITEM)
   1125 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Receive", "CancelReceiving", "Message/Receive/CancelReceiving", GTK_UI_MANAGER_MENUITEM)
   1126 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Receive", "Separator1", "Message/Receive/---", GTK_UI_MANAGER_SEPARATOR)
   1127 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Receive", "PlaceHolder", "Message/Receive/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1128 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "SendQueue", "Message/SendQueue", GTK_UI_MANAGER_MENUITEM)
   1129 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "CancelSending", "Message/CancelSending", GTK_UI_MANAGER_MENUITEM)
   1130 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Separator1", "Message/---", GTK_UI_MANAGER_SEPARATOR)
   1131 
   1132 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "ComposeEmail", "Message/ComposeEmail", GTK_UI_MANAGER_MENUITEM)
   1133 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Reply", "Message/Reply", GTK_UI_MANAGER_MENUITEM)
   1134 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "ReplyTo", "Message/ReplyTo", GTK_UI_MANAGER_MENU)
   1135 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/ReplyTo", "All", "Message/ReplyTo/All", GTK_UI_MANAGER_MENUITEM)
   1136 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/ReplyTo", "Sender", "Message/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM)
   1137 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/ReplyTo", "List", "Message/ReplyTo/List", GTK_UI_MANAGER_MENUITEM)
   1138 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "FollowupReply", "Message/FollowupReply", GTK_UI_MANAGER_MENUITEM)
   1139 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR)
   1140 
   1141 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Forward", "Message/Forward", GTK_UI_MANAGER_MENUITEM)
   1142 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "ForwardAtt", "Message/ForwardAtt", GTK_UI_MANAGER_MENUITEM)
   1143 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Redirect", "Message/Redirect", GTK_UI_MANAGER_MENUITEM)
   1144 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "MailingList", "Message/MailingList", GTK_UI_MANAGER_MENU)
   1145 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList", "Post", "Message/MailingList/Post", GTK_UI_MANAGER_MENU)
   1146 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList", "Help", "Message/MailingList/Help", GTK_UI_MANAGER_MENU)
   1147 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList", "Subscribe", "Message/MailingList/Subscribe", GTK_UI_MANAGER_MENU)
   1148 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList", "Unsubscribe", "Message/MailingList/Unsubscribe", GTK_UI_MANAGER_MENU)
   1149 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList", "ViewArchive", "Message/MailingList/ViewArchive", GTK_UI_MANAGER_MENU)
   1150 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList", "ContactOwner", "Message/MailingList/ContactOwner", GTK_UI_MANAGER_MENU)
   1151 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList/Post", "PlaceHolder", "Message/MailingList/Post/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1152 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList/Help", "PlaceHolder", "Message/MailingList/Help/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1153 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList/Subscribe", "PlaceHolder", "Message/MailingList/Subscribe/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1154 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList/Unsubscribe", "PlaceHolder", "Message/MailingList/Unsubscribe/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1155 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList/ViewArchive", "PlaceHolder", "Message/MailingList/ViewArchive/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1156 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/MailingList/ContactOwner", "PlaceHolder", "Message/MailingList/ContactOwner/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1157 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Separator3", "Message/---", GTK_UI_MANAGER_SEPARATOR)
   1158 
   1159 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Move", "Message/Move", GTK_UI_MANAGER_MENUITEM)
   1160 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Copy", "Message/Copy", GTK_UI_MANAGER_MENUITEM)
   1161 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Trash", "Message/Trash", GTK_UI_MANAGER_MENUITEM)
   1162 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Delete", "Message/Delete", GTK_UI_MANAGER_MENUITEM)
   1163 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "TrashThread", "Message/TrashThread", GTK_UI_MANAGER_MENUITEM)
   1164 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "DeleteThread", "Message/DeleteThread", GTK_UI_MANAGER_MENUITEM)
   1165 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "CancelNews", "Message/CancelNews", GTK_UI_MANAGER_MENUITEM)
   1166 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Separator4", "Message/---", GTK_UI_MANAGER_SEPARATOR)
   1167 
   1168 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Marks", "Message/Marks", GTK_UI_MANAGER_MENU)
   1169 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Mark", "Message/Marks/Mark", GTK_UI_MANAGER_MENUITEM)
   1170 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Unmark", "Message/Marks/Unmark", GTK_UI_MANAGER_MENUITEM)
   1171 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Separator1", "Message/Marks/---", GTK_UI_MANAGER_SEPARATOR)
   1172 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "MarkRead", "Message/Marks/MarkRead", GTK_UI_MANAGER_MENUITEM)
   1173 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "MarkUnread", "Message/Marks/MarkUnread", GTK_UI_MANAGER_MENUITEM)
   1174 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Separator2", "Message/Marks/---", GTK_UI_MANAGER_SEPARATOR)
   1175 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "MarkAllRead", "Message/Marks/MarkAllRead", GTK_UI_MANAGER_MENUITEM)
   1176 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "MarkAllUnread", "Message/Marks/MarkAllUnread", GTK_UI_MANAGER_MENUITEM)
   1177 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Separator3", "Message/Marks/---", GTK_UI_MANAGER_SEPARATOR)
   1178 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "IgnoreThread", "Message/Marks/IgnoreThread", GTK_UI_MANAGER_MENUITEM)
   1179 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "UnignoreThread", "Message/Marks/UnignoreThread", GTK_UI_MANAGER_MENUITEM)
   1180 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "WatchThread", "Message/Marks/WatchThread", GTK_UI_MANAGER_MENUITEM)
   1181 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "UnwatchThread", "Message/Marks/UnwatchThread", GTK_UI_MANAGER_MENUITEM)
   1182 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Separator4", "Message/Marks/---", GTK_UI_MANAGER_SEPARATOR)
   1183 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Separator5", "Message/Marks/---", GTK_UI_MANAGER_SEPARATOR)
   1184 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Lock", "Message/Marks/Lock", GTK_UI_MANAGER_MENUITEM)
   1185 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message/Marks", "Unlock", "Message/Marks/Unlock", GTK_UI_MANAGER_MENUITEM)
   1186 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Separator5", "Message/---", GTK_UI_MANAGER_SEPARATOR)
   1187 
   1188 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Reedit", "Message/Reedit", GTK_UI_MANAGER_MENUITEM)
   1189 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Separator6", "Message/---", GTK_UI_MANAGER_SEPARATOR)
   1190 
   1191 /* Tools menu */
   1192 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "AddressBook", "Tools/AddressBook", GTK_UI_MANAGER_MENUITEM)
   1193 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "AddSenderToAB", "Tools/AddSenderToAB", GTK_UI_MANAGER_MENUITEM)
   1194 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator1", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
   1195 
   1196 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "CheckNewMessages", "Tools/CheckNewMessages", GTK_UI_MANAGER_MENUITEM)
   1197 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "DeleteDuplicates", "Tools/DeleteDuplicates", GTK_UI_MANAGER_MENU)
   1198 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools/DeleteDuplicates", "SelFolder", "Tools/DeleteDuplicates/SelFolder", GTK_UI_MANAGER_MENUITEM)
   1199 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools/DeleteDuplicates", "AllFolders", "Tools/DeleteDuplicates/AllFolders", GTK_UI_MANAGER_MENUITEM)
   1200 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator5", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
   1201 
   1202 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Execute", "Tools/Execute", GTK_UI_MANAGER_MENUITEM)
   1203 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Expunge", "Tools/Expunge", GTK_UI_MANAGER_MENUITEM)
   1204 
   1205 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator7", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
   1206 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "NetworkLog", "Tools/NetworkLog", GTK_UI_MANAGER_MENUITEM)
   1207 
   1208 /* Configuration menu */
   1209 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "ChangeAccount", "Configuration/ChangeAccount", GTK_UI_MANAGER_MENU)
   1210 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration/ChangeAccount", "PlaceHolder", "Configuration/ChangeAccount/PlaceHolder", GTK_UI_MANAGER_MENUITEM)
   1211 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "AccountPrefs", "Configuration/AccountPrefs", GTK_UI_MANAGER_MENUITEM)
   1212 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "CreateAccount", "Configuration/CreateAccount", GTK_UI_MANAGER_MENUITEM)
   1213 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "EditAccounts", "Configuration/EditAccounts", GTK_UI_MANAGER_MENUITEM)
   1214 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "Separator1", "Configuration/---", GTK_UI_MANAGER_SEPARATOR)
   1215 
   1216 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "Preferences", "Configuration/Preferences", GTK_UI_MANAGER_MENUITEM)
   1217 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "Actions", "Configuration/Actions", GTK_UI_MANAGER_MENUITEM)
   1218 
   1219 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "Separator2", "Configuration/---", GTK_UI_MANAGER_SEPARATOR)
   1220 
   1221 /* Help menu */
   1222 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Manual", "Help/Manual", GTK_UI_MANAGER_MENUITEM)
   1223 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "FAQ", "Help/FAQ", GTK_UI_MANAGER_MENUITEM)
   1224 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "IconLegend", "Help/IconLegend", GTK_UI_MANAGER_MENUITEM)
   1225 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator2", "Help/---", GTK_UI_MANAGER_SEPARATOR)
   1226 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM)
   1227 
   1228 
   1229 	menubar = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu");
   1230 	if (prefs_common.mainwin_menubar)
   1231 		gtk_widget_show_all(menubar);
   1232 	else
   1233 		gtk_widget_hide(menubar);
   1234 	gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(mainwin->ui_manager));
   1235 
   1236 	/* Create a menu container for the different popup menus we
   1237 	 * will be adding from other UI elements. */
   1238 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/", "Menus", "Menus", GTK_UI_MANAGER_MENUBAR)
   1239 
   1240 	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
   1241 
   1242 	handlebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
   1243 	gtk_widget_show(handlebox);
   1244 	gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
   1245 	/* link window to mainwin->window to avoid gdk warnings */
   1246 	mainwin->window       = window;
   1247 	mainwin_list = g_list_append(mainwin_list, mainwin);
   1248 
   1249 	mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
   1250 					  handlebox,
   1251 					  (gpointer)mainwin);
   1252 
   1253 	/* vbox that contains body */
   1254 	vbox_body = gtk_box_new(GTK_ORIENTATION_VERTICAL, BORDER_WIDTH);
   1255 	gtk_widget_show(vbox_body);
   1256 	gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
   1257 	gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
   1258 
   1259 	hbox_stat = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
   1260 	gtk_widget_set_name(GTK_WIDGET(hbox_stat), "hbox_stat");
   1261 	gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
   1262 	warning_btn = gtk_button_new();
   1263 	gtk_button_set_image(GTK_BUTTON(warning_btn),
   1264 			     gtk_image_new_from_icon_name("dialog-warning-symbolic", GTK_ICON_SIZE_BUTTON));
   1265 	CLAWS_SET_TIP(warning_btn,
   1266 			     _("Some error(s) happened. Click here to view log."));
   1267 
   1268 	mainwin->warning_btn      = warning_btn;
   1269 
   1270 	g_signal_connect(G_OBJECT(warning_btn), "clicked",
   1271 			 G_CALLBACK(warning_btn_pressed), mainwin);
   1272 	g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
   1273 			 G_CALLBACK(warning_visi_notify), mainwin);
   1274 	g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
   1275 			 G_CALLBACK(warning_leave_notify), mainwin);
   1276 	g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
   1277 			 G_CALLBACK(warning_enter_notify), mainwin);
   1278 
   1279 	gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
   1280 
   1281 	statusbar = statusbar_create();
   1282 	gtk_widget_set_margin_start(statusbar, 2);
   1283 	gtk_widget_set_margin_end(statusbar, 0);
   1284 	gtk_widget_set_margin_top(statusbar, 0);
   1285 	gtk_widget_set_margin_bottom(statusbar, 0);
   1286 	gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
   1287 
   1288 	progressbar = gtk_progress_bar_new();
   1289 	gtk_widget_set_size_request(progressbar, 120, 1);
   1290 	gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
   1291 
   1292 	online_pixmap = stock_pixmap_widget(STOCK_PIXMAP_ONLINE);
   1293 	offline_pixmap = stock_pixmap_widget(STOCK_PIXMAP_OFFLINE);
   1294 	online_switch = gtk_button_new ();
   1295 	gtk_widget_set_can_focus(online_switch, FALSE);
   1296 	CLAWS_SET_TIP(online_switch,
   1297 			     _("You are online. Click the icon to go offline"));
   1298 	offline_switch = gtk_button_new ();
   1299 	CLAWS_SET_TIP(offline_switch,
   1300 			     _("You are offline. Click the icon to go online"));
   1301 	gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
   1302 	gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
   1303 	g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
   1304 	gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
   1305 	gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
   1306 	gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
   1307 	g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
   1308 	gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
   1309 
   1310 	statuslabel = gtk_label_new("");
   1311 	gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
   1312 
   1313 	ac_button = gtk_button_new();
   1314 	CLAWS_SET_TIP(ac_button, _("Select account"));
   1315 	gtk_widget_set_can_focus(ac_button, FALSE);
   1316 	gtk_widget_set_size_request(ac_button, -1, 0);
   1317 	gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
   1318 	g_signal_connect(G_OBJECT(ac_button), "button_press_event",
   1319 			 G_CALLBACK(ac_label_button_pressed), mainwin);
   1320 
   1321 	ac_label = gtk_label_new("");
   1322 	gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
   1323 
   1324 	gtk_widget_show_all(hbox_stat);
   1325 
   1326 	gtk_widget_hide(offline_switch);
   1327 	gtk_widget_hide(progressbar);
   1328 	gtk_widget_hide(warning_btn);
   1329 
   1330 	/* create views */
   1331 	mainwin->folderview  = folderview  = folderview_create(mainwin);
   1332 	mainwin->summaryview = summaryview = summary_create(mainwin);
   1333 	mainwin->messageview = messageview = messageview_create(mainwin);
   1334 
   1335 	/* init log instances data before creating log views */
   1336 	set_log_title(LOG_PROTOCOL, _("Network log"));
   1337 	set_log_prefs(LOG_PROTOCOL,
   1338 			&prefs_common.logwin_width,
   1339 			&prefs_common.logwin_height);
   1340 
   1341 	mainwin->logwin = log_window_create(LOG_PROTOCOL);
   1342 	log_window_init(mainwin->logwin);
   1343 
   1344 	folderview->mainwin      = mainwin;
   1345 	folderview->summaryview  = summaryview;
   1346 
   1347 	summaryview->mainwin     = mainwin;
   1348 	summaryview->folderview  = folderview;
   1349 	summaryview->messageview = messageview;
   1350 	summaryview->window      = window;
   1351 
   1352 	mainwin->vbox           = vbox;
   1353 	mainwin->menubar        = menubar;
   1354 	mainwin->handlebox      = handlebox;
   1355 	mainwin->vbox_body      = vbox_body;
   1356 	mainwin->online_switch  = online_switch;
   1357 	mainwin->offline_switch    = offline_switch;
   1358 	messageview->statusbar  = statusbar;
   1359 	mainwin->statusbar      = statusbar;
   1360 	mainwin->hbox_stat      = hbox_stat;
   1361 	mainwin->progressbar    = progressbar;
   1362 	mainwin->statuslabel    = statuslabel;
   1363 	mainwin->online_pixmap  = online_pixmap;
   1364 	mainwin->offline_pixmap = offline_pixmap;
   1365 	mainwin->ac_button      = ac_button;
   1366 	mainwin->ac_label       = ac_label;
   1367 	/* set context IDs for status bar */
   1368 	mainwin->mainwin_cid = gtk_statusbar_get_context_id
   1369 		(GTK_STATUSBAR(statusbar), "Main Window");
   1370 	mainwin->folderview_cid = gtk_statusbar_get_context_id
   1371 		(GTK_STATUSBAR(statusbar), "Folder View");
   1372 	mainwin->summaryview_cid = gtk_statusbar_get_context_id
   1373 		(GTK_STATUSBAR(statusbar), "Summary View");
   1374 	mainwin->messageview_cid = gtk_statusbar_get_context_id
   1375 		(GTK_STATUSBAR(statusbar), "Message View");
   1376 	messageview->statusbar_cid = mainwin->messageview_cid;
   1377 
   1378 	/* allocate colors for summary view and folder view */
   1379 	summaryview->color_marked.red = summaryview->color_marked.green = 0;
   1380 	summaryview->color_marked.blue = (guint16)65535;
   1381 
   1382 	summaryview->color_dim.red = summaryview->color_dim.green =
   1383 		summaryview->color_dim.blue = COLOR_DIM;
   1384 
   1385 	folderview->color_new = prefs_common.color[COL_NEW];
   1386 	folderview->color_op = prefs_common.color[COL_TGT_FOLDER];
   1387 
   1388 	debug_print("done.\n");
   1389 
   1390 	messageview->visible = prefs_common.msgview_visible;
   1391 
   1392 	main_window_set_widgets(mainwin, prefs_common.layout_mode);
   1393 
   1394 	g_signal_connect(G_OBJECT(window), "size_allocate",
   1395 			 G_CALLBACK(main_window_size_allocate_cb),
   1396 			 mainwin);
   1397 
   1398 	/* set menu items */
   1399 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Encoding/"CS_AUTO, TRUE);
   1400 
   1401 	menuitem = NULL;
   1402 	switch (prefs_common.toolbar_style) {
   1403 	case TOOLBAR_NONE:
   1404 		menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar/Hide");
   1405 		break;
   1406 	case TOOLBAR_ICON:
   1407 		menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar/IconOnly");
   1408 		break;
   1409 	case TOOLBAR_TEXT:
   1410 		menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar/TextOnly");
   1411 		break;
   1412 	case TOOLBAR_BOTH:
   1413 		menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar/TextBelowIcon");
   1414 		break;
   1415 	case TOOLBAR_BOTH_HORIZ:
   1416 		menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar/TextBesideIcon");
   1417 	}
   1418 	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
   1419 
   1420 	toolbar_set_style(mainwin->toolbar->toolbar,
   1421 			  mainwin->handlebox,
   1422 			  prefs_common.toolbar_style);
   1423 
   1424 	gtk_widget_hide(mainwin->hbox_stat);
   1425 	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/StatusBar");
   1426 	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
   1427 				       prefs_common.show_statusbar);
   1428 
   1429 	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/ColumnHeaders");
   1430 	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
   1431 				       prefs_common.show_col_headers);
   1432 	/* set account selection menu */
   1433 	ac_menu = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Configuration/ChangeAccount");
   1434 	mainwin->ac_menu = ac_menu;
   1435 
   1436 	toolbar_main_set_sensitive(mainwin);
   1437 
   1438 	/* create actions menu */
   1439 	main_window_update_actions_menu(mainwin);
   1440 
   1441 	main_create_mailing_list_menu (mainwin, NULL);
   1442 
   1443 	/* attach accel groups to main window */
   1444 #define	ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win)			\
   1445 	gtk_window_add_accel_group					\
   1446 		(GTK_WINDOW(win), 					\
   1447 		 gtk_ui_manager_get_accel_group(gtkut_ui_manager()));
   1448 
   1449 	ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
   1450 
   1451 	g_signal_connect(G_OBJECT(window), "window_state_event",
   1452 			 G_CALLBACK(mainwindow_state_event_cb), mainwin);
   1453 	g_signal_connect(G_OBJECT(window), "visibility_notify_event",
   1454 			 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
   1455 	gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
   1456 
   1457 	if (prefs_common.layout_mode == VERTICAL_LAYOUT) {
   1458 		summary_relayout(mainwin->summaryview);
   1459 	}
   1460 	summary_update_unread(mainwin->summaryview, NULL);
   1461 
   1462 	/* initialize views */
   1463 	folderview_init(folderview);
   1464 	summary_init(summaryview);
   1465 	messageview_init(messageview);
   1466 
   1467 	mainwin->lock_count = 0;
   1468 	mainwin->menu_lock_count = 0;
   1469 	mainwin->cursor_count = 0;
   1470 
   1471 	mainwin->progressindicator_hook =
   1472 		hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
   1473 
   1474 	if (!watch_cursor)
   1475 		watch_cursor = gdk_cursor_new_for_display(
   1476 				gtk_widget_get_display(mainwin->window), GDK_WATCH);
   1477 	if (!hand_cursor)
   1478 		hand_cursor = gdk_cursor_new_for_display(
   1479 				gtk_widget_get_display(mainwin->window), GDK_HAND2);
   1480 
   1481 	/* init work_offline */
   1482 	if (prefs_common.work_offline)
   1483 		online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
   1484 
   1485 	if (prefs_common.mainwin_fullscreen) {
   1486 		cm_toggle_menu_set_active_full(mainwin->ui_manager,
   1487 			"Menu/View/FullScreen",
   1488 			TRUE);
   1489 	}
   1490 	if (prefs_common.mainwin_menubar)
   1491 		cm_toggle_menu_set_active_full(mainwin->ui_manager,"Menu/View/ShowHide/MenuBar", TRUE);
   1492 
   1493 	return mainwin;
   1494 }
   1495 
   1496 void main_window_update_actions_menu(MainWindow *mainwin)
   1497 {
   1498 	action_update_mainwin_menu(mainwin->ui_manager, "/Menu/Tools/Actions", mainwin);
   1499 }
   1500 
   1501 void main_window_cursor_wait(MainWindow *mainwin)
   1502 {
   1503 	GdkDisplay *display;
   1504 
   1505 	display = gdk_display_get_default();
   1506 
   1507 	if (mainwin->cursor_count == 0) {
   1508 		gdk_window_set_cursor(gtk_widget_get_window(mainwin->window), watch_cursor);
   1509 		textview_cursor_wait(mainwin->messageview->mimeview->textview);
   1510 	}
   1511 
   1512 	mainwin->cursor_count++;
   1513 
   1514 	gdk_display_flush(display);
   1515 }
   1516 
   1517 void main_window_cursor_normal(MainWindow *mainwin)
   1518 {
   1519 	GdkDisplay *display;
   1520 
   1521 	display = gdk_display_get_default();
   1522 
   1523 	if (mainwin->cursor_count)
   1524 		mainwin->cursor_count--;
   1525 
   1526 	if (mainwin->cursor_count == 0) {
   1527 		gdk_window_set_cursor(gtk_widget_get_window(mainwin->window), NULL);
   1528 		textview_cursor_normal(mainwin->messageview->mimeview->textview);
   1529 	}
   1530 	gdk_display_flush(display);
   1531 }
   1532 
   1533 /* lock / unlock the user-interface */
   1534 void main_window_lock(MainWindow *mainwin)
   1535 {
   1536 	if (mainwin->lock_count == 0 && mainwin->ac_button)
   1537 		gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
   1538 
   1539 	mainwin->lock_count++;
   1540 
   1541 	main_window_set_menu_sensitive(mainwin);
   1542 	toolbar_main_set_sensitive(mainwin);
   1543 }
   1544 
   1545 void main_window_unlock(MainWindow *mainwin)
   1546 {
   1547 	if (mainwin->lock_count)
   1548 		mainwin->lock_count--;
   1549 
   1550 	main_window_set_menu_sensitive(mainwin);
   1551 	toolbar_main_set_sensitive(mainwin);
   1552 
   1553 	if (mainwin->lock_count == 0 && mainwin->ac_button)
   1554 		gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
   1555 }
   1556 
   1557 static void main_window_menu_callback_block(MainWindow *mainwin)
   1558 {
   1559 	mainwin->menu_lock_count++;
   1560 }
   1561 
   1562 static void main_window_menu_callback_unblock(MainWindow *mainwin)
   1563 {
   1564 	if (mainwin->menu_lock_count)
   1565 		mainwin->menu_lock_count--;
   1566 }
   1567 
   1568 static guint prefs_tag = 0;
   1569 
   1570 void main_window_reflect_prefs_all(void)
   1571 {
   1572 	main_window_reflect_prefs_all_real(FALSE);
   1573 }
   1574 
   1575 static gboolean reflect_prefs_timeout_cb(gpointer data)
   1576 {
   1577 	gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
   1578 	GList *cur;
   1579 	MainWindow *mainwin;
   1580 	GtkWidget *pixmap;
   1581 
   1582 	for (cur = mainwin_list; cur != NULL; cur = cur->next) {
   1583 		mainwin = (MainWindow *)cur->data;
   1584 
   1585 		main_window_show_cur_account(mainwin);
   1586 		main_window_set_menu_sensitive(mainwin);
   1587 		toolbar_main_set_sensitive(mainwin);
   1588 
   1589 		/* pixmap themes */
   1590 		if (pixmap_theme_changed) {
   1591 			toolbar_update(TOOLBAR_MAIN, mainwin);
   1592 			messageview_reflect_prefs_pixmap_theme();
   1593 			compose_reflect_prefs_pixmap_theme();
   1594 			folderview_init(mainwin->folderview);
   1595 			summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
   1596 			foldersel_reflect_prefs_pixmap_theme();
   1597 			addressbook_reflect_prefs_pixmap_theme();
   1598 			pixmap = stock_pixmap_widget(STOCK_PIXMAP_ONLINE);
   1599 			gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
   1600 					     mainwin->online_pixmap);
   1601 			gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
   1602 			gtk_widget_show(pixmap);
   1603 			mainwin->online_pixmap = pixmap;
   1604 			pixmap = stock_pixmap_widget(STOCK_PIXMAP_OFFLINE);
   1605 			gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
   1606 					     mainwin->offline_pixmap);
   1607 			gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
   1608 			gtk_widget_show(pixmap);
   1609 			mainwin->offline_pixmap = pixmap;
   1610 			hooks_invoke(THEME_CHANGED_HOOKLIST, NULL);
   1611 		}
   1612 
   1613 		textview_reflect_prefs(mainwin->messageview->mimeview->textview);
   1614 		summary_redisplay_msg(mainwin->summaryview);
   1615 	}
   1616 	prefs_tag = 0;
   1617 	return FALSE;
   1618 }
   1619 
   1620 void main_window_reflect_prefs_all_now(void)
   1621 {
   1622 	reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
   1623 }
   1624 
   1625 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
   1626 {
   1627 	if (prefs_tag == 0) {
   1628 		prefs_tag = g_timeout_add(100, reflect_prefs_timeout_cb,
   1629 						GINT_TO_POINTER(pixmap_theme_changed));
   1630 	}
   1631 }
   1632 
   1633 void main_window_set_summary_column(void)
   1634 {
   1635 	GList *cur;
   1636 	MainWindow *mainwin;
   1637 
   1638 	for (cur = mainwin_list; cur != NULL; cur = cur->next) {
   1639 		mainwin = (MainWindow *)cur->data;
   1640 		summary_set_column_order(mainwin->summaryview);
   1641 	}
   1642 }
   1643 
   1644 void main_window_set_folder_column(void)
   1645 {
   1646 	GList *cur;
   1647 	MainWindow *mainwin;
   1648 
   1649 	for (cur = mainwin_list; cur != NULL; cur = cur->next) {
   1650 		mainwin = (MainWindow *)cur->data;
   1651 		folderview_set_column_order(mainwin->folderview);
   1652 	}
   1653 }
   1654 
   1655 static void main_window_set_account_selector_menu(MainWindow *mainwin,
   1656 						  GList *account_list)
   1657 {
   1658 	GList *cur_ac;
   1659 	GtkWidget *menuitem;
   1660 	PrefsAccount *ac_prefs;
   1661 	GtkWidget *menu;
   1662 	gchar *accel_path;
   1663 
   1664 	menu = gtk_menu_new();
   1665 	gtk_menu_set_accel_group (GTK_MENU (menu),
   1666 		gtk_ui_manager_get_accel_group(mainwin->ui_manager));
   1667 
   1668 	for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
   1669 		ac_prefs = (PrefsAccount *)cur_ac->data;
   1670 
   1671 		menuitem = gtk_menu_item_new_with_label
   1672 			(ac_prefs->account_name
   1673 			 ? ac_prefs->account_name : _("Untitled"));
   1674 		gtk_widget_show(menuitem);
   1675 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
   1676 		g_signal_connect(G_OBJECT(menuitem), "activate",
   1677 				 G_CALLBACK(account_selector_menu_cb),
   1678 				 ac_prefs);
   1679 		accel_path = g_strconcat("<Actions>/Menu/Configuration/ChangeAccount/",(ac_prefs->account_name
   1680 			 ? ac_prefs->account_name : _("Untitled")), NULL );
   1681 		gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), accel_path);
   1682 		g_free(accel_path);
   1683 	}
   1684 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(mainwin->ac_menu), menu);
   1685 }
   1686 
   1687 static void main_window_set_account_receive_menu(MainWindow *mainwin,
   1688 						 GList *account_list)
   1689 {
   1690 	GList *children, *child;
   1691 	GtkWidget *menu;
   1692 	GtkWidget *menuitem;
   1693 	PrefsAccount *ac_prefs;
   1694 
   1695 	menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
   1696 		gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive")));
   1697 
   1698 	/* search for separator */
   1699 	children = gtk_container_get_children(GTK_CONTAINER(menu));
   1700 	for (child = children; child != NULL; child = child->next) {
   1701 		if (child->data == gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive/Separator1")) {
   1702 			child = child->next;
   1703 			break;
   1704 		}
   1705 	}
   1706 
   1707 	/* destroy all previous menu item */
   1708 	while (child != NULL) {
   1709 		gtk_widget_destroy(GTK_WIDGET(child->data));
   1710 		child = child->next;
   1711 	}
   1712 
   1713 	g_list_free(children);
   1714 
   1715 	for (child = account_list; child != NULL; child = child->next) {
   1716 		ac_prefs = (PrefsAccount *)child->data;
   1717 
   1718 		if (ac_prefs->protocol == A_NONE)
   1719 			continue;
   1720 
   1721 		menuitem = gtk_menu_item_new_with_label
   1722 			(ac_prefs->account_name ? ac_prefs->account_name
   1723 			 : _("Untitled"));
   1724 		gtk_widget_show(menuitem);
   1725 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
   1726 		g_signal_connect(G_OBJECT(menuitem), "activate",
   1727 				 G_CALLBACK(account_receive_menu_cb),
   1728 				 ac_prefs);
   1729 	}
   1730 }
   1731 
   1732 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
   1733 						       GList *account_list)
   1734 {
   1735 	GList *cur_ac;
   1736 	GtkWidget *menuitem;
   1737 	PrefsAccount *ac_prefs;
   1738 	GtkWidget *menu = NULL;
   1739 
   1740 	if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
   1741 		return;
   1742 
   1743 	menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
   1744 	if (menu)
   1745 		gtk_widget_destroy(menu);
   1746 	menu = gtk_menu_new();
   1747 
   1748 	for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
   1749 		ac_prefs = (PrefsAccount *)cur_ac->data;
   1750 
   1751 		if (ac_prefs->protocol == A_NONE)
   1752 			continue;
   1753 
   1754 		menuitem = gtk_menu_item_new_with_label
   1755 			(ac_prefs->account_name
   1756 			 ? ac_prefs->account_name : _("Untitled"));
   1757 		gtk_widget_show(menuitem);
   1758 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
   1759 		g_signal_connect(G_OBJECT(menuitem), "activate",
   1760 				 G_CALLBACK(account_receive_menu_cb),
   1761 				 ac_prefs);
   1762 	}
   1763 	gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
   1764 }
   1765 
   1766 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
   1767 						       GList *account_list)
   1768 {
   1769 	GList *cur_ac;
   1770 	GtkWidget *menuitem;
   1771 	PrefsAccount *ac_prefs;
   1772 	GtkWidget *menu = NULL;
   1773 
   1774 	if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
   1775 		return;
   1776 
   1777 	menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
   1778 	if (menu)
   1779 		gtk_widget_destroy(menu);
   1780 	menu = gtk_menu_new();
   1781 
   1782 	for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
   1783 		ac_prefs = (PrefsAccount *)cur_ac->data;
   1784 
   1785 		menuitem = gtk_menu_item_new_with_label
   1786 			(ac_prefs->account_name
   1787 			 ? ac_prefs->account_name : _("Untitled"));
   1788 		gtk_widget_show(menuitem);
   1789 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
   1790 		g_signal_connect(G_OBJECT(menuitem), "activate",
   1791 				 G_CALLBACK(account_compose_menu_cb),
   1792 				 ac_prefs);
   1793 	}
   1794 	gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
   1795 }
   1796 
   1797 void main_window_set_account_menu(GList *account_list)
   1798 {
   1799 	GList *cur;
   1800 	MainWindow *mainwin;
   1801 
   1802 	for (cur = mainwin_list; cur != NULL; cur = cur->next) {
   1803 		mainwin = (MainWindow *)cur->data;
   1804 		main_window_set_account_selector_menu(mainwin, account_list);
   1805 		main_window_set_account_receive_menu(mainwin, account_list);
   1806 		main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
   1807 		main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
   1808 	}
   1809 	hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
   1810 }
   1811 
   1812 void main_window_set_account_menu_only_toolbar(GList *account_list)
   1813 {
   1814 	GList *cur;
   1815 	MainWindow *mainwin;
   1816 
   1817 	for (cur = mainwin_list; cur != NULL; cur = cur->next) {
   1818 		mainwin = (MainWindow *)cur->data;
   1819 		main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
   1820 		main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
   1821 	}
   1822 }
   1823 
   1824 static void main_window_show_cur_account(MainWindow *mainwin)
   1825 {
   1826 	gchar *buf;
   1827 	gchar *ac_name;
   1828 
   1829 	ac_name = g_strdup(cur_account
   1830 			   ? (cur_account->account_name
   1831 			      ? cur_account->account_name : _("Untitled"))
   1832 			   : _("none"));
   1833 
   1834 	if (cur_account)
   1835 		buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
   1836 	else
   1837 		buf = g_strdup(PROG_VERSION);
   1838 	gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
   1839 	g_free(buf);
   1840 
   1841 	if (mainwin->ac_label)
   1842 		gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
   1843 	if (mainwin->ac_button)
   1844 		gtk_widget_queue_resize(mainwin->ac_button);
   1845 
   1846 	g_free(ac_name);
   1847 }
   1848 
   1849 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
   1850 {
   1851 	GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
   1852 	GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
   1853 	GtkWidget *message_wid = mainwin->messageview->vbox;
   1854 
   1855 	if (layout_mode == prefs_common.layout_mode)
   1856 		return;
   1857 
   1858 	debug_print("Changing window separation type from %d to %d\n",
   1859 		    prefs_common.layout_mode, layout_mode);
   1860 
   1861 	/* remove widgets from those containers */
   1862 	g_object_ref(folder_wid);
   1863 	g_object_ref(summary_wid);
   1864 	g_object_ref(message_wid);
   1865 	gtk_container_remove
   1866 		(GTK_CONTAINER(gtk_widget_get_parent(folder_wid)), folder_wid);
   1867 	gtk_container_remove
   1868 		(GTK_CONTAINER(gtk_widget_get_parent(summary_wid)), summary_wid);
   1869 	gtk_container_remove
   1870 		(GTK_CONTAINER(gtk_widget_get_parent(message_wid)), message_wid);
   1871 
   1872 	gtk_widget_hide(mainwin->window);
   1873 	main_window_set_widgets(mainwin, layout_mode);
   1874 	gtk_widget_show(mainwin->window);
   1875 
   1876 	g_object_unref(folder_wid);
   1877 	g_object_unref(summary_wid);
   1878 	g_object_unref(message_wid);
   1879 }
   1880 
   1881 void mainwindow_reset_paned(GtkPaned *paned)
   1882 {
   1883 		gint min, max, mid;
   1884 
   1885 		if (gtk_paned_get_child1(GTK_PANED(paned)))
   1886 			gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
   1887 		if (gtk_paned_get_child2(GTK_PANED(paned)))
   1888 			gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
   1889 
   1890 GTK_EVENTS_FLUSH();
   1891         	g_object_get (G_OBJECT(paned),
   1892                         	"min-position",
   1893                         	&min, NULL);
   1894         	g_object_get (G_OBJECT(paned),
   1895                         	"max-position",
   1896                         	&max, NULL);
   1897 		mid = (min+max)/2;
   1898 		gtk_paned_set_position(GTK_PANED(paned), mid);
   1899 }
   1900 
   1901 void main_window_toggle_message_view(MainWindow *mainwin)
   1902 {
   1903 	SummaryView *summaryview = mainwin->summaryview;
   1904 	GtkWidget *ppaned = NULL;
   1905 	GtkWidget *container = NULL;
   1906 
   1907 	switch (prefs_common.layout_mode) {
   1908 	case NORMAL_LAYOUT:
   1909 	case VERTICAL_LAYOUT:
   1910 		ppaned = mainwin->vpaned;
   1911 		container = mainwin->hpaned;
   1912 		if (gtk_widget_get_parent(ppaned) != NULL) {
   1913 			mainwin->messageview->visible = FALSE;
   1914 			summaryview->displayed = NULL;
   1915 			g_object_ref(ppaned);
   1916 			gtk_container_remove(GTK_CONTAINER(container), ppaned);
   1917 			gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
   1918 		} else {
   1919 			mainwin->messageview->visible = TRUE;
   1920 			gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
   1921 			gtk_container_add(GTK_CONTAINER(container), ppaned);
   1922 			gtk_paned_set_position(GTK_PANED(ppaned),
   1923 					       prefs_common.summaryview_height);
   1924 			g_object_unref(ppaned);
   1925 		}
   1926 		break;
   1927 	}
   1928 
   1929 	if (messageview_is_visible(mainwin->messageview))
   1930 		 gtk_image_set_from_icon_name(GTK_IMAGE(mainwin->summaryview->toggle_arrow),
   1931 					      "pan-down-symbolic", GTK_ICON_SIZE_MENU);
   1932 	else
   1933 		gtk_image_set_from_icon_name(GTK_IMAGE(mainwin->summaryview->toggle_arrow),
   1934 					     "pan-up-symbolic", GTK_ICON_SIZE_MENU);
   1935 
   1936 	if (mainwin->messageview->visible == FALSE)
   1937 		messageview_clear(mainwin->messageview);
   1938 
   1939 	main_window_set_menu_sensitive(mainwin);
   1940 
   1941 	prefs_common.msgview_visible = mainwin->messageview->visible;
   1942 
   1943 	if (messageview_is_visible(mainwin->messageview)) {
   1944 		gtk_widget_queue_resize(mainwin->hpaned);
   1945 		gtk_widget_queue_resize(mainwin->vpaned);
   1946 	}
   1947 	summary_grab_focus(summaryview);
   1948 	if (!summary_is_list(summaryview)) {
   1949 		summary_show(summaryview, summaryview->folder_item, FALSE);
   1950 	}
   1951 }
   1952 
   1953 void main_window_get_size(MainWindow *mainwin)
   1954 {
   1955 	GtkAllocation allocation;
   1956 
   1957 	if (mainwin_list == NULL || mainwin->messageview == NULL) {
   1958 		debug_print("called after messageview "
   1959 			    "has been deallocated!\n");
   1960 		return;
   1961 	}
   1962 
   1963 	gtk_widget_get_allocation(GTK_WIDGET_PTR(mainwin->summaryview), &allocation);
   1964 	if (allocation.width > 1 && allocation.height > 1) {
   1965 		prefs_common.summaryview_width = allocation.width;
   1966 
   1967 		if (messageview_is_visible(mainwin->messageview))
   1968 			prefs_common.summaryview_height = allocation.height;
   1969 
   1970 		prefs_common.mainview_width = allocation.width;
   1971 	}
   1972 
   1973 	gtk_window_get_size(GTK_WINDOW(mainwin->window), &allocation.width, &allocation.height);
   1974 	if (allocation.width > 1 && allocation.height > 1) {
   1975 		prefs_common.mainview_height = allocation.height;
   1976 		prefs_common.mainwin_width   = allocation.width;
   1977 		prefs_common.mainwin_height  = allocation.height;
   1978 	}
   1979 
   1980 	gtk_widget_get_allocation(GTK_WIDGET_PTR(mainwin->folderview), &allocation);
   1981 	if (allocation.width > 1 && allocation.height > 1) {
   1982 		prefs_common.folderview_width  = allocation.width;
   1983 		prefs_common.folderview_height = allocation.height;
   1984 	}
   1985 
   1986 	gtk_widget_get_allocation(GTK_WIDGET_PTR(mainwin->messageview), &allocation);
   1987 	if (allocation.width > 1 && allocation.height > 1) {
   1988 		prefs_common.msgview_width = allocation.width;
   1989 		prefs_common.msgview_height = allocation.height;
   1990 	}
   1991 
   1992 /*	debug_print("summaryview size: %d x %d\n",
   1993 		    prefs_common.summaryview_width,
   1994 		    prefs_common.summaryview_height);
   1995 	debug_print("folderview size: %d x %d\n",
   1996 		    prefs_common.folderview_width,
   1997 		    prefs_common.folderview_height);
   1998 	debug_print("messageview size: %d x %d\n",
   1999 		    prefs_common.msgview_width,
   2000 		    prefs_common.msgview_height); */
   2001 }
   2002 
   2003 void main_window_get_position(MainWindow *mainwin)
   2004 {
   2005 	gint x, y;
   2006 
   2007 	if (prefs_common.mainwin_maximised || prefs_common.mainwin_fullscreen)
   2008 		return;
   2009 
   2010 	gtk_window_get_position(GTK_WINDOW(mainwin->window), &x, &y);
   2011 
   2012 	prefs_common.mainview_x = x;
   2013 	prefs_common.mainview_y = y;
   2014 	prefs_common.mainwin_x = x;
   2015 	prefs_common.mainwin_y = y;
   2016 
   2017 	debug_print("main window position: %d, %d\n", x, y);
   2018 }
   2019 
   2020 void main_window_progress_on(MainWindow *mainwin)
   2021 {
   2022 	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
   2023 }
   2024 
   2025 void main_window_progress_off(MainWindow *mainwin)
   2026 {
   2027 	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
   2028 	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
   2029 }
   2030 
   2031 gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean for_quit)
   2032 {
   2033 	if (confirm && procmsg_have_trashed_mails_fast()) {
   2034 		AlertValue val;
   2035 
   2036 		if (for_quit)
   2037 			val = alertpanel(_("Empty trash"),
   2038 			       _("Delete all messages in trash folders?"),
   2039 			       NULL, _("_No"), NULL, _("_Yes"), NULL, _("Don't quit"),
   2040 						 ALERTFOCUS_SECOND);
   2041 		else
   2042 			val = alertpanel(_("Empty trash"),
   2043 			       _("Delete all messages in trash folders?"),
   2044 			       NULL, _("_No"), NULL, _("_Yes"), NULL, NULL,
   2045 						 ALERTFOCUS_SECOND);
   2046 		if (val == G_ALERTALTERNATE) {
   2047 			debug_print("will empty trash\n");
   2048 		} else if (val == G_ALERTDEFAULT) {
   2049 			debug_print("will not empty trash\n");
   2050 			return TRUE;
   2051 		} else {
   2052 			return FALSE; /* cancel exit */
   2053 		}
   2054 		manage_window_focus_in(mainwin->window, NULL, NULL);
   2055 	}
   2056 
   2057 	procmsg_empty_all_trash();
   2058 
   2059 	if (mainwin->summaryview->folder_item &&
   2060 	    mainwin->summaryview->folder_item->stype == F_TRASH)
   2061 		folderview_grab_focus(mainwin->folderview);
   2062 	return TRUE;
   2063 }
   2064 
   2065 static void main_window_add_mailbox(MainWindow *mainwin)
   2066 {
   2067 	gchar *path;
   2068 	Folder *folder;
   2069 
   2070 	path = input_dialog(_("Add mailbox"),
   2071 			    _("Input the location of the mailbox.\n"
   2072 			      "The location can be either the full path or relative to the \n"
   2073 			      "home directory.\n"
   2074 			      "If the location of an existing mailbox is specified, it will be\n"
   2075 			      "scanned automatically."),
   2076 			    "Mail");
   2077 	if (!path) return;
   2078 	if (folder_find_from_path(path)) {
   2079 		alertpanel_error(_("The mailbox '%s' already exists."), path);
   2080 		g_free(path);
   2081 		return;
   2082 	}
   2083 	folder = folder_new(folder_get_class_from_string("mh"),
   2084 			    !strcmp(path, "Mail") ? _("Mailbox") :
   2085 			    g_path_get_basename(path), path);
   2086 	g_free(path);
   2087 
   2088 	if (folder->klass->create_tree(folder) < 0) {
   2089 		alertpanel_error(_("Creation of the mailbox failed.\n"
   2090 				   "Maybe some files already exist, or you don't have the permission to write there."));
   2091 		folder_destroy(folder);
   2092 		return;
   2093 	}
   2094 
   2095 	folder_add(folder);
   2096 	folder_set_ui_func(folder, scan_tree_func, mainwin);
   2097 	folder_scan_tree(folder, TRUE);
   2098 	folder_set_ui_func(folder, NULL, NULL);
   2099 }
   2100 
   2101 SensitiveCondMask main_window_get_current_state(MainWindow *mainwin)
   2102 {
   2103 	SensitiveCondMask state = 0;
   2104 	SummarySelection selection;
   2105 	FolderItem *item = mainwin->summaryview->folder_item;
   2106 	GList *account_list = account_get_list();
   2107 
   2108 	selection = summary_get_selection_type(mainwin->summaryview);
   2109 
   2110 #define UPDATE_STATE(...) \
   2111 	do { \
   2112 		state |= main_window_get_mask(__VA_ARGS__, -1); \
   2113 	} while (0)
   2114 
   2115 	if (mainwin->lock_count == 0 && !claws_is_starting())
   2116 		UPDATE_STATE(M_UNLOCKED);
   2117 	if (selection != SUMMARY_NONE && selection != SUMMARY_SELECTED_NONE)
   2118 		UPDATE_STATE(M_MSG_SELECTED);
   2119 	if (item && item->total_msgs > 0)
   2120 		UPDATE_STATE(M_MSG_EXIST);
   2121 	if (item && item->path && folder_item_parent(item) && !item->no_select) {
   2122 		UPDATE_STATE(M_EXEC);
   2123 		/*		if (item->folder->type != F_NEWS) */
   2124 		UPDATE_STATE(M_ALLOW_DELETE);
   2125 
   2126 		if (prefs_common.immediate_exec == 0
   2127 		    && mainwin->lock_count == 0)
   2128 			UPDATE_STATE(M_DELAY_EXEC);
   2129 
   2130 		if ((selection == SUMMARY_NONE && item->hide_read_msgs)
   2131 		    || selection != SUMMARY_NONE)
   2132 			UPDATE_STATE(M_HIDE_READ_MSG);
   2133 
   2134 		if ((selection == SUMMARY_NONE && item->hide_read_threads)
   2135 		    || selection != SUMMARY_NONE)
   2136 			UPDATE_STATE(M_HIDE_READ_THREADS);
   2137 	}
   2138 	if (mainwin->summaryview->threaded)
   2139 		UPDATE_STATE(M_THREADED);
   2140 	else
   2141 		UPDATE_STATE(M_UNTHREADED);
   2142 	if (selection == SUMMARY_SELECTED_SINGLE ||
   2143 	    selection == SUMMARY_SELECTED_MULTIPLE)
   2144 		UPDATE_STATE(M_TARGET_EXIST);
   2145 	if (selection == SUMMARY_SELECTED_SINGLE)
   2146 		UPDATE_STATE(M_SINGLE_TARGET_EXIST);
   2147 	if (mainwin->summaryview->folder_item &&
   2148 	    mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
   2149 		UPDATE_STATE(M_NEWS);
   2150 	else
   2151 		UPDATE_STATE(M_NOT_NEWS);
   2152 	if (mainwin->summaryview->folder_item &&
   2153 	    (mainwin->summaryview->folder_item->stype != F_TRASH ||
   2154 	     !folder_has_parent_of_type(mainwin->summaryview->folder_item, F_TRASH)))
   2155 		UPDATE_STATE(M_NOT_TRASH);
   2156 
   2157 	if (mainwin->summaryview->folder_item
   2158 	    && mainwin->summaryview->folder_item->stype != F_DRAFT)
   2159 		UPDATE_STATE(M_NOT_DRAFT);
   2160 
   2161 	if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
   2162 		UPDATE_STATE(M_ACTIONS_EXIST);
   2163 
   2164 	if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
   2165 		UPDATE_STATE(M_HAVE_QUEUED_MAILS);
   2166 
   2167 	if (selection == SUMMARY_SELECTED_SINGLE &&
   2168 	    (item &&
   2169 	     (folder_has_parent_of_type(item, F_DRAFT) ||
   2170 	      folder_has_parent_of_type(item, F_OUTBOX) ||
   2171 	      folder_has_parent_of_type(item, F_QUEUE))))
   2172 		UPDATE_STATE(M_ALLOW_REEDIT);
   2173 	if (cur_account)
   2174 		UPDATE_STATE(M_HAVE_ACCOUNT);
   2175 
   2176 	if (cur_account && cur_account->protocol != A_NONE)
   2177 		UPDATE_STATE(M_HAVE_RETRIEVABLE_ACCOUNT);
   2178 
   2179 	if (item && item->prefs->processing && selection != SUMMARY_NONE)
   2180 		UPDATE_STATE(M_HAVE_PROCESSING);
   2181 
   2182 	if (g_list_length(account_list) > 1)
   2183 		UPDATE_STATE(M_HAVE_MULTI_ACCOUNT);
   2184 
   2185 	for (account_list = account_get_list(); account_list != NULL; account_list = account_list->next) {
   2186 		if (((PrefsAccount*)account_list->data)->protocol != A_NONE) {
   2187 			UPDATE_STATE(M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
   2188 			break;
   2189 		}
   2190 	}
   2191 
   2192 	if (mainwin->summaryview->folder_item) {
   2193 		UPDATE_STATE(M_FOLDER_SELECTED);
   2194 	}
   2195 
   2196 	if (inc_is_active())
   2197 		UPDATE_STATE(M_INC_ACTIVE);
   2198 	if (imap_cancel_all_enabled())
   2199 		UPDATE_STATE(M_INC_ACTIVE);
   2200 
   2201 	if (send_is_active() | procmsg_is_sending())
   2202 		UPDATE_STATE(M_SEND_ACTIVE);
   2203 
   2204 	if (mainwin->summaryview->deleted > 0)
   2205 		UPDATE_STATE(M_DELETED_EXISTS);
   2206 
   2207 	if (mainwin->summaryview->deleted > 0 ||
   2208 	    mainwin->summaryview->moved > 0 ||
   2209 	    mainwin->summaryview->copied > 0)
   2210 		UPDATE_STATE(M_DELAY_EXEC);
   2211 
   2212 	if (summary_is_list(mainwin->summaryview))
   2213 		UPDATE_STATE(M_SUMMARY_ISLIST);
   2214 
   2215 	if (mainwin->in_folder)
   2216 		UPDATE_STATE(M_IN_MSGLIST);
   2217 
   2218 #undef UPDATE_STATE
   2219 
   2220 	return state;
   2221 }
   2222 
   2223 SensitiveCondMask main_window_get_mask(SensitiveCond cond, ...)
   2224 {
   2225 	va_list args;
   2226 	gint i;
   2227 	SensitiveCondMask value;
   2228 	static SensitiveCondMask SensitiveCond_table[M_MAX_RESERVED];
   2229 	static gboolean first_time = TRUE;
   2230 
   2231 	if (first_time) {
   2232 		for (i = 0; i < M_MAX_RESERVED; i++)
   2233 			SensitiveCond_table[i] = (SensitiveCondMask) ((SensitiveCondMask)1 << i);
   2234 		first_time = FALSE;
   2235 	}
   2236 
   2237 	value = 0;
   2238 
   2239 	va_start(args, cond);
   2240 	for (i = (gint) cond; i >= 0 && i < M_MAX_RESERVED; i = va_arg(args, gint))
   2241 		value |= SensitiveCond_table[i];
   2242 	va_end(args);
   2243 
   2244 	return value;
   2245 }
   2246 
   2247 void main_window_set_menu_sensitive(MainWindow *mainwin)
   2248 {
   2249 	SensitiveCondMask state;
   2250 	gboolean sensitive;
   2251 	SummaryView *summaryview;
   2252 	gchar *menu_path;
   2253 	GtkWidget *menu;
   2254 	GList *children, *cur_item;
   2255 	gboolean mimepart_selected = FALSE;
   2256 
   2257 	state = main_window_get_current_state(mainwin);
   2258 
   2259 #define SET_SENSITIVE(entry_str, ...) \
   2260 { \
   2261 	SensitiveCondMask cond = main_window_get_mask(__VA_ARGS__, -1); \
   2262 	cm_menu_set_sensitive_full(mainwin->ui_manager, \
   2263 			(const gchar *) entry_str, \
   2264 			((cond & state) == cond)); \
   2265 }
   2266 	SET_SENSITIVE("Menu/File/SaveAs", M_TARGET_EXIST);
   2267 	SET_SENSITIVE("Menu/File/SavePartAs", M_SINGLE_TARGET_EXIST);
   2268 	SET_SENSITIVE("Menu/File/Exit", M_UNLOCKED);
   2269 
   2270 	SET_SENSITIVE("Menu/Edit/SelectThread", M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2271 	SET_SENSITIVE("Menu/Edit/Find", M_SINGLE_TARGET_EXIST);
   2272 
   2273 	SET_SENSITIVE("Menu/View/SetColumns/Folderlist", M_UNLOCKED, M_SUMMARY_ISLIST);
   2274 	SET_SENSITIVE("Menu/View/Sort", M_EXEC, M_SUMMARY_ISLIST);
   2275 	SET_SENSITIVE("Menu/View/ThreadView", M_EXEC, M_SUMMARY_ISLIST);
   2276 	SET_SENSITIVE("Menu/View/ExpandThreads", M_MSG_EXIST, M_SUMMARY_ISLIST);
   2277 	SET_SENSITIVE("Menu/View/CollapseThreads", M_MSG_EXIST, M_SUMMARY_ISLIST);
   2278 	SET_SENSITIVE("Menu/View/HideReadThreads", M_HIDE_READ_THREADS, M_SUMMARY_ISLIST, M_NOT_DRAFT);
   2279 	SET_SENSITIVE("Menu/View/HideReadMessages", M_HIDE_READ_MSG, M_SUMMARY_ISLIST, M_NOT_DRAFT);
   2280 	SET_SENSITIVE("Menu/View/HideDelMessages", M_SUMMARY_ISLIST, M_NOT_DRAFT);
   2281 	SET_SENSITIVE("Menu/View/Goto/Prev", M_MSG_SELECTED);
   2282 	SET_SENSITIVE("Menu/View/Goto/Next", M_MSG_SELECTED);
   2283 	SET_SENSITIVE("Menu/View/Goto/PrevUnread", M_MSG_SELECTED);
   2284 	SET_SENSITIVE("Menu/View/Goto/NextUnread", M_MSG_SELECTED);
   2285 	SET_SENSITIVE("Menu/View/Goto/PrevNew", M_MSG_SELECTED);
   2286 	SET_SENSITIVE("Menu/View/Goto/NextNew", M_MSG_SELECTED);
   2287 	SET_SENSITIVE("Menu/View/Goto/PrevMarked", M_MSG_SELECTED);
   2288 	SET_SENSITIVE("Menu/View/Goto/NextMarked", M_MSG_SELECTED);
   2289 	SET_SENSITIVE("Menu/View/Goto/PrevLabeled", M_MSG_SELECTED);
   2290 	SET_SENSITIVE("Menu/View/Goto/NextLabeled", M_MSG_SELECTED);
   2291 	SET_SENSITIVE("Menu/View/Goto/ParentMessage", M_SINGLE_TARGET_EXIST);
   2292 	SET_SENSITIVE("Menu/View/Goto/NextPart", M_SINGLE_TARGET_EXIST);
   2293 	SET_SENSITIVE("Menu/View/Goto/PrevPart", M_SINGLE_TARGET_EXIST);
   2294 	SET_SENSITIVE("Menu/View/OpenNewWindow", M_SINGLE_TARGET_EXIST);
   2295 	SET_SENSITIVE("Menu/View/MessageSource", M_SINGLE_TARGET_EXIST);
   2296 	SET_SENSITIVE("Menu/View/Part", M_SINGLE_TARGET_EXIST);
   2297 	SET_SENSITIVE("Menu/View/AllHeaders", M_SINGLE_TARGET_EXIST);
   2298 	SET_SENSITIVE("Menu/View/Quotes", M_SINGLE_TARGET_EXIST);
   2299 
   2300 	SET_SENSITIVE("Menu/Message/Receive/CurrentAccount", M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_RETRIEVABLE_ACCOUNT);
   2301 	SET_SENSITIVE("Menu/Message/Receive/AllAccounts", M_HAVE_ACCOUNT, M_UNLOCKED, M_HAVE_ANY_RETRIEVABLE_ACCOUNT);
   2302 	SET_SENSITIVE("Menu/Message/Receive/CancelReceiving", M_INC_ACTIVE);
   2303 	SET_SENSITIVE("Menu/Message/SendQueue", M_HAVE_ACCOUNT, M_HAVE_QUEUED_MAILS);
   2304 	SET_SENSITIVE("Menu/Message/CancelSending", M_SEND_ACTIVE);
   2305 	SET_SENSITIVE("Menu/Message/ComposeEmail", M_HAVE_ACCOUNT);
   2306 	SET_SENSITIVE("Menu/Message/Reply", M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2307 	SET_SENSITIVE("Menu/Message/ReplyTo", M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2308 	SET_SENSITIVE("Menu/Message/FollowupReply", M_HAVE_ACCOUNT, M_TARGET_EXIST, M_NEWS, M_SUMMARY_ISLIST);
   2309 	SET_SENSITIVE("Menu/Message/Forward", M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2310 	SET_SENSITIVE("Menu/Message/ForwardAtt", M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2311 	SET_SENSITIVE("Menu/Message/Redirect", M_HAVE_ACCOUNT, M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2312 	SET_SENSITIVE("Menu/Message/Move", M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
   2313 	SET_SENSITIVE("Menu/Message/Copy", M_TARGET_EXIST, M_EXEC);
   2314 	SET_SENSITIVE("Menu/Message/Trash", M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS, M_NOT_TRASH);
   2315 	SET_SENSITIVE("Menu/Message/Delete", M_TARGET_EXIST, M_ALLOW_DELETE);
   2316 	SET_SENSITIVE("Menu/Message/TrashThread", M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2317 	SET_SENSITIVE("Menu/Message/DeleteThread", M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2318 	SET_SENSITIVE("Menu/Message/CancelNews", M_TARGET_EXIST, M_ALLOW_DELETE, M_NEWS);
   2319 	SET_SENSITIVE("Menu/Message/Marks", M_TARGET_EXIST, M_SUMMARY_ISLIST);
   2320 	SET_SENSITIVE("Menu/Message/Marks/IgnoreThread", M_TARGET_EXIST);
   2321 	SET_SENSITIVE("Menu/Message/Marks/UnignoreThread", M_TARGET_EXIST);
   2322 	SET_SENSITIVE("Menu/Message/Marks/Lock", M_TARGET_EXIST);
   2323 	SET_SENSITIVE("Menu/Message/Marks/Unlock", M_TARGET_EXIST);
   2324 	SET_SENSITIVE("Menu/Message/Reedit", M_HAVE_ACCOUNT, M_ALLOW_REEDIT);
   2325 
   2326 	SET_SENSITIVE("Menu/Tools/AddSenderToAB", M_SINGLE_TARGET_EXIST);
   2327 	SET_SENSITIVE("Menu/Tools/Execute", M_DELAY_EXEC);
   2328 	SET_SENSITIVE("Menu/Tools/Expunge", M_DELETED_EXISTS);
   2329 	SET_SENSITIVE("Menu/Tools/DeleteDuplicates/SelFolder", M_MSG_EXIST, M_ALLOW_DELETE);
   2330 
   2331 	SET_SENSITIVE("Menu/Configuration", M_UNLOCKED);
   2332 	SET_SENSITIVE("Menu/Configuration/ChangeAccount", M_HAVE_MULTI_ACCOUNT);
   2333 	SET_SENSITIVE("Menu/Configuration/AccountPrefs", M_UNLOCKED);
   2334 	SET_SENSITIVE("Menu/Configuration/CreateAccount", M_UNLOCKED);
   2335 	SET_SENSITIVE("Menu/Configuration/EditAccounts", M_UNLOCKED);
   2336 #undef SET_SENSITIVE
   2337 
   2338 	menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
   2339 		gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive")));
   2340 
   2341 	children = gtk_container_get_children(GTK_CONTAINER(menu));
   2342 	for (cur_item = children; cur_item != NULL; cur_item = cur_item->next) {
   2343 		if (cur_item->data == gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive/Separator1")) {
   2344 			cur_item = cur_item->next;
   2345 			break;
   2346 		}
   2347 	}
   2348 
   2349 	for (; cur_item != NULL; cur_item = cur_item->next) {
   2350 		gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
   2351 					 (main_window_get_mask(M_UNLOCKED, -1) & state) != 0);
   2352 	}
   2353 
   2354 	g_list_free(children);
   2355 
   2356 	main_window_menu_callback_block(mainwin);
   2357 
   2358 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/ShowHide/MessageView",
   2359 			      messageview_is_visible(mainwin->messageview));
   2360 
   2361 	summaryview = mainwin->summaryview;
   2362 
   2363 	switch (summaryview->sort_key) {
   2364 	case SORT_BY_NUMBER:
   2365 		menu_path = "Menu/View/Sort/Number"; break;
   2366 	case SORT_BY_SIZE:
   2367 		menu_path = "Menu/View/Sort/Size"; break;
   2368 	case SORT_BY_DATE:
   2369 		menu_path = "Menu/View/Sort/Date"; break;
   2370 	case SORT_BY_THREAD_DATE:
   2371 		menu_path = "Menu/View/Sort/ThreadDate"; break;
   2372 	case SORT_BY_FROM:
   2373 		menu_path = "Menu/View/Sort/From"; break;
   2374 	case SORT_BY_TO:
   2375 		menu_path = "Menu/View/Sort/To"; break;
   2376 	case SORT_BY_SUBJECT:
   2377 		menu_path = "Menu/View/Sort/Subject"; break;
   2378 	case SORT_BY_MARK:
   2379 		menu_path = "Menu/View/Sort/Mark"; break;
   2380 	case SORT_BY_STATUS:
   2381 		menu_path = "Menu/View/Sort/Status"; break;
   2382 	case SORT_BY_MIME:
   2383 		menu_path = "Menu/View/Sort/Attachment"; break;
   2384 	case SORT_BY_SCORE:
   2385 		menu_path = "Menu/View/Sort/Score"; break;
   2386 	case SORT_BY_LOCKED:
   2387 		menu_path = "Menu/View/Sort/Locked"; break;
   2388 	case SORT_BY_NONE:
   2389 	default:
   2390 		menu_path = "Menu/View/Sort/DontSort"; break;
   2391 	}
   2392 	cm_toggle_menu_set_active_full(mainwin->ui_manager, menu_path, TRUE);
   2393 
   2394 	if (summaryview->sort_type == SORT_ASCENDING) {
   2395 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Sort/Ascending", TRUE);
   2396 	} else {
   2397 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Sort/Descending", TRUE);
   2398 	}
   2399 
   2400 	if (summaryview->sort_key != SORT_BY_NONE) {
   2401 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Sort/Ascending", TRUE);
   2402 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Sort/Descending", TRUE);
   2403 	} else {
   2404 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Sort/Ascending", FALSE);
   2405 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Sort/Descending", FALSE);
   2406 	}
   2407 
   2408 	if (mainwin->messageview
   2409 	&&  mainwin->messageview->mimeview
   2410 	&&  mainwin->messageview->mimeview->textview)
   2411 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/AllHeaders",
   2412 			      			prefs_common.show_all_headers);
   2413 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/ThreadView", (state & main_window_get_mask(M_THREADED, -1)) != 0);
   2414 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/ExpandThreads", (state & main_window_get_mask(M_THREADED, -1)) != 0);
   2415 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/CollapseThreads", (state & main_window_get_mask(M_THREADED, -1)) != 0);
   2416 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", (state & main_window_get_mask(M_THREADED, -1)) != 0 && (state & main_window_get_mask(M_NOT_DRAFT, -1)) != 0);
   2417 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/CollapseAll", (prefs_common.hide_quotes == 1));
   2418 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse2", (prefs_common.hide_quotes == 2));
   2419 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse3", (prefs_common.hide_quotes == 3));
   2420 
   2421 	if (mainwin->summaryview->folder_item && !mainwin->summaryview->folder_item->threaded)
   2422 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/HideReadThreads", FALSE);
   2423 	if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_msgs)
   2424 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", FALSE);
   2425 	if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_threads)
   2426 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadMessages", FALSE);
   2427 
   2428 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/PrevHistory",
   2429 		messageview_nav_has_prev(mainwin->messageview));
   2430 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/NextHistory",
   2431 		messageview_nav_has_next(mainwin->messageview));
   2432 
   2433 	if (mainwin->messageview
   2434 	&&  mainwin->messageview->mimeview)
   2435 		mimepart_selected = !mimeview_tree_is_empty(mainwin->messageview->mimeview);
   2436 
   2437 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/File/SavePartAs", mimepart_selected);
   2438 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/NextPart", mimepart_selected);
   2439 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/PrevPart", mimepart_selected);
   2440 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Part", mimepart_selected);
   2441 
   2442 	sensitive = TRUE;
   2443 	if (mimepart_selected) {
   2444 		MimeInfo *partinfo = messageview_get_selected_mime_part(mainwin->messageview);
   2445 
   2446 		if (partinfo && (partinfo->type == MIMETYPE_MESSAGE ||
   2447 				 partinfo->type == MIMETYPE_IMAGE ||
   2448 				 partinfo->type == MIMETYPE_MULTIPART)) {
   2449 			sensitive = FALSE;
   2450 		}
   2451 	}
   2452 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Part/AsText", sensitive);
   2453 
   2454 	main_window_menu_callback_unblock(mainwin);
   2455 }
   2456 
   2457 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
   2458 {
   2459 	gint is_menu = 0;
   2460 
   2461 	if (msginfo)
   2462 		is_menu = mailing_list_create_submenu (mainwin, msginfo);
   2463 	if (is_menu)
   2464 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList", TRUE);
   2465 	else
   2466 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList", FALSE);
   2467 }
   2468 
   2469 static gint mailing_list_create_submenu (MainWindow *mainwin, MsgInfo *msginfo)
   2470 {
   2471 	gint menu_nb = 0;
   2472 	GtkWidget *menuitem;
   2473 
   2474 	if (!msginfo || !msginfo->extradata) {
   2475 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList/Post", FALSE);
   2476 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList/Help", FALSE);
   2477 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList/Subscribe", FALSE);
   2478 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList/Unsubscribe", FALSE);
   2479 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList/ViewArchive", FALSE);
   2480 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/Message/MailingList/ContactOwner", FALSE);
   2481 		return 0;
   2482 	}
   2483 
   2484 	/* Mailing list post */
   2485 	if (!g_strcmp0 (msginfo->extradata->list_post, "NO")) {
   2486 		g_free(msginfo->extradata->list_post);
   2487 		msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
   2488  	}
   2489  	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/MailingList/Post");
   2490 
   2491  	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
   2492 
   2493  	/* Mailing list help */
   2494 	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/MailingList/Help");
   2495 
   2496 	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
   2497 
   2498 	/* Mailing list subscribe */
   2499 	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/MailingList/Subscribe");
   2500 
   2501 	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
   2502 
   2503 	/* Mailing list unsubscribe */
   2504 	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/MailingList/Unsubscribe");
   2505 
   2506 	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
   2507 
   2508 	/* Mailing list view archive */
   2509 	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/MailingList/ViewArchive");
   2510 
   2511 	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
   2512 
   2513 	/* Mailing list contact owner */
   2514 	menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/MailingList/ContactOwner");
   2515 
   2516 	menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
   2517 
   2518 	return menu_nb;
   2519 }
   2520 
   2521 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
   2522 {
   2523 	GtkWidget *item, *menu;
   2524 	const gchar *url_pt ;
   2525 	gchar url_decoded[MAX_MENU_LABEL_LENGTH];
   2526 	GList *children, *amenu;
   2527 	gint menu_nb = 0;
   2528 
   2529 	menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
   2530 
   2531 	/* First delete old submenu */
   2532 	/* FIXME: we can optimize this, and only change/add/delete necessary items */
   2533 	children = gtk_container_get_children(GTK_CONTAINER(menu));
   2534 	for (amenu = children; amenu; amenu = amenu->next) {
   2535 		item = GTK_WIDGET (amenu->data);
   2536 		gtk_widget_destroy (item);
   2537 	}
   2538 	g_list_free(children);
   2539 	if (list_header) {
   2540 		for (url_pt = list_header; url_pt && *url_pt;) {
   2541 			get_url_part (&url_pt, url_decoded);
   2542 			item = NULL;
   2543 			if (!g_ascii_strncasecmp(url_decoded, "mailto:", 7)) {
   2544  				item = gtk_menu_item_new_with_label(url_decoded);
   2545 				g_signal_connect(G_OBJECT(item), "activate",
   2546 						 G_CALLBACK(mailing_list_compose),
   2547 						 NULL);
   2548 			}
   2549  			else if (!g_ascii_strncasecmp(url_decoded, "http:", 5) ||
   2550 				 !g_ascii_strncasecmp(url_decoded, "https:",6)) {
   2551 
   2552 				item = gtk_menu_item_new_with_label(url_decoded);
   2553 				g_signal_connect(G_OBJECT(item), "activate",
   2554 						 G_CALLBACK(mailing_list_open_uri),
   2555 						 NULL);
   2556 			}
   2557 			if (item) {
   2558 				gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   2559 				gtk_widget_show (item);
   2560 				menu_nb++;
   2561 			}
   2562 		}
   2563 	}
   2564 	if (menu_nb)
   2565 		gtk_widget_set_sensitive (menuitem, TRUE);
   2566 	else
   2567 		gtk_widget_set_sensitive (menuitem, FALSE);
   2568 
   2569 
   2570 	return menu_nb;
   2571 }
   2572 
   2573 static void get_url_part (const gchar **buffer, gchar *url_decoded)
   2574 {
   2575 	gchar tmp[BUFFSIZE];
   2576 	const gchar *buf;
   2577 	gint i = 0;
   2578 	buf = *buffer;
   2579 	gboolean with_plus = TRUE;
   2580 
   2581 	if (buf == 0x00) {
   2582 		*url_decoded = '\0';
   2583 		*buffer = NULL;
   2584 		return;
   2585 	}
   2586 	/* Ignore spaces, comments  and tabs () */
   2587 	for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
   2588 		if (*buf == '(')
   2589 			for (;*buf != ')' && *buf != 0x00; buf++);
   2590 
   2591 	/* First non space and non comment must be a < */
   2592 	if (*buf =='<' ) {
   2593 		buf++;
   2594 		if (!strncmp(buf, "mailto:", strlen("mailto:")))
   2595 			with_plus = FALSE;
   2596 		for (i = 0;
   2597 		     *buf != '>' && *buf != 0x00 && i < BUFFSIZE;
   2598 			tmp[i++] = *(buf++));
   2599 		if (*buf == 0) {
   2600 			*buffer = NULL;
   2601 			*url_decoded = '\0';
   2602 			return;
   2603 		}
   2604 		buf++;
   2605 	}
   2606 	else  {
   2607 		*buffer = NULL;
   2608 		*url_decoded = '\0';
   2609 		return;
   2610 	}
   2611 
   2612 	*url_decoded = '\0';
   2613 	*buffer = NULL;
   2614 
   2615 	if (i == BUFFSIZE) {
   2616 		return;
   2617 	}
   2618 	tmp[i] = 0x00;
   2619 	decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
   2620 
   2621 	/* Prepare the work for the next url in the list */
   2622 	/* after the closing bracket >, ignore space, comments and tabs */
   2623 	for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
   2624 		if (*buf == '(')
   2625 			for (;*buf != ')' && *buf != 0x00; buf++);
   2626 
   2627 	if (!buf || !*buf) {
   2628 		*buffer = NULL;
   2629 		return;
   2630 	}
   2631 
   2632 	/* now first non space, non comment must be a comma */
   2633 	if (*buf != ',')
   2634 		for (;*buf != 0x00; buf++);
   2635 	else
   2636 		buf++;
   2637 	*buffer = buf;
   2638 }
   2639 
   2640 static void mailing_list_compose (GtkWidget *w, gpointer *data)
   2641 {
   2642 	const gchar *mailto;
   2643 	PrefsAccount *account = NULL;
   2644 	FolderItem   *folder_item = NULL;
   2645 
   2646 	mailto = gtk_label_get_text(GTK_LABEL (gtk_bin_get_child(GTK_BIN((w)))));
   2647 	if (mainwindow_get_mainwindow()) {
   2648 		folder_item = mainwindow_get_mainwindow()->summaryview->folder_item;
   2649 		if (folder_item && folder_item->prefs && folder_item->prefs->enable_default_account)
   2650 			account = account_find_from_id(folder_item->prefs->default_account);
   2651 		if (folder_item && !account)
   2652 			account = account_find_from_item(folder_item);
   2653 	}
   2654 	if (mailto)
   2655 		compose_new_with_folderitem(account, folder_item, mailto+7);
   2656 }
   2657 
   2658  static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
   2659 {
   2660 
   2661  	const gchar *mailto;
   2662 
   2663 	mailto = gtk_label_get_text(GTK_LABEL (gtk_bin_get_child(GTK_BIN((w)))));
   2664 	if (mailto)
   2665  		open_uri (mailto, prefs_common_get_uri_cmd());
   2666 }
   2667 
   2668 static void fix_folderview_scroll(MainWindow *mainwin)
   2669 {
   2670 	static gboolean fix_done = FALSE;
   2671 
   2672 	if (fix_done)
   2673 		return;
   2674 
   2675 	gtk_widget_queue_resize(mainwin->folderview->ctree);
   2676 
   2677 	fix_done = TRUE;
   2678 }
   2679 
   2680 void main_window_popup(MainWindow *mainwin)
   2681 {
   2682 	static gboolean first_start = TRUE;
   2683 
   2684 	if (!gtk_widget_get_visible(GTK_WIDGET(mainwin->window)))
   2685 		main_window_show(mainwin);
   2686 
   2687 	if (prefs_common.mainwin_maximised)
   2688 		gtk_window_maximize(GTK_WINDOW(mainwin->window));
   2689 
   2690 	if (first_start) {
   2691 		first_start = FALSE;
   2692 	} else {
   2693 		gtkut_window_popup(mainwin->window);
   2694 	}
   2695 	fix_folderview_scroll(mainwin);
   2696 }
   2697 
   2698 void main_window_show(MainWindow *mainwin)
   2699 {
   2700 	gtk_widget_show(mainwin->window);
   2701 	gtk_widget_show(mainwin->vbox_body);
   2702         gtk_window_move(GTK_WINDOW(mainwin->window),
   2703                                  prefs_common.mainwin_x,
   2704                                  prefs_common.mainwin_y);
   2705 }
   2706 
   2707 void main_window_hide(MainWindow *mainwin)
   2708 {
   2709 	main_window_get_size(mainwin);
   2710 	main_window_get_position(mainwin);
   2711 
   2712 	gtk_widget_hide(mainwin->window);
   2713 	gtk_widget_hide(mainwin->vbox_body);
   2714 }
   2715 
   2716 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
   2717 {
   2718 	GtkWidget *folderwin = NULL;
   2719 	GtkWidget *messagewin = NULL;
   2720 	GtkWidget *hpaned;
   2721 	GtkWidget *vpaned;
   2722 	GtkWidget *vbox_body = mainwin->vbox_body;
   2723 	debug_print("Setting widgets...\n");
   2724 
   2725 	mainwin->messageview->statusbar = mainwin->statusbar;
   2726 	mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
   2727 	/* clean top-most container */
   2728 	if (mainwin->hpaned) {
   2729 		if (gtk_widget_get_parent(mainwin->hpaned) == mainwin->vpaned)
   2730 			gtk_widget_destroy(mainwin->vpaned);
   2731 		else
   2732 			gtk_widget_destroy(mainwin->hpaned);
   2733 	}
   2734 
   2735 	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/ShowHide/MessageView", TRUE);
   2736 	switch (layout_mode) {
   2737 	case VERTICAL_LAYOUT:
   2738 	case NORMAL_LAYOUT:
   2739 		hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
   2740 		if (layout_mode == VERTICAL_LAYOUT)
   2741 			vpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
   2742 		else
   2743 			vpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
   2744 		gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
   2745 		gtk_paned_add1(GTK_PANED(hpaned),
   2746 			       GTK_WIDGET_PTR(mainwin->folderview));
   2747 		gtk_widget_show(hpaned);
   2748 
   2749 		if (messageview_is_visible(mainwin->messageview)) {
   2750 			gtk_paned_add2(GTK_PANED(hpaned), vpaned);
   2751 			gtk_paned_pack1(GTK_PANED(vpaned),
   2752 				       GTK_WIDGET_PTR(mainwin->summaryview), TRUE, TRUE);
   2753 		} else {
   2754 			gtk_paned_add2(GTK_PANED(hpaned),
   2755 				       GTK_WIDGET_PTR(mainwin->summaryview));
   2756 			g_object_ref(vpaned);
   2757 		}
   2758 		gtk_paned_add2(GTK_PANED(vpaned),
   2759 			       GTK_WIDGET_PTR(mainwin->messageview));
   2760 		gtk_widget_show(vpaned);
   2761 
   2762 		gtk_paned_set_position(GTK_PANED(hpaned),
   2763 				       prefs_common_get_prefs()->folderview_width);
   2764 
   2765 		if (layout_mode == NORMAL_LAYOUT &&
   2766 		    messageview_is_visible(mainwin->messageview)) {
   2767 			gtk_paned_set_position(GTK_PANED(vpaned),
   2768 					       prefs_common_get_prefs()->summaryview_height);
   2769 		}
   2770 		if (layout_mode == VERTICAL_LAYOUT &&
   2771 		    messageview_is_visible(mainwin->messageview)) {
   2772 			gtk_paned_set_position(GTK_PANED(vpaned),
   2773 					       prefs_common_get_prefs()->summaryview_width);
   2774 		}
   2775 
   2776 		break;
   2777 	default:
   2778 		g_warning("unknown layout");
   2779 		return;
   2780 	}
   2781 
   2782 	mainwin->hpaned = hpaned;
   2783 	mainwin->vpaned = vpaned;
   2784 
   2785 	gtk_window_set_default_size(GTK_WINDOW(mainwin->window),
   2786 			    prefs_common.mainwin_width,
   2787 			    prefs_common.mainwin_height);
   2788 
   2789 	if (mainwin->messageview->visible)
   2790 		gtk_image_set_from_icon_name(GTK_IMAGE(mainwin->summaryview->toggle_arrow),
   2791 					      "pan-down-symbolic", GTK_ICON_SIZE_MENU);
   2792 	else
   2793 		gtk_image_set_from_icon_name(GTK_IMAGE(mainwin->summaryview->toggle_arrow),
   2794 					      "pan-up-symbolic", GTK_ICON_SIZE_MENU);
   2795 
   2796 	gtk_window_move(GTK_WINDOW(mainwin->window),
   2797 			prefs_common.mainwin_x,
   2798 			prefs_common.mainwin_y);
   2799 
   2800 	/*
   2801 	 * previous "gtk_widget_show_all" makes mimeview
   2802 	 * icon list/ctree lose track of their visibility states.
   2803 	 */
   2804 	if (mainwin->messageview->mimeview->ctree_mode)
   2805 		gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
   2806 	else
   2807 		gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
   2808 
   2809 	prefs_common.layout_mode = layout_mode;
   2810 
   2811 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/ShowHide/MessageView",
   2812 		 messageview_is_visible(mainwin->messageview));
   2813 
   2814 	switch (prefs_common.layout_mode) {
   2815 	case NORMAL_LAYOUT:
   2816 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Layout/Standard", TRUE);
   2817 		break;
   2818 	case VERTICAL_LAYOUT:
   2819 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Layout/ThreeColumns", TRUE);
   2820 		break;
   2821 	}
   2822 
   2823 	if (folderwin) {
   2824 		g_signal_connect
   2825 			(G_OBJECT(folderwin), "size_allocate",
   2826 			 G_CALLBACK(folder_window_size_allocate_cb),
   2827 			 mainwin);
   2828 	}
   2829 	if (messagewin) {
   2830 		g_signal_connect
   2831 			(G_OBJECT(messagewin), "size_allocate",
   2832 			 G_CALLBACK(message_window_size_allocate_cb),
   2833 			 mainwin);
   2834 	}
   2835 
   2836 	debug_print("Setting widgets done.\n");
   2837 }
   2838 
   2839 void main_window_destroy_all(void)
   2840 {
   2841 	while (mainwin_list != NULL) {
   2842 		MainWindow *mainwin = (MainWindow*)mainwin_list->data;
   2843 
   2844 		/* free toolbar stuff */
   2845 		toolbar_clear_list(TOOLBAR_MAIN);
   2846 		toolbar_destroy(mainwin->toolbar);
   2847 
   2848 		summaryview_destroy(mainwin->summaryview);
   2849 		mainwin->folderview->mainwin = NULL;
   2850 		mainwin->summaryview->mainwin = NULL;
   2851 		mainwin->messageview->mainwin = NULL;
   2852 
   2853 		g_free(mainwin->toolbar);
   2854 		mainwin_list = g_list_remove(mainwin_list, mainwin);
   2855 		g_free(mainwin);
   2856 	}
   2857 	g_list_free(mainwin_list);
   2858 	mainwin_list = NULL;
   2859 }
   2860 
   2861 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
   2862 				    gpointer data)
   2863 {
   2864 	MainWindow *mainwin = (MainWindow *)data;
   2865 	GtkWidget *menu = NULL;
   2866 
   2867 	if (!event) return FALSE;
   2868 
   2869 	gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
   2870 
   2871 	menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(mainwin->ac_menu));
   2872 
   2873 	gtk_menu_popup_at_widget(GTK_MENU(menu), widget, 3, 3, NULL);
   2874 
   2875 	return TRUE;
   2876 }
   2877 
   2878 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
   2879 				 gpointer data)
   2880 {
   2881 	MainWindow *mainwin = (MainWindow *)data;
   2882 	gboolean close_allowed = TRUE;
   2883 
   2884 	hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
   2885 
   2886 	if (close_allowed && mainwin->lock_count == 0)
   2887 		app_exit_cb(NULL, data);
   2888 
   2889 	return TRUE;
   2890 }
   2891 
   2892 static void main_window_size_allocate_cb(GtkWidget *widget,
   2893 					 GtkAllocation *allocation,
   2894 					 gpointer data)
   2895 {
   2896 	MainWindow *mainwin = (MainWindow *)data;
   2897 	main_window_get_size(mainwin);
   2898 }
   2899 
   2900 static void folder_window_size_allocate_cb(GtkWidget *widget,
   2901 					   GtkAllocation *allocation,
   2902 					   gpointer data)
   2903 {
   2904 	MainWindow *mainwin = (MainWindow *)data;
   2905 
   2906 	main_window_get_size(mainwin);
   2907 }
   2908 
   2909 static void message_window_size_allocate_cb(GtkWidget *widget,
   2910 					    GtkAllocation *allocation,
   2911 					    gpointer data)
   2912 {
   2913 	MainWindow *mainwin = (MainWindow *)data;
   2914 
   2915 	main_window_get_size(mainwin);
   2916 }
   2917 
   2918 static void add_mailbox_cb(GtkAction *action, gpointer data)
   2919 {
   2920 	MainWindow *mainwin = (MainWindow *)data;
   2921 	main_window_add_mailbox(mainwin);
   2922 }
   2923 
   2924 static void update_folderview_cb(GtkAction *action, gpointer data)
   2925 {
   2926 	MainWindow *mainwin = (MainWindow *)data;
   2927 	summary_show(mainwin->summaryview, NULL, FALSE);
   2928 	folderview_check_new_all();
   2929 }
   2930 
   2931 static void foldersort_cb(GtkAction *action, gpointer data)
   2932 {
   2933 	foldersort_open();
   2934 }
   2935 
   2936 static void empty_trash_cb(GtkAction *action, gpointer data)
   2937 {
   2938 	MainWindow *mainwin = (MainWindow *)data;
   2939 	main_window_empty_trash(mainwin, TRUE, FALSE);
   2940 }
   2941 
   2942 static void save_as_cb(GtkAction *action, gpointer data)
   2943 {
   2944 	MainWindow *mainwin = (MainWindow *)data;
   2945 	summary_save_as(mainwin->summaryview);
   2946 }
   2947 
   2948 static void app_exit_cb(GtkAction *action, gpointer data)
   2949 {
   2950 	MainWindow *mainwin = (MainWindow *)data;
   2951 	app_will_exit(NULL, mainwin);
   2952 }
   2953 
   2954 static void search_cb(GtkAction *action, gpointer data)
   2955 {
   2956 	MainWindow *mainwin = (MainWindow *)data;
   2957 	message_search(mainwin->messageview);
   2958 }
   2959 
   2960 static void toggle_message_cb(GtkAction *action, gpointer data)
   2961 {
   2962 	MainWindow *mainwin = (MainWindow *)data;
   2963 	gboolean active;
   2964 
   2965 	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
   2966 
   2967 	if (active != messageview_is_visible(mainwin->messageview))
   2968 		summary_toggle_view(mainwin->summaryview);
   2969 }
   2970 
   2971 static void toggle_toolbar_cb(GtkAction *action, GtkRadioAction *current, gpointer data)
   2972 {
   2973 	gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
   2974 	MainWindow *mainwin = (MainWindow *)data;
   2975 	toolbar_toggle(value, mainwin);
   2976 }
   2977 
   2978 static void main_window_reply_cb(GtkAction *gaction, gpointer data)
   2979 {
   2980 	MainWindow *mainwin = (MainWindow *)data;
   2981 	MessageView *msgview = (MessageView*)mainwin->messageview;
   2982 	GSList *msginfo_list = NULL;
   2983 	gint action = COMPOSE_REPLY;
   2984 	const gchar *a_name = gtk_action_get_name(gaction);
   2985 
   2986 	DO_ACTION("Message/Reply", COMPOSE_REPLY);
   2987 	DO_ACTION("Message/ReplyTo/All", COMPOSE_REPLY_TO_ALL);
   2988 	DO_ACTION("Message/ReplyTo/Sender", COMPOSE_REPLY_TO_SENDER);
   2989 	DO_ACTION("Message/ReplyTo/List", COMPOSE_REPLY_TO_LIST);
   2990 	DO_ACTION("Message/Forward", COMPOSE_FORWARD_INLINE);
   2991 	DO_ACTION("Message/ForwardAtt", COMPOSE_FORWARD_AS_ATTACH);
   2992 	DO_ACTION("Message/Redirect", COMPOSE_REDIRECT);
   2993 	DO_ACTION("Message/FollowupReply", COMPOSE_FOLLOWUP_AND_REPLY_TO);
   2994 
   2995 	cm_return_if_fail(msgview != NULL);
   2996 
   2997 	msginfo_list = summary_get_selection(mainwin->summaryview);
   2998 	cm_return_if_fail(msginfo_list != NULL);
   2999 
   3000 	if (!summary_has_opened_message(mainwin->summaryview)) {
   3001 		compose_reply_from_messageview(NULL, msginfo_list, action);
   3002 	} else if (summary_is_opened_message_selected(mainwin->summaryview)) {
   3003 		compose_reply_from_messageview(msgview, msginfo_list, action);
   3004 	} else {
   3005 		compose_reply_from_messageview(msgview, NULL, action);
   3006 	}
   3007 
   3008 	g_slist_free(msginfo_list);
   3009 }
   3010 
   3011 static void toggle_col_headers_cb(GtkAction *gaction, gpointer data)
   3012 {
   3013 	MainWindow *mainwin = (MainWindow *)data;
   3014 	FolderView *folderview = mainwin->folderview;
   3015 	SummaryView *summaryview = mainwin->summaryview;
   3016 	MimeView *mimeview = mainwin->messageview->mimeview;
   3017 
   3018 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (gaction))) {
   3019 		gtk_cmclist_column_titles_show(GTK_CMCLIST(folderview->ctree));
   3020 		gtk_cmclist_column_titles_show(GTK_CMCLIST(summaryview->ctree));
   3021   		gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(mimeview->ctree), TRUE);
   3022 		prefs_common.show_col_headers = TRUE;
   3023 	} else {
   3024 		gtk_cmclist_column_titles_hide(GTK_CMCLIST(folderview->ctree));
   3025 		gtk_cmclist_column_titles_hide(GTK_CMCLIST(summaryview->ctree));
   3026    		gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(mimeview->ctree), FALSE);
   3027 		prefs_common.show_col_headers = FALSE;
   3028 	}
   3029 }
   3030 
   3031 static void toggle_statusbar_cb(GtkAction *gaction, gpointer data)
   3032 {
   3033 	MainWindow *mainwin = (MainWindow *)data;
   3034 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (gaction))) {
   3035 		gtk_widget_show(mainwin->hbox_stat);
   3036 		prefs_common.show_statusbar = TRUE;
   3037 	} else {
   3038 		gtk_widget_hide(mainwin->hbox_stat);
   3039 		prefs_common.show_statusbar = FALSE;
   3040 	}
   3041 }
   3042 
   3043 static void set_layout_cb(GtkAction *action, GtkRadioAction *current, gpointer data)
   3044 {
   3045 	MainWindow *mainwin = (MainWindow *)data;
   3046 	gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
   3047 	LayoutType layout_mode = value;
   3048 	if (mainwin->menu_lock_count) {
   3049 		return;
   3050 	}
   3051 	if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current))) {
   3052 		return;
   3053 	}
   3054 
   3055 	if (layout_mode == prefs_common.layout_mode) {
   3056 		return;
   3057 	}
   3058 
   3059 	if (!mainwin->messageview->visible)
   3060 		main_window_toggle_message_view(mainwin);
   3061 
   3062 	main_window_separation_change(mainwin, layout_mode);
   3063 	mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
   3064 	summary_relayout(mainwin->summaryview);
   3065 	summary_update_unread(mainwin->summaryview, NULL);
   3066 }
   3067 
   3068 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
   3069 					gboolean ask_sync)
   3070 {
   3071 	static gboolean switching = FALSE;
   3072 
   3073 	if (switching)
   3074 		return;
   3075 
   3076 	switching = TRUE;
   3077 
   3078 	offline_ask_sync = ask_sync;
   3079 	if (offline)
   3080 		online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
   3081 	else
   3082 		online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
   3083 	offline_ask_sync = TRUE;
   3084 
   3085 	inc_reset_offline_override_timers();
   3086 
   3087 	switching = FALSE;
   3088 }
   3089 
   3090 static void toggle_work_offline_cb (GtkAction *action, gpointer data)
   3091 {
   3092 	MainWindow *mainwin = (MainWindow *)data;
   3093 	main_window_toggle_work_offline(mainwin, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)), TRUE);
   3094 }
   3095 
   3096 static gboolean any_folder_want_synchronise(void)
   3097 {
   3098 	GList *folderlist = folder_get_list();
   3099 
   3100 	/* see if there are synchronised folders */
   3101 	for (; folderlist; folderlist = folderlist->next) {
   3102 		Folder *folder = (Folder *)folderlist->data;
   3103 		if (folder_want_synchronise(folder)) {
   3104 			return TRUE;
   3105 		}
   3106 	}
   3107 
   3108 	return FALSE;
   3109 }
   3110 
   3111 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
   3112 {
   3113 
   3114 	if (!any_folder_want_synchronise())
   3115 		return;
   3116 
   3117 	if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
   3118 			_("Do you want to synchronise your folders now?"),
   3119 			NULL, _("_No"), NULL, _("_Synchronise"), NULL, NULL,
   3120 			ALERTFOCUS_SECOND) != G_ALERTALTERNATE)
   3121 		return;
   3122 
   3123 	if (offline_ask_sync)
   3124 		folder_synchronise(NULL);
   3125 }
   3126 
   3127 static void online_switch_clicked (GtkButton *btn, gpointer data)
   3128 {
   3129 	MainWindow *mainwin;
   3130 
   3131 	mainwin = (MainWindow *) data;
   3132 
   3133 	cm_return_if_fail(mainwin != NULL);
   3134 
   3135 	if (btn == GTK_BUTTON(mainwin->online_switch)) {
   3136 		gtk_widget_hide (mainwin->online_switch);
   3137 		gtk_widget_show (mainwin->offline_switch);
   3138 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/File/OfflineMode", TRUE);
   3139 
   3140 		/* go offline */
   3141 		if (prefs_common.work_offline)
   3142 			return;
   3143 
   3144 		mainwindow_check_synchronise(mainwin, TRUE);
   3145 		prefs_common.work_offline = TRUE;
   3146 		imap_disconnect_all(TRUE);
   3147 		hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
   3148 	} else {
   3149 		/*go online */
   3150 		if (!prefs_common.work_offline)
   3151 			return;
   3152 		gtk_widget_hide (mainwin->offline_switch);
   3153 		gtk_widget_show (mainwin->online_switch);
   3154 		cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/File/OfflineMode", FALSE);
   3155 		prefs_common.work_offline = FALSE;
   3156 		hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
   3157 	}
   3158 }
   3159 
   3160 static void addressbook_open_cb(GtkAction *action, gpointer data)
   3161 {
   3162 	addressbook_open(NULL);
   3163 }
   3164 
   3165 static void log_window_show_cb(GtkAction *action, gpointer data)
   3166 {
   3167 	MainWindow *mainwin = (MainWindow *)data;
   3168 	log_window_show(mainwin->logwin);
   3169 }
   3170 
   3171 static void inc_cancel_cb(GtkAction *action, gpointer data)
   3172 {
   3173 	inc_cancel_all();
   3174 	imap_cancel_all();
   3175 }
   3176 
   3177 static void send_cancel_cb(GtkAction *action, gpointer data)
   3178 {
   3179 	send_cancel();
   3180 }
   3181 
   3182 static void move_to_cb(GtkAction *action, gpointer data)
   3183 {
   3184 	MainWindow *mainwin = (MainWindow *)data;
   3185 	summary_move_to(mainwin->summaryview);
   3186 }
   3187 
   3188 static void copy_to_cb(GtkAction *action, gpointer data)
   3189 {
   3190 	MainWindow *mainwin = (MainWindow *)data;
   3191 	summary_copy_to(mainwin->summaryview);
   3192 }
   3193 
   3194 static void delete_cb(GtkAction *action, gpointer data)
   3195 {
   3196 	MainWindow *mainwin = (MainWindow *)data;
   3197 	summary_delete(mainwin->summaryview);
   3198 }
   3199 
   3200 static void delete_trash_cb(GtkAction *action, gpointer data)
   3201 {
   3202 	MainWindow *mainwin = (MainWindow *)data;
   3203 	summary_delete_trash(mainwin->summaryview);
   3204 }
   3205 
   3206 static void cancel_cb(GtkAction *action, gpointer data)
   3207 {
   3208 	MainWindow *mainwin = (MainWindow *)data;
   3209 	summary_cancel(mainwin->summaryview);
   3210 }
   3211 
   3212 static void open_msg_cb(GtkAction *action, gpointer data)
   3213 {
   3214 	MainWindow *mainwin = (MainWindow *)data;
   3215 	summary_open_msg(mainwin->summaryview, TRUE, FALSE);
   3216 }
   3217 
   3218 static void view_source_cb(GtkAction *action, gpointer data)
   3219 {
   3220 	MainWindow *mainwin = (MainWindow *)data;
   3221 	summary_view_source(mainwin->summaryview);
   3222 }
   3223 
   3224 static void show_all_header_cb(GtkAction *action, gpointer data)
   3225 {
   3226 	MainWindow *mainwin = (MainWindow *)data;
   3227 	if (mainwin->menu_lock_count) return;
   3228 	prefs_common.show_all_headers =
   3229 			gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
   3230 	summary_display_msg_selected(mainwin->summaryview,
   3231 				     gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
   3232 }
   3233 
   3234 static void toggle_fullscreen_cb(GtkAction *action, gpointer data)
   3235 {
   3236 	MainWindow *mainwin = (MainWindow *)data;
   3237 	if (mainwin->menu_lock_count) return;
   3238 	if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
   3239 		gtk_window_unfullscreen(GTK_WINDOW(mainwin->window));
   3240 		prefs_common.mainwin_fullscreen = FALSE;
   3241 	}
   3242 	else {
   3243 		prefs_common.mainwin_fullscreen = TRUE;
   3244 		gtk_window_fullscreen(GTK_WINDOW(mainwin->window));
   3245 	}
   3246 }
   3247 
   3248 static void toggle_menubar_cb(GtkAction *action, gpointer data)
   3249 {
   3250 	MainWindow *mainwin = (MainWindow *)data;
   3251 	if (mainwin->menu_lock_count) return;
   3252 	if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
   3253 		gtk_widget_hide(GTK_WIDGET(mainwin->menubar));
   3254 		prefs_common.mainwin_menubar = FALSE;
   3255 	} else {
   3256 		gtk_widget_show(GTK_WIDGET(mainwin->menubar));
   3257 		prefs_common.mainwin_menubar = TRUE;
   3258 	}
   3259 }
   3260 
   3261 static void hide_quotes_cb(GtkAction *action, gpointer data)
   3262 {
   3263 	MainWindow *mainwin = (MainWindow *)data;
   3264 
   3265 	if (mainwin->menu_lock_count) return;
   3266 
   3267 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
   3268 		const gchar *a_name = gtk_action_get_name(GTK_ACTION(action));
   3269 		if (!strcmp(a_name, "View/Quotes/CollapseAll")) prefs_common.hide_quotes = 1;
   3270 		else if (!strcmp(a_name, "View/Quotes/Collapse2")) prefs_common.hide_quotes = 2;
   3271 		else if (!strcmp(a_name, "View/Quotes/Collapse3")) prefs_common.hide_quotes = 3;
   3272 	} else
   3273 		prefs_common.hide_quotes = 0;
   3274 
   3275 	mainwin->menu_lock_count++;
   3276 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/CollapseAll", (prefs_common.hide_quotes == 1));
   3277 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse2", (prefs_common.hide_quotes == 2));
   3278 	cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse3", (prefs_common.hide_quotes == 3));
   3279 	mainwin->menu_lock_count--;
   3280 
   3281 	summary_redisplay_msg(mainwin->summaryview);
   3282 }
   3283 
   3284 static void mark_cb(GtkAction *action, gpointer data)
   3285 {
   3286 	MainWindow *mainwin = (MainWindow *)data;
   3287 	summary_mark(mainwin->summaryview);
   3288 }
   3289 
   3290 static void unmark_cb(GtkAction *action, gpointer data)
   3291 {
   3292 	MainWindow *mainwin = (MainWindow *)data;
   3293 	summary_unmark(mainwin->summaryview);
   3294 }
   3295 
   3296 static void mark_as_read_cb(GtkAction *action, gpointer data)
   3297 {
   3298 	MainWindow *mainwin = (MainWindow *)data;
   3299 	summary_mark_as_read(mainwin->summaryview);
   3300 }
   3301 
   3302 static void mark_as_unread_cb(GtkAction *action, gpointer data)
   3303 {
   3304 	MainWindow *mainwin = (MainWindow *)data;
   3305 	summary_mark_as_unread(mainwin->summaryview);
   3306 }
   3307 
   3308 static void mark_all_read_cb(GtkAction *action, gpointer data)
   3309 {
   3310 	MainWindow *mainwin = (MainWindow *)data;
   3311 	summary_mark_all_read(mainwin->summaryview, TRUE);
   3312 }
   3313 
   3314 static void mark_all_unread_cb(GtkAction *action, gpointer data)
   3315 {
   3316 	MainWindow *mainwin = (MainWindow *)data;
   3317 	summary_mark_all_unread(mainwin->summaryview, TRUE);
   3318 }
   3319 
   3320 static void ignore_thread_cb(GtkAction *action, gpointer data)
   3321 {
   3322 	MainWindow *mainwin = (MainWindow *)data;
   3323 	summary_ignore_thread(mainwin->summaryview);
   3324 }
   3325 
   3326 static void unignore_thread_cb(GtkAction *action, gpointer data)
   3327 {
   3328 	MainWindow *mainwin = (MainWindow *)data;
   3329 	summary_unignore_thread(mainwin->summaryview);
   3330 }
   3331 
   3332 static void watch_thread_cb(GtkAction *action, gpointer data)
   3333 {
   3334 	MainWindow *mainwin = (MainWindow *)data;
   3335 	summary_watch_thread(mainwin->summaryview);
   3336 }
   3337 
   3338 static void unwatch_thread_cb(GtkAction *action, gpointer data)
   3339 {
   3340 	MainWindow *mainwin = (MainWindow *)data;
   3341 	summary_unwatch_thread(mainwin->summaryview);
   3342 }
   3343 
   3344 static void lock_msgs_cb(GtkAction *action, gpointer data)
   3345 {
   3346 	MainWindow *mainwin = (MainWindow *)data;
   3347 	summary_msgs_lock(mainwin->summaryview);
   3348 }
   3349 
   3350 static void unlock_msgs_cb(GtkAction *action, gpointer data)
   3351 {
   3352 	MainWindow *mainwin = (MainWindow *)data;
   3353 	summary_msgs_unlock(mainwin->summaryview);
   3354 }
   3355 
   3356 
   3357 static void reedit_cb(GtkAction *action, gpointer data)
   3358 {
   3359 	MainWindow *mainwin = (MainWindow *)data;
   3360 	summary_reedit(mainwin->summaryview);
   3361 }
   3362 
   3363 static void add_address_cb(GtkAction *action, gpointer data)
   3364 {
   3365 	MainWindow *mainwin = (MainWindow *)data;
   3366 	summary_add_address(mainwin->summaryview);
   3367 }
   3368 
   3369 static void set_charset_cb(GtkAction *action, GtkRadioAction *current, gpointer data)
   3370 {
   3371 	MainWindow *mainwin = (MainWindow *)data;
   3372 	gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
   3373 	const gchar *str;
   3374 
   3375 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current))) {
   3376 		str = conv_get_charset_str((CharSet)value);
   3377 
   3378 		g_free(mainwin->messageview->forced_charset);
   3379 		mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
   3380 		procmime_force_charset(str);
   3381 
   3382 		summary_redisplay_msg(mainwin->summaryview);
   3383 
   3384 		debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
   3385 	}
   3386 }
   3387 
   3388 static void set_decode_cb(GtkAction *action, GtkRadioAction *current, gpointer data)
   3389 {
   3390 	MainWindow *mainwin = (MainWindow *)data;
   3391 	gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
   3392 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current))) {
   3393 		mainwin->messageview->forced_encoding = (EncodingType)value;
   3394 
   3395 		summary_redisplay_msg(mainwin->summaryview);
   3396 
   3397 		debug_print("forced encoding: %d\n", value);
   3398 	}
   3399 }
   3400 
   3401 static void hide_read_messages (GtkAction *action, gpointer data)
   3402 {
   3403 	MainWindow *mainwin = (MainWindow *)data;
   3404 	GtkWidget *menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/HideReadMessages");
   3405 	if (!mainwin->summaryview->folder_item
   3406 	    || g_object_get_data(G_OBJECT(menuitem), "dont_toggle"))
   3407 		return;
   3408 	summary_toggle_show_read_messages(mainwin->summaryview);
   3409 }
   3410 
   3411 static void hide_del_messages (GtkAction *action, gpointer data)
   3412 {
   3413 	MainWindow *mainwin = (MainWindow *)data;
   3414 	GtkWidget *menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/HideDelMessages");
   3415 	if (!mainwin->summaryview->folder_item
   3416 	    || g_object_get_data(G_OBJECT(menuitem), "dont_toggle"))
   3417 		return;
   3418 	summary_toggle_show_del_messages(mainwin->summaryview);
   3419 }
   3420 
   3421 static void hide_read_threads (GtkAction *action, gpointer data)
   3422 {
   3423 	MainWindow *mainwin = (MainWindow *)data;
   3424 	GtkWidget *menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/HideReadThreads");
   3425 	if (!mainwin->summaryview->folder_item
   3426 	    || g_object_get_data(G_OBJECT(menuitem), "dont_toggle"))
   3427 		return;
   3428 	summary_toggle_show_read_threads(mainwin->summaryview);
   3429 }
   3430 
   3431 static void thread_cb(GtkAction *action, gpointer data)
   3432 {
   3433 	MainWindow *mainwin = (MainWindow *)data;
   3434 	gboolean threaded = FALSE;
   3435 	guint selected_msgnum = 0;
   3436 
   3437 	if (mainwin->menu_lock_count) return;
   3438 	if (!mainwin->summaryview->folder_item) return;
   3439 
   3440 	main_window_cursor_wait(mainwin);
   3441 
   3442 	selected_msgnum = summary_get_msgnum(mainwin->summaryview, mainwin->summaryview->selected);
   3443 
   3444 	threaded = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
   3445 
   3446 	mainwin->summaryview->folder_item->threaded = threaded;
   3447 
   3448 	mainwin->summaryview->threaded = threaded;
   3449 
   3450 	summary_show(mainwin->summaryview,
   3451 			mainwin->summaryview->folder_item, FALSE);
   3452 	summary_select_by_msgnum(mainwin->summaryview, selected_msgnum, FALSE);
   3453 
   3454 	main_window_cursor_normal(mainwin);
   3455 }
   3456 
   3457 static void expand_threads_cb(GtkAction *action, gpointer data)
   3458 {
   3459 	MainWindow *mainwin = (MainWindow *)data;
   3460 	summary_expand_threads(mainwin->summaryview);
   3461 }
   3462 
   3463 static void collapse_threads_cb(GtkAction *action, gpointer data)
   3464 {
   3465 	MainWindow *mainwin = (MainWindow *)data;
   3466 	summary_collapse_threads(mainwin->summaryview);
   3467 }
   3468 
   3469 static void set_summary_display_item_cb(GtkAction *action, gpointer data)
   3470 {
   3471 	prefs_summary_column_open();
   3472 }
   3473 
   3474 static void set_folder_display_item_cb(GtkAction *action, gpointer data)
   3475 {
   3476 	prefs_folder_column_open();
   3477 }
   3478 
   3479 static void sort_summary_cb(GtkAction *action, GtkRadioAction *current, gpointer data)
   3480 {
   3481 	MainWindow *mainwin = (MainWindow *)data;
   3482 	gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
   3483 
   3484 	if (mainwin->menu_lock_count) return;
   3485 
   3486 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current))) {
   3487 		summary_sort(mainwin->summaryview, (FolderSortKey)value,
   3488 			     mainwin->summaryview->sort_type);
   3489 	}
   3490 }
   3491 
   3492 static void sort_summary_type_cb(GtkAction *gaction, GtkRadioAction *current, gpointer data)
   3493 {
   3494 	MainWindow *mainwin = (MainWindow *)data;
   3495 	gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
   3496 
   3497 	if (mainwin->menu_lock_count) return;
   3498 
   3499 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current)))
   3500 		summary_sort(mainwin->summaryview,
   3501 			     mainwin->summaryview->sort_key, (FolderSortType)value);
   3502 }
   3503 
   3504 static void attract_by_subject_cb(GtkAction *action, gpointer data)
   3505 {
   3506 	MainWindow *mainwin = (MainWindow *)data;
   3507 	summary_attract_by_subject(mainwin->summaryview);
   3508 }
   3509 
   3510 void mainwindow_delete_duplicated(MainWindow *mainwin)
   3511 {
   3512 	FolderItem *item = folderview_get_selected_item(mainwin->folderview);
   3513 	if (!item)
   3514 		return;
   3515 	main_window_cursor_wait(mainwin);
   3516 	STATUSBAR_PUSH(mainwin, "Deleting duplicate messages...");
   3517 	int dupes = folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
   3518 				      DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
   3519 	STATUSBAR_POP(mainwin);
   3520 	main_window_cursor_normal(mainwin);
   3521 	if (dupes < 0) {
   3522 		return;
   3523 	} else if (dupes == 0) {
   3524 		alertpanel_notice("No duplicates found in selected folder.\n");
   3525 		return;
   3526 	}
   3527 
   3528 	char *msg = "Marked %d duplicates for deletion in selected folder.\n";
   3529 	if (prefs_common.immediate_exec)
   3530 		msg = "Deleted %d duplicates in selected folder.\n";
   3531 	alertpanel_notice(msg, dupes);
   3532 }
   3533 
   3534 static void delete_duplicated_cb(GtkAction *action, gpointer data)
   3535 {
   3536 	mainwindow_delete_duplicated((MainWindow *)data);
   3537 }
   3538 
   3539 struct DelDupsData
   3540 {
   3541 	guint	dups;
   3542 	guint	folders;
   3543 };
   3544 
   3545 static void deldup_all(FolderItem *item, gpointer _data)
   3546 {
   3547 	struct DelDupsData *data = _data;
   3548 	gint result;
   3549 
   3550 	result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
   3551 	if (result >= 0) {
   3552 		data->dups += result;
   3553 		data->folders += 1;
   3554 	}
   3555 }
   3556 
   3557 void mainwindow_delete_duplicated_all(MainWindow *mainwin)
   3558 {
   3559 	struct DelDupsData data = {0, 0};
   3560 
   3561 	main_window_cursor_wait(mainwin);
   3562 	STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages in all folders..."));
   3563 	folder_func_to_all_folders(deldup_all, &data);
   3564 	STATUSBAR_POP(mainwin);
   3565 	main_window_cursor_normal(mainwin);
   3566 
   3567 	if (data.dups > 0)
   3568 		alertpanel_notice("Deleted %d duplicates in %d folders.\n", data.dups, data.folders);
   3569 	else
   3570 		alertpanel_notice("No duplicates in %d folders.\n", data.folders);
   3571 }
   3572 
   3573 static void delete_duplicated_all_cb(GtkAction *action, gpointer mw)
   3574 {
   3575 	MainWindow *mainwin = (MainWindow *)mw;
   3576 
   3577 	mainwindow_delete_duplicated_all(mainwin);
   3578 }
   3579 
   3580 static void execute_summary_cb(GtkAction *action, gpointer data)
   3581 {
   3582 	MainWindow *mainwin = (MainWindow *)data;
   3583 	summary_execute(mainwin->summaryview);
   3584 }
   3585 
   3586 static void expunge_summary_cb(GtkAction *action, gpointer data)
   3587 {
   3588 	MainWindow *mainwin = (MainWindow *)data;
   3589 	summary_expunge(mainwin->summaryview);
   3590 }
   3591 
   3592 static void update_summary_cb(GtkAction *action, gpointer data)
   3593 {
   3594 	MainWindow *mainwin = (MainWindow *)data;
   3595 	FolderItem *fitem;
   3596 	FolderView *folderview = mainwin->folderview;
   3597 
   3598 	if (!mainwin->summaryview->folder_item) return;
   3599 	if ((fitem = folderview_get_opened_item(folderview)) == NULL) return;
   3600 
   3601 	folder_update_op_count();
   3602 	folder_item_scan(fitem);
   3603 	summary_show(mainwin->summaryview, fitem, FALSE);
   3604 }
   3605 
   3606 static void prev_cb(GtkAction *action, gpointer data)
   3607 {
   3608 	MainWindow *mainwin = (MainWindow *)data;
   3609 	summary_select_prev(mainwin->summaryview);
   3610 }
   3611 
   3612 static void next_cb(GtkAction *action, gpointer data)
   3613 {
   3614 	MainWindow *mainwin = (MainWindow *)data;
   3615 	summary_select_next(mainwin->summaryview);
   3616 }
   3617 
   3618 static void prev_unread_cb(GtkAction *action, gpointer data)
   3619 {
   3620 	MainWindow *mainwin = (MainWindow *)data;
   3621 	summary_select_prev_unread(mainwin->summaryview);
   3622 }
   3623 
   3624 static void next_unread_cb(GtkAction *action, gpointer data)
   3625 {
   3626 	MainWindow *mainwin = (MainWindow *)data;
   3627 	summary_select_next_unread(mainwin->summaryview);
   3628 }
   3629 
   3630 static void prev_new_cb(GtkAction *action, gpointer data)
   3631 {
   3632 	MainWindow *mainwin = (MainWindow *)data;
   3633 	summary_select_prev_new(mainwin->summaryview);
   3634 }
   3635 
   3636 static void next_new_cb(GtkAction *action, gpointer data)
   3637 {
   3638 	MainWindow *mainwin = (MainWindow *)data;
   3639 	summary_select_next_new(mainwin->summaryview);
   3640 }
   3641 
   3642 static void prev_marked_cb(GtkAction *action, gpointer data)
   3643 {
   3644 	MainWindow *mainwin = (MainWindow *)data;
   3645 	summary_select_prev_marked(mainwin->summaryview);
   3646 }
   3647 
   3648 static void next_marked_cb(GtkAction *action, gpointer data)
   3649 {
   3650 	MainWindow *mainwin = (MainWindow *)data;
   3651 	summary_select_next_marked(mainwin->summaryview);
   3652 }
   3653 
   3654 static void prev_labeled_cb(GtkAction *action, gpointer data)
   3655 {
   3656 	MainWindow *mainwin = (MainWindow *)data;
   3657 	summary_select_prev_labeled(mainwin->summaryview);
   3658 }
   3659 
   3660 static void next_labeled_cb(GtkAction *action, gpointer data)
   3661 {
   3662 	MainWindow *mainwin = (MainWindow *)data;
   3663 	summary_select_next_labeled(mainwin->summaryview);
   3664 }
   3665 
   3666 static void prev_history_cb(GtkAction *action, gpointer data)
   3667 {
   3668 	MainWindow *mainwin = (MainWindow *)data;
   3669 	MsgInfo *info = messageview_nav_get_prev(mainwin->messageview);
   3670 	if (info) {
   3671 		if (info->folder != mainwin->summaryview->folder_item)
   3672 			folderview_select(mainwin->folderview, info->folder);
   3673 		summary_select_by_msgnum(mainwin->summaryview, info->msgnum,
   3674 				OPEN_SELECTED_ON_PREVNEXT);
   3675 		procmsg_msginfo_free(&info);
   3676 		main_window_set_menu_sensitive(mainwindow_get_mainwindow());
   3677 		toolbar_main_set_sensitive(mainwindow_get_mainwindow());
   3678 	}
   3679 }
   3680 
   3681 static void next_history_cb(GtkAction *action, gpointer data)
   3682 {
   3683 	MainWindow *mainwin = (MainWindow *)data;
   3684 	MsgInfo *info = messageview_nav_get_next(mainwin->messageview);
   3685 	if (info) {
   3686 		if (info->folder != mainwin->summaryview->folder_item)
   3687 			folderview_select(mainwin->folderview, info->folder);
   3688 		summary_select_by_msgnum(mainwin->summaryview, info->msgnum,
   3689 				OPEN_SELECTED_ON_PREVNEXT);
   3690 		procmsg_msginfo_free(&info);
   3691 		main_window_set_menu_sensitive(mainwindow_get_mainwindow());
   3692 		toolbar_main_set_sensitive(mainwindow_get_mainwindow());
   3693 	}
   3694 }
   3695 
   3696 static void parent_cb(GtkAction *action, gpointer data)
   3697 {
   3698 	MainWindow *mainwin = (MainWindow *)data;
   3699 	summary_select_parent(mainwin->summaryview);
   3700 }
   3701 
   3702 static void goto_folder_cb(GtkAction *action, gpointer data)
   3703 {
   3704 	MainWindow *mainwin = (MainWindow *)data;
   3705 	FolderItem *to_folder;
   3706 
   3707 	to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL, FALSE,
   3708 			_("Select folder to go to"));
   3709 
   3710 	if (to_folder)
   3711 		folderview_select(mainwin->folderview, to_folder);
   3712 }
   3713 
   3714 static void goto_unread_folder_cb(GtkAction *action, gpointer data)
   3715 {
   3716 	MainWindow *mainwin = (MainWindow *)data;
   3717 	folderview_select_next_with_flag(mainwin->folderview, MSG_UNREAD);
   3718 }
   3719 
   3720 static void copy_cb(GtkAction *action, gpointer data)
   3721 {
   3722 	MainWindow *mainwin = (MainWindow *)data;
   3723 	messageview_copy_clipboard(mainwin->messageview);
   3724 }
   3725 
   3726 static void allsel_cb(GtkAction *action, gpointer data)
   3727 {
   3728 	MainWindow *mainwin = (MainWindow *)data;
   3729 	MessageView *msgview = mainwin->messageview;
   3730 
   3731 	if (messageview_is_visible(msgview) &&
   3732 		 (gtk_widget_has_focus(msgview->mimeview->textview->text)))
   3733 		messageview_select_all(mainwin->messageview);
   3734 	else
   3735 		summary_select_all(mainwin->summaryview);
   3736 }
   3737 
   3738 static void select_thread_cb(GtkAction *action, gpointer data)
   3739 {
   3740 	MainWindow *mainwin = (MainWindow *)data;
   3741 	summary_select_thread(mainwin->summaryview, FALSE, FALSE);
   3742 }
   3743 
   3744 static void trash_thread_cb(GtkAction *action, gpointer data)
   3745 {
   3746 	MainWindow *mainwin = (MainWindow *)data;
   3747 	summary_select_thread(mainwin->summaryview, FALSE, TRUE);
   3748 }
   3749 
   3750 static void delete_thread_cb(GtkAction *action, gpointer data)
   3751 {
   3752 	MainWindow *mainwin = (MainWindow *)data;
   3753 	summary_select_thread(mainwin->summaryview, TRUE, FALSE);
   3754 }
   3755 
   3756 static void prefs_actions_open_cb(GtkAction *action, gpointer data)
   3757 {
   3758 	MainWindow *mainwin = (MainWindow *)data;
   3759 	prefs_actions_open(mainwin);
   3760 }
   3761 
   3762 static void prefs_account_open_cb(GtkAction *action, gpointer data)
   3763 {
   3764 	MainWindow *mainwin = (MainWindow *)data;
   3765 	if (!cur_account) {
   3766 		new_account_cb(NULL, mainwin);
   3767 	} else {
   3768 		account_open(cur_account, FALSE);
   3769 	}
   3770 }
   3771 
   3772 static void new_account_cb(GtkAction *action, gpointer data)
   3773 {
   3774 	account_edit_open(NULL, NULL);
   3775 	if (!compose_get_compose_list()) account_add();
   3776 }
   3777 
   3778 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
   3779 {
   3780 	FolderItem *item = NULL;
   3781 	cur_account = (PrefsAccount *)data;
   3782 
   3783 	if (!mainwindow_get_mainwindow())
   3784 		return;
   3785 	main_window_show_cur_account(mainwindow_get_mainwindow());
   3786 	toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
   3787 	main_window_set_menu_sensitive(mainwindow_get_mainwindow());
   3788 	toolbar_main_set_sensitive(mainwindow_get_mainwindow());
   3789 	item = folderview_get_selected_item(
   3790 			mainwindow_get_mainwindow()->folderview);
   3791 	if (item) {
   3792 		toolbar_set_compose_button
   3793 			(mainwindow_get_mainwindow()->toolbar,
   3794 			 FOLDER_TYPE(item->folder) == F_NEWS ?
   3795 			 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
   3796 	}
   3797 }
   3798 
   3799 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
   3800 {
   3801 	MainWindow *mainwin = (MainWindow *)mainwin_list->data;
   3802 	PrefsAccount *account = (PrefsAccount *)data;
   3803 
   3804 	inc_account_mail(mainwin, account);
   3805 }
   3806 
   3807 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
   3808 {
   3809 	PrefsAccount *account = (PrefsAccount *)data;
   3810 
   3811 	compose_new_with_folderitem(account, NULL, NULL);
   3812 }
   3813 
   3814 static void prefs_open_cb(GtkAction *action, gpointer data)
   3815 {
   3816 	prefs_gtk_open();
   3817 }
   3818 
   3819 static void manual_open_cb(GtkAction *action, gpointer data)
   3820 {
   3821 	manual_open(MANUAL_MANUAL_CLAWS, NULL);
   3822 }
   3823 
   3824 static void manual_faq_open_cb(GtkAction *action, gpointer data)
   3825 {
   3826 	manual_open(MANUAL_FAQ_CLAWS, NULL);
   3827 }
   3828 
   3829 static void legend_open_cb(GtkAction *action, gpointer data)
   3830 {
   3831 	legend_show();
   3832 }
   3833 
   3834 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
   3835 {
   3836 	MainWindow *mainwin = (MainWindow *)data;
   3837 	gchar *str;
   3838 
   3839 	if (item->path)
   3840 		str = g_strdup_printf(_("Scanning folder %s%c%s..."),
   3841 				      LOCAL_FOLDER(folder)->rootpath,
   3842 				      G_DIR_SEPARATOR,
   3843 				      item->path);
   3844 	else
   3845 		str = g_strdup_printf(_("Scanning folder %s..."),
   3846 				      LOCAL_FOLDER(folder)->rootpath);
   3847 
   3848 	STATUSBAR_PUSH(mainwin, str);
   3849 	STATUSBAR_POP(mainwin);
   3850 	g_free(str);
   3851 }
   3852 
   3853 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
   3854 					  gpointer data)
   3855 {
   3856 	SummaryView *summary;
   3857 
   3858 	cm_return_val_if_fail(data, FALSE);
   3859 	if (!g_list_find(mainwin_list, data))
   3860 		return TRUE;
   3861 	summary = ((MainWindow *)data)->summaryview;
   3862 	cm_return_val_if_fail(summary, FALSE);
   3863 
   3864 	if (GTK_CMCLIST(summary->ctree)->selection &&
   3865 	    g_list_length(GTK_CMCLIST(summary->ctree)->selection) > 1)
   3866 		return FALSE;
   3867 
   3868 	return FALSE;
   3869 }
   3870 
   3871 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
   3872 					  gpointer data)
   3873 {
   3874 	is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
   3875 	return FALSE;
   3876 }
   3877 
   3878 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
   3879 					  gpointer data)
   3880 {
   3881 	if (!claws_is_starting()
   3882 		&& state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
   3883 		&& state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
   3884 
   3885 		if (iconified_count > 0)
   3886 			hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
   3887 		iconified_count++;
   3888 	} else if (!claws_is_starting()) {
   3889 		prefs_common.mainwin_maximised =
   3890 			((state->new_window_state&GDK_WINDOW_STATE_MAXIMIZED) != 0);
   3891 	}
   3892 	if (state->new_window_state == 0)
   3893 		gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
   3894 	return FALSE;
   3895 }
   3896 
   3897 gboolean mainwindow_is_obscured(void)
   3898 {
   3899 	return is_obscured;
   3900 }
   3901 
   3902 /*!
   3903  *\brief	get a MainWindow
   3904  *
   3905  *\return	MainWindow * The first mainwindow in the mainwin_list
   3906  */
   3907 MainWindow *mainwindow_get_mainwindow(void)
   3908 {
   3909 	if (mainwin_list && mainwin_list->data)
   3910 		return (MainWindow *)(mainwin_list->data);
   3911 	else
   3912 		return NULL;
   3913 }
   3914 
   3915 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
   3916 {
   3917 	ProgressData *data = (ProgressData *) source;
   3918 	MainWindow *mainwin = (MainWindow *) userdata;
   3919 
   3920 	switch (data->cmd) {
   3921 	case PROGRESS_COMMAND_START:
   3922 	case PROGRESS_COMMAND_STOP:
   3923 		gtk_progress_bar_set_fraction
   3924 			(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
   3925 		break;
   3926 	case PROGRESS_COMMAND_SET_PERCENTAGE:
   3927 		gtk_progress_bar_set_fraction
   3928 			(GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
   3929 		break;
   3930 	}
   3931 	while (gtk_events_pending()) gtk_main_iteration ();
   3932 
   3933 	return FALSE;
   3934 }
   3935 
   3936 static void sync_cb(GtkAction *action, gpointer data)
   3937 {
   3938 	MainWindow *mainwin = (MainWindow *)data;
   3939 	mainwindow_check_synchronise(mainwin, FALSE);
   3940 }
   3941 
   3942 void mainwindow_jump_to(const gchar *target, gboolean popup)
   3943 {
   3944 	gchar *tmp = NULL;
   3945 	FolderItem *item = NULL;
   3946 	gchar *msg = NULL;
   3947 	MainWindow *mainwin = mainwindow_get_mainwindow();
   3948 	gchar *from_uri = NULL;
   3949 	if (!target)
   3950 		return;
   3951 
   3952 	if (!mainwin) {
   3953 		g_print("not initialized\n");
   3954 		return;
   3955 	}
   3956 
   3957 	if ((from_uri = g_filename_from_uri(target, NULL, NULL)) != NULL)
   3958 		tmp = from_uri;
   3959 	else
   3960 		tmp = g_strdup(target);
   3961 
   3962 	strcrlftrunc(tmp);
   3963 
   3964 	if ((item = folder_find_item_from_identifier(tmp))) {
   3965 		g_print("selecting folder '%s'\n", tmp);
   3966 		folderview_select(mainwin->folderview, item);
   3967 		if (popup)
   3968 			main_window_popup(mainwin);
   3969 		g_free(tmp);
   3970 		return;
   3971 	}
   3972 
   3973 	msg = strrchr(tmp, '/');
   3974 	if (msg) {
   3975 		*msg++ = '\0';
   3976 		if ((item = folder_find_item_from_identifier(tmp))) {
   3977 			g_print("selecting folder '%s'\n", tmp);
   3978 			folderview_select(mainwin->folderview, item);
   3979 		} else if ((item = folder_find_item_from_real_path(tmp))) {
   3980 			g_print("selecting folder '%s'\n", tmp);
   3981 			folderview_select(mainwin->folderview, item);
   3982 		} else {
   3983 			g_print("'%s' not found\n", tmp);
   3984 		}
   3985 		if (item && msg && atoi(msg)) {
   3986 			g_print("selecting message %d\n", atoi(msg));
   3987 			summary_select_by_msgnum(mainwin->summaryview, atoi(msg), TRUE);
   3988 			if (popup)
   3989 				main_window_popup(mainwin);
   3990 			g_free(tmp);
   3991 			return;
   3992 		} else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
   3993 			MsgInfo *msginfo = NULL;
   3994 			msg++;
   3995 			msg[strlen(msg)-1] = '\0';
   3996 			msginfo = folder_item_get_msginfo_by_msgid(item, msg);
   3997 			if (msginfo) {
   3998 				g_print("selecting message %s\n", msg);
   3999 				summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum, TRUE);
   4000 				if (popup)
   4001 					main_window_popup(mainwin);
   4002 				g_free(tmp);
   4003 				procmsg_msginfo_free(&msginfo);
   4004 				return;
   4005 			} else {
   4006 				g_print("'%s' not found\n", msg);
   4007 			}
   4008 		} else {
   4009 			g_print("'%s' not found\n", msg);
   4010 		}
   4011 	} else {
   4012 		g_print("'%s' not found\n", tmp);
   4013 	}
   4014 
   4015 	g_free(tmp);
   4016 }
   4017 
   4018 void mainwindow_exit_folder(MainWindow *mainwin) {
   4019 	mainwin->in_folder = FALSE;
   4020 	main_window_set_menu_sensitive(mainwin);
   4021 }
   4022 
   4023 void mainwindow_enter_folder(MainWindow *mainwin) {
   4024 	mainwin->in_folder = TRUE;
   4025 	main_window_set_menu_sensitive(mainwin);
   4026 }
   4027 
   4028 static void save_part_as_cb(GtkAction *action, gpointer data)
   4029 {
   4030 	MainWindow *mainwin = (MainWindow *)data;
   4031 
   4032 	if (mainwin->messageview
   4033 	&&  mainwin->messageview->mimeview)
   4034 		mimeview_save_as(mainwin->messageview->mimeview);
   4035 }
   4036 
   4037 static void view_part_as_text_cb(GtkAction *action, gpointer data)
   4038 {
   4039 	MainWindow *mainwin = (MainWindow *)data;
   4040 
   4041 	if (mainwin->messageview
   4042 	&&  mainwin->messageview->mimeview)
   4043 		mimeview_display_as_text(mainwin->messageview->mimeview);
   4044 }
   4045 
   4046 static void open_part_cb(GtkAction *action, gpointer data)
   4047 {
   4048 	MainWindow *mainwin = (MainWindow *)data;
   4049 
   4050 	if (mainwin->messageview
   4051 	&&  mainwin->messageview->mimeview)
   4052 		mimeview_launch(mainwin->messageview->mimeview, NULL);
   4053 }
   4054 
   4055 static void open_part_with_cb(GtkAction *action, gpointer data)
   4056 {
   4057 	MainWindow *mainwin = (MainWindow *)data;
   4058 
   4059 	if (mainwin->messageview
   4060 	&&  mainwin->messageview->mimeview)
   4061 		mimeview_open_with(mainwin->messageview->mimeview);
   4062 }
   4063 
   4064 static void goto_next_part_cb(GtkAction *action, gpointer data)
   4065 {
   4066 	MainWindow *mainwin = (MainWindow *)data;
   4067 
   4068 	if (mainwin->messageview
   4069 	&&  mainwin->messageview->mimeview)
   4070 		mimeview_select_next_part(mainwin->messageview->mimeview);
   4071 }
   4072 
   4073 static void goto_prev_part_cb(GtkAction *action, gpointer data)
   4074 {
   4075 	MainWindow *mainwin = (MainWindow *)data;
   4076 
   4077 	if (mainwin->messageview
   4078 	&&  mainwin->messageview->mimeview)
   4079 		mimeview_select_prev_part(mainwin->messageview->mimeview);
   4080 }