0.8.8claws71
[claws.git] / src / compose.c
index 2434118b589a2b4a0dd74311801875e2f8314b49..da487c138b54aa24266e201b94a2df17cc177d68 100644 (file)
 #include "template.h"
 #include "undo.h"
 #include "foldersel.h"
+#include "toolbar.h"
 
 #if USE_GPGME
 #  include "rfc2015.h"
@@ -158,12 +159,12 @@ static GList *compose_list = NULL;
 
 Compose *compose_generic_new                   (PrefsAccount   *account,
                                                 const gchar    *to,
-                                                FolderItem     *item);
+                                                FolderItem     *item,
+                                                GPtrArray      *attach_files);
 
 static Compose *compose_create                 (PrefsAccount   *account,
                                                 ComposeMode     mode);
-static void compose_toolbar_create             (Compose        *compose,
-                                                GtkWidget      *container);
+
 static GtkWidget *compose_account_option_menu_create
                                                (Compose        *compose);
 static void compose_set_template_menu          (Compose        *compose);
@@ -188,6 +189,7 @@ static gchar *compose_quote_fmt                     (Compose        *compose,
 static void compose_reply_set_entry            (Compose        *compose,
                                                 MsgInfo        *msginfo,
                                                 gboolean        to_all,
+                                                gboolean        to_ml,
                                                 gboolean        to_sender,
                                                 gboolean
                                                 followup_and_reply_to);
@@ -204,7 +206,11 @@ static void compose_attach_parts           (Compose        *compose,
                                                 MsgInfo        *msginfo);
 static void compose_wrap_line                  (Compose        *compose);
 static void compose_wrap_line_all              (Compose        *compose);
+static void compose_wrap_line_all_full         (Compose        *compose,
+                                                gboolean        autowrap);
 static void compose_set_title                  (Compose        *compose);
+static void compose_select_account             (Compose        *compose,
+                                                PrefsAccount   *account);
 
 static PrefsAccount *compose_current_mail_account(void);
 /* static gint compose_send                    (Compose        *compose); */
@@ -218,6 +224,7 @@ static gint compose_write_to_file           (Compose        *compose,
 static gint compose_write_body_to_file         (Compose        *compose,
                                                 const gchar    *file);
 static gint compose_remove_reedit_target       (Compose        *compose);
+void compose_remove_draft                      (Compose        *compose);
 static gint compose_queue                      (Compose        *compose,
                                                 gint           *msgnum,
                                                 FolderItem     **item);
@@ -284,32 +291,8 @@ static void compose_update_priority_menu_item(Compose * compose);
 static gboolean compose_edit_size_alloc (GtkEditable   *widget,
                                         GtkAllocation  *allocation,
                                         GtkSHRuler     *shruler);
-
-static void toolbar_send_cb            (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_send_later_cb      (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_draft_cb           (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_insert_cb          (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_attach_cb          (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_sig_cb             (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_ext_editor_cb      (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_linewrap_cb                (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_address_cb         (GtkWidget      *widget,
-                                        gpointer        data);
-
-static void select_account             (Compose        *compose,
-                                        PrefsAccount   *ac);
-
 static void account_activated          (GtkMenuItem    *menuitem,
                                         gpointer        data);
-
 static void attach_selected            (GtkCList       *clist,
                                         gint            row,
                                         gint            column,
@@ -415,6 +398,12 @@ static void compose_toggle_sign_cb (gpointer        data,
 static void compose_toggle_encrypt_cb  (gpointer        data,
                                         guint           action,
                                         GtkWidget      *widget);
+static void compose_set_gnupg_mode_cb  (gpointer        data,
+                                        guint           action,
+                                        GtkWidget      *widget);
+static void compose_update_gnupg_mode_menu_item(Compose * compose);
+static void activate_gnupg_mode        (Compose *compose, 
+                                        PrefsAccount *account);
 #endif
 static void compose_toggle_return_receipt_cb(gpointer data, guint action,
                                             GtkWidget *widget);
@@ -464,7 +453,7 @@ static void text_inserted           (GtkWidget      *widget,
                                         gint           *position,
                                         Compose        *compose);
 static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
-                                 gboolean to_all,
+                                 gboolean to_all, gboolean to_ml,
                                  gboolean ignore_replyto,
                                  gboolean followup_and_reply_to,
                                  const gchar *body);
@@ -477,7 +466,7 @@ void compose_headerentry_key_press_event_cb(GtkWidget              *entry,
 
 static void compose_show_first_last_header (Compose *compose, gboolean show_first);
 
-#if USE_PSPELL
+#if USE_ASPELL
 static void compose_check_all             (Compose *compose);
 static void compose_highlight_all         (Compose *compose);
 static void compose_check_backwards       (Compose *compose);
@@ -596,7 +585,7 @@ static GtkItemFactoryEntry compose_entries[] =
                                        "<control><alt>L", compose_wrap_line_all, 0, NULL},
        {N_("/_Edit/Edit with e_xternal editor"),
                                        "<shift><control>X", compose_ext_editor_cb, 0, NULL},
-#if USE_PSPELL
+#if USE_ASPELL
        {N_("/_Spelling"),              NULL, NULL, 0, "<Branch>"},
        {N_("/_Spelling/_Check all or check selection"),
                                        NULL, compose_check_all, 0, NULL},
@@ -648,6 +637,8 @@ static GtkItemFactoryEntry compose_entries[] =
        {N_("/_Message/---"),           NULL, NULL, 0, "<Separator>"},
        {N_("/_Message/Si_gn"),         NULL, compose_toggle_sign_cb   , 0, "<ToggleItem>"},
        {N_("/_Message/_Encrypt"),      NULL, compose_toggle_encrypt_cb, 0, "<ToggleItem>"},
+       {N_("/_Message/Mode/MIME"),             NULL, compose_set_gnupg_mode_cb,   GNUPG_MODE_DETACH, "<RadioItem>"},   
+       {N_("/_Message/Mode/Inline"),   NULL, compose_set_gnupg_mode_cb,   GNUPG_MODE_INLINE, "/Message/Mode/MIME"},    
 #endif /* USE_GPGME */
        {N_("/_Message/---"),           NULL,           NULL,   0, "<Separator>"},
        {N_("/_Message/_Priority"),     NULL,           NULL,   0, "<Branch>"},
@@ -672,74 +663,19 @@ static GtkTargetEntry compose_mime_types[] =
        {"text/uri-list", 0, 0}
 };
 
-Compose *compose_new(PrefsAccount *account)
+Compose *compose_new(PrefsAccount *account, const gchar *mailto,
+                    GPtrArray *attach_files)
 {
-       return compose_generic_new(account, NULL, NULL);
-}
-
-Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
-{
-       Compose *c;
-       gchar *filename;
-       GtkItemFactory *ifactory;
-       
-       c = compose_generic_new(account, NULL, NULL);
-
-       filename = procmsg_get_message_file(msginfo);
-       if (filename == NULL)
-               return NULL;
-
-       c->redirect_filename = filename;
-
-       if (msginfo->subject)
-               gtk_entry_set_text(GTK_ENTRY(c->subject_entry),
-                                  msginfo->subject);
-       gtk_editable_set_editable(GTK_EDITABLE(c->subject_entry), FALSE);
-
-       compose_quote_fmt(c, msginfo, "%M", NULL, NULL);
-       gtk_editable_set_editable(GTK_EDITABLE(c->text), FALSE);
-
-       ifactory = gtk_item_factory_from_widget(c->popupmenu);
-       menu_set_sensitive(ifactory, "/Add...", FALSE);
-       menu_set_sensitive(ifactory, "/Remove", FALSE);
-       menu_set_sensitive(ifactory, "/Property...", FALSE);
-
-       ifactory = gtk_item_factory_from_widget(c->menubar);
-       menu_set_sensitive(ifactory, "/File/Insert file", FALSE);
-       menu_set_sensitive(ifactory, "/File/Attach file", FALSE);
-       menu_set_sensitive(ifactory, "/File/Insert signature", FALSE);
-       menu_set_sensitive(ifactory, "/Edit/Paste", FALSE);
-       menu_set_sensitive(ifactory, "/Edit/Wrap current paragraph", FALSE);
-       menu_set_sensitive(ifactory, "/Edit/Wrap all long lines", FALSE);
-       menu_set_sensitive(ifactory, "/Edit/Edit with external editor", FALSE);
-       menu_set_sensitive(ifactory, "/Message/Attach", FALSE);
-#if USE_GPGME
-       menu_set_sensitive(ifactory, "/Message/Sign", FALSE);
-       menu_set_sensitive(ifactory, "/Message/Encrypt", FALSE);
-#endif
-       menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
-       menu_set_sensitive(ifactory, "/Tools/Template", FALSE);
-       
-       gtk_widget_set_sensitive(c->insert_btn, FALSE);
-       gtk_widget_set_sensitive(c->attach_btn, FALSE);
-       gtk_widget_set_sensitive(c->sig_btn, FALSE);
-       gtk_widget_set_sensitive(c->exteditor_btn, FALSE);
-       gtk_widget_set_sensitive(c->linewrap_btn, FALSE);
-
-       return c;
-}
-
-Compose *compose_new_with_recipient(PrefsAccount *account, const gchar *mailto)
-{
-       return compose_generic_new(account, mailto, NULL);
+       return compose_generic_new(account, mailto, NULL, attach_files);
 }
 
 Compose *compose_new_with_folderitem(PrefsAccount *account, FolderItem *item)
 {
-       return compose_generic_new(account, NULL, item);
+       return compose_generic_new(account, NULL, item, NULL);
 }
 
-Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item)
+Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
+                            GPtrArray *attach_files)
 {
        Compose *compose;
        GtkSText *text;
@@ -767,16 +703,11 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
        gtk_stext_thaw(text);
 
-       /* workaround for initial XIM problem */
-       gtk_widget_grab_focus(compose->text);
-       gtkut_widget_wait_for_draw(compose->text);
-
-
        if (account->protocol != A_NNTP) {
-               if (mailto) {
+               if (mailto && *mailto != '\0') {
                        compose_entries_set(compose, mailto);
 
-               } else if(item && item->prefs->enable_default_to) {
+               } else if (item && item->prefs->enable_default_to) {
                        compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
                        compose_entry_select(compose, item->prefs->default_to);
                        grab_focus_on_last = FALSE;
@@ -794,10 +725,21 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                 */
                menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE); 
        }
+
+       if (attach_files) {
+               gint i;
+               gchar *file;
+
+               for (i = 0; i < attach_files->len; i++) {
+                       file = g_ptr_array_index(attach_files, i);
+                       compose_attach_append(compose, file, file, NULL);
+               }
+       }
+
        compose_show_first_last_header(compose, TRUE);
 
        /* Set save folder */
-       if(item && item->prefs && item->prefs->save_copy_to_folder) {
+       if (item && item->prefs && item->prefs->save_copy_to_folder) {
                gchar *folderidentifier;
 
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), prefs_common.savemsg);
@@ -807,7 +749,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        }
        
        /* Grab focus on last header only if no default_to was set */
-       if(grab_focus_on_last)
+       if (grab_focus_on_last)
                gtk_widget_grab_focus(compose->header_last->entry);
 
        if (prefs_common.auto_exteditor)
@@ -816,14 +758,6 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
         return compose;
 }
 
-#define CHANGE_FLAGS(msginfo) \
-{ \
-if (msginfo->folder->folder->change_flags != NULL) \
-msginfo->folder->folder->change_flags(msginfo->folder->folder, \
-                                     msginfo->folder, \
-                                     msginfo); \
-}
-
 /*
 Compose *compose_new_followup_and_replyto(PrefsAccount *account,
                                           const gchar *followupto, gchar * to)
@@ -850,10 +784,11 @@ Compose *compose_new_followup_and_replyto(PrefsAccount *account,
 */
 
 void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
-                  gboolean ignore_replyto, const gchar *body)
+                  gboolean to_ml, gboolean ignore_replyto, 
+                  const gchar *body)
 {
-       compose_generic_reply(msginfo, quote, to_all, ignore_replyto, FALSE,
-                             body);
+       compose_generic_reply(msginfo, quote, to_all, to_ml, 
+                             ignore_replyto, FALSE, body);
 }
 
 void compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
@@ -861,55 +796,26 @@ void compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
                                   gboolean ignore_replyto,
                                   const gchar *body)
 {
-       compose_generic_reply(msginfo, quote, to_all, ignore_replyto, TRUE,
-                             body);
+       compose_generic_reply(msginfo, quote, to_all, FALSE, 
+                             ignore_replyto, TRUE, body);
 }
 
 static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
-                                 gboolean to_all,
+                                 gboolean to_all, gboolean to_ml,
                                  gboolean ignore_replyto,
                                  gboolean followup_and_reply_to,
                                  const gchar *body)
 {
        Compose *compose;
-       PrefsAccount *account;
+       PrefsAccount *account = NULL;
        PrefsAccount *reply_account;
        GtkSText *text;
 
        g_return_if_fail(msginfo != NULL);
        g_return_if_fail(msginfo->folder != NULL);
 
-       account = NULL;
-       /* select the account set in folderitem's property (if enabled) */
-       if (msginfo->folder->prefs && msginfo->folder->prefs->enable_default_account)
-               account = account_find_from_id(msginfo->folder->prefs->default_account);
+       account = account_get_reply_account(msginfo, prefs_common.reply_account_autosel);
        
-       /* select the account for the whole folder (IMAP / NNTP) */
-       if (!account)
-               /* FIXME: this is not right, because folder may be nested. we should
-                * ascend the tree until we find a parent with proper account 
-                * information */
-               account = msginfo->folder->folder->account;
-
-       /* select account by to: and cc: header if enabled */
-       if (prefs_common.reply_account_autosel) {
-               if (!account && msginfo->to) {
-                       gchar *to;
-                       Xstrdup_a(to, msginfo->to, return);
-                       extract_address(to);
-                       account = account_find_from_address(to);
-               }
-               if (!account) {
-                       gchar cc[BUFFSIZE];
-                       if(!get_header_from_msginfo(msginfo, cc, sizeof(cc), "CC:")) { /* Found a CC header */
-                               extract_address(cc);
-                               account = account_find_from_address(cc);
-                       }        
-               }
-       }
-
-       /* select current account */
-       if (!account) account = cur_account;
        g_return_if_fail(account != NULL);
 
        if (ignore_replyto && account->protocol == A_NNTP &&
@@ -924,16 +830,11 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                reply_account = account;
 
        compose = compose_create(account, COMPOSE_REPLY);
-       compose->replyinfo = procmsg_msginfo_new_ref(msginfo);
 
-#if 0 /* NEW COMPOSE GUI */
-       if (followup_and_reply_to) {
-               gtk_widget_show(compose->to_hbox);
-               gtk_widget_show(compose->to_entry);
-               gtk_table_set_row_spacing(GTK_TABLE(compose->table), 1, 4);
-               compose->use_to = TRUE;
-       }
-#endif
+       compose->replyinfo = procmsg_msginfo_get_full_info(msginfo);
+       if (!compose->replyinfo)
+               compose->replyinfo = procmsg_msginfo_copy(msginfo);
+
        if (msginfo->folder && msginfo->folder->ret_rcpt) {
                GtkItemFactory *ifactory;
        
@@ -942,7 +843,7 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
        }
 
        /* Set save folder */
-       if(msginfo->folder && msginfo->folder->prefs && msginfo->folder->prefs->save_copy_to_folder) {
+       if (msginfo->folder && msginfo->folder->prefs && msginfo->folder->prefs->save_copy_to_folder) {
                gchar *folderidentifier;
 
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
@@ -952,8 +853,8 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
        }
 
        if (compose_parse_header(compose, msginfo) < 0) return;
-       compose_reply_set_entry(compose, msginfo, to_all, ignore_replyto,
-                               followup_and_reply_to);
+       compose_reply_set_entry(compose, msginfo, to_all, to_ml, 
+                               ignore_replyto, followup_and_reply_to);
        compose_show_first_last_header(compose, TRUE);
 
        text = GTK_STEXT(compose->text);
@@ -968,7 +869,7 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                else
                        qmark = "> ";
 
-               quote_str = compose_quote_fmt(compose, msginfo,
+               quote_str = compose_quote_fmt(compose, compose->replyinfo,
                                              prefs_common.quotefmt,
                                              qmark, body);
        }
@@ -989,8 +890,6 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                compose_exec_ext_editor(compose);
 }
 
-static void set_toolbar_style(Compose *compose);
-
 #define INSERT_FW_HEADER(var, hdr) \
 if (msginfo->var && *msginfo->var) { \
        gtk_stext_insert(text, NULL, NULL, NULL, hdr, -1); \
@@ -1002,13 +901,15 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                         gboolean as_attach, const gchar *body)
 {
        Compose *compose;
-       /*      PrefsAccount *account; */
        GtkSText *text;
 
        g_return_val_if_fail(msginfo != NULL, NULL);
        g_return_val_if_fail(msginfo->folder != NULL, NULL);
 
-       account = msginfo->folder->folder->account;
+       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);
@@ -1016,9 +917,9 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                account = account_find_from_address(to);
        }
 
-       if(!account && prefs_common.forward_account_autosel) {
+       if (!account && prefs_common.forward_account_autosel) {
                gchar cc[BUFFSIZE];
-               if(!get_header_from_msginfo(msginfo,cc,sizeof(cc),"CC:")){ /* Found a CC header */
+               if (!get_header_from_msginfo(msginfo,cc,sizeof(cc),"CC:")){ /* Found a CC header */
                        extract_address(cc);
                        account = account_find_from_address(cc);
                 }
@@ -1037,7 +938,6 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
        MSG_SET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
        if (MSG_IS_IMAP(msginfo->flags))
                imap_msg_unset_perm_flags(msginfo, MSG_REPLIED);
-       CHANGE_FLAGS(msginfo);
 
        compose = compose_create(account, COMPOSE_FORWARD);
 
@@ -1056,7 +956,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 
                        msgfile = procmsg_get_message_file_path(msginfo);
                        if (!is_file_exist(msgfile))
-                               g_warning(_("%s: file not exist\n"), msgfile);
+                               g_warning("%s: file not exist\n", msgfile);
                        else
                                compose_attach_append(compose, msgfile, msgfile,
                                                      "message/rfc822");
@@ -1065,6 +965,11 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                } else {
                        gchar *qmark;
                        gchar *quote_str;
+                       MsgInfo *full_msginfo;
+
+                       full_msginfo = procmsg_msginfo_get_full_info(msginfo);
+                       if (!full_msginfo)
+                               full_msginfo = procmsg_msginfo_copy(msginfo);
 
                        if (prefs_common.fw_quotemark &&
                            *prefs_common.fw_quotemark)
@@ -1072,10 +977,12 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                        else
                                qmark = "> ";
 
-                       quote_str = compose_quote_fmt(compose, msginfo,
+                       quote_str = compose_quote_fmt(compose, full_msginfo,
                                                      prefs_common.fw_quotefmt,
                                                      qmark, body);
                        compose_attach_parts(compose, msginfo);
+
+                       procmsg_msginfo_free(full_msginfo);
                }
 
        if (prefs_common.auto_sig)
@@ -1098,6 +1005,16 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 
        if (prefs_common.auto_exteditor)
                compose_exec_ext_editor(compose);
+       
+       /*save folder*/
+       if (msginfo->folder && msginfo->folder->prefs && msginfo->folder->prefs->save_copy_to_folder) {
+               gchar *folderidentifier;
+
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
+               folderidentifier = folder_item_get_identifier(msginfo->folder);
+               gtk_entry_set_text(GTK_ENTRY(compose->savemsg_entry), folderidentifier);
+               g_free(folderidentifier);
+       }
 
         return compose;
 }
@@ -1130,7 +1047,6 @@ Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list)
        for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
                MSG_UNSET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_REPLIED);
                MSG_SET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_FORWARDED);
-               CHANGE_FLAGS(((MsgInfo *)msginfo->data));
        }
 
        compose = compose_create(account, COMPOSE_FORWARD);
@@ -1141,7 +1057,7 @@ Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list)
        for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
                msgfile = procmsg_get_message_file_path((MsgInfo *)msginfo->data);
                if (!is_file_exist(msgfile))
-                       g_warning(_("%s: file not exist\n"), msgfile);
+                       g_warning("%s: file not exist\n", msgfile);
                else
                        compose_attach_append(compose, msgfile, msgfile,
                                "message/rfc822");
@@ -1158,6 +1074,8 @@ Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list)
        gtk_stext_set_point(GTK_STEXT(compose->text), 0);
 
        gtk_stext_thaw(text);
+       gtk_widget_grab_focus(compose->header_last->entry);
+       
 #if 0 /* NEW COMPOSE GUI */
        if (account->protocol != A_NNTP)
                gtk_widget_grab_focus(compose->to_entry);
@@ -1179,12 +1097,17 @@ void compose_reedit(MsgInfo *msginfo)
        g_return_if_fail(msginfo != NULL);
        g_return_if_fail(msginfo->folder != NULL);
 
-        if (msginfo->folder->stype == F_QUEUE) {
+        if (msginfo->folder->stype == F_QUEUE || msginfo->folder->stype == F_DRAFT) {
                gchar queueheader_buf[BUFFSIZE];
                gint id;
 
                /* Select Account from queue headers */
                if (!get_header_from_msginfo(msginfo, queueheader_buf, 
+                                            sizeof(queueheader_buf), "X-Sylpheed-Account-Id:")) {
+                       id = atoi(&queueheader_buf[22]);
+                       account = account_find_from_id(id);
+               }
+               if (!account && !get_header_from_msginfo(msginfo, queueheader_buf, 
                                             sizeof(queueheader_buf), "NAID:")) {
                        id = atoi(&queueheader_buf[5]);
                        account = account_find_from_id(id);
@@ -1214,7 +1137,8 @@ void compose_reedit(MsgInfo *msginfo)
        compose = compose_create(account, COMPOSE_REEDIT);
        compose->targetinfo = procmsg_msginfo_copy(msginfo);
 
-        if (msginfo->folder->stype == F_QUEUE) {
+        if (msginfo->folder->stype == F_QUEUE
+       ||  msginfo->folder->stype == F_DRAFT) {
                gchar queueheader_buf[BUFFSIZE];
 
                /* Set message save folder */
@@ -1234,10 +1158,12 @@ void compose_reedit(MsgInfo *msginfo)
        gtk_stext_freeze(text);
 
        if ((fp = procmime_get_first_text_content(msginfo)) == NULL)
-               g_warning(_("Can't get text part\n"));
+               g_warning("Can't get text part\n");
        else {
-               while (fgets(buf, sizeof(buf), fp) != NULL)
+               while (fgets(buf, sizeof(buf), fp) != NULL) {
+                       strcrchomp(buf);
                        gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
+               }
                fclose(fp);
        }
        compose_attach_parts(compose, msginfo);
@@ -1249,6 +1175,78 @@ void compose_reedit(MsgInfo *msginfo)
                compose_exec_ext_editor(compose);
 }
 
+Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
+{
+       Compose *compose;
+       gchar *filename;
+       GtkItemFactory *ifactory;
+
+       g_return_val_if_fail(msginfo != NULL, NULL);
+
+       if (!account)
+               account = cur_account;
+       g_return_val_if_fail(account != NULL, NULL);
+
+       compose = compose_create(account, COMPOSE_REDIRECT);
+       ifactory = gtk_item_factory_from_widget(compose->menubar);
+
+       compose->replyinfo = NULL;
+
+       compose_show_first_last_header(compose, TRUE);
+
+       gtk_widget_grab_focus(compose->header_last->entry);
+
+       filename = procmsg_get_message_file(msginfo);
+       if (filename == NULL)
+               return NULL;
+
+       compose->redirect_filename = filename;
+       
+       compose_attach_parts(compose, msginfo);
+
+       if (msginfo->subject)
+               gtk_entry_set_text(GTK_ENTRY(compose->subject_entry),
+                                  msginfo->subject);
+       gtk_editable_set_editable(GTK_EDITABLE(compose->subject_entry), FALSE);
+
+       gtk_stext_freeze(GTK_STEXT(compose->text));
+       compose_quote_fmt(compose, msginfo, "%M", NULL, NULL);
+       gtk_editable_set_editable(GTK_EDITABLE(compose->text), FALSE);
+       gtk_stext_thaw(GTK_STEXT(compose->text));
+
+       ifactory = gtk_item_factory_from_widget(compose->popupmenu);
+       menu_set_sensitive(ifactory, "/Add...", FALSE);
+       menu_set_sensitive(ifactory, "/Remove", FALSE);
+       menu_set_sensitive(ifactory, "/Property...", FALSE);
+
+       ifactory = gtk_item_factory_from_widget(compose->menubar);
+       menu_set_sensitive(ifactory, "/File/Insert file", FALSE);
+       menu_set_sensitive(ifactory, "/File/Attach file", FALSE);
+       menu_set_sensitive(ifactory, "/File/Insert signature", FALSE);
+       menu_set_sensitive(ifactory, "/Edit", FALSE);
+       menu_set_sensitive(ifactory, "/Message/Save to draft folder", FALSE);
+       menu_set_sensitive(ifactory, "/Message/Save and keep editing", FALSE);
+#if USE_GPGME
+       menu_set_sensitive(ifactory, "/Message/Sign", FALSE);
+       menu_set_sensitive(ifactory, "/Message/Encrypt", FALSE);
+       menu_set_sensitive(ifactory, "/Message/Mode/MIME", FALSE);
+       menu_set_sensitive(ifactory, "/Message/Mode/Inline", FALSE);
+#endif
+       menu_set_sensitive(ifactory, "/Message/Priority", FALSE);
+       menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
+       menu_set_sensitive(ifactory, "/Tools/Show ruler", FALSE);
+       menu_set_sensitive(ifactory, "/Tools/Actions", FALSE);
+       
+       gtk_widget_set_sensitive(compose->toolbar->draft_btn, FALSE);
+       gtk_widget_set_sensitive(compose->toolbar->insert_btn, FALSE);
+       gtk_widget_set_sensitive(compose->toolbar->attach_btn, FALSE);
+       gtk_widget_set_sensitive(compose->toolbar->sig_btn, FALSE);
+       gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, FALSE);
+       gtk_widget_set_sensitive(compose->toolbar->linewrap_btn, FALSE);
+
+        return compose;
+}
+
 GList *compose_get_compose_list(void)
 {
        return compose_list;
@@ -1324,99 +1322,100 @@ void compose_entry_select (Compose *compose, const gchar *mailto)
        }
 }
 
+void compose_toolbar_cb(gint action, gpointer data)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       Compose *compose = (Compose*)toolbar_item->parent;
+       
+       g_return_if_fail(compose != NULL);
+
+       switch(action) {
+       case A_SEND:
+               compose_send_cb(compose, 0, NULL);
+               break;
+       case A_SENDL:
+               compose_send_later_cb(compose, 0, NULL);
+               break;
+       case A_DRAFT:
+               compose_draft_cb(compose, 0, NULL);
+               break;
+       case A_INSERT:
+               compose_insert_file_cb(compose, 0, NULL);
+               break;
+       case A_ATTACH:
+               compose_attach_cb(compose, 0, NULL);
+               break;
+       case A_SIG:
+               compose_insert_sig(compose);
+               break;
+       case A_EXTEDITOR:
+               compose_ext_editor_cb(compose, 0, NULL);
+               break;
+       case A_LINEWRAP:
+               compose_wrap_line(compose);
+               break;
+       case A_ADDRBOOK:
+               compose_address_cb(compose, 0, NULL);
+               break;
+       default:
+               break;
+       }
+}
+
 static void compose_entries_set(Compose *compose, const gchar *mailto)
 {
-       gchar *subject = NULL;
        gchar *to = NULL;
        gchar *cc = NULL;
        gchar *bcc = NULL;
+       gchar *subject = NULL;
        gchar *body = NULL;
-       gchar *p;
-       gchar *tmp_mailto;
-
-       Xstrdup_a(tmp_mailto, mailto, return);
-
-       to = tmp_mailto;
-
-       p = strchr(tmp_mailto, '?');
-       if (p) {
-               *p = '\0';
-               p++;
-       }
-
-       while (p) {
-               gchar *field, *value;
-
-               field = p;
 
-               p = strchr(p, '=');
-               if (!p) break;
-               *p = '\0';
-               p++;
-
-               value = p;
-
-               p = strchr(p, '&');
-               if (p) {
-                       *p = '\0';
-                       p++;
-               }
-
-               if (*value == '\0') continue;
-
-               if (!g_strcasecmp(field, "subject")) {
-                       Xalloca(subject, strlen(value) + 1, return);
-                       decode_uri(subject, value);
-               } else if (!g_strcasecmp(field, "cc")) {
-                       cc = value;
-               } else if (!g_strcasecmp(field, "bcc")) {
-                       bcc = value;
-               } else if (!g_strcasecmp(field, "body")) {
-                       Xalloca(body, strlen(value) + 1, return);
-                       decode_uri(body, value);
-               }
-       }
+       scan_mailto_url(mailto, &to, &cc, &bcc, &subject, &body);
 
        if (to)
                compose_entry_append(compose, to, COMPOSE_TO);
-       if (subject)
-               gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
        if (cc)
                compose_entry_append(compose, cc, COMPOSE_CC);
        if (bcc)
                compose_entry_append(compose, bcc, COMPOSE_BCC);
+       if (subject)
+               gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
        if (body) {
                gtk_stext_insert(GTK_STEXT(compose->text),
                                NULL, NULL, NULL, body, -1);
                gtk_stext_insert(GTK_STEXT(compose->text),
                                NULL, NULL, NULL, "\n", 1);
        }
+
+       g_free(to);
+       g_free(cc);
+       g_free(bcc);
+       g_free(subject);
+       g_free(body);
 }
 
 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
 {
-       static HeaderEntry hentry[] = {{"Reply-To:",       NULL, TRUE},
-                                      {"Cc:",             NULL, FALSE},
-                                      {"References:",     NULL, FALSE},
-                                      {"Bcc:",            NULL, FALSE},
-                                      {"Newsgroups:",     NULL, FALSE},
-                                      {"Followup-To:",    NULL, FALSE},
-                                      {"X-Mailing-List:", NULL, FALSE},
-                                      {"X-BeenThere:",    NULL, FALSE},
-                                      {"X-Priority:",     NULL, FALSE},
-                                      {NULL,              NULL, FALSE}};
+       static HeaderEntry hentry[] = {{"Reply-To:",    NULL, TRUE},
+                                      {"Cc:",          NULL, FALSE},
+                                      {"References:",  NULL, FALSE},
+                                      {"Bcc:",         NULL, FALSE},
+                                      {"Newsgroups:",  NULL, FALSE},
+                                      {"Followup-To:", NULL, FALSE},
+                                      {"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_X_MAILING_LIST = 6,
-               H_X_BEENTHERE    = 7,
-               H_X_PRIORITY     = 8
+               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;
@@ -1437,26 +1436,6 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
                compose->cc = hentry[H_CC].body;
                hentry[H_CC].body = NULL;
        }
-       if (hentry[H_X_MAILING_LIST].body != NULL) {
-               /* this is good enough to parse debian-devel */
-               gchar *buf = g_malloc(strlen(hentry[H_X_MAILING_LIST].body) + 1);
-               g_return_val_if_fail(buf != NULL, -1 );
-               if (1 == sscanf(hentry[H_X_MAILING_LIST].body, "<%[^>]>", buf))
-                       compose->mailinglist = g_strdup(buf);
-               g_free(buf);
-               g_free(hentry[H_X_MAILING_LIST].body);
-               hentry[H_X_MAILING_LIST].body = NULL ;
-       }
-       if (hentry[H_X_BEENTHERE].body != NULL) {
-               /* this is good enough to parse the sylpheed-claws lists */
-               gchar *buf = g_malloc(strlen(hentry[H_X_BEENTHERE].body) + 1);
-               g_return_val_if_fail(buf != NULL, -1 );
-               if (1 == sscanf(hentry[H_X_BEENTHERE].body, "%[^>]", buf))
-                       compose->mailinglist = g_strdup(buf);
-               g_free(buf);
-               g_free(hentry[H_X_BEENTHERE].body);
-               hentry[H_X_BEENTHERE].body = NULL ;
-       }
        if (hentry[H_REFERENCES].body != NULL) {
                if (compose->mode == COMPOSE_REEDIT)
                        compose->references = hentry[H_REFERENCES].body;
@@ -1484,7 +1463,23 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
                compose->followup_to = hentry[H_FOLLOWUP_TO].body;
                hentry[H_FOLLOWUP_TO].body = NULL;
        }
+       if (hentry[H_LIST_POST].body != NULL) {
+               gchar *to = NULL;
+
+               extract_address(hentry[H_LIST_POST].body);
+               if (hentry[H_LIST_POST].body[0] != '\0') {
+                       scan_mailto_url(hentry[H_LIST_POST].body,
+                                       &to, NULL, NULL, NULL, NULL);
+                       if (to) {
+                               g_free(compose->ml_post);
+                               compose->ml_post = to;
+                       }
+               }
+               g_free(hentry[H_LIST_POST].body);
+               hentry[H_LIST_POST].body = NULL;
+       }
 
+       /* CLAWS - X-Priority */
        if (compose->mode == COMPOSE_REEDIT)
                if (hentry[H_X_PRIORITY].body != NULL) {
                        gint priority;
@@ -1630,7 +1625,8 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
 }
 
 static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
-                                   gboolean to_all, gboolean ignore_replyto,
+                                   gboolean to_all, gboolean to_ml,
+                                   gboolean ignore_replyto,
                                    gboolean followup_and_reply_to)
 {
        GSList *cc_list = NULL;
@@ -1642,27 +1638,46 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
        g_return_if_fail(compose->account != NULL);
        g_return_if_fail(msginfo != NULL);
 
-       if ((compose->account->protocol != A_NNTP) || followup_and_reply_to)
-               compose_entry_append(compose,
-                                   ((compose->replyto && !ignore_replyto)
-                                    ? compose->replyto
-                                    : (compose->mailinglist && !ignore_replyto)
-                                    ? compose->mailinglist
-                                    : msginfo->from ? msginfo->from : ""),
-                                    COMPOSE_TO);
-
-       if (compose->account->protocol == A_NNTP) {
+       if (compose->account->protocol != A_NNTP || followup_and_reply_to) {
+               if (!compose->replyto && to_ml && compose->ml_post
+                   && !(msginfo->folder && msginfo->folder->prefs->enable_default_reply_to))
+                       compose_entry_append(compose,
+                                          compose->ml_post,
+                                          COMPOSE_TO);
+               else if (!(to_all || ignore_replyto)
+                        && msginfo->folder
+                        && msginfo->folder->prefs->enable_default_reply_to) {
+                       compose_entry_append(compose,
+                           msginfo->folder->prefs->default_reply_to,
+                           COMPOSE_TO);
+               } else
+                       compose_entry_append(compose,
+                                (compose->replyto && !ignore_replyto)
+                                ? compose->replyto
+                                : msginfo->from ? msginfo->from : "",
+                                COMPOSE_TO);
+       } else {
                if (ignore_replyto)
                        compose_entry_append
                                (compose, msginfo->from ? msginfo->from : "",
                                 COMPOSE_TO);
-               else
-                       compose_entry_append
-                               (compose,
-                                compose->followup_to ? compose->followup_to
-                                : compose->newsgroups ? compose->newsgroups
-                                : "",
-                                COMPOSE_NEWSGROUPS);
+               else {
+                       if (compose->followup_to && !strncmp(compose->followup_to, "poster", 6)) {
+                               compose_entry_append
+                                       (compose,
+                                       ((compose->replyto && !ignore_replyto)
+                                       ? compose->replyto
+                                       : msginfo->from ? msginfo->from : ""),
+                                       COMPOSE_TO);                            
+                       } else {
+                               compose_entry_append
+                                       (compose,
+                                        compose->followup_to ? compose->followup_to
+                                        : compose->newsgroups ? compose->newsgroups
+                                        : "",
+                                        COMPOSE_NEWSGROUPS);
+                       }
+               }
        }
 
        if (msginfo->subject && *msginfo->subject) {
@@ -1682,6 +1697,7 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
        } else
                gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), "Re: ");
 
+       if (to_ml && compose->ml_post) return;
        if (!to_all || compose->account->protocol == A_NNTP) return;
 
        if (compose->replyto) {
@@ -1693,16 +1709,9 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
                extract_address(from);
        }
 
-       if (compose->mailinglist && from) {
-               cc_list = address_list_append(cc_list, from);
-       }
-
        if (replyto && from)
                cc_list = address_list_append(cc_list, from);
-
-       if (!compose->mailinglist)
-               cc_list = address_list_append(cc_list, msginfo->to);
-
+       cc_list = address_list_append(cc_list, msginfo->to);
        cc_list = address_list_append(cc_list, compose->cc);
 
        to_table = g_hash_table_new(g_str_hash, g_str_equal);
@@ -1757,30 +1766,11 @@ static void compose_reedit_set_entry(Compose *compose, MsgInfo *msginfo)
        SET_ADDRESS(COMPOSE_REPLYTO, compose->replyto);
 
        compose_update_priority_menu_item(compose);
-
+#if USE_GPGME  
+       compose_update_gnupg_mode_menu_item(compose);
+#endif
        compose_show_first_last_header(compose, TRUE);
 
-#if 0 /* NEW COMPOSE GUI */
-       if (compose->bcc) {
-               GtkItemFactory *ifactory;
-               GtkWidget *menuitem;
-
-               ifactory = gtk_item_factory_from_widget(compose->menubar);
-               menuitem = gtk_item_factory_get_item(ifactory, "/View/Bcc");
-               gtk_check_menu_item_set_active
-                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-       }
-       if (compose->replyto) {
-               GtkItemFactory *ifactory;
-               GtkWidget *menuitem;
-
-               ifactory = gtk_item_factory_from_widget(compose->menubar);
-               menuitem = gtk_item_factory_get_item
-                       (ifactory, "/View/Reply to");
-               gtk_check_menu_item_set_active
-                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-       }
-#endif
 }
 
 #undef SET_ENTRY
@@ -1900,11 +1890,11 @@ static void compose_attach_append(Compose *compose, const gchar *file,
        gint row;
 
        if (!is_file_exist(file)) {
-               g_warning(_("File %s doesn't exist\n"), file);
+               g_warning("File %s doesn't exist\n", file);
                return;
        }
        if ((size = get_file_size(file)) < 0) {
-               g_warning(_("Can't get file size of %s\n"), file);
+               g_warning("Can't get file size of %s\n", file);
                return;
        }
        if (size == 0) {
@@ -1996,6 +1986,7 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
                procmime_mimeinfo_free_all(mimeinfo);
                return;
        }
+
        if (IS_FIRST_PART_TEXT(child))
                child = child->next;
 
@@ -2006,11 +1997,17 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
                        child = procmime_mimeinfo_next(child);
                        continue;
                }
-
+               if(child->parent && child->parent->parent
+               && !strcasecmp(child->parent->parent->content_type, "multipart/signed")
+               && child->mime_type == MIME_TEXT) {
+                       /* this is the main text part of a signed message */
+                       child = procmime_mimeinfo_next(child);
+                       continue;
+               }
                outfile = procmime_get_tmp_file_name(child);
                if (procmime_get_part(outfile, infile, child) < 0)
-                       g_warning(_("Can't get the part of multipart message."));
-               else
+                       g_warning("Can't get the part of multipart message.");
+               else if (compose->mode != COMPOSE_REEDIT || strcmp(child->content_type, "application/pgp-signature"))
                        compose_attach_append
                                (compose, outfile,
                                 child->filename ? child->filename : child->name,
@@ -2204,15 +2201,16 @@ compose_end:
 /* Darko: used when I debug wrapping */
 void dump_text(GtkSText *text, int pos, int tlen, int breakoncr)
 {
-       gint i;
-       gchar ch;
+       gint i, clen;
+       gchar cbuf[MB_LEN_MAX];
 
        printf("%d [", pos);
        for (i = pos; i < tlen; i++) {
-               ch = GTK_STEXT_INDEX(text, i);
-               if (breakoncr && ch == '\n')
+               GET_CHAR(i, cbuf, clen);
+               if (clen < 0) break;
+               if (breakoncr && clen == 1 && cbuf[0] == '\n')
                        break;
-               printf("%c", ch);
+               fwrite(cbuf, clen, 1, stdout);
        }
        printf("]\n");
 }
@@ -2317,7 +2315,7 @@ static guint ins_quote(GtkSText *text, guint indent_len,
 
 /* check if we should join the next line */
 static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
-                              guint prev_ilen)
+                              guint prev_ilen, gboolean autowrap)
 {
        guint indent_len, ch_len;
        gboolean do_join = FALSE;
@@ -2325,7 +2323,7 @@ static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
 
        indent_len = get_indent_length(text, start_pos, tlen);
 
-       if ((indent_len > 0) && (indent_len == prev_ilen)) {
+       if ((autowrap || indent_len > 0) && indent_len == prev_ilen) {
                GET_CHAR(start_pos + indent_len, cbuf, ch_len);
                if (ch_len > 0 && (cbuf[0] != '\n'))
                        do_join = TRUE;
@@ -2335,6 +2333,14 @@ static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
 }
 
 static void compose_wrap_line_all(Compose *compose)
+{
+       compose_wrap_line_all_full(compose, FALSE);
+}
+
+#define STEXT_FREEZE() \
+       if (!frozen) { gtk_stext_freeze(text); frozen = TRUE; }
+
+static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
 {
        GtkSText *text = GTK_STEXT(compose->text);
        guint tlen;
@@ -2344,15 +2350,13 @@ static void compose_wrap_line_all(Compose *compose)
        gboolean is_new_line = TRUE, do_delete = FALSE;
        guint i_len = 0;
        gboolean linewrap_quote = TRUE;
+       gboolean set_editable_pos = FALSE;
+       gint editable_pos = 0;
+       gboolean frozen = FALSE;
        guint linewrap_len = prefs_common.linewrap_len;
        gchar *qfmt = prefs_common.quotemark;
        gchar cbuf[MB_LEN_MAX];
 
-       gtk_stext_freeze(text);
-
-       /* make text buffer contiguous */
-       /* gtk_stext_compact_buffer(text); */
-
        tlen = gtk_stext_get_length(text);
 
        for (; cur_pos < tlen; cur_pos++) {
@@ -2364,7 +2368,7 @@ static void compose_wrap_line_all(Compose *compose)
                        is_new_line = FALSE;
                        p_pos = cur_pos;
 #ifdef WRAP_DEBUG
-                       printf("new line i_len=%d p_pos=", i_len);
+                       g_print("new line i_len=%d p_pos=", i_len);
                        dump_text(text, p_pos, tlen, 1);
 #endif
                }
@@ -2377,7 +2381,7 @@ static void compose_wrap_line_all(Compose *compose)
                        guint tab_offset = line_len % tab_width;
 
 #ifdef WRAP_DEBUG
-                       printf("found tab at pos=%d line_len=%d ", cur_pos,
+                       g_print("found tab at pos=%d line_len=%d ", cur_pos,
                                line_len);
 #endif
                        if (tab_offset) {
@@ -2392,32 +2396,34 @@ static void compose_wrap_line_all(Compose *compose)
                /* we have encountered line break */
                if (ch_len == 1 && *cbuf == '\n') {
                        gint clen;
-                       gchar cb[MB_CUR_MAX];
+                       gchar cb[MB_LEN_MAX];
 
                        /* should we join the next line */
-                       if ((i_len != cur_len) && do_delete &&
-                           join_next_line(text, cur_pos + 1, tlen, i_len))
+                       if ((autowrap || i_len != cur_len) && do_delete &&
+                           join_next_line
+                               (text, cur_pos + 1, tlen, i_len, autowrap))
                                do_delete = TRUE;
                        else
                                do_delete = FALSE;
 
 #ifdef WRAP_DEBUG
-                       printf("found CR at %d do_del is %d next line is ",
+                       g_print("found CR at %d do_del is %d next line is ",
                               cur_pos, do_delete);
                        dump_text(text, cur_pos + 1, tlen, 1);
 #endif
 
                        /* skip delete if it is continuous URL */
                        if (do_delete && (line_pos - p_pos <= i_len) &&
-                           gtkut_stext_is_uri_string(text, line_pos, tlen))
+                           gtk_stext_is_uri_string(text, line_pos, tlen))
                                do_delete = FALSE;
 
 #ifdef WRAP_DEBUG
-                       printf("l_len=%d wrap_len=%d do_del=%d\n",
+                       g_print("l_len=%d wrap_len=%d do_del=%d\n",
                                line_len, linewrap_len, do_delete);
 #endif
                        /* should we delete to perform smart wrapping */
                        if (line_len < linewrap_len && do_delete) {
+                               STEXT_FREEZE();
                                /* get rid of newline */
                                gtk_stext_set_point(text, cur_pos);
                                gtk_stext_forward_delete(text, 1);
@@ -2427,7 +2433,7 @@ static void compose_wrap_line_all(Compose *compose)
                                   indent string, delete them */
                                if (i_len) {
                                        guint ilen;
-                                       ilen =  gtkut_stext_str_compare_n
+                                       ilen =  gtk_stext_str_compare_n
                                                (text, cur_pos, p_pos, i_len,
                                                 tlen);
                                        if (ilen) {
@@ -2444,7 +2450,6 @@ static void compose_wrap_line_all(Compose *compose)
                                    ((clen > 1) || isalnum(cb[0]))) {
                                        gtk_stext_insert(text, NULL, NULL,
                                                        NULL, " ", 1);
-                                       /* gtk_stext_compact_buffer(text); */
                                        tlen++;
                                }
 
@@ -2455,7 +2460,7 @@ static void compose_wrap_line_all(Compose *compose)
                                do_delete = FALSE;
                                is_new_line = TRUE;
 #ifdef WRAP_DEBUG
-                               printf("after delete l_pos=");
+                               g_print("after delete l_pos=");
                                dump_text(text, line_pos, tlen, 1);
 #endif
                                continue;
@@ -2485,26 +2490,34 @@ static void compose_wrap_line_all(Compose *compose)
                        gint clen;
 
 #ifdef WRAP_DEBUG
-                       printf("should wrap cur_pos=%d ", cur_pos);
+                       g_print("should wrap cur_pos=%d ", cur_pos);
                        dump_text(text, p_pos, tlen, 1);
                        dump_text(text, line_pos, tlen, 1);
 #endif
                        /* force wrapping if it is one long word but not URL */
                        if (line_pos - p_pos <= i_len)
-                               if (!gtkut_stext_is_uri_string
+                               if (!gtk_stext_is_uri_string
                                    (text, line_pos, tlen))
                                        line_pos = cur_pos - 1;
 #ifdef WRAP_DEBUG
-                       printf("new line_pos=%d\n", line_pos);
+                       g_print("new line_pos=%d\n", line_pos);
 #endif
 
                        GET_CHAR(line_pos - 1, cbuf, clen);
 
                        /* if next character is space delete it */
-                        if (clen == 1 && isspace(*cbuf)) {
+                       if (clen == 1 && isspace(*cbuf)) {
                                if (p_pos + i_len != line_pos ||
-                                   !gtkut_stext_is_uri_string
+                                   !gtk_stext_is_uri_string
                                        (text, line_pos, tlen)) {
+                                       STEXT_FREEZE();
+                                       /* workaround for correct cursor
+                                          position */
+                                       if (set_editable_pos == FALSE) {
+                                               editable_pos = gtk_editable_get_position(GTK_EDITABLE(text));
+                                               if (editable_pos == line_pos)
+                                                       set_editable_pos = TRUE;
+                                       }
                                        gtk_stext_set_point(text, line_pos);
                                        gtk_stext_backward_delete(text, 1);
                                        tlen--;
@@ -2517,15 +2530,16 @@ static void compose_wrap_line_all(Compose *compose)
 
                        /* if it is URL at beginning of line don't wrap */
                        if (p_pos + i_len == line_pos &&
-                           gtkut_stext_is_uri_string(text, line_pos, tlen)) {
+                           gtk_stext_is_uri_string(text, line_pos, tlen)) {
 #ifdef WRAP_DEBUG
-                               printf("found URL at ");
+                               g_print("found URL at ");
                                dump_text(text, line_pos, tlen, 1);
 #endif
                                continue;
                        }
 
                        /* insert CR */
+                       STEXT_FREEZE();
                        gtk_stext_set_point(text, line_pos);
                        gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
                        /* gtk_stext_compact_buffer(text); */
@@ -2535,14 +2549,13 @@ static void compose_wrap_line_all(Compose *compose)
                        cur_pos = line_pos - 1;
                        /* start over with current line */
                        is_new_line = TRUE;
-                       line_len = 0;
-                       cur_len = 0;
-                       if (i_len)
+                       line_len = cur_len = 0;
+                       if (autowrap || i_len > 0)
                                do_delete = TRUE;
                        else
                                do_delete = FALSE;
 #ifdef WRAP_DEBUG
-                       printf("after CR insert ");
+                       g_print("after CR insert ");
                        dump_text(text, line_pos, tlen, 1);
                        dump_text(text, cur_pos, tlen, 1);
 #endif
@@ -2550,7 +2563,7 @@ static void compose_wrap_line_all(Compose *compose)
                        /* should we insert quotation ? */
                        if (linewrap_quote && i_len) {
                                /* only if line is not already quoted  */
-                               if (!gtkut_stext_str_compare
+                               if (!gtk_stext_str_compare
                                        (text, line_pos, tlen, qfmt)) {
                                        guint ins_len;
 
@@ -2558,12 +2571,10 @@ static void compose_wrap_line_all(Compose *compose)
                                                ins_len = ins_quote
                                                        (text, i_len, p_pos,
                                                         tlen, qfmt);
-
-                                               /* gtk_stext_compact_buffer(text); */
                                                tlen += ins_len;
                                        }
 #ifdef WRAP_DEBUG
-                                       printf("after quote insert ");
+                                       g_print("after quote insert ");
                                        dump_text(text, line_pos, tlen, 1);
 #endif
                                }
@@ -2579,9 +2590,14 @@ static void compose_wrap_line_all(Compose *compose)
                cur_len += ch_len;
        }
 
-       gtk_stext_thaw(text);
+       if (frozen)
+               gtk_stext_thaw(text);
+
+       if (set_editable_pos && editable_pos <= tlen)
+               gtk_editable_set_position(GTK_EDITABLE(text), editable_pos);
 }
 
+#undef STEXT_FREEZE
 #undef GET_CHAR
 
 static void compose_set_title(Compose *compose)
@@ -2626,6 +2642,93 @@ compose_current_mail_account(void)
        return ac;
 }
 
+static void compose_select_account(Compose *compose, PrefsAccount *account)
+{
+       GtkWidget *menuitem;
+       GtkItemFactory *ifactory;
+
+       g_return_if_fail(account != NULL);
+
+       compose->account = account;
+
+       compose_set_title(compose);
+
+       ifactory = gtk_item_factory_from_widget(compose->menubar);
+#if 0
+       if (account->protocol == A_NNTP) {
+               gtk_widget_show(compose->newsgroups_hbox);
+               gtk_widget_show(compose->newsgroups_entry);
+               gtk_table_set_row_spacing(GTK_TABLE(compose->table), 2, 4);
+               compose->use_newsgroups = TRUE;
+
+               menuitem = gtk_item_factory_get_item(ifactory, "/View/To");
+               gtk_check_menu_item_set_active
+                       (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
+               gtk_widget_set_sensitive(menuitem, TRUE);
+               menuitem = gtk_item_factory_get_item(ifactory, "/View/Cc");
+               gtk_check_menu_item_set_active
+                       (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
+               gtk_widget_set_sensitive(menuitem, TRUE);
+
+               menu_set_sensitive(ifactory, "/View/Followup to", TRUE);
+       } else {
+               gtk_widget_hide(compose->newsgroups_hbox);
+               gtk_widget_hide(compose->newsgroups_entry);
+               gtk_table_set_row_spacing(GTK_TABLE(compose->table), 2, 0);
+               gtk_widget_queue_resize(compose->table_vbox);
+               compose->use_newsgroups = FALSE;
+
+               menuitem = gtk_item_factory_get_item(ifactory, "/View/To");
+               gtk_check_menu_item_set_active
+                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+               gtk_widget_set_sensitive(menuitem, FALSE);
+               menuitem = gtk_item_factory_get_item(ifactory, "/View/Cc");
+               gtk_check_menu_item_set_active
+                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+               gtk_widget_set_sensitive(menuitem, FALSE);
+
+               menuitem = gtk_item_factory_get_item(ifactory, "/View/Followup to");
+               gtk_check_menu_item_set_active
+                       (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
+               gtk_widget_set_sensitive(menuitem, FALSE);
+       }
+
+       if (account->set_autocc) {
+               compose_entry_show(compose, COMPOSE_ENTRY_CC);
+               if (account->auto_cc && compose->mode != COMPOSE_REEDIT)
+                       compose_entry_set(compose, account->auto_cc,
+                                         COMPOSE_ENTRY_CC);
+       }
+       if (account->set_autobcc) {
+               compose_entry_show(compose, COMPOSE_ENTRY_BCC);
+               if (account->auto_bcc && compose->mode != COMPOSE_REEDIT)
+                       compose_entry_set(compose, account->auto_bcc,
+                                         COMPOSE_ENTRY_BCC);
+       }
+       if (account->set_autoreplyto) {
+               compose_entry_show(compose, COMPOSE_ENTRY_REPLY_TO);
+               if (account->auto_replyto && compose->mode != COMPOSE_REEDIT)
+                       compose_entry_set(compose, account->auto_replyto,
+                                         COMPOSE_ENTRY_REPLY_TO);
+       }
+
+       menuitem = gtk_item_factory_get_item(ifactory, "/View/Ruler");
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+                                      prefs_common.show_ruler);
+#endif
+
+#if USE_GPGME
+       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Sign");
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+                                      account->default_sign);
+       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Encrypt");
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+                                      account->default_encrypt);
+                                      
+       activate_gnupg_mode(compose, account);          
+#endif /* USE_GPGME */
+}
+
 gboolean compose_check_for_valid_recipient(Compose *compose) {
        gchar *recipient_headers_mail[] = {"To:", "Cc:", "Bcc:", NULL};
        gchar *recipient_headers_news[] = {"Newsgroups:", NULL};
@@ -2643,26 +2746,27 @@ gboolean compose_check_for_valid_recipient(Compose *compose) {
         compose->newsgroup_list = NULL;
 
        /* search header entries for to and newsgroup entries */
-       for(list = compose->header_list; list; list = list->next) {
+       for (list = compose->header_list; list; list = list->next) {
                gchar *header;
                gchar *entry;
-               header = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry));
+               header = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry), 0, -1);
                entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
                g_strstrip(entry);
-               if(entry[0] != '\0') {
-                       for(strptr = recipient_headers_mail; *strptr != NULL; strptr++) {
-                               if(!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
+               if (entry[0] != '\0') {
+                       for (strptr = recipient_headers_mail; *strptr != NULL; strptr++) {
+                               if (!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
                                        compose->to_list = address_list_append(compose->to_list, entry);
                                        recipient_found = TRUE;
                                }
                        }
-                       for(strptr = recipient_headers_news; *strptr != NULL; strptr++) {
-                               if(!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
+                       for (strptr = recipient_headers_news; *strptr != NULL; strptr++) {
+                               if (!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
                                        compose->newsgroup_list = newsgroup_list_append(compose->newsgroup_list, entry);
                                        recipient_found = TRUE;
                                }
                        }
                }
+               g_free(header);
                g_free(entry);
        }
        return recipient_found;
@@ -2696,6 +2800,7 @@ gint compose_send(Compose *compose)
        gint msgnum;
        FolderItem *folder;
        gint val;
+       gchar *msgpath;
 
        if (compose_check_entries(compose, TRUE) == FALSE)
                return -1;
@@ -2706,10 +2811,11 @@ gint compose_send(Compose *compose)
                return -1;
        }
        
-       val = procmsg_send_message_queue(folder_item_fetch_msg(folder, msgnum));
+       msgpath = folder_item_fetch_msg(folder, msgnum);
+       val = procmsg_send_message_queue(msgpath);
+       g_free(msgpath);
 
        folder_item_remove_msg(folder, msgnum);
-       folderview_update_item(folder, TRUE);
 
        return val;
 }
@@ -2724,7 +2830,6 @@ gint compose_send(Compose *compose)
        if (lock) return 1;
 
        g_return_val_if_fail(compose->account != NULL, -1);
-       g_return_val_if_fail(compose->orig_account != NULL, -1);
 
        lock = TRUE;
 
@@ -2734,8 +2839,8 @@ gint compose_send(Compose *compose)
        }
 
        /* write to temporary file */
-       g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg%d",
-                  get_rc_dir(), G_DIR_SEPARATOR, (gint)compose);
+       g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.%08x",
+                  get_tmp_dir(), G_DIR_SEPARATOR, (gint)compose);
 
        if (prefs_common.linewrap_at_send)
                compose_wrap_line_all(compose);
@@ -2746,7 +2851,7 @@ gint compose_send(Compose *compose)
        }
 
        if (!compose->to_list && !compose->newsgroup_list) {
-               g_warning(_("can't get recipient list."));
+               g_warning("can't get recipient list.");
                unlink(tmp);
                lock = FALSE;
                return -1;
@@ -2758,13 +2863,17 @@ gint compose_send(Compose *compose)
 #if 0 /* NEW COMPOSE GUI */
                if (compose->account->protocol != A_NNTP)
                        ac = compose->account;
-               else if (compose->orig_account->protocol != A_NNTP)
-                       ac = compose->orig_account;
-               else if (cur_account && cur_account->protocol != A_NNTP)
-                       ac = cur_account;
                else {
-                       ac = compose_current_mail_account();
+                       ac = account_find_from_address(compose->account->address);
                        if (!ac) {
+                               if (cur_account && cur_account->protocol != A_NNTP)
+                                       ac = cur_account;
+                               else
+                                       ac = account_get_default();
+                       }
+                       if (!ac || ac->protocol == A_NNTP) {
+                               alertpanel_error(_("Account for sending mail is not specified.\n"
+                                                  "Please select a mail account before sending."));
                                unlink(tmp);
                                lock = FALSE;
                                return -1;
@@ -2774,18 +2883,10 @@ gint compose_send(Compose *compose)
                ac = compose->account;
 
                ok = send_message(tmp, ac, compose->to_list);
-               statusbar_pop_all();
        }
 
        if (ok == 0 && compose->newsgroup_list) {
-               Folder *folder;
-
-               if (compose->account->protocol == A_NNTP)
-                       folder = FOLDER(compose->account->folder);
-               else
-                       folder = FOLDER(compose->orig_account->folder);
-
-               ok = news_post(folder, tmp);
+               ok = news_post(FOLDER(compose->account->folder), tmp);
                if (ok < 0) {
                        alertpanel_error(_("Error occurred while posting the message to %s ."),
                                         compose->account->nntp_server);
@@ -2815,9 +2916,6 @@ gint compose_send(Compose *compose)
        } else {
                if (compose->mode == COMPOSE_REEDIT) {
                        compose_remove_reedit_target(compose);
-                       if (compose->targetinfo)
-                               folderview_update_item
-                                       (compose->targetinfo->folder, TRUE);
                }
                /* save message to outbox */
                if (prefs_common.savemsg) {
@@ -2828,8 +2926,6 @@ gint compose_send(Compose *compose)
                        if (procmsg_save_to_outbox(outbox, tmp, FALSE) < 0)
                                alertpanel_error
                                        (_("Can't save the message to Sent."));
-                       else
-                               folderview_update_item(outbox, TRUE);
                }
        }
 
@@ -2855,26 +2951,26 @@ static gint compose_redirect_write_headers_from_headerlist(Compose *compose,
        gchar *cc_hdr;
        gchar *to_hdr;
 
-       debug_print(_("Writing redirect header\n"));
+       debug_print("Writing redirect header\n");
 
        cc_hdr = prefs_common.trans_hdr ? _("Cc:") : "Cc:";
        to_hdr = prefs_common.trans_hdr ? _("To:") : "To:";
 
        first_address = TRUE;
-       for(list = compose->header_list; list; list = list->next) {
+       for (list = compose->header_list; list; list = list->next) {
                headerentry = ((ComposeHeaderEntry *)list->data);
                headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
 
-               if(g_strcasecmp(headerentryname, cc_hdr) == 0 
+               if (g_strcasecmp(headerentryname, cc_hdr) == 0 
                   || g_strcasecmp(headerentryname, to_hdr) == 0) {
                        str = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
                        Xstrdup_a(str, str, return -1);
                        g_strstrip(str);
-                       if(str[0] != '\0') {
+                       if (str[0] != '\0') {
                                compose_convert_header
                                        (buf, sizeof(buf), str,
                                        strlen("Resent-To") + 2);
-                               if(first_address) {
+                               if (first_address) {
                                        fprintf(fp, "Resent-To: ");
                                        first_address = FALSE;
                                } else {
@@ -2884,7 +2980,7 @@ static gint compose_redirect_write_headers_from_headerlist(Compose *compose,
                        }
                }
        }
-       /* if(!first_address) { */
+       /* if (!first_address) { */
        fprintf(fp, "\n");
        /* } */
 
@@ -2963,7 +3059,7 @@ static gint compose_redirect_write_to_file(Compose *compose, const gchar *file)
        /* chmod for security */
        if (change_file_mode_rw(fdest, file) < 0) {
                FILE_OP_ERROR(file, "chmod");
-               g_warning(_("can't change file mode\n"));
+               g_warning("can't change file mode\n");
        }
 
        while (procheader_get_unfolded_line(buf, sizeof(buf), fp)) {
@@ -3033,43 +3129,69 @@ static gint compose_redirect_write_to_file(Compose *compose, const gchar *file)
 }
 
 
-#ifdef USE_GPGME
-/*
- * interfaces to rfc2015 to keep out the prefs stuff there.
+#if USE_GPGME
+/* interfaces to rfc2015 to keep out the prefs stuff there.
  * returns 0 on success and -1 on error. */
-static int compose_create_signers_list (Compose *compose, GSList **pkey_list)
+static gint compose_create_signers_list(Compose *compose, GSList **pkey_list)
 {
-       const char *keyid = NULL;
+       const gchar *key_id = NULL;
        GSList *key_list;
 
        switch (compose->account->sign_key) {
        case SIGN_KEY_DEFAULT:
                *pkey_list = NULL;
-               return 0;               /* nothing to do */
-
+               return 0;
        case SIGN_KEY_BY_FROM:
-               keyid = compose->account->address;
+               key_id = compose->account->address;
                break;
-
        case SIGN_KEY_CUSTOM:
-               keyid = compose->account->sign_key_id;
+               key_id = compose->account->sign_key_id;
                break;
-
        default:
-               g_assert_not_reached ();
+               break;
        }
 
-       key_list = rfc2015_create_signers_list(keyid);
+       key_list = rfc2015_create_signers_list(key_id);
 
        if (!key_list) {
-           alertpanel_error("Could not find any key associated with currently "
-                               "selected keyid `%s'!", keyid);
-           return -1;
+               alertpanel_error(_("Could not find any key associated with "
+                                  "currently selected key id `%s'."), key_id);
+               return -1;
        }
-       
+
        *pkey_list = key_list;
        return 0;
 }
+
+/* clearsign message body text */
+static gint compose_clearsign_text(Compose *compose, gchar **text)
+{
+       GSList *key_list;
+       gchar *tmp_file;
+
+       tmp_file = get_tmp_file();
+       if (str_write_to_file(*text, tmp_file) < 0) {
+               g_free(tmp_file);
+               return -1;
+       }
+
+       if (canonicalize_file_replace(tmp_file) < 0 ||
+           compose_create_signers_list(compose, &key_list) < 0 ||
+           rfc2015_clearsign(tmp_file, key_list) < 0) {
+               unlink(tmp_file);
+               g_free(tmp_file);
+               return -1;
+       }
+
+       g_free(*text);
+       *text = file_read_to_str(tmp_file);
+       unlink(tmp_file);
+       g_free(tmp_file);
+       if (*text == NULL)
+               return -1;
+
+       return 0;
+}
 #endif /* USE_GPGME */
 
 static gint compose_write_to_file(Compose *compose, const gchar *file,
@@ -3090,14 +3212,15 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        /* chmod for security */
        if (change_file_mode_rw(fp, file) < 0) {
                FILE_OP_ERROR(file, "chmod");
-               g_warning(_("can't change file mode\n"));
+               g_warning("can't change file mode\n");
        }
 
        /* get all composed text */
        chars = gtk_editable_get_chars(GTK_EDITABLE(compose->text), 0, -1);
        len = strlen(chars);
        if (is_ascii_str(chars)) {
-               buf = g_strdup(chars);
+               buf = chars;
+               chars = NULL;
                out_codeset = CS_US_ASCII;
                encoding = ENC_7BIT;
        } else {
@@ -3108,6 +3231,13 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
                        out_codeset = CS_ISO_8859_1;
                encoding = procmime_get_encoding_for_charset(out_codeset);
 
+#if USE_GPGME
+               if (!is_draft &&
+                   compose->use_signing && !compose->gnupg_mode &&
+                   encoding == ENC_8BIT)
+                       encoding = ENC_BASE64;
+#endif
+
                src_codeset = conv_get_current_charset_str();
                /* if current encoding is US-ASCII, set it the same as
                   outgoing one to prevent code conversion failure */
@@ -3131,16 +3261,57 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
                                unlink(file);
                                return -1;
                        } else {
-                               buf = g_strdup(chars);
+                               buf = chars;
+                               chars = NULL;
                        }
                }
        }
        g_free(chars);
 
+       /* Canonicalize line endings in the message text */
+       {
+               gchar *canon_buf, *out;
+               const gchar *p;
+               guint new_len = 0;
+
+               for (p = buf ; *p; ++p) {
+                       if (*p != '\r') {
+                               ++new_len;
+                               if (*p == '\n')
+                                       ++new_len;
+                       }
+               }
+
+               out = canon_buf = g_new(gchar, new_len + 1);
+               for (p = buf; *p; ++p) {
+                       if (*p != '\r') {
+                               if (*p == '\n')
+                                       *out++ = '\r';
+                               *out++ = *p;
+                       }
+               }
+               *out = '\0';
+
+               free(buf);
+               buf = canon_buf;
+       }
+
+#if USE_GPGME
+       if (!is_draft && compose->use_signing && compose->gnupg_mode) {
+               if (compose_clearsign_text(compose, &buf) < 0) {
+                       g_warning("clearsign failed\n");
+                       fclose(fp);
+                       unlink(file);
+                       g_free(buf);
+                       return -1;
+               }
+       }
+#endif
+
        /* write headers */
        if (compose_write_headers
                (compose, fp, out_codeset, encoding, is_draft) < 0) {
-               g_warning(_("can't write headers\n"));
+               g_warning("can't write headers\n");
                fclose(fp);
                /* unlink(file); */
                g_free(buf);
@@ -3195,18 +3366,29 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        }
 
 #if USE_GPGME
-       if (compose->use_signing) {
+       if (is_draft)
+               return 0;
+
+       if ((compose->use_signing && !compose->gnupg_mode) ||
+           compose->use_encryption) {
+               if (canonicalize_file_replace(file) < 0) {
+                       unlink(file);
+                       return -1;
+               }
+       }
+
+       if (compose->use_signing && !compose->gnupg_mode) {
                GSList *key_list;
-               
-               if (compose_create_signers_list(compose, &key_list) == -1 ||
-                       rfc2015_sign(file, key_list) < 0) {
-                   
+
+               if (compose_create_signers_list(compose, &key_list) < 0 ||
+                   rfc2015_sign(file, key_list) < 0) {
                        unlink(file);
                        return -1;
                }
        }
        if (compose->use_encryption) {
-               if (rfc2015_encrypt(file, compose->to_list, compose->account->ascii_armored) < 0) {
+               if (rfc2015_encrypt(file, compose->to_list,
+                                   compose->gnupg_mode) < 0) {
                        unlink(file);
                        return -1;
                }
@@ -3230,7 +3412,7 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
        /* chmod for security */
        if (change_file_mode_rw(fp, file) < 0) {
                FILE_OP_ERROR(file, "chmod");
-               g_warning(_("can't change file mode\n"));
+               g_warning("can't change file mode\n");
        }
 
        chars = gtk_editable_get_chars(GTK_EDITABLE(compose->text), 0, -1);
@@ -3269,7 +3451,7 @@ static gint compose_remove_reedit_target(Compose *compose)
        if (procmsg_msg_exist(msginfo) &&
            (item->stype == F_DRAFT || item->stype == F_QUEUE)) {
                if (folder_item_remove_msg(item, msginfo->msgnum) < 0) {
-                       g_warning(_("can't remove the old message\n"));
+                       g_warning("can't remove the old message\n");
                        return -1;
                }
        }
@@ -3277,6 +3459,18 @@ static gint compose_remove_reedit_target(Compose *compose)
        return 0;
 }
 
+void compose_remove_draft(Compose *compose)
+{
+       FolderItem *drafts;
+       MsgInfo *msginfo = compose->targetinfo;
+       drafts = account_get_special_folder(compose->account, F_DRAFT);
+
+       if (procmsg_msg_exist(msginfo)) {
+               folder_item_remove_msg(drafts, msginfo->msgnum);
+       }
+
+}
+
 static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
 {
        return compose_queue_sub (compose, msgnum, item, FALSE);
@@ -3292,9 +3486,8 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
         static gboolean lock = FALSE;
        PrefsAccount *mailac = NULL, *newsac = NULL;
        
-       debug_print(_("queueing message...\n"));
+       debug_print("queueing message...\n");
        g_return_val_if_fail(compose->account != NULL, -1);
-        g_return_val_if_fail(compose->orig_account != NULL, -1);
 
         lock = TRUE;
        
@@ -3304,16 +3497,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        }
 
        if (!compose->to_list && !compose->newsgroup_list) {
-               g_warning(_("can't get recipient list."));
+               g_warning("can't get recipient list.");
                lock = FALSE;
                 return -1;
         }
 
-       if(compose->to_list) {
+       if (compose->to_list) {
                if (compose->account->protocol != A_NNTP)
                        mailac = compose->account;
-               else if (compose->orig_account->protocol != A_NNTP)
-                       mailac = compose->orig_account;
                else if (cur_account && cur_account->protocol != A_NNTP)
                        mailac = cur_account;
                else if (!(mailac = compose_current_mail_account())) {
@@ -3323,10 +3514,10 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                }
        }
 
-       if(compose->newsgroup_list) {
+       if (compose->newsgroup_list) {
                 if (compose->account->protocol == A_NNTP)
                         newsac = compose->account;
-                else if(!(newsac = compose->orig_account) || (newsac->protocol != A_NNTP)) {
+                else if (!newsac->protocol != A_NNTP) {
                        lock = FALSE;
                        alertpanel_error(_("No account for posting news available!"));
                        return -1;
@@ -3374,7 +3565,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        }
        if (change_file_mode_rw(fp, tmp) < 0) {
                FILE_OP_ERROR(tmp, "chmod");
-               g_warning(_("can't change file mode\n"));
+               g_warning("can't change file mode\n");
        }
 
        /* queueing variables */
@@ -3402,30 +3593,30 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                fprintf(fp, "NSV:\n");
        fprintf(fp, "SSH:\n");
        /* write recepient list */
-       fprintf(fp, "R:");
-       if(compose->to_list) {
-               fprintf(fp, "<%s>", (gchar *)compose->to_list->data);
-               for (cur = compose->to_list->next; cur != NULL; cur = cur->next)
+       if (compose->to_list) {
+               fprintf(fp, "R:<%s>", (gchar *)compose->to_list->data);
+               for (cur = compose->to_list->next; cur != NULL;
+                    cur = cur->next)
                        fprintf(fp, ",<%s>", (gchar *)cur->data);
+               fprintf(fp, "\n");
        }
-       fprintf(fp, "\n");
        /* write newsgroup list */
-       fprintf(fp, "NG:");
-       if(compose->newsgroup_list) {
+       if (compose->newsgroup_list) {
+               fprintf(fp, "NG:");
                fprintf(fp, "%s", (gchar *)compose->newsgroup_list->data);
                for (cur = compose->newsgroup_list->next; cur != NULL; cur = cur->next)
                        fprintf(fp, ",%s", (gchar *)cur->data);
+               fprintf(fp, "\n");
        }
-       fprintf(fp, "\n");
        /* Sylpheed account IDs */
-       if(mailac) {
+       if (mailac) {
                fprintf(fp, "MAID:%d\n", mailac->account_id);
        }
-       if(newsac) {
+       if (newsac) {
                fprintf(fp, "NAID:%d\n", newsac->account_id);
        }
        /* Save copy folder */
-       if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn))) {
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn))) {
                gchar *savefolderid;
                
                savefolderid = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
@@ -3433,7 +3624,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                g_free(savefolderid);
        }
        /* Message-ID of message replying to */
-       if((compose->replyinfo != NULL) && (compose->replyinfo->msgid != NULL)) {
+       if ((compose->replyinfo != NULL) && (compose->replyinfo->msgid != NULL)) {
                gchar *folderid;
                
                folderid = folder_item_get_identifier(compose->replyinfo->folder);
@@ -3466,14 +3657,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
 
        queue = account_get_special_folder(compose->account, F_QUEUE);
        if (!queue) {
-               g_warning(_("can't find queue folder\n"));
+               g_warning("can't find queue folder\n");
                unlink(tmp);
                g_free(tmp);
                return -1;
        }
        folder_item_scan(queue);
        if ((num = folder_item_add_msg(queue, tmp, TRUE)) < 0) {
-               g_warning(_("can't queue the message\n"));
+               g_warning("can't queue the message\n");
                unlink(tmp);
                g_free(tmp);
                return -1;
@@ -3485,15 +3676,9 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
 
        if (compose->mode == COMPOSE_REEDIT) {
                compose_remove_reedit_target(compose);
-               if (compose->targetinfo &&
-                   compose->targetinfo->folder != queue)
-                       folderview_update_item
-                               (compose->targetinfo->folder, TRUE);
        }
 
-       folderview_update_item(queue, TRUE);
-
-       if((msgnum != NULL) && (item != NULL)) {
+       if ((msgnum != NULL) && (item != NULL)) {
                *msgnum = num;
                *item = queue;
        }
@@ -3516,7 +3701,7 @@ static void compose_write_attach(Compose *compose, FILE *fp)
                gchar inbuf[B64_LINE_SIZE], outbuf[B64_BUFFSIZE];
 
                if ((attach_fp = fopen(ainfo->file, "rb")) == NULL) {
-                       g_warning(_("Can't open file %s\n"), ainfo->file);
+                       g_warning("Can't open file %s\n", ainfo->file);
                        continue;
                }
 
@@ -3526,8 +3711,8 @@ static void compose_write_attach(Compose *compose, FILE *fp)
                        fprintf(fp, "Content-Type: %s\n", ainfo->content_type);
                        fprintf(fp, "Content-Disposition: inline\n");
                } else {
-                       conv_encode_header(filename, sizeof(filename),
-                                          ainfo->name, 12);
+                       compose_convert_header(filename, sizeof(filename),
+                                              ainfo->name, 12);
                        fprintf(fp, "Content-Type: %s;\n"
                                    " name=\"%s\"\n",
                                ainfo->content_type, filename);
@@ -3565,6 +3750,9 @@ static void compose_write_attach(Compose *compose, FILE *fp)
                                fputc('\n', fp);
                        }
                        break;
+               default:
+                       debug_print("Tried to write attachment in unsupported encoding type\n");
+                       break;
                }
 
                fclose(attach_fp);
@@ -3575,7 +3763,8 @@ static void compose_write_attach(Compose *compose, FILE *fp)
 
 #define QUOTE_IF_REQUIRED(out, str)                    \
 {                                                      \
-       if (*str != '"' && strchr(str, ',')) {          \
+       if (*str != '"' && (strchr(str, ',')            \
+                       || strchr(str, '.'))) {         \
                gchar *__tmp;                           \
                gint len;                               \
                                                        \
@@ -3622,25 +3811,25 @@ static gint compose_write_headers_from_headerlist(Compose *compose,
                return 0;
        }
 
-       debug_print(_("Writing %s-header\n"), header);
+       debug_print("Writing %s-header\n", header);
 
        header_w_colon = g_strconcat(header, ":", NULL);
        trans_hdr = (prefs_common.trans_hdr ? gettext(header_w_colon) : header_w_colon);
 
        first_address = TRUE;
-       for(list = compose->header_list; list; list = list->next) {
+       for (list = compose->header_list; list; list = list->next) {
                headerentry = ((ComposeHeaderEntry *)list->data);
                headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
 
-               if(!g_strcasecmp(trans_hdr, headerentryname)) {
+               if (!g_strcasecmp(trans_hdr, headerentryname)) {
                        str = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
                        Xstrdup_a(str, str, return -1);
                        g_strstrip(str);
-                       if(str[0] != '\0') {
+                       if (str[0] != '\0') {
                                compose_convert_header
                                        (buf, sizeof(buf), str,
                                        strlen(header) + 2);
-                               if(first_address) {
+                               if (first_address) {
                                        fprintf(fp, "%s: ", header);
                                        first_address = FALSE;
                                } else {
@@ -3650,7 +3839,7 @@ static gint compose_write_headers_from_headerlist(Compose *compose,
                        }
                }
        }
-       if(!first_address) {
+       if (!first_address) {
                fprintf(fp, "\n");
        }
 
@@ -3666,6 +3855,9 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        gchar buf[BUFFSIZE];
        gchar *str;
        gchar *name;
+       GSList *list;
+       gchar *std_headers[] = {"To:", "Cc:", "Bcc:", "Newsgroups:", "Reply-To:", "Followup-To:", NULL};
+
        /* struct utsname utsbuf; */
 
        g_return_val_if_fail(fp != NULL, -1);
@@ -3673,6 +3865,20 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        g_return_val_if_fail(compose->account != NULL, -1);
        g_return_val_if_fail(compose->account->address != NULL, -1);
 
+       /* Save draft infos */
+       if (is_draft) {
+               fprintf(fp, "X-Sylpheed-Account-Id:%d\n", compose->account->account_id);
+               fprintf(fp, "S:%s\n", compose->account->address);
+               if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn))) {
+                       gchar *savefolderid;
+
+                       savefolderid = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
+                       fprintf(fp, "SCF:%s\n", savefolderid);
+                       g_free(savefolderid);
+               }
+               fprintf(fp, "\n");
+       }
+
        /* Date */
        if (compose->account->add_date) {
                get_rfc822_date(buf, sizeof(buf));
@@ -3704,18 +3910,20 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        /* Newsgroups */
        compose_write_headers_from_headerlist(compose, fp, "Newsgroups");
 #if 0 /* NEW COMPOSE GUI */
-       str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
-       if (*str != '\0') {
-               Xstrdup_a(str, str, return -1);
-               g_strstrip(str);
-               remove_space(str);
+       if (compose->use_newsgroups) {
+               str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
                if (*str != '\0') {
-                       compose->newsgroup_list =
-                               newsgroup_list_append(compose->newsgroup_list,
-                                                     str);
-                       compose_convert_header(buf, sizeof(buf), str,
-                                              strlen("Newsgroups: "));
-                       fprintf(fp, "Newsgroups: %s\n", buf);
+                       Xstrdup_a(str, str, return -1);
+                       g_strstrip(str);
+                       remove_space(str);
+                       if (*str != '\0') {
+                               compose->newsgroup_list =
+                                       newsgroup_list_append
+                                               (compose->newsgroup_list, str);
+                               compose_convert_header(buf, sizeof(buf), str,
+                                                      strlen("Newsgroups: "));
+                               fprintf(fp, "Newsgroups: %s\n", buf);
+                       }
                }
        }
 #endif
@@ -3882,7 +4090,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                case PRIORITY_LOWEST: fprintf(fp, "Importance: low\n"
                                                  "X-Priority: 5 (Lowest)\n");
                        break;
-               default: debug_print(_("compose: priority unknown : %d\n"),
+               default: debug_print("compose: priority unknown : %d\n",
                                     compose->priority);
        }
 
@@ -3898,6 +4106,45 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                }
        }
 
+       /* get special headers */
+       for (list = compose->header_list; list; list = list->next) {
+               ComposeHeaderEntry *headerentry;
+               gchar *tmp;
+               gchar *headername;
+               gchar *headername_wcolon;
+               gchar *headername_trans;
+               gchar *headervalue;
+               gchar **string;
+               gboolean standard_header = FALSE;
+
+               headerentry = ((ComposeHeaderEntry *)list->data);
+               
+               tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry)));
+               if (!strstr(tmp, ":")) {
+                       headername_wcolon = g_strconcat(tmp, ":", NULL);
+                       headername = g_strdup(tmp);
+               } else {
+                       headername_wcolon = g_strdup(tmp);
+                       headername = g_strdup(strtok(tmp, ":"));
+               }
+               g_free(tmp);
+               
+               headervalue = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
+               string = std_headers;
+               while (*string != NULL) {
+                       headername_trans = prefs_common.trans_hdr ? gettext(*string) : *string;
+                       if (!strcmp(headername_trans,headername_wcolon))
+                               standard_header = TRUE;
+                       string++;
+               }
+               if (!standard_header && !IS_IN_CUSTOM_HEADER(headername))
+                       fprintf(fp, "%s %s\n", headername_wcolon, headervalue);
+                               
+               g_free(headername);
+               g_free(headername_wcolon);
+               
+       }
+
        /* separator between header and body */
        fputs("\n", fp);
 
@@ -3914,14 +4161,9 @@ static void compose_convert_header(gchar *dest, gint len, gchar *src,
 
        if (len < 1) return;
 
-       remove_return(src);
+       g_strchomp(src);
 
-       if (is_ascii_str(src)) {
-               strncpy2(dest, src, len);
-               dest[len - 1] = '\0';
-               return;
-       } else
-               conv_encode_header(dest, len, src, header_len);
+       conv_encode_header(dest, len, src, header_len);
 }
 
 static void compose_generate_msgid(Compose *compose, gchar *buf, gint len)
@@ -3950,7 +4192,7 @@ static void compose_generate_msgid(Compose *compose, gchar *buf, gint len)
                   lt->tm_min, lt->tm_sec,
                   (guint)random(), addr);
 
-       debug_print(_("generated Message-ID: %s\n"), buf);
+       debug_print("generated Message-ID: %s\n", buf);
 
        g_free(addr);
 }
@@ -3962,8 +4204,9 @@ static void compose_create_header_entry(Compose *compose)
        GtkWidget *combo;
        GtkWidget *entry;
        GList *combo_list = NULL;
-       gchar **string, *header;
+       gchar **string, *header = NULL;
        ComposeHeaderEntry *headerentry;
+       gboolean standard_header = FALSE;
 
        headerentry = g_new0(ComposeHeaderEntry, 1);
 
@@ -3971,17 +4214,26 @@ static void compose_create_header_entry(Compose *compose)
        combo = gtk_combo_new();
        string = headers; 
        while(*string != NULL) {
-           combo_list = g_list_append(combo_list, (prefs_common.trans_hdr ? gettext(*string) : *string));
-           string++;
+               combo_list = g_list_append(combo_list, (prefs_common.trans_hdr ? gettext(*string) : *string));
+               string++;
        }
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), combo_list);
        g_list_free(combo_list);
-       gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry), FALSE);
+       gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry), TRUE);
        gtk_widget_show(combo);
        gtk_table_attach(GTK_TABLE(compose->header_table), combo, 0, 1, compose->header_nextrow, compose->header_nextrow+1, GTK_SHRINK, GTK_FILL, 0, 0);
-       if(compose->header_last) {      
-               header = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
-       } else {
+       if (compose->header_last) {     
+               gchar *last_header_entry = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
+               string = headers;
+               while (*string != NULL) {
+                       if (!strcmp(*string, last_header_entry))
+                               standard_header = TRUE;
+                       string++;
+               }
+               if (standard_header)
+                       header = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
+       }
+       if (!compose->header_last || !standard_header) {
                switch(compose->account->protocol) {
                        case A_NNTP:
                                header = prefs_common.trans_hdr ? _("Newsgroups:") : "Newsgroups:";
@@ -3991,7 +4243,8 @@ static void compose_create_header_entry(Compose *compose)
                                break;
                }                                                                   
        }
-       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), header);
+       if (header)
+               gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), header);
 
        /* Entry field */
        entry = gtk_entry_new(); 
@@ -4201,7 +4454,7 @@ GtkWidget *compose_create_attach(Compose *compose)
        /* drag and drop */
        gtk_drag_dest_set(attach_clist,
                          GTK_DEST_DEFAULT_ALL, compose_mime_types, 1,
-                         GDK_ACTION_COPY);
+                         GDK_ACTION_COPY | GDK_ACTION_MOVE);
        gtk_signal_connect(GTK_OBJECT(attach_clist), "drag_data_received",
                           GTK_SIGNAL_FUNC(compose_attach_drag_received_cb),
                           compose);
@@ -4235,7 +4488,7 @@ static GtkWidget *compose_create_others(Compose *compose)
        savemsg_checkbtn = gtk_check_button_new_with_label(_("Save Message to "));
        gtk_widget_show(savemsg_checkbtn);
        gtk_table_attach(GTK_TABLE(table), savemsg_checkbtn, 0, 1, rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
-       if(account_get_special_folder(compose->account, F_OUTBOX)) {
+       if (account_get_special_folder(compose->account, F_OUTBOX)) {
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(savemsg_checkbtn), prefs_common.savemsg);
        }
        gtk_signal_connect(GTK_OBJECT(savemsg_checkbtn), "toggled",
@@ -4245,7 +4498,7 @@ static GtkWidget *compose_create_others(Compose *compose)
        gtk_widget_show(savemsg_entry);
        gtk_table_attach_defaults(GTK_TABLE(table), savemsg_entry, 1, 2, rowcount, rowcount + 1);
        gtk_editable_set_editable(GTK_EDITABLE(savemsg_entry), prefs_common.savemsg);
-       if(account_get_special_folder(compose->account, F_OUTBOX)) {
+       if (account_get_special_folder(compose->account, F_OUTBOX)) {
                folderidentifier = folder_item_get_identifier(account_get_special_folder
                                  (compose->account, F_OUTBOX));
                gtk_entry_set_text(GTK_ENTRY(savemsg_entry), folderidentifier);
@@ -4320,23 +4573,21 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
        GdkColormap *cmap;
        GdkColor color[1];
        gboolean success[1];
-       GdkFont   *font;
        GtkWidget *popupmenu;
-       GtkWidget *menuitem;
        GtkItemFactory *popupfactory;
        GtkItemFactory *ifactory;
        GtkWidget *tmpl_menu;
        gint n_entries;
 
-#if USE_PSPELL
-        GtkPspell * gtkpspell = NULL;
+#if USE_ASPELL
+        GtkAspell * gtkaspell = NULL;
 #endif
 
        static GdkGeometry geometry;
 
        g_return_val_if_fail(account != NULL, NULL);
 
-       debug_print(_("Creating compose window...\n"));
+       debug_print("Creating compose window...\n");
        compose = g_new0(Compose, 1);
 
        titles[COL_MIMETYPE] = _("MIME type");
@@ -4344,7 +4595,6 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
        titles[COL_NAME]     = _("Name");
 
        compose->account = account;
-       compose->orig_account = account;
 
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
@@ -4378,7 +4628,8 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
        handlebox = gtk_handle_box_new();
        gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
 
-       compose_toolbar_create(compose, handlebox);
+       compose->toolbar = toolbar_create(TOOLBAR_COMPOSE, handlebox,
+                                         (gpointer)compose);
 
        vbox2 = gtk_vbox_new(FALSE, 2);
        gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0);
@@ -4484,7 +4735,7 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
 
        /* drag and drop */
        gtk_drag_dest_set(text, GTK_DEST_DEFAULT_ALL, compose_mime_types, 1,
-                         GDK_ACTION_COPY);
+                         GDK_ACTION_COPY | GDK_ACTION_MOVE);
        gtk_signal_connect(GTK_OBJECT(text), "drag_data_received",
                           GTK_SIGNAL_FUNC(compose_insert_drag_received_cb),
                           compose);
@@ -4513,16 +4764,9 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
                new_style = gtk_style_copy(style);
 
        if (prefs_common.textfont) {
-               if (MB_CUR_MAX == 1) {
-                       gchar *fontstr, *p;
+               GdkFont *font;
 
-                       Xstrdup_a(fontstr, prefs_common.textfont, );
-                       if (fontstr && (p = strchr(fontstr, ',')) != NULL)
-                               *p = '\0';
-                       font = gdk_font_load(fontstr);
-               } else
-                       font = gdk_fontset_load(prefs_common.textfont);
-               if (font) {
+               if ((font = gtkut_font_load(prefs_common.textfont)) != NULL) {
                        gdk_font_unref(new_style->font);
                        new_style->font = font;
                }
@@ -4573,7 +4817,6 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
                gtk_widget_hide(newsgroups_hbox);
                gtk_widget_hide(newsgroups_entry);
                gtk_table_set_row_spacing(GTK_TABLE(table), 2, 0);
-               menu_set_sensitive(ifactory, "/View/Followup to", FALSE);
        }
 #endif
 
@@ -4584,8 +4827,6 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
        undo_set_change_state_func(undostruct, &compose_undo_state_changed,
                                   menubar);
 
-       gtk_widget_show(window);
-
        address_completion_start(window);
 
        compose->window        = window;
@@ -4616,10 +4857,12 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
        compose->replyinfo  = NULL;
 
        compose->replyto     = NULL;
-       compose->mailinglist = NULL;
        compose->cc          = NULL;
        compose->bcc         = NULL;
        compose->followup_to = NULL;
+
+       compose->ml_post     = NULL;
+
        compose->inreplyto   = NULL;
        compose->references  = NULL;
        compose->msgid       = NULL;
@@ -4645,272 +4888,88 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
 
        compose->redirect_filename = NULL;
        compose->undostruct = undostruct;
-#if USE_PSPELL
-       
+#if USE_ASPELL
        menu_set_sensitive(ifactory, "/Spelling", FALSE);
-        if (prefs_common.enable_pspell) {
-               gtkpspell = gtkpspell_new((const gchar*)prefs_common.dictionary,
-                                         conv_get_current_charset_str(),
-                                         prefs_common.misspelled_col,
-                                         prefs_common.check_while_typing,
-                                         prefs_common.use_alternate,
-                                         GTK_STEXT(text));
-               if (!gtkpspell) {
-                       alertpanel_error(_("Spell checker could not be started.\n%s"), gtkpspellcheckers->error_message);
-                       gtkpspell_checkers_reset_error();
-               } else {
+       if (mode != COMPOSE_REDIRECT) {
+               if (prefs_common.enable_aspell && prefs_common.dictionary &&
+                   strcmp(prefs_common.dictionary, _("None"))) {
+                       gtkaspell = gtkaspell_new((const gchar*)prefs_common.dictionary,
+                                                 conv_get_current_charset_str(),
+                                                 prefs_common.misspelled_col,
+                                                 prefs_common.check_while_typing,
+                                                 prefs_common.use_alternate,
+                                                 GTK_STEXT(text));
+                       if (!gtkaspell) {
+                               alertpanel_error(_("Spell checker could not be started.\n%s"), gtkaspellcheckers->error_message);
+                               gtkaspell_checkers_reset_error();
+                       } else {
 
-                       GtkWidget *menuitem;
+                               GtkWidget *menuitem;
 
-                       if (!gtkpspell_set_sug_mode(gtkpspell, prefs_common.pspell_sugmode)) {
-                               debug_print(_("Pspell: could not set suggestion mode %s\n"),
-                                   gtkpspellcheckers->error_message);
-                               gtkpspell_checkers_reset_error();
-                       }
+                               if (!gtkaspell_set_sug_mode(gtkaspell, prefs_common.aspell_sugmode)) {
+                                       debug_print("Aspell: could not set suggestion mode %s\n",
+                                       gtkaspellcheckers->error_message);
+                                       gtkaspell_checkers_reset_error();
+                               }
 
-                       menuitem = gtk_item_factory_get_item(ifactory, "/Spelling/Spelling Configuration");
-                       gtkpspell_populate_submenu(gtkpspell, menuitem);
-                       menu_set_sensitive(ifactory, "/Spelling", TRUE);
-                       }
-        }
+                               menuitem = gtk_item_factory_get_item(ifactory, "/Spelling/Spelling Configuration");
+                               gtkaspell_populate_submenu(gtkaspell, menuitem);
+                               menu_set_sensitive(ifactory, "/Spelling", TRUE);
+                               }
+               }
+       }
 #endif
 
-       compose_set_title(compose);
-
-#if 0 /* NEW COMPOSE GUI */
-       compose->use_bcc        = FALSE;
-       compose->use_replyto    = FALSE;
-       compose->use_followupto = FALSE;
-#endif
+       compose_select_account(compose, account);
 
-#if USE_PSPELL
-        compose->gtkpspell      = gtkpspell;
+#if USE_ASPELL
+        compose->gtkaspell      = gtkaspell;
 #endif
 
-#if 0 /* NEW COMPOSE GUI */
-       if (account->protocol != A_NNTP) {
-               menuitem = gtk_item_factory_get_item(ifactory, "/View/To");
-               gtk_check_menu_item_set_active
-                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-               gtk_widget_set_sensitive(menuitem, FALSE);
-               menuitem = gtk_item_factory_get_item(ifactory, "/View/Cc");
-               gtk_check_menu_item_set_active
-                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-               gtk_widget_set_sensitive(menuitem, FALSE);
-       }
-#endif
-       if (account->set_autocc && account->auto_cc && mode != COMPOSE_REEDIT) {
+       if (account->set_autocc && account->auto_cc && mode != COMPOSE_REEDIT)
                compose_entry_append(compose, account->auto_cc, COMPOSE_CC);
-#if 0 /* NEW COMPOSE GUI */
-               compose->use_cc = TRUE;
-               gtk_entry_set_text(GTK_ENTRY(cc_entry), account->auto_cc);
-               menuitem = gtk_item_factory_get_item(ifactory, "/View/Cc");
-               gtk_check_menu_item_set_active
-                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-#endif
-       }
-       if (account->set_autobcc) {
+
+       if (account->set_autobcc) 
                compose_entry_append(compose, account->auto_bcc, COMPOSE_BCC);
-#if 0 /* NEW COMPOSE GUI */
-               menuitem = gtk_item_factory_get_item(ifactory, "/View/Bcc");
-               gtk_check_menu_item_set_active
-                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-               if (account->auto_bcc && mode != COMPOSE_REEDIT)
-                       gtk_entry_set_text(GTK_ENTRY(bcc_entry),
-                                          account->auto_bcc);
-#endif
-       }
-       if (account->set_autoreplyto && account->auto_replyto && mode != COMPOSE_REEDIT) {
+       
+       if (account->set_autoreplyto && account->auto_replyto && mode != COMPOSE_REEDIT)
                compose_entry_append(compose, account->auto_replyto, COMPOSE_REPLYTO);
-#if 0 /* NEW COMPOSE GUI */
-               compose->use_replyto = TRUE;
-               menuitem = gtk_item_factory_get_item(ifactory,
-                                                    "/View/Reply to");
-               gtk_check_menu_item_set_active
-                       (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-               gtk_entry_set_text(GTK_ENTRY(reply_entry),
-                                  account->auto_replyto);
-#endif
-       }
 
-       if (account->protocol != A_NNTP) {
+
+       if (account->protocol != A_NNTP)
                gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry), prefs_common.trans_hdr ? _("To:") : "To:");
-       } else {
+       else
                gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry), prefs_common.trans_hdr ? _("Newsgroups:") : "Newsgroups:");
-       }
-
-#if 0 /* NEW COMPOSE GUI */
-       menuitem = gtk_item_factory_get_item(ifactory, "/View/Ruler");
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
-                                      prefs_common.show_ruler);
-#endif                                
-
-#if USE_GPGME
-       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Sign");
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
-                                      account->default_sign);
-       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Encrypt");
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
-                                      account->default_encrypt);
-#endif /* USE_GPGME */
 
        addressbook_set_target_compose(compose);
-       compose_set_template_menu(compose);
+       update_compose_actions_menu(ifactory, "/Tools/Actions", compose);
+       
+       if (mode != COMPOSE_REDIRECT)
+               compose_set_template_menu(compose);
+       else {
+               GtkWidget *menuitem;
+               menuitem = gtk_item_factory_get_item(ifactory, "/Tools/Template");
+               menu_set_sensitive(ifactory, "/Tools/Template", FALSE);
+       }
 
        compose_list = g_list_append(compose_list, compose);
 
-#if 0 /* NEW COMPOSE GUI */
-       compose->use_to         = FALSE;
-       compose->use_cc         = FALSE;
-       compose->use_attach     = TRUE;
-#endif
-
-#if 0 /* NEW COMPOSE GUI */
-       if (!compose->use_bcc) {
-               gtk_widget_hide(bcc_hbox);
-               gtk_widget_hide(bcc_entry);
-               gtk_table_set_row_spacing(GTK_TABLE(table), 4, 0);
-       }
-       if (!compose->use_replyto) {
-               gtk_widget_hide(reply_hbox);
-               gtk_widget_hide(reply_entry);
-               gtk_table_set_row_spacing(GTK_TABLE(table), 5, 0);
-       }
-       if (!compose->use_followupto) {
-               gtk_widget_hide(followup_hbox);
-               gtk_widget_hide(followup_entry);
-               gtk_table_set_row_spacing(GTK_TABLE(table), 6, 0);
-       }
-#endif
        if (!prefs_common.show_ruler)
                gtk_widget_hide(ruler_hbox);
 
        /* Priority */
        compose->priority = PRIORITY_NORMAL;
        compose_update_priority_menu_item(compose);
-
-       select_account(compose, account);
-       set_toolbar_style(compose);
-
+       
+#if USE_GPGME
+       activate_gnupg_mode(compose, account);
+#endif 
+       toolbar_set_style(compose->toolbar->toolbar, compose->handlebox, prefs_common.toolbar_style);
+       gtk_widget_show(window);
+       
        return compose;
 }
 
-static void compose_toolbar_create(Compose *compose, GtkWidget *container)
-{
-       GtkWidget *toolbar;
-       GtkWidget *icon_wid;
-       GtkWidget *send_btn;
-       GtkWidget *sendl_btn;
-       GtkWidget *draft_btn;
-       GtkWidget *insert_btn;
-       GtkWidget *attach_btn;
-       GtkWidget *sig_btn;
-       GtkWidget *exteditor_btn;
-       GtkWidget *linewrap_btn;
-       GtkWidget *addrbook_btn;
-
-       toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
-                                 GTK_TOOLBAR_BOTH);
-       gtk_container_add(GTK_CONTAINER(container), toolbar);
-       gtk_container_set_border_width(GTK_CONTAINER(container), 2);
-       gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
-       gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
-                                   GTK_TOOLBAR_SPACE_LINE);
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
-       send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                          _("Send"),
-                                          _("Send message"),
-                                          "Send",
-                                          icon_wid, toolbar_send_cb, compose);
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND_QUEUE);
-       sendl_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                          _("Send later"),
-                                          _("Put into queue folder and send later"),
-                                          "Send later",
-                                          icon_wid, toolbar_send_later_cb,
-                                          compose);
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL);
-       draft_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                           _("Draft"),
-                                           _("Save to draft folder"),
-                                           "Draft",
-                                           icon_wid, toolbar_draft_cb,
-                                           compose);
-
-       gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_INSERT_FILE);
-       insert_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                            _("Insert"),
-                                            _("Insert file"),
-                                            "Insert",
-                                            icon_wid, toolbar_insert_cb,
-                                            compose);
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_ATTACH);
-       attach_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                            _("Attach"),
-                                            _("Attach file"),
-                                            "Attach",
-                                            icon_wid, toolbar_attach_cb,
-                                            compose);
-
-       gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SIGN);
-       sig_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                         _("Signature"),
-                                         _("Insert signature"),
-                                         "Signature",
-                                         icon_wid, toolbar_sig_cb, compose);
-
-       gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EDIT_EXTERN);
-       exteditor_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                               _("Editor"),
-                                               _("Edit with external editor"),
-                                               "Editor",
-                                               icon_wid,
-                                               toolbar_ext_editor_cb,
-                                               compose);
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_LINEWRAP);
-       linewrap_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                              _("Linewrap"),
-                                              _("Wrap all long lines"),
-                                              "Linewrap",
-                                              icon_wid,
-                                              toolbar_linewrap_cb,
-                                              compose);
-
-       gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
-
-       icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_ADDRESS_BOOK);
-       addrbook_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                              _("Address"),
-                                              _("Address book"),
-                                              "Address",
-                                              icon_wid, toolbar_address_cb,
-                                              compose);
-
-       compose->toolbar       = toolbar;
-       compose->send_btn      = send_btn;
-       compose->sendl_btn     = sendl_btn;
-       compose->draft_btn     = draft_btn;
-       compose->insert_btn    = insert_btn;
-       compose->attach_btn    = attach_btn;
-       compose->sig_btn       = sig_btn;
-       compose->exteditor_btn = exteditor_btn;
-       compose->linewrap_btn  = linewrap_btn;
-       compose->addrbook_btn  = addrbook_btn;
-
-       gtk_widget_show_all(toolbar);
-}
-
 static GtkWidget *compose_account_option_menu_create(Compose *compose)
 {
        GList *accounts;
@@ -4941,7 +5000,7 @@ static GtkWidget *compose_account_option_menu_create(Compose *compose)
                else
                        name = g_strdup_printf("%s: %s",
                                               ac->account_name, ac->address);
-               MENUITEM_ADD(menu, menuitem, name, ac);
+               MENUITEM_ADD(menu, menuitem, name, ac->account_id);
                g_free(name);
                gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
                                   GTK_SIGNAL_FUNC(account_activated),
@@ -4993,6 +5052,41 @@ static void compose_update_priority_menu_item(Compose * compose)
        }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
 }      
