Fix a leak.
[claws.git] / src / compose.c
index 498c560a9ddf04963f71caaace72247b9356ff8d..71b96d19cbe31458586335fe8bb04b6c1c34b544 100644 (file)
@@ -122,7 +122,8 @@ enum
 
 typedef enum
 {
-       COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE,
+       COMPOSE_CALL_ADVANCED_ACTION_UNDEFINED = -1,
+       COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE = 0,
        COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_CHARACTER,
        COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_CHARACTER,
        COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_WORD,
@@ -183,6 +184,20 @@ typedef enum {
 #define COMPOSE_DRAFT_TIMEOUT_UNSET -1
 #define COMPOSE_DRAFT_TIMEOUT_FORBIDDEN -2
 
+static GdkColor default_header_bgcolor = {
+       (gulong)0,
+       (gushort)0,
+       (gushort)0,
+       (gushort)0
+};
+
+static GdkColor default_header_color = {
+       (gulong)0,
+       (gushort)0,
+       (gushort)0,
+       (gushort)0
+};
+
 static GList *compose_list = NULL;
 static GSList *extra_headers = NULL;
 
@@ -197,7 +212,7 @@ static Compose *compose_create                      (PrefsAccount   *account,
                                                 ComposeMode     mode,
                                                 gboolean batch);
 
-static void compose_entry_mark_default_to      (Compose          *compose,
+static void compose_entry_indicate     (Compose          *compose,
                                         const gchar      *address);
 static Compose *compose_followup_and_reply_to  (MsgInfo        *msginfo,
                                         ComposeQuoteMode        quote_mode,
@@ -555,7 +570,7 @@ static void compose_check_backwards    (GtkAction *action, gpointer data);
 static void compose_check_forwards_go     (GtkAction *action, gpointer data);
 #endif
 
-static PrefsAccount *compose_guess_forward_account_from_msginfo        (MsgInfo *msginfo);
+static PrefsAccount *compose_find_account      (MsgInfo *msginfo);
 
 static MsgInfo *compose_msginfo_new_from_compose(Compose *compose);
 
@@ -571,156 +586,154 @@ static void from_name_activate_cb(GtkWidget *widget, gpointer data);
 
 static GtkActionEntry compose_popup_entries[] =
 {
-       {"Compose",                     NULL, "Compose" },
-       {"Compose/Add",                 NULL, N_("_Add..."), NULL, NULL, G_CALLBACK(compose_attach_cb) },
-       {"Compose/Remove",                      NULL, N_("_Remove"), NULL, NULL, G_CALLBACK(compose_attach_remove_selected) },
-       {"Compose/---",                 NULL, "---", NULL, NULL, NULL },
-       {"Compose/Properties",          NULL, N_("_Properties..."), NULL, NULL, G_CALLBACK(compose_attach_property) },
+       {"Compose",            NULL, "Compose", NULL, NULL, NULL },
+       {"Compose/Add",        NULL, N_("_Add..."), NULL, NULL, G_CALLBACK(compose_attach_cb) },
+       {"Compose/Remove",     NULL, N_("_Remove"), NULL, NULL, G_CALLBACK(compose_attach_remove_selected) },
+       {"Compose/---",        NULL, "---", NULL, NULL, NULL },
+       {"Compose/Properties", NULL, N_("_Properties..."), NULL, NULL, G_CALLBACK(compose_attach_property) },
 };
 
 static GtkActionEntry compose_entries[] =
 {
-       {"Menu",                                NULL, "Menu" },
+       {"Menu",                          NULL, "Menu", NULL, NULL, NULL },
 /* menus */
-       {"Message",                     NULL, N_("_Message") },
-       {"Edit",                        NULL, N_("_Edit") },
+       {"Message",                       NULL, N_("_Message"), NULL, NULL, NULL },
+       {"Edit",                          NULL, N_("_Edit"), NULL, NULL, NULL },
 #if USE_ENCHANT
-       {"Spelling",                    NULL, N_("_Spelling") },
+       {"Spelling",                      NULL, N_("_Spelling"), NULL, NULL, NULL },
 #endif
-       {"Options",                     NULL, N_("_Options") },
-       {"Tools",                       NULL, N_("_Tools") },
-       {"Help",                        NULL, N_("_Help") },
+       {"Options",                       NULL, N_("_Options"), NULL, NULL, NULL },
+       {"Tools",                         NULL, N_("_Tools"), NULL, NULL, NULL },
+       {"Help",                          NULL, N_("_Help"), NULL, NULL, NULL },
 /* Message menu */
-       {"Message/Send",                NULL, N_("S_end"), "<control>Return", NULL, G_CALLBACK(compose_send_cb) },
-       {"Message/SendLater",           NULL, N_("Send _later"), "<shift><control>S", NULL, G_CALLBACK(compose_send_later_cb) },
-       {"Message/---",                 NULL, "---" },
-
-       {"Message/AttachFile",          NULL, N_("_Attach file"), "<control>M", NULL, G_CALLBACK(compose_attach_cb) },
-       {"Message/InsertFile",          NULL, N_("_Insert file"), "<control>I", NULL, G_CALLBACK(compose_insert_file_cb) },
-       {"Message/InsertSig",           NULL, N_("Insert si_gnature"), "<control>G", NULL, G_CALLBACK(compose_insert_sig_cb) },
-       {"Message/ReplaceSig",          NULL, N_("_Replace signature"), NULL, NULL, G_CALLBACK(compose_replace_sig_cb) },
-       /* {"Message/---",              NULL, "---" }, */
-       {"Message/Save",                NULL, N_("_Save"), "<control>S", NULL, G_CALLBACK(compose_save_cb) }, /*COMPOSE_KEEP_EDITING*/
-       /* {"Message/---",              NULL, "---" }, */
-       {"Message/Print",               NULL, N_("_Print"), NULL, NULL, G_CALLBACK(compose_print_cb) },
-       /* {"Message/---",              NULL, "---" }, */
-       {"Message/Close",               NULL, N_("_Close"), "<control>W", NULL, G_CALLBACK(compose_close_cb) },
+       {"Message/Send",                  NULL, N_("S_end"), "<control>Return", NULL, G_CALLBACK(compose_send_cb) },
+       {"Message/SendLater",             NULL, N_("Send _later"), "<shift><control>S", NULL, G_CALLBACK(compose_send_later_cb) },
+       {"Message/---",                   NULL, "---", NULL, NULL, NULL },
+
+       {"Message/AttachFile",            NULL, N_("_Attach file"), "<control>M", NULL, G_CALLBACK(compose_attach_cb) },
+       {"Message/InsertFile",            NULL, N_("_Insert file"), "<control>I", NULL, G_CALLBACK(compose_insert_file_cb) },
+       {"Message/InsertSig",             NULL, N_("Insert si_gnature"), "<control>G", NULL, G_CALLBACK(compose_insert_sig_cb) },
+       {"Message/ReplaceSig",            NULL, N_("_Replace signature"), NULL, NULL, G_CALLBACK(compose_replace_sig_cb) },
+       /* {"Message/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Message/Save",                  NULL, N_("_Save"), "<control>S", NULL, G_CALLBACK(compose_save_cb) }, /*COMPOSE_KEEP_EDITING*/
+       /* {"Message/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Message/Print",                 NULL, N_("_Print"), NULL, NULL, G_CALLBACK(compose_print_cb) },
+       /* {"Message/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Message/Close",                 NULL, N_("_Close"), "<control>W", NULL, G_CALLBACK(compose_close_cb) },
 
 /* Edit menu */
-       {"Edit/Undo",                   NULL, N_("_Undo"), "<control>Z", NULL, G_CALLBACK(compose_undo_cb) },
-       {"Edit/Redo",                   NULL, N_("_Redo"), "<control>Y", NULL, G_CALLBACK(compose_redo_cb) },
-       {"Edit/---",                    NULL, "---" },
-
-       {"Edit/Cut",                    NULL, N_("Cu_t"), "<control>X", NULL, G_CALLBACK(compose_cut_cb) },
-       {"Edit/Copy",                   NULL, N_("_Copy"), "<control>C", NULL, G_CALLBACK(compose_copy_cb) },
-       {"Edit/Paste",                  NULL, N_("_Paste"), "<control>V", NULL, G_CALLBACK(compose_paste_cb) },
-
-       {"Edit/SpecialPaste",           NULL, N_("_Special paste") },
-       {"Edit/SpecialPaste/AsQuotation",       NULL, N_("As _quotation"), NULL, NULL, G_CALLBACK(compose_paste_as_quote_cb) },
-       {"Edit/SpecialPaste/Wrapped",   NULL, N_("_Wrapped"), NULL, NULL, G_CALLBACK(compose_paste_wrap_cb) },
-       {"Edit/SpecialPaste/Unwrapped", NULL, N_("_Unwrapped"), NULL, NULL, G_CALLBACK(compose_paste_no_wrap_cb) },
-
-       {"Edit/SelectAll",              NULL, N_("Select _all"), "<control>A", NULL, G_CALLBACK(compose_allsel_cb) },
-
-       {"Edit/Advanced",               NULL, N_("A_dvanced") },
-       {"Edit/Advanced/BackChar",      NULL, N_("Move a character backward"), "<shift><control>B", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_CHARACTER*/
-       {"Edit/Advanced/ForwChar",      NULL, N_("Move a character forward"), "<shift><control>F", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_CHARACTER*/
-       {"Edit/Advanced/BackWord",      NULL, N_("Move a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_WORD*/
-       {"Edit/Advanced/ForwWord",      NULL, N_("Move a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_WORD*/
-       {"Edit/Advanced/BegLine",       NULL, N_("Move to beginning of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE*/
-       {"Edit/Advanced/EndLine",       NULL, N_("Move to end of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_END_OF_LINE*/
-       {"Edit/Advanced/PrevLine",      NULL, N_("Move to previous line"), "<control>P", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_PREVIOUS_LINE*/
-       {"Edit/Advanced/NextLine",      NULL, N_("Move to next line"), "<control>N", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_NEXT_LINE*/
-       {"Edit/Advanced/DelBackChar",   NULL, N_("Delete a character backward"), "<control>H", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_CHARACTER*/
-       {"Edit/Advanced/DelForwChar",   NULL, N_("Delete a character forward"), "<control>D", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_CHARACTER*/
-       {"Edit/Advanced/DelBackWord",   NULL, N_("Delete a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD*/
-       {"Edit/Advanced/DelForwWord",   NULL, N_("Delete a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD*/
-       {"Edit/Advanced/DelLine",       NULL, N_("Delete line"), "<control>U", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE*/
-       {"Edit/Advanced/DelEndLine",    NULL, N_("Delete to end of line"), "<control>K", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END*/
-
-       /* {"Edit/---",                 NULL, "---" }, */
-       {"Edit/Find",           NULL, N_("_Find"), "<control>F", NULL, G_CALLBACK(compose_find_cb) },
-
-       /* {"Edit/---",                 NULL, "---" }, */
-       {"Edit/WrapPara",               NULL, N_("_Wrap current paragraph"), "<control>L", NULL, G_CALLBACK(compose_wrap_cb) }, /* 0 */
-       {"Edit/WrapAllLines",           NULL, N_("Wrap all long _lines"), "<control><alt>L", NULL, G_CALLBACK(compose_wrap_all_cb) }, /* 1 */
-       /* {"Edit/---",                 NULL, "---" }, */
-       {"Edit/ExtEditor",              NULL, N_("Edit with e_xternal editor"), "<shift><control>X", NULL, G_CALLBACK(compose_ext_editor_cb) },
+       {"Edit/Undo",                     NULL, N_("_Undo"), "<control>Z", NULL, G_CALLBACK(compose_undo_cb) },
+       {"Edit/Redo",                     NULL, N_("_Redo"), "<control>Y", NULL, G_CALLBACK(compose_redo_cb) },
+       {"Edit/---",                      NULL, "---", NULL, NULL, NULL },
+
+       {"Edit/Cut",                      NULL, N_("Cu_t"), "<control>X", NULL, G_CALLBACK(compose_cut_cb) },
+       {"Edit/Copy",                     NULL, N_("_Copy"), "<control>C", NULL, G_CALLBACK(compose_copy_cb) },
+       {"Edit/Paste",                    NULL, N_("_Paste"), "<control>V", NULL, G_CALLBACK(compose_paste_cb) },
+
+       {"Edit/SpecialPaste",             NULL, N_("_Special paste"), NULL, NULL, NULL },
+       {"Edit/SpecialPaste/AsQuotation", NULL, N_("As _quotation"), NULL, NULL, G_CALLBACK(compose_paste_as_quote_cb) },
+       {"Edit/SpecialPaste/Wrapped",     NULL, N_("_Wrapped"), NULL, NULL, G_CALLBACK(compose_paste_wrap_cb) },
+       {"Edit/SpecialPaste/Unwrapped",   NULL, N_("_Unwrapped"), NULL, NULL, G_CALLBACK(compose_paste_no_wrap_cb) },
+
+       {"Edit/SelectAll",                NULL, N_("Select _all"), "<control>A", NULL, G_CALLBACK(compose_allsel_cb) },
+
+       {"Edit/Advanced",                 NULL, N_("A_dvanced"), NULL, NULL, NULL },
+       {"Edit/Advanced/BackChar",        NULL, N_("Move a character backward"), "<shift><control>B", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_CHARACTER*/
+       {"Edit/Advanced/ForwChar",        NULL, N_("Move a character forward"), "<shift><control>F", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_CHARACTER*/
+       {"Edit/Advanced/BackWord",        NULL, N_("Move a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_WORD*/
+       {"Edit/Advanced/ForwWord",        NULL, N_("Move a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_WORD*/
+       {"Edit/Advanced/BegLine",         NULL, N_("Move to beginning of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE*/
+       {"Edit/Advanced/EndLine",         NULL, N_("Move to end of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_END_OF_LINE*/
+       {"Edit/Advanced/PrevLine",        NULL, N_("Move to previous line"), "<control>P", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_PREVIOUS_LINE*/
+       {"Edit/Advanced/NextLine",        NULL, N_("Move to next line"), "<control>N", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_NEXT_LINE*/
+       {"Edit/Advanced/DelBackChar",     NULL, N_("Delete a character backward"), "<control>H", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_CHARACTER*/
+       {"Edit/Advanced/DelForwChar",     NULL, N_("Delete a character forward"), "<control>D", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_CHARACTER*/
+       {"Edit/Advanced/DelBackWord",     NULL, N_("Delete a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD*/
+       {"Edit/Advanced/DelForwWord",     NULL, N_("Delete a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD*/
+       {"Edit/Advanced/DelLine",         NULL, N_("Delete line"), "<control>U", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE*/
+       {"Edit/Advanced/DelEndLine",      NULL, N_("Delete to end of line"), "<control>K", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END*/
+
+       /* {"Edit/---",                   NULL, "---", NULL, NULL, NULL }, */
+       {"Edit/Find",                     NULL, N_("_Find"), "<control>F", NULL, G_CALLBACK(compose_find_cb) },
+
+       /* {"Edit/---",                   NULL, "---", NULL, NULL, NULL }, */
+       {"Edit/WrapPara",                 NULL, N_("_Wrap current paragraph"), "<control>L", NULL, G_CALLBACK(compose_wrap_cb) }, /* 0 */
+       {"Edit/WrapAllLines",             NULL, N_("Wrap all long _lines"), "<control><alt>L", NULL, G_CALLBACK(compose_wrap_all_cb) }, /* 1 */
+       /* {"Edit/---",                   NULL, "---", NULL, NULL, NULL }, */
+       {"Edit/ExtEditor",                NULL, N_("Edit with e_xternal editor"), "<shift><control>X", NULL, G_CALLBACK(compose_ext_editor_cb) },
 #if USE_ENCHANT
 /* Spelling menu */
-       {"Spelling/CheckAllSel",        NULL, N_("_Check all or check selection"), NULL, NULL, G_CALLBACK(compose_check_all) },
-       {"Spelling/HighlightAll",       NULL, N_("_Highlight all misspelled words"), NULL, NULL, G_CALLBACK(compose_highlight_all) },
-       {"Spelling/CheckBackwards",     NULL, N_("Check _backwards misspelled word"), NULL, NULL, G_CALLBACK(compose_check_backwards) },
-       {"Spelling/ForwardNext",        NULL, N_("_Forward to next misspelled word"), NULL, NULL, G_CALLBACK(compose_check_forwards_go) },
+       {"Spelling/CheckAllSel",          NULL, N_("_Check all or check selection"), NULL, NULL, G_CALLBACK(compose_check_all) },
+       {"Spelling/HighlightAll",         NULL, N_("_Highlight all misspelled words"), NULL, NULL, G_CALLBACK(compose_highlight_all) },
+       {"Spelling/CheckBackwards",       NULL, N_("Check _backwards misspelled word"), NULL, NULL, G_CALLBACK(compose_check_backwards) },
+       {"Spelling/ForwardNext",          NULL, N_("_Forward to next misspelled word"), NULL, NULL, G_CALLBACK(compose_check_forwards_go) },
 
-       {"Spelling/---",                NULL, "---" },
-       {"Spelling/Options",            NULL, N_("_Options") },
+       {"Spelling/---",                  NULL, "---", NULL, NULL, NULL },
+       {"Spelling/Options",              NULL, N_("_Options"), NULL, NULL, NULL },
 #endif
 
 /* Options menu */
+       {"Options/ReplyMode",                 NULL, N_("Reply _mode"), NULL, NULL, NULL },
+       {"Options/---",                       NULL, "---", NULL, NULL, NULL },
+       {"Options/PrivacySystem",             NULL, N_("Privacy _System"), NULL, NULL, NULL },
+       {"Options/PrivacySystem/PlaceHolder", NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
 
-       {"Options/ReplyMode",           NULL, N_("Reply _mode") },
-       {"Options/---",                 NULL, "---" },
-       {"Options/PrivacySystem",       NULL, N_("Privacy _System") },
-       {"Options/PrivacySystem/PlaceHolder",   NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
+       /* {"Options/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Options/Priority",              NULL, N_("_Priority"), NULL, NULL, NULL },
 
-       /* {"Options/---",              NULL, "---" }, */
-
-       {"Options/Priority",            NULL, N_("_Priority") },
-
-       {"Options/Encoding",            NULL, N_("Character _encoding") },
-       {"Options/Encoding/---",        NULL, "---" },
+       {"Options/Encoding",              NULL, N_("Character _encoding"), NULL, NULL, NULL },
+       {"Options/Encoding/---",          NULL, "---", NULL, NULL, NULL },
 #define ENC_ACTION(cs_char,c_char,string) \
-       { "Options/Encoding/" cs_char, NULL, N_(string), NULL, NULL, c_char }
-
-       {"Options/Encoding/Western",    NULL, N_("Western European") },
-       {"Options/Encoding/Baltic",     NULL, N_("Baltic") },
-       {"Options/Encoding/Hebrew",     NULL, N_("Hebrew") },
-       {"Options/Encoding/Arabic",     NULL, N_("Arabic") },
-       {"Options/Encoding/Cyrillic",   NULL, N_("Cyrillic") },
-       {"Options/Encoding/Japanese",   NULL, N_("Japanese") },
-       {"Options/Encoding/Chinese",    NULL, N_("Chinese") },
-       {"Options/Encoding/Korean",     NULL, N_("Korean") },
-       {"Options/Encoding/Thai",       NULL, N_("Thai") },
+       {"Options/Encoding/" cs_char, NULL, N_(string), NULL, NULL, c_char }
+
+       {"Options/Encoding/Western",      NULL, N_("Western European"), NULL, NULL, NULL },
+       {"Options/Encoding/Baltic",       NULL, N_("Baltic"), NULL, NULL, NULL },
+       {"Options/Encoding/Hebrew",       NULL, N_("Hebrew"), NULL, NULL, NULL },
+       {"Options/Encoding/Arabic",       NULL, N_("Arabic"), NULL, NULL, NULL },
+       {"Options/Encoding/Cyrillic",     NULL, N_("Cyrillic"), NULL, NULL, NULL },
+       {"Options/Encoding/Japanese",     NULL, N_("Japanese"), NULL, NULL, NULL },
+       {"Options/Encoding/Chinese",      NULL, N_("Chinese"), NULL, NULL, NULL },
+       {"Options/Encoding/Korean",       NULL, N_("Korean"), NULL, NULL, NULL },
+       {"Options/Encoding/Thai",         NULL, N_("Thai"), NULL, NULL, NULL },
 
 /* Tools menu */
-       {"Tools/AddressBook",           NULL, N_("_Address book"), NULL, NULL, G_CALLBACK(compose_address_cb) }, 
+       {"Tools/AddressBook",             NULL, N_("_Address book"), NULL, NULL, G_CALLBACK(compose_address_cb) }, 
 
-       {"Tools/Template",      NULL, N_("_Template") },
-       {"Tools/Template/PlaceHolder",  NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
-       {"Tools/Actions",       NULL, N_("Actio_ns") },
-       {"Tools/Actions/PlaceHolder",   NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
+       {"Tools/Template",                NULL, N_("_Template"), NULL, NULL, NULL },
+       {"Tools/Template/PlaceHolder",    NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
+       {"Tools/Actions",                 NULL, N_("Actio_ns"), NULL, NULL, NULL },
+       {"Tools/Actions/PlaceHolder",     NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
 
 /* Help menu */
-       {"Help/About",          NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_show_cb) }, 
+       {"Help/About",                    NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_show_cb) }, 
 };
 
 static GtkToggleActionEntry compose_toggle_entries[] =
 {
-       {"Edit/AutoWrap",               NULL, N_("Aut_o wrapping"), "<shift><control>L", NULL, G_CALLBACK(compose_toggle_autowrap_cb) }, /* TOGGLE */
-       {"Edit/AutoIndent",             NULL, N_("Auto _indent"), NULL, NULL, G_CALLBACK(compose_toggle_autoindent_cb) }, /* TOGGLE */
-       {"Options/Sign",                NULL, N_("Si_gn"), NULL, NULL, G_CALLBACK(compose_toggle_sign_cb) }, /* Toggle */
-       {"Options/Encrypt",             NULL, N_("_Encrypt"), NULL, NULL, G_CALLBACK(compose_toggle_encrypt_cb) }, /* Toggle */
-       {"Options/RequestRetRcpt",      NULL, N_("_Request Return Receipt"), NULL, NULL, G_CALLBACK(compose_toggle_return_receipt_cb) }, /* TOGGLE */
-       {"Options/RemoveReferences",    NULL, N_("Remo_ve references"), NULL, NULL, G_CALLBACK(compose_toggle_remove_refs_cb) }, /* TOGGLE */
-       {"Tools/ShowRuler",             NULL, N_("Show _ruler"), NULL, NULL, G_CALLBACK(compose_toggle_ruler_cb) }, /* Toggle */
+       {"Edit/AutoWrap",            NULL, N_("Aut_o wrapping"), "<shift><control>L", NULL, G_CALLBACK(compose_toggle_autowrap_cb), FALSE }, /* Toggle */
+       {"Edit/AutoIndent",          NULL, N_("Auto _indent"), NULL, NULL, G_CALLBACK(compose_toggle_autoindent_cb), FALSE }, /* Toggle */
+       {"Options/Sign",             NULL, N_("Si_gn"), NULL, NULL, G_CALLBACK(compose_toggle_sign_cb), FALSE }, /* Toggle */
+       {"Options/Encrypt",          NULL, N_("_Encrypt"), NULL, NULL, G_CALLBACK(compose_toggle_encrypt_cb), FALSE }, /* Toggle */
+       {"Options/RequestRetRcpt",   NULL, N_("_Request Return Receipt"), NULL, NULL, G_CALLBACK(compose_toggle_return_receipt_cb), FALSE }, /* Toggle */
+       {"Options/RemoveReferences", NULL, N_("Remo_ve references"), NULL, NULL, G_CALLBACK(compose_toggle_remove_refs_cb), FALSE }, /* Toggle */
+       {"Tools/ShowRuler",          NULL, N_("Show _ruler"), NULL, NULL, G_CALLBACK(compose_toggle_ruler_cb), FALSE }, /* Toggle */
 };
 
 static GtkRadioActionEntry compose_radio_rm_entries[] =
 {
-       {"Options/ReplyMode/Normal",    NULL, N_("_Normal"), NULL, NULL, COMPOSE_REPLY }, /* RADIO compose_reply_change_mode_cb */
-       {"Options/ReplyMode/All",       NULL, N_("_All"), NULL, NULL, COMPOSE_REPLY_TO_ALL }, /* RADIO compose_reply_change_mode_cb */
-       {"Options/ReplyMode/Sender",    NULL, N_("_Sender"), NULL, NULL, COMPOSE_REPLY_TO_SENDER }, /* RADIO compose_reply_change_mode_cb */
-       {"Options/ReplyMode/List",      NULL, N_("_Mailing-list"), NULL, NULL, COMPOSE_REPLY_TO_LIST }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/Normal", NULL, N_("_Normal"), NULL, NULL, COMPOSE_REPLY }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/All",    NULL, N_("_All"), NULL, NULL, COMPOSE_REPLY_TO_ALL }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/Sender", NULL, N_("_Sender"), NULL, NULL, COMPOSE_REPLY_TO_SENDER }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/List",   NULL, N_("_Mailing-list"), NULL, NULL, COMPOSE_REPLY_TO_LIST }, /* RADIO compose_reply_change_mode_cb */
 };
 
 static GtkRadioActionEntry compose_radio_prio_entries[] =
 {
-       {"Options/Priority/Highest",    NULL, N_("_Highest"), NULL, NULL, PRIORITY_HIGHEST }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/High",       NULL, N_("Hi_gh"), NULL, NULL, PRIORITY_HIGH }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/Normal",     NULL, N_("_Normal"), NULL, NULL, PRIORITY_NORMAL }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/Low",        NULL, N_("Lo_w"), NULL, NULL, PRIORITY_LOW }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/Lowest",     NULL, N_("_Lowest"), NULL, NULL, PRIORITY_LOWEST }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Highest", NULL, N_("_Highest"), NULL, NULL, PRIORITY_HIGHEST }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/High",    NULL, N_("Hi_gh"), NULL, NULL, PRIORITY_HIGH }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Normal",  NULL, N_("_Normal"), NULL, NULL, PRIORITY_NORMAL }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Low",     NULL, N_("Lo_w"), NULL, NULL, PRIORITY_LOW }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Lowest",  NULL, N_("_Lowest"), NULL, NULL, PRIORITY_LOWEST }, /* RADIO compose_set_priority_cb */
 };
 
 static GtkRadioActionEntry compose_radio_enc_entries[] =
@@ -1756,9 +1769,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
        cm_return_val_if_fail(msginfo != NULL, NULL);
        cm_return_val_if_fail(msginfo->folder != NULL, NULL);
 
-       if (!account && 
-           !(account = compose_guess_forward_account_from_msginfo
-                               (msginfo)))
+       if (!account && !(account = compose_find_account(msginfo)))
                account = cur_account;
 
        if (!prefs_common.forward_as_attachment)
@@ -1962,8 +1973,7 @@ static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_
 
        /* guess account from first selected message */
        if (!account && 
-           !(account = compose_guess_forward_account_from_msginfo
-                               (msginfo_list->data)))
+           !(account = compose_find_account(msginfo_list->data)))
                account = cur_account;
 
        cm_return_val_if_fail(account != NULL, NULL);
@@ -2643,6 +2653,7 @@ void compose_entry_append(Compose *compose, const gchar *address,
                        while (*tmp == ' ' || *tmp == '\t')
                                tmp++;
                        compose_add_header_entry(compose, header, tmp, pref_type);
+                       compose_entry_indicate(compose, tmp);
                        g_free(o_tmp);
                        continue;
                }
@@ -2655,50 +2666,26 @@ void compose_entry_append(Compose *compose, const gchar *address,
                while (*tmp == ' ' || *tmp == '\t')
                        tmp++;
                compose_add_header_entry(compose, header, tmp, pref_type);
+               compose_entry_indicate(compose, tmp);
                g_free(o_tmp);          
        }
 }
 
-static void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
+static void compose_entry_indicate(Compose *compose, const gchar *mailto)
 {
-#if !GTK_CHECK_VERSION(3, 0, 0)
-       static GdkColor yellow;
-       static GdkColor black;
-       static gboolean yellow_initialised = FALSE;
-#else
-       static GdkColor yellow = { (guint32)0, (guint16)0xf5, (guint16)0xf6, (guint16)0xbe };
-       static GdkColor black = { (guint32)0, (guint16)0x0, (guint16)0x0, (guint16)0x0 };
-#endif
        GSList *h_list;
        GtkEntry *entry;
                
-#if !GTK_CHECK_VERSION(3, 0, 0)
-       if (!yellow_initialised) {
-               gdk_color_parse("#f5f6be", &yellow);
-               gdk_color_parse("#000000", &black);
-               yellow_initialised = gdk_colormap_alloc_color(
-                       gdk_colormap_get_system(), &yellow, FALSE, TRUE);
-               yellow_initialised &= gdk_colormap_alloc_color(
-                       gdk_colormap_get_system(), &black, FALSE, TRUE);
-       }
-#endif
-
        for (h_list = compose->header_list; h_list != NULL; h_list = h_list->next) {
                entry = GTK_ENTRY(((ComposeHeaderEntry *)h_list->data)->entry);
                if (gtk_entry_get_text(entry) && 
                    !g_utf8_collate(gtk_entry_get_text(entry), mailto)) {
-#if !GTK_CHECK_VERSION(3, 0, 0)
-                       if (yellow_initialised) {
-#endif
                                gtk_widget_modify_base(
                                        GTK_WIDGET(((ComposeHeaderEntry *)h_list->data)->entry),
-                                       GTK_STATE_NORMAL, &yellow);
+                                       GTK_STATE_NORMAL, &default_header_bgcolor);
                                gtk_widget_modify_text(
                                        GTK_WIDGET(((ComposeHeaderEntry *)h_list->data)->entry),
-                                       GTK_STATE_NORMAL, &black);
-#if !GTK_CHECK_VERSION(3, 0, 0)
-                       }
-#endif
+                                       GTK_STATE_NORMAL, &default_header_color);
                }
        }
 }
@@ -2714,7 +2701,7 @@ void compose_toolbar_cb(gint action, gpointer data)
        case A_SEND:
                compose_send_cb(NULL, compose);
                break;
-       case A_SENDL:
+       case A_SEND_LATER:
                compose_send_later_cb(NULL, compose);
                break;
        case A_DRAFT:
@@ -2858,26 +2845,28 @@ static MailField compose_entries_set(Compose *compose, const gchar *mailto, Comp
 
 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
 {
-       static HeaderEntry hentry[] = {{"Reply-To:",    NULL, TRUE},
-                                      {"Cc:",          NULL, TRUE},
-                                      {"References:",  NULL, FALSE},
-                                      {"Bcc:",         NULL, TRUE},
-                                      {"Newsgroups:",  NULL, TRUE},
-                                      {"Followup-To:", NULL, TRUE},
-                                      {"List-Post:",   NULL, FALSE},
-                                      {"X-Priority:",  NULL, FALSE},
-                                      {NULL,           NULL, FALSE}};
+       static HeaderEntry hentry[] = {
+                                      {"Reply-To:",    NULL, TRUE },
+                                      {"Cc:",          NULL, TRUE },
+                                      {"References:",  NULL, FALSE },
+                                      {"Bcc:",         NULL, TRUE },
+                                      {"Newsgroups:",  NULL, TRUE },
+                                      {"Followup-To:", NULL, TRUE },
+                                      {"List-Post:",   NULL, FALSE },
+                                      {"X-Priority:",  NULL, FALSE },
+                                      {NULL,           NULL, FALSE }
+       };
 
        enum
        {
-               H_REPLY_TO      = 0,
-               H_CC            = 1,
-               H_REFERENCES    = 2,
-               H_BCC           = 3,
-               H_NEWSGROUPS    = 4,
-               H_FOLLOWUP_TO   = 5,
-               H_LIST_POST     = 6,
-               H_X_PRIORITY    = 7
+               H_REPLY_TO    = 0,
+               H_CC          = 1,
+               H_REFERENCES  = 2,
+               H_BCC         = 3,
+               H_NEWSGROUPS  = 4,
+               H_FOLLOWUP_TO = 5,
+               H_LIST_POST   = 6,
+               H_X_PRIORITY  = 7
        };
 
        FILE *fp;
@@ -2971,27 +2960,29 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
        if (compose->mode == COMPOSE_REEDIT) {
                if (msginfo->inreplyto && *msginfo->inreplyto)
                        compose->inreplyto = g_strdup(msginfo->inreplyto);
-               return 0;
-       }
 
-       if (msginfo->msgid && *msginfo->msgid)
-               compose->inreplyto = g_strdup(msginfo->msgid);
-
-       if (!compose->references) {
-               if (msginfo->msgid && *msginfo->msgid) {
-                       if (msginfo->inreplyto && *msginfo->inreplyto)
-                               compose->references =
-                                       g_strdup_printf("<%s>\n\t<%s>",
-                                                       msginfo->inreplyto,
-                                                       msginfo->msgid);
-                       else
+               if (msginfo->msgid && *msginfo->msgid)
+                       compose->msgid = g_strdup(msginfo->msgid);
+       } else {
+               if (msginfo->msgid && *msginfo->msgid)
+                       compose->inreplyto = g_strdup(msginfo->msgid);
+
+               if (!compose->references) {
+                       if (msginfo->msgid && *msginfo->msgid) {
+                               if (msginfo->inreplyto && *msginfo->inreplyto)
+                                       compose->references =
+                                               g_strdup_printf("<%s>\n\t<%s>",
+                                                               msginfo->inreplyto,
+                                                               msginfo->msgid);
+                               else
+                                       compose->references =
+                                               g_strconcat("<", msginfo->msgid, ">",
+                                                           NULL);
+                       } else if (msginfo->inreplyto && *msginfo->inreplyto) {
                                compose->references =
-                                       g_strconcat("<", msginfo->msgid, ">",
+                                       g_strconcat("<", msginfo->inreplyto, ">",
                                                    NULL);
-               } else if (msginfo->inreplyto && *msginfo->inreplyto) {
-                       compose->references =
-                               g_strconcat("<", msginfo->inreplyto, ">",
-                                           NULL);
+                       }
                }
        }
 
@@ -3244,17 +3235,23 @@ static void compose_set_folder_prefs(Compose *compose, FolderItem *folder,
        if (respect_default_to && folder->prefs->enable_default_to) {
                compose_entry_append(compose, folder->prefs->default_to,
                                        COMPOSE_TO, PREF_FOLDER);
-               compose_entry_mark_default_to(compose, folder->prefs->default_to);
+               compose_entry_indicate(compose, folder->prefs->default_to);
        }
-       if (folder->prefs->enable_default_cc)
+       if (folder->prefs->enable_default_cc) {
                compose_entry_append(compose, folder->prefs->default_cc,
                                        COMPOSE_CC, PREF_FOLDER);
-       if (folder->prefs->enable_default_bcc)
+               compose_entry_indicate(compose, folder->prefs->default_cc);
+       }
+       if (folder->prefs->enable_default_bcc) {
                compose_entry_append(compose, folder->prefs->default_bcc,
                                        COMPOSE_BCC, PREF_FOLDER);
-       if (folder->prefs->enable_default_replyto)
+               compose_entry_indicate(compose, folder->prefs->default_bcc);
+       }
+       if (folder->prefs->enable_default_replyto) {
                compose_entry_append(compose, folder->prefs->default_replyto,
                                        COMPOSE_REPLYTO, PREF_FOLDER);
+               compose_entry_indicate(compose, folder->prefs->default_replyto);
+       }
 }
 
 static void compose_reply_set_subject(Compose *compose, MsgInfo *msginfo)
@@ -3333,7 +3330,7 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
                        compose_entry_append(compose,
                            msginfo->folder->prefs->default_reply_to,
                            COMPOSE_TO, PREF_FOLDER);
-                       compose_entry_mark_default_to(compose,
+                       compose_entry_indicate(compose,
                                msginfo->folder->prefs->default_reply_to);
                } else {
                        gchar *tmp1 = NULL;
@@ -4236,7 +4233,7 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                can_break = TRUE;
        }
 
-//     debug_print("compose_get_line_break_pos(): do_break = %d, pos = %d, col = %d\n", do_break, pos, col);
+/*     debug_print("compose_get_line_break_pos(): do_break = %d, pos = %d, col = %d\n", do_break, pos, col); */
 
        g_free(attrs);
        g_free(str);
@@ -4482,7 +4479,7 @@ static gboolean compose_beautify_paragraph(Compose *compose, GtkTextIter *par_it
                quote_str = compose_get_quote_str(buffer, &iter, &quote_len);
 
                if (quote_str) {
-//                     debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str);
+/*                     debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str); */
                        if (startq_offset == -1) 
                                startq_offset = gtk_text_iter_get_offset(&iter);
                        quotelevel = get_quote_level(quote_str, prefs_common.quote_chars);
@@ -4728,11 +4725,11 @@ colorize:
                        }
                }
                if (!modified) {
-//                     debug_print("not modified, out after %d lines\n", lines);
+/*                     debug_print("not modified, out after %d lines\n", lines); */
                        goto end;
                }
        }
-//     debug_print("modified, out after %d lines\n", lines);
+/*     debug_print("modified, out after %d lines\n", lines); */
 end:
        g_free(itemized_chars);
        if (par_iter)
@@ -5036,12 +5033,16 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                }
                if (!found_other) {
                        AlertValue aval;
+                       gchar *text;
                        if (compose->batch) {
                                gtk_widget_show_all(compose->window);
                        }
+                       text = g_strdup_printf(_("The only recipient is the default '%s' address. Send anyway?"),
+                                          prefs_common_translated_header_name("Cc"));
                        aval = alertpanel(_("Send"),
-                                         _("The only recipient is the default CC address. Send anyway?"),
+                                         text,
                                          GTK_STOCK_CANCEL, g_strconcat("+", _("_Send"), NULL), NULL);
+                       g_free(text);
                        if (aval != G_ALERTALTERNATE)
                                return FALSE;
                }
@@ -5061,6 +5062,7 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                        ||  strcmp(header, prefs_common_translated_header_name("Bcc:"))) {
                                found_other = TRUE;
                                g_free(entry);
+                               g_free(header);
                                break;
                        }
                        g_free(entry);
@@ -5068,12 +5070,16 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                }
                if (!found_other) {
                        AlertValue aval;
+                       gchar *text;
                        if (compose->batch) {
                                gtk_widget_show_all(compose->window);
                        }
+                       text = g_strdup_printf(_("The only recipient is the default '%s' address. Send anyway?"),
+                                          prefs_common_translated_header_name("Bcc"));
                        aval = alertpanel(_("Send"),
-                                         _("The only recipient is the default BCC address. Send anyway?"),
+                                         text,
                                          GTK_STOCK_CANCEL, g_strconcat("+", _("_Send"), NULL), NULL);
+                       g_free(text);
                        if (aval != G_ALERTALTERNATE)
                                return FALSE;
                }
@@ -5382,7 +5388,10 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
        cm_return_val_if_fail(compose->account->address != NULL, -1);
 
        /* Resent-Date */
-       get_rfc822_date(buf, sizeof(buf));
+       if (prefs_common.hide_timezone)
+               get_rfc822_date_hide_tz(buf, sizeof(buf));
+       else
+               get_rfc822_date(buf, sizeof(buf));
        err |= (fprintf(fp, "Resent-Date: %s\n", buf) < 0);
 
        /* Resent-From */
@@ -5408,27 +5417,12 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
        }
 
        /* Resent-Message-ID */
-       if (compose->account->set_domain && compose->account->domain) {
-               g_snprintf(buf, sizeof(buf), "%s", compose->account->domain); 
-       } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
-               g_snprintf(buf, sizeof(buf), "%s", 
-                       strchr(compose->account->address, '@') ?
-                               strchr(compose->account->address, '@')+1 :
-                               compose->account->address);
-       } else {
-               g_snprintf(buf, sizeof(buf), "%s", "");
-       }
-
        if (compose->account->gen_msgid) {
-               gchar *addr = NULL;
-               if (compose->account->msgid_with_addr) {
-                       addr = compose->account->address;
-               }
-               generate_msgid(buf, sizeof(buf), addr);
-               err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
+               gchar *addr = prefs_account_generate_msgid(compose->account);
+               err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", addr) < 0);
                if (compose->msgid)
                        g_free(compose->msgid);
-               compose->msgid = g_strdup(buf);
+               compose->msgid = addr;
        } else {
                compose->msgid = NULL;
        }
@@ -5546,9 +5540,17 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        gchar *from_name = NULL;
        FolderItem *outbox;
 
-       if (action == COMPOSE_WRITE_FOR_SEND)
+       if (action == COMPOSE_WRITE_FOR_SEND) {
                attach_parts = TRUE;
 
+               /* We're sending the message, generate a Message-ID
+                * if necessary. */
+               if (compose->msgid == NULL &&
+                               compose->account->gen_msgid) {
+                       compose->msgid = prefs_account_generate_msgid(compose->account);
+               }
+       }
+
        /* create message MimeInfo */
        mimemsg = procmime_mimeinfo_new();
         mimemsg->type = MIMETYPE_MESSAGE;
@@ -5650,7 +5652,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        }
        g_free(chars);
 
-       if (encoding == ENC_8BIT || encoding == ENC_7BIT) {
+       if (prefs_common.rewrite_first_from && (encoding == ENC_8BIT || encoding == ENC_7BIT)) {
                if (!strncmp(buf, "From ", sizeof("From ")-1) ||
                    strstr(buf, "\nFrom ") != NULL) {
                        encoding = ENC_QUOTED_PRINTABLE;
@@ -5673,8 +5675,12 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
            privacy_system_can_sign(compose->privacy_system)) {
                encoding = ENC_QUOTED_PRINTABLE;
        }
-       
+
+#ifdef G_OS_WIN32
+       debug_print("main text: %Id bytes encoded as %s in %d\n",
+#else
        debug_print("main text: %zd bytes encoded as %s in %d\n",
+#endif
                strlen(buf), out_codeset, encoding);
 
        /* check for line length limit */
@@ -6459,7 +6465,10 @@ static gchar *compose_get_header(Compose *compose)
        header = g_string_sized_new(64);
 
        /* Date */
-       get_rfc822_date(buf, sizeof(buf));
+       if (prefs_common.hide_timezone)
+               get_rfc822_date_hide_tz(buf, sizeof(buf));
+       else
+               get_rfc822_date(buf, sizeof(buf));
        g_string_append_printf(header, "Date: %s\n", buf);
 
        /* From */
@@ -6555,29 +6564,9 @@ static gchar *compose_get_header(Compose *compose)
        g_free(str);
 
        /* Message-ID */
-       if (compose->account->set_domain && compose->account->domain) {
-               g_snprintf(buf, sizeof(buf), "%s", compose->account->domain); 
-       } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
-               g_snprintf(buf, sizeof(buf), "%s", 
-                       strchr(compose->account->address, '@') ?
-                               strchr(compose->account->address, '@')+1 :
-                               compose->account->address);
-       } else {
-               g_snprintf(buf, sizeof(buf), "%s", "");
-       }
-       
-       if (compose->account->gen_msgid) {
-               gchar *addr = NULL;
-               if (compose->account->msgid_with_addr) {
-                       addr = compose->account->address;
-               }
-               generate_msgid(buf, sizeof(buf), addr);
-               g_string_append_printf(header, "Message-ID: <%s>\n", buf);
-               if (compose->msgid)
-                       g_free(compose->msgid);
-               compose->msgid = g_strdup(buf);
-       } else {
-               compose->msgid = NULL;
+       if (compose->msgid != NULL && strlen(compose->msgid) > 0) {
+               g_string_append_printf(header, "Message-ID: <%s>\n",
+                               compose->msgid);
        }
 
        if (compose->remove_references == FALSE) {
@@ -7524,6 +7513,11 @@ static Compose *compose_create(PrefsAccount *account,
 
        cm_return_val_if_fail(account != NULL, NULL);
 
+       gtkut_convert_int_to_gdk_color(prefs_common.default_header_bgcolor,
+                                          &default_header_bgcolor);
+       gtkut_convert_int_to_gdk_color(prefs_common.default_header_color,
+                                          &default_header_color);
+
        debug_print("Creating compose window...\n");
        compose = g_new0(Compose, 1);
 
@@ -8170,6 +8164,14 @@ static GtkWidget *compose_account_option_menu_create(Compose *compose)
                                                       ac->address);
                                gtk_entry_set_text(GTK_ENTRY(from_name), from);
                        }
+                       if (cur_account != compose->account) {
+                               gtk_widget_modify_base(
+                                       GTK_WIDGET(from_name),
+                                       GTK_STATE_NORMAL, &default_header_bgcolor);
+                               gtk_widget_modify_text(
+                                       GTK_WIDGET(from_name),
+                                       GTK_STATE_NORMAL, &default_header_color);
+                       }
                }
                COMBOBOX_ADD(menu, name, ac->account_id);
                g_free(name);
@@ -8661,6 +8663,20 @@ static void compose_template_apply(Compose *compose, Template *tmpl,
 #endif
 }
 
+static void compose_template_apply_fields_error(const gchar *header)
+{
+       gchar *tr;
+       gchar *text;
+
+       tr = g_strdup(C_("'%s' stands for a header name",
+                                 "Template '%s' format error."));
+       text = g_strdup_printf(tr, prefs_common_translated_header_name(header));
+       alertpanel_error(text);
+
+       g_free(text);
+       g_free(tr);
+}
+
 static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 {
        MsgInfo* dummyinfo = NULL;
@@ -8688,7 +8704,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template From format error."));
+                       compose_template_apply_fields_error("From");
                } else {
                        gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
                }
@@ -8706,7 +8722,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template To format error."));
+                       compose_template_apply_fields_error("To");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_TO, PREF_TEMPLATE);
                }
@@ -8724,7 +8740,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template Cc format error."));
+                       compose_template_apply_fields_error("Cc");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_CC, PREF_TEMPLATE);
                }
@@ -8742,7 +8758,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template Bcc format error."));
+                       compose_template_apply_fields_error("Bcc");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_BCC, PREF_TEMPLATE);
                }
@@ -8760,7 +8776,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template Reply-To format error."));
+                       compose_template_apply_fields_error("Reply-To");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_REPLYTO, PREF_TEMPLATE);
                }
@@ -8779,7 +8795,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template subject format error."));
+                       compose_template_apply_fields_error("Subject");
                } else {
                        gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
                }
@@ -9379,6 +9395,14 @@ static void compose_exec_ext_editor(Compose *compose)
 #endif /* G_OS_UNIX */
 }
 
+static gboolean compose_can_autosave(Compose *compose)
+{
+       if (compose->privacy_system && compose->use_encryption)
+               return prefs_common.autosave && prefs_common.autosave_encrypted;
+       else
+               return prefs_common.autosave;
+}
+
 #ifdef G_OS_UNIX
 static gboolean compose_get_ext_editor_cmd_valid()
 {
@@ -9529,7 +9553,10 @@ static gboolean compose_input_cb(GIOChannel *source, GIOCondition condition,
                gtk_text_buffer_set_text(buffer, "", -1);
                compose_insert_file(compose, compose->exteditor_file);
                compose_changed_cb(NULL, compose);
-               compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
+
+               /* Check if we should save the draft or not */
+               if (compose_can_autosave(compose))
+                 compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
 
                if (claws_unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
@@ -9759,13 +9786,6 @@ static void account_activated(GtkComboBox *optmenu, gpointer data)
        GtkTreeIter iter;
        GSList *list, *saved_list = NULL;
        HeaderEntryState *state;
-       GtkRcStyle *style = NULL;
-#if !GTK_CHECK_VERSION(3, 0, 0)
-       static GdkColor yellow;
-       static gboolean color_set = FALSE;
-#else
-       static GdkColor yellow = { (guint32)0, (guint32)0xf5, (guint32)0xf6, (guint32)0xbe };
-#endif
 
        /* Get ID of active account in the combo box */
        menu = gtk_combo_box_get_model(optmenu);
@@ -9785,26 +9805,12 @@ static void account_activated(GtkComboBox *optmenu, gpointer data)
                                compose_destroy_headerentry(compose, hentry);
                                continue;
                        }
-                       
                        state = g_malloc0(sizeof(HeaderEntryState));
                        state->header = gtk_editable_get_chars(GTK_EDITABLE(
                                        gtk_bin_get_child(GTK_BIN(hentry->combo))), 0, -1);
                        state->entry = gtk_editable_get_chars(
                                        GTK_EDITABLE(hentry->entry), 0, -1);
                        state->type = hentry->type;
-                               
-#if !GTK_CHECK_VERSION(3, 0, 0)
-                       if (!color_set) {
-                               gdk_color_parse("#f5f6be", &yellow);
-                               color_set = gdk_colormap_alloc_color(
-                                                       gdk_colormap_get_system(),
-                                                       &yellow, FALSE, TRUE);
-                       }
-#endif
-                               
-                       style = gtk_widget_get_modifier_style(hentry->entry);
-                       state->entry_marked = gdk_color_equal(&yellow,
-                                               &style->base[GTK_STATE_NORMAL]);
 
                        saved_list = g_slist_append(saved_list, state);
                        compose_destroy_headerentry(compose, hentry);
@@ -9819,29 +9825,25 @@ static void account_activated(GtkComboBox *optmenu, gpointer data)
                if (ac->set_autocc && ac->auto_cc)
                        compose_entry_append(compose, ac->auto_cc,
                                                COMPOSE_CC, PREF_ACCOUNT);
-
-               if (ac->set_autobcc && ac->auto_bcc) 
+               if (ac->set_autobcc && ac->auto_bcc)
                        compose_entry_append(compose, ac->auto_bcc,
                                                COMPOSE_BCC, PREF_ACCOUNT);
-       
                if (ac->set_autoreplyto && ac->auto_replyto)
                        compose_entry_append(compose, ac->auto_replyto,
                                                COMPOSE_REPLYTO, PREF_ACCOUNT);
                
                for (list = saved_list; list; list = list->next) {
                        state = (HeaderEntryState *) list->data;
-                       
+
                        compose_add_header_entry(compose, state->header,
                                                state->entry, state->type);
-                       if (state->entry_marked)
-                               compose_entry_mark_default_to(compose, state->entry);
-                       
-                       g_free(state->header);  
+
+                       g_free(state->header);
                        g_free(state->entry);
                        g_free(state);
                }
                g_slist_free(saved_list);
-               
+
                combobox_select_by_data(GTK_COMBO_BOX(compose->header_last->combo),
                                        (ac->protocol == A_NNTP) ? 
                                        COMPOSE_NEWSGROUPS : COMPOSE_TO);
@@ -10329,7 +10331,7 @@ static void compose_attach_cb(GtkAction *action, gpointer data)
         * which unsets it (via focus_out_event callback on compose window). */
        manage_window_focus_in(compose->window, NULL, NULL);
 
-       file_list = filesel_select_multiple_files_open(_("Select file"));
+       file_list = filesel_select_multiple_files_open(_("Select file"), NULL);
 
        if (file_list) {
                compose_attach_from_list(compose, file_list, TRUE);
@@ -10343,7 +10345,7 @@ static void compose_insert_file_cb(GtkAction *action, gpointer data)
        GList *file_list;
        gint files_inserted = 0;
 
-       file_list = filesel_select_multiple_files_open(_("Select file"));
+       file_list = filesel_select_multiple_files_open(_("Select file"), NULL);
 
        if (file_list) {
                GList *tmp;
@@ -10415,14 +10417,6 @@ void compose_close_toolbar(Compose *compose)
        compose_close_cb(NULL, compose);
 }
 
-static gboolean compose_can_autosave(Compose *compose)
-{
-       if (compose->privacy_system && compose->use_encryption)
-               return prefs_common.autosave && prefs_common.autosave_encrypted;
-       else
-               return prefs_common.autosave;
-}
-
 static void compose_close_cb(GtkAction *action, gpointer data)
 {
        Compose *compose = (Compose *)data;
@@ -10539,6 +10533,12 @@ static void compose_ext_editor_cb(GtkAction *action, gpointer data)
 {
        Compose *compose = (Compose *)data;
 
+#ifdef G_OS_UNIX
+       if (compose->exteditor_tag != -1) {
+               debug_print("ignoring open external editor: external editor still open\n");
+               return;
+       }
+#endif
        compose_exec_ext_editor(compose);
 }
 
@@ -11061,14 +11061,14 @@ static ComposeCallAdvancedAction compose_call_advanced_action_from_path(GtkActio
        DO_ACTION("Edit/Advanced/DelForwWord", COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD);
        DO_ACTION("Edit/Advanced/DelLine", COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE);
        DO_ACTION("Edit/Advanced/DelEndLine", COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END);
-       return -1;
+       return COMPOSE_CALL_ADVANCED_ACTION_UNDEFINED;
 }
 
 static void compose_advanced_action_cb(GtkAction *gaction, gpointer data)
 {
        Compose *compose = (Compose *)data;
        GtkTextView *text = GTK_TEXT_VIEW(compose->text);
-       ComposeCallAdvancedAction action = -1;
+       ComposeCallAdvancedAction action = COMPOSE_CALL_ADVANCED_ACTION_UNDEFINED;
        
        action = compose_call_advanced_action_from_path(gaction);
 
@@ -11187,7 +11187,7 @@ static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
 static void compose_changed_cb(GtkTextBuffer *textbuf, Compose *compose)
 {
        compose->modified = TRUE;
-//     compose_beautify_paragraph(compose, NULL, TRUE);
+/*     compose_beautify_paragraph(compose, NULL, TRUE); */
 #ifndef GENERIC_UMPC
        compose_set_title(compose);
 #endif
@@ -11360,6 +11360,8 @@ static void compose_insert_drag_received_cb (GtkWidget          *widget,
        Compose *compose = (Compose *)user_data;
        GList *list, *tmp;
        GdkAtom type;
+       guint num_files;
+       gchar *msg;
 
        /* strangely, testing data->type == gdk_atom_intern("text/uri-list", TRUE)
         * does not work */
@@ -11369,6 +11371,7 @@ static void compose_insert_drag_received_cb (GtkWidget          *widget,
                const gchar* ddata = (const gchar *)gtk_selection_data_get_data(data);
 
                list = uri_list_extract_filenames(ddata);
+               num_files = g_list_length(list);
                if (list == NULL && strstr(ddata, "://")) {
                        /* Assume a list of no files, and data has ://, is a remote link */
                        gchar *tmpdata = g_strstrip(g_strdup(ddata));
@@ -11384,11 +11387,18 @@ static void compose_insert_drag_received_cb (GtkWidget                *widget,
                }
                switch (prefs_common.compose_dnd_mode) {
                        case COMPOSE_DND_ASK:
-                               val = alertpanel_full(_("Insert or attach?"),
-                                        _("Do you want to insert the contents of the file(s) "
-                                          "into the message body, or attach it to the email?"),
+                               msg = g_strdup_printf(
+                                               ngettext(
+                                                       "Do you want to insert the contents of the file "
+                                                       "into the message body, or attach it to the email?",
+                                                       "Do you want to insert the contents of the %d files "
+                                                       "into the message body, or attach them to the email?",
+                                                       num_files),
+                                               num_files);
+                               val = alertpanel_full(_("Insert or attach?"), msg,
                                          GTK_STOCK_CANCEL, g_strconcat("+", _("_Insert"), NULL), _("_Attach"),
                                          TRUE, NULL, ALERT_QUESTION, G_ALERTALTERNATE);
+                               g_free(msg);
                                break;
                        case COMPOSE_DND_INSERT:
                                val = G_ALERTALTERNATE;
@@ -11736,7 +11746,7 @@ static void compose_check_forwards_go(GtkAction *action, gpointer data)
  *\brief       Guess originating forward account from MsgInfo and several 
  *             "common preference" settings. Return NULL if no guess. 
  */
-static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo)
+static PrefsAccount *compose_find_account(MsgInfo *msginfo)
 {
        PrefsAccount *account = NULL;
        
@@ -11747,9 +11757,6 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo
        if (msginfo->folder->prefs->enable_default_account)
                account = account_find_from_id(msginfo->folder->prefs->default_account);
                
-       if (!account) 
-               account = msginfo->folder->folder->account;
-               
        if (!account && msginfo->to && prefs_common.forward_account_autosel) {
                gchar *to;
                Xstrdup_a(to, msginfo->to, return NULL);
@@ -11776,6 +11783,9 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo
                        account = account_find_from_address(buf, FALSE);
                 }
        }
+
+       if (!account)
+               account = msginfo->folder->folder->account;
        
        return account;
 }