+
+#if USE_GPGME 
+static void compose_set_gnupg_mode_cb(gpointer data,
+                                   guint action,
+                                   GtkWidget *widget)
+{
+       Compose *compose = (Compose *) data;
+       compose->gnupg_mode = action;
+}
+
+static void compose_update_gnupg_mode_menu_item(Compose * compose)
+{
+       GtkItemFactory *ifactory;
+       GtkWidget *menuitem = NULL;
+
+       ifactory = gtk_item_factory_from_widget(compose->menubar);
+       
+       switch (compose->gnupg_mode) {
+               case GNUPG_MODE_DETACH:
+                       menuitem = gtk_item_factory_get_item
+                               (ifactory, "/Message/Mode/MIME");
+                       break;
+               case GNUPG_MODE_INLINE:
+                       menuitem = gtk_item_factory_get_item
+                               (ifactory, "/Message/Mode/Inline");
+                       break;
+       }
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+       
+       if (compose->use_encryption == TRUE || compose->use_signing == TRUE)
+               menu_set_sensitive(ifactory, "/Message/Mode", TRUE);
+       else 
+               menu_set_sensitive(ifactory, "/Message/Mode", FALSE);
+}      
+#endif
  
 static void compose_set_template_menu(Compose *compose)
 {
@@ -5038,10 +5132,7 @@ void compose_reflect_prefs_pixmap_theme(void)
 
        for (cur = compose_list; cur != NULL; cur = cur->next) {
                compose = (Compose *)cur->data;
-               gtk_container_remove(GTK_CONTAINER(compose->handlebox), GTK_WIDGET(compose->toolbar));
-               compose->toolbar = NULL;
-               compose_toolbar_create(compose, compose->handlebox);
-               set_toolbar_style(compose);
+               toolbar_update(TOOLBAR_COMPOSE, compose);
        }
 }
 
@@ -5060,6 +5151,11 @@ static void compose_template_apply(Compose *compose, Template *tmpl,
                                   tmpl->subject);
        if (tmpl->to && *tmpl->to != '\0')
                compose_entry_append(compose, tmpl->to, COMPOSE_TO);
+       if (tmpl->cc && *tmpl->cc != '\0')
+               compose_entry_append(compose, tmpl->cc, COMPOSE_CC);
+
+       if (tmpl->bcc && *tmpl->bcc != '\0')
+               compose_entry_append(compose, tmpl->bcc, COMPOSE_BCC);
 
        if (replace)
                gtk_stext_clear(GTK_STEXT(compose->text));
@@ -5117,6 +5213,8 @@ static void compose_destroy(Compose *compose)
        g_free(compose->newsgroups);
        g_free(compose->followup_to);
 
+       g_free(compose->ml_post);
+
        g_free(compose->inreplyto);
        g_free(compose->references);
        g_free(compose->msgid);
@@ -5134,9 +5232,9 @@ static void compose_destroy(Compose *compose)
        if (addressbook_get_target_compose() == compose)
                addressbook_set_target_compose(NULL);
 
-#if USE_PSPELL
-        if (compose->gtkpspell) {
-               gtkpspell_delete(compose->gtkpspell);
+#if USE_ASPELL
+        if (compose->gtkaspell) {
+               gtkaspell_delete(compose->gtkaspell);
         }
 #endif
 
@@ -5145,6 +5243,8 @@ static void compose_destroy(Compose *compose)
 
        gtk_widget_destroy(compose->paned);
 
+       toolbar_destroy(compose->toolbar);
+       g_free(compose->toolbar);
        g_free(compose);
 
        compose_list = g_list_remove(compose_list, compose);
@@ -5205,9 +5305,11 @@ static void compose_attach_property(Compose *compose)
 
        optmenu = GTK_OPTION_MENU(attach_prop.encoding_optmenu);
        if (ainfo->encoding == ENC_UNKNOWN)
-               gtk_option_menu_set_history(optmenu, ENC_BASE64);
+               menu_select_by_data(gtk_option_menu_get_menu(optmenu),
+                                   GINT_TO_POINTER(ENC_BASE64));
        else
-               gtk_option_menu_set_history(optmenu, ainfo->encoding);
+               menu_select_by_data(gtk_option_menu_get_menu(optmenu),
+                                   GINT_TO_POINTER(ainfo->encoding));
 
        gtk_entry_set_text(GTK_ENTRY(attach_prop.mimetype_entry),
                           ainfo->content_type ? ainfo->content_type : "");
@@ -5462,20 +5564,22 @@ static void attach_property_key_pressed(GtkWidget *widget, GdkEventKey *event,
 
 static void compose_exec_ext_editor(Compose *compose)
 {
-       gchar tmp[64];
+       gchar *tmp;
        pid_t pid;
        gint pipe_fds[2];
 
-       g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.%08x",
-                  g_get_tmp_dir(), G_DIR_SEPARATOR, (gint)compose);
+       tmp = g_strdup_printf("%s%ctmpmsg.%08x", get_tmp_dir(),
+                             G_DIR_SEPARATOR, (gint)compose);
 
        if (pipe(pipe_fds) < 0) {
                perror("pipe");
+               g_free(tmp);
                return;
        }
 
        if ((pid = fork()) < 0) {
                perror("fork");
+               g_free(tmp);
                return;
        }
 
@@ -5520,6 +5624,8 @@ static void compose_exec_ext_editor(Compose *compose)
                close(pipe_fds[1]);
                _exit(0);
        }
+
+       g_free(tmp);
 }
 
 static gint compose_exec_ext_editor_real(const gchar *file)
@@ -5550,7 +5656,7 @@ static gint compose_exec_ext_editor_real(const gchar *file)
                g_snprintf(buf, sizeof(buf), prefs_common.ext_editor_cmd, file);
        } else {
                if (prefs_common.ext_editor_cmd)
-                       g_warning(_("External editor command line is invalid: `%s'\n"),
+                       g_warning("External editor command line is invalid: `%s'\n",
                                  prefs_common.ext_editor_cmd);
                g_snprintf(buf, sizeof(buf), def_cmd, file);
        }
@@ -5589,8 +5695,8 @@ static gboolean compose_ext_editor_kill(Compose *compose)
                        if (kill(pgid, SIGTERM) < 0) perror("kill");
                        waitpid(compose->exteditor_pid, NULL, 0);
 
-                       g_warning(_("Terminated process group id: %d"), -pgid);
-                       g_warning(_("Temporary file: %s"),
+                       g_warning("Terminated process group id: %d", -pgid);
+                       g_warning("Temporary file: %s",
                                  compose->exteditor_file);
 
                        compose_set_ext_editor_sensitive(compose, TRUE);
@@ -5614,7 +5720,7 @@ static void compose_input_cb(gpointer data, gint source,
        Compose *compose = (Compose *)data;
        gint i = 0;
 
-       debug_print(_("Compose: input from monitoring process\n"));
+       debug_print("Compose: input from monitoring process\n");
 
        gdk_input_remove(compose->exteditor_tag);
 
@@ -5647,13 +5753,13 @@ static void compose_input_cb(gpointer data, gint source,
                if (unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
        } else if (buf[0] == '1') {     /* failed */
-               g_warning(_("Couldn't exec external editor\n"));
+               g_warning("Couldn't exec external editor\n");
                if (unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
        } else if (buf[0] == '2') {
-               g_warning(_("Couldn't write to file\n"));
+               g_warning("Couldn't write to file\n");
        } else if (buf[0] == '3') {
-               g_warning(_("Pipe read failed\n"));
+               g_warning("Pipe read failed\n");
        }
 
        close(source);
@@ -5685,14 +5791,14 @@ static void compose_set_ext_editor_sensitive(Compose *compose,
        menu_set_sensitive(ifactory, "/Edit/Edit with external editor",
                           sensitive);
 
-       gtk_widget_set_sensitive(compose->text,          sensitive);
-       gtk_widget_set_sensitive(compose->send_btn,      sensitive);
-       gtk_widget_set_sensitive(compose->sendl_btn,     sensitive);
-       gtk_widget_set_sensitive(compose->draft_btn,     sensitive);
-       gtk_widget_set_sensitive(compose->insert_btn,    sensitive);
-       gtk_widget_set_sensitive(compose->sig_btn,       sensitive);
-       gtk_widget_set_sensitive(compose->exteditor_btn, sensitive);
-       gtk_widget_set_sensitive(compose->linewrap_btn,  sensitive);
+       gtk_widget_set_sensitive(compose->text,                   sensitive);
+       gtk_widget_set_sensitive(compose->toolbar->send_btn,      sensitive);
+       gtk_widget_set_sensitive(compose->toolbar->sendl_btn,     sensitive);
+       gtk_widget_set_sensitive(compose->toolbar->draft_btn,     sensitive);
+       gtk_widget_set_sensitive(compose->toolbar->insert_btn,    sensitive);
+       gtk_widget_set_sensitive(compose->toolbar->sig_btn,       sensitive);
+       gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, sensitive);
+       gtk_widget_set_sensitive(compose->toolbar->linewrap_btn,  sensitive);
 }
 
 /**
@@ -5803,174 +5909,18 @@ static gboolean compose_edit_size_alloc(GtkEditable *widget,
        return TRUE;
 }
 
-static void toolbar_send_cb(GtkWidget *widget, gpointer data)
-{
-       compose_send_cb(data, 0, NULL);
-}
-
-static void toolbar_send_later_cb(GtkWidget *widget, gpointer data)
-{
-       compose_send_later_cb(data, 0, NULL);
-}
-
-static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
-{
-       compose_draft_cb(data, 0, NULL);
-}
-
-static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
-{
-       compose_insert_file_cb(data, 0, NULL);
-}
-
-static void toolbar_attach_cb(GtkWidget *widget, gpointer data)
-{
-       compose_attach_cb(data, 0, NULL);
-}
-
-static void toolbar_sig_cb(GtkWidget *widget, gpointer data)
-{
-       Compose *compose = (Compose *)data;
-
-       compose_insert_sig(compose);
-}
-
-static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
-{
-       Compose *compose = (Compose *)data;
-
-       compose_exec_ext_editor(compose);
-}
-
-static void toolbar_linewrap_cb(GtkWidget *widget, gpointer data)
-{
-       Compose *compose = (Compose *)data;
-
-       compose_wrap_line(compose);
-}
-
-static void toolbar_address_cb(GtkWidget *widget, gpointer data)
-{
-       compose_address_cb(data, 0, NULL);
-}
-
-static void select_account(Compose * compose, PrefsAccount * ac)
-{
-#if USE_GPGME
-       GtkItemFactory *ifactory;
-       GtkWidget *menuitem;
-#endif /* USE_GPGME */
-       compose->account = ac;
-       compose_set_title(compose);
-
-#if 0 /* NEW COMPOSE GUI */
-               if (ac->protocol == A_NNTP) {
-                       GtkItemFactory *ifactory;
-                       GtkWidget *menuitem;
-
-                       ifactory = gtk_item_factory_from_widget(compose->menubar);
-                       menu_set_sensitive(ifactory,
-                                          "/Message/Followup to", TRUE);
-                       gtk_widget_show(compose->newsgroups_hbox);
-                       gtk_widget_show(compose->newsgroups_entry);
-                       gtk_table_set_row_spacing(GTK_TABLE(compose->table),
-                                                 1, 4);
-
-                       compose->use_to = FALSE;
-                       compose->use_cc = FALSE;
-
-                       menuitem = gtk_item_factory_get_item(ifactory, "/Message/To");
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
-
-                       menu_set_sensitive(ifactory,
-                                          "/Message/To", TRUE);
-                       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Cc");
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
-
-                       gtk_widget_hide(compose->to_hbox);
-                       gtk_widget_hide(compose->to_entry);
-                       gtk_widget_hide(compose->cc_hbox);
-                       gtk_widget_hide(compose->cc_entry);
-                       gtk_table_set_row_spacing(GTK_TABLE(compose->table),
-                                                 0, 0);
-                       gtk_table_set_row_spacing(GTK_TABLE(compose->table),
-                                                 3, 0);
-               }
-               else {
-                       GtkItemFactory *ifactory;
-                       GtkWidget *menuitem;
-
-                       ifactory = gtk_item_factory_from_widget(compose->menubar);
-                       menu_set_sensitive(ifactory,
-                                          "/Message/Followup to", FALSE);
-                       gtk_entry_set_text(GTK_ENTRY(compose->newsgroups_entry), "");
-                       gtk_widget_hide(compose->newsgroups_hbox);
-                       gtk_widget_hide(compose->newsgroups_entry);
-                       gtk_table_set_row_spacing(GTK_TABLE(compose->table),
-                                                 1, 0);
-
-                       compose->use_to = TRUE;
-                       compose->use_cc = TRUE;
-
-                       menuitem = gtk_item_factory_get_item(ifactory, "/Message/To");
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-                       menu_set_sensitive(ifactory,
-                                          "/Message/To", FALSE);
-                       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Cc");
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-                       gtk_widget_show(compose->to_hbox);
-                       gtk_widget_show(compose->to_entry);
-                       gtk_widget_show(compose->cc_hbox);
-                       gtk_widget_show(compose->cc_entry);
-
-                       gtk_table_set_row_spacing(GTK_TABLE(compose->table),
-                                                 0, 4);
-                       gtk_table_set_row_spacing(GTK_TABLE(compose->table),
-                                                 3, 4);
-               }
-               gtk_widget_queue_resize(compose->table_vbox);
-#endif
-#if USE_GPGME
-               ifactory = gtk_item_factory_from_widget(compose->menubar);
-                       menu_set_sensitive(ifactory,
-                                          "/Message/Sign", TRUE);
-                       menu_set_sensitive(ifactory,
-                                          "/Message/Encrypt", TRUE);
-
-                       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Sign");
-               if (ac->default_sign)
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-               else
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
-
-                       menuitem = gtk_item_factory_get_item(ifactory, "/Message/Encrypt");
-               if (ac->default_encrypt)
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-               else
-                       gtk_check_menu_item_set_active
-                               (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
-#endif /* USE_GPGME */
-
-}
-
 static void account_activated(GtkMenuItem *menuitem, gpointer data)
 {
        Compose *compose = (Compose *)data;
 
        PrefsAccount *ac;
 
-       ac = (PrefsAccount *)gtk_object_get_user_data(GTK_OBJECT(menuitem));
+       ac = account_find_from_id(
+               GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(menuitem))));
        g_return_if_fail(ac != NULL);
 
        if (ac != compose->account)
-               select_account(compose, ac);
+               compose_select_account(compose, ac);
 }
 
 static void attach_selected(GtkCList *clist, gint row, gint column,
@@ -6021,6 +5971,18 @@ static void attach_key_pressed(GtkWidget *widget, GdkEventKey *event,
        }
 }
 
+static void compose_allow_user_actions (Compose *compose, gboolean allow)
+{
+       GtkItemFactory *ifactory = gtk_item_factory_from_widget(compose->menubar);
+       toolbar_comp_set_sensitive(compose, allow);
+       menu_set_sensitive(ifactory, "/File", allow);
+       menu_set_sensitive(ifactory, "/Edit", allow);
+       menu_set_sensitive(ifactory, "/Spelling", allow);
+       menu_set_sensitive(ifactory, "/Message", allow);
+       menu_set_sensitive(ifactory, "/Tools", allow);
+       menu_set_sensitive(ifactory, "/Help", allow);
+}
+
 static void compose_send_cb(gpointer data, guint action, GtkWidget *widget)
 {
        Compose *compose = (Compose *)data;
@@ -6030,9 +5992,13 @@ static void compose_send_cb(gpointer data, guint action, GtkWidget *widget)
                if (alertpanel(_("Offline warning"), 
                               _("You're working offline. Override?"),
                               _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
-               return;
-
+                       return;
+       
+       compose_allow_user_actions (compose, FALSE);
+       compose->sending = TRUE;
        val = compose_send(compose);
+       compose_allow_user_actions (compose, TRUE);
+       compose->sending = FALSE;
 
        if (val == 0) gtk_widget_destroy(compose->window);
 }
@@ -6047,6 +6013,11 @@ static void compose_send_later_cb(gpointer data, guint action,
        if (!val) gtk_widget_destroy(compose->window);
 }
 
+void compose_draft (gpointer data) 
+{
+       compose_draft_cb(data, 0, NULL);        
+}
+
 static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
 {
        Compose *compose = (Compose *)data;
@@ -6063,7 +6034,7 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
 
        lock = TRUE;
 
-       tmp = g_strdup_printf("%s%cdraft.%d", g_get_tmp_dir(),
+       tmp = g_strdup_printf("%s%cdraft.%08x", get_tmp_dir(),
                              G_DIR_SEPARATOR, (gint)compose);
 
        if (compose_write_to_file(compose, tmp, TRUE) < 0) {
@@ -6083,16 +6054,14 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
 
        if (compose->mode == COMPOSE_REEDIT) {
                compose_remove_reedit_target(compose);
-               if (compose->targetinfo &&
-                   compose->targetinfo->folder != draft)
-                       folderview_update_item(compose->targetinfo->folder,
-                                              TRUE);
        }
 
-       newmsginfo = folder_item_fetch_msginfo(draft, msgnum);
-       procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
-       folderview_update_item(draft, TRUE);
-       procmsg_msginfo_free(newmsginfo);
+       newmsginfo = folder_item_get_msginfo(draft, msgnum);
+       if (newmsginfo) {
+               procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
+               procmsg_msginfo_set_flags(newmsginfo, 0, MSG_DRAFT);
+               procmsg_msginfo_free(newmsginfo);
+       }
        
        lock = FALSE;
 
@@ -6169,7 +6138,10 @@ static void compose_insert_file_cb(gpointer data, guint action,
 static gint compose_delete_cb(GtkWidget *widget, GdkEventAny *event,
                              gpointer data)
 {
-       compose_close_cb(data, 0, NULL);
+       Compose *compose = (Compose *)data;
+       if (compose->sending)
+               return TRUE;
+       compose_close_cb(compose, 0, NULL);
        return TRUE;
 }
 
@@ -6177,7 +6149,7 @@ static void compose_close_cb(gpointer data, guint action, GtkWidget *widget)
 {
        Compose *compose = (Compose *)data;
        AlertValue val;
-
+       
        if (compose->exteditor_tag != -1) {
                if (!compose_ext_editor_kill(compose))
                        return;
@@ -6190,6 +6162,8 @@ static void compose_close_cb(gpointer data, guint action, GtkWidget *widget)
 
                switch (val) {
                case G_ALERTDEFAULT:
+                       if (prefs_common.autosave)
+                               compose_remove_draft(compose);                  
                        break;
                case G_ALERTALTERNATE:
                        compose_draft_cb(data, 0, NULL);
@@ -6198,6 +6172,7 @@ static void compose_close_cb(gpointer data, guint action, GtkWidget *widget)
                        return;
                }
        }
+
        gtk_widget_destroy(compose->window);
 }
 
@@ -6240,6 +6215,8 @@ static void compose_ext_editor_cb(gpointer data, guint action,
 
 static void compose_destroy_cb(GtkWidget *widget, Compose *compose)
 {
+       if (compose->sending)
+               return;
        compose_destroy(compose);
 }
 
@@ -6296,60 +6273,35 @@ static void compose_allsel_cb(Compose *compose)
                        (GTK_EDITABLE(compose->focused_editable), 0, -1);
 }
 
-static void compose_gtk_stext_action_cb(Compose *compose, ComposeCallGtkSTextAction action)
+static void compose_gtk_stext_action_cb(Compose *compose,
+                                       ComposeCallGtkSTextAction action)
 {
-       if (!(compose->focused_editable && GTK_WIDGET_HAS_FOCUS(compose->focused_editable))) return;
-               
-       switch (action) {
-               case COMPOSE_CALL_GTK_STEXT_MOVE_BEGINNING_OF_LINE:
-                       gtk_stext_move_beginning_of_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_CHARACTER:
-                       gtk_stext_move_forward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_CHARACTER:
-                       gtk_stext_move_backward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_FORWARD_WORD:
-                       gtk_stext_move_forward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_BACKWARD_WORD:
-                       gtk_stext_move_backward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_END_OF_LINE:
-                       gtk_stext_move_end_of_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_NEXT_LINE:
-                       gtk_stext_move_next_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_MOVE_PREVIOUS_LINE:
-                       gtk_stext_move_previous_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_CHARACTER:
-                       gtk_stext_delete_forward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_CHARACTER:
-                       gtk_stext_delete_backward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_FORWARD_WORD:
-                       gtk_stext_delete_forward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_BACKWARD_WORD:
-                       gtk_stext_delete_backward_word(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_LINE:
-                       gtk_stext_delete_line(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_LINE_N:
-                       gtk_stext_delete_line(GTK_STEXT(compose->focused_editable));
-                       gtk_stext_delete_forward_character(GTK_STEXT(compose->focused_editable));
-                       break;
-               case COMPOSE_CALL_GTK_STEXT_DELETE_TO_LINE_END:
-                       gtk_stext_delete_to_line_end(GTK_STEXT(compose->focused_editable));
-                       break;
-               default:
-                       break;
-       }
+       GtkSText *text = GTK_STEXT(compose->text);
+       static struct {
+               void (*do_action) (GtkSText *text);
+       } action_table[] = {
+               {gtk_stext_move_beginning_of_line},
+               {gtk_stext_move_forward_character},
+               {gtk_stext_move_backward_character},
+               {gtk_stext_move_forward_word},
+               {gtk_stext_move_backward_word},
+               {gtk_stext_move_end_of_line},
+               {gtk_stext_move_next_line},
+               {gtk_stext_move_previous_line},
+               {gtk_stext_delete_forward_character},
+               {gtk_stext_delete_backward_character},
+               {gtk_stext_delete_forward_word},
+               {gtk_stext_delete_backward_word},
+               {gtk_stext_delete_line},
+               {gtk_stext_delete_line}, /* gtk_stext_delete_line_n */
+               {gtk_stext_delete_to_line_end}
+       };
+
+       if (!GTK_WIDGET_HAS_FOCUS(text)) return;
+
+       if (action >= COMPOSE_CALL_GTK_STEXT_MOVE_BEGINNING_OF_LINE &&
+           action <= COMPOSE_CALL_GTK_STEXT_DELETE_TO_LINE_END)
+               action_table[action].do_action(text);
 }
 
 static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
@@ -6534,6 +6486,8 @@ static void compose_toggle_sign_cb(gpointer data, guint action,
                compose->use_signing = TRUE;
        else
                compose->use_signing = FALSE;
+
+       compose_update_gnupg_mode_menu_item(compose);
 }
 
 static void compose_toggle_encrypt_cb(gpointer data, guint action,
@@ -6545,6 +6499,18 @@ static void compose_toggle_encrypt_cb(gpointer data, guint action,
                compose->use_encryption = TRUE;
        else
                compose->use_encryption = FALSE;
+               
+       compose_update_gnupg_mode_menu_item(compose);
+}
+
+static void activate_gnupg_mode (Compose *compose, PrefsAccount *account) 
+{
+       if (account->default_gnupg_mode)
+               compose->gnupg_mode = GNUPG_MODE_INLINE;
+       else
+               compose->gnupg_mode = GNUPG_MODE_DETACH;
+               
+       compose_update_gnupg_mode_menu_item(compose);
 }
 #endif /* USE_GPGME */
 
@@ -6773,12 +6739,17 @@ static void text_inserted(GtkWidget *widget, const gchar *text,
                gtk_editable_insert_text(editable, text, length, position);
 
        if (prefs_common.autowrap)
-               compose_wrap_line_all(compose);
+               compose_wrap_line_all_full(compose, TRUE);
 
        gtk_signal_handler_unblock_by_func(GTK_OBJECT(widget),
                                           GTK_SIGNAL_FUNC(text_inserted),
                                           compose);
        gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
+
+       
+       if (prefs_common.autosave && 
+           gtk_stext_get_length(GTK_STEXT(widget)) % prefs_common.autosave_length == 0)
+               compose_draft_cb((gpointer)compose, 1, NULL);
 }
 
 static gboolean compose_send_control_enter(Compose *compose)
@@ -6803,8 +6774,11 @@ static gboolean compose_send_control_enter(Compose *compose)
        ifactory = gtk_item_factory_from_widget(compose->menubar);
        send_menu = gtk_item_factory_get_widget(ifactory, "/Message/Send");
        list = gtk_accel_group_entries_from_object(GTK_OBJECT(send_menu));
+       if (!list)
+               return FALSE;
+
        accel = (GtkAccelEntry *)list->data;
-       if (accel->accelerator_key == kev->keyval &&
+       if (accel && accel->accelerator_key == kev->keyval &&
            (accel->accelerator_mods & ~ignored_mods) ==
            (kev->state & ~ignored_mods)) {
                compose_send_cb(compose, 0, NULL);
@@ -6814,23 +6788,23 @@ static gboolean compose_send_control_enter(Compose *compose)
        return FALSE;
 }
 
-#if USE_PSPELL
+#if USE_ASPELL
 static void compose_check_all(Compose *compose)
 {
-       if (compose->gtkpspell)
-               gtkpspell_check_all(compose->gtkpspell);
+       if (compose->gtkaspell)
+               gtkaspell_check_all(compose->gtkaspell);
 }
 
 static void compose_highlight_all(Compose *compose)
 {
-       if (compose->gtkpspell)
-               gtkpspell_highlight_all(compose->gtkpspell);
+       if (compose->gtkaspell)
+               gtkaspell_highlight_all(compose->gtkaspell);
 }
 
 static void compose_check_backwards(Compose *compose)
 {
-       if (compose->gtkpspell) 
-               gtkpspell_check_backwards(compose->gtkpspell);
+       if (compose->gtkaspell) 
+               gtkaspell_check_backwards(compose->gtkaspell);
        else {
                GtkItemFactory *ifactory;
                ifactory = gtk_item_factory_from_widget(compose->popupmenu);
@@ -6841,8 +6815,8 @@ static void compose_check_backwards(Compose *compose)
 
 static void compose_check_forwards_go(Compose *compose)
 {
-       if (compose->gtkpspell) 
-               gtkpspell_check_forwards_go(compose->gtkpspell);
+       if (compose->gtkaspell) 
+               gtkaspell_check_forwards_go(compose->gtkaspell);
        else {
                GtkItemFactory *ifactory;
                ifactory = gtk_item_factory_from_widget(compose->popupmenu);
@@ -6852,28 +6826,3 @@ static void compose_check_forwards_go(Compose *compose)
 }
 #endif
 
-static void set_toolbar_style(Compose *compose)
-{
-       switch (prefs_common.toolbar_style) {
-       case TOOLBAR_NONE:
-               gtk_widget_hide(compose->handlebox);
-               break;
-       case TOOLBAR_ICON:
-               gtk_toolbar_set_style(GTK_TOOLBAR(compose->toolbar),
-                                     GTK_TOOLBAR_ICONS);
-               break;
-       case TOOLBAR_TEXT:
-               gtk_toolbar_set_style(GTK_TOOLBAR(compose->toolbar),
-                                     GTK_TOOLBAR_TEXT);
-               break;
-       case TOOLBAR_BOTH:
-               gtk_toolbar_set_style(GTK_TOOLBAR(compose->toolbar),
-                                     GTK_TOOLBAR_BOTH);
-               break;
-       }
-       
-       if (prefs_common.toolbar_style != TOOLBAR_NONE) {
-               gtk_widget_show(compose->handlebox);
-               gtk_widget_queue_resize(compose->handlebox);
-       }
-}