2007-10-07 [colin] 3.0.2cvs24
[claws.git] / src / toolbar.c
index 8c986c0f467631290e169106d073fb2fe7d4ad2b..7694b506cc1851d7c74c05e90f6ab778458c5273 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2003 Hiroyuki Yamamoto and the Sylpheed-Claws team
+ * Copyright (C) 2001-2007 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 /*
@@ -28,6 +28,7 @@
 #include "defs.h"
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <dirent.h>
@@ -35,7 +36,7 @@
 #include <math.h>
 #include <setjmp.h>
 
-#include "intl.h"
+#include "main.h"
 #include "mainwindow.h"
 #include "summaryview.h"
 #include "compose.h"
@@ -55,6 +56,7 @@
 #include "prefs_common.h"
 #include "prefs_toolbar.h"
 #include "alertpanel.h"
+#include "imap.h"
 
 /* elements */
 #define TOOLBAR_TAG_INDEX        "toolbar"
@@ -65,7 +67,7 @@
 #define TOOLBAR_ICON_TEXT   "text"     
 #define TOOLBAR_ICON_ACTION "action"    
 
-gboolean      toolbar_is_duplicate             (gint           action,
+static gboolean      toolbar_is_duplicate              (gint           action,
                                                 ToolbarType    source);
 static void   toolbar_parse_item               (XMLFile        *file,
                                                 ToolbarType    source);
@@ -81,8 +83,6 @@ static void   toolbar_style                   (ToolbarType     type,
                                                 guint           action, 
                                                 gpointer        data);
 
-static GtkWidget *get_window_widget            (ToolbarType     type, 
-                                                gpointer        data);
 static MainWindow *get_mainwin                 (gpointer data);
 static void activate_compose_button            (Toolbar        *toolbar,
                                                 ToolbarStyle    style,
@@ -91,12 +91,19 @@ static void activate_compose_button                 (Toolbar        *toolbar,
 /* toolbar callbacks */
 static void toolbar_reply                      (gpointer        data, 
                                                 guint           action);
+static void toolbar_learn                      (gpointer        data, 
+                                                guint           action);
 static void toolbar_delete_cb                  (GtkWidget      *widget,
                                                 gpointer        data);
+static void toolbar_trash_cb                   (GtkWidget      *widget,
+                                                gpointer        data);
 
 static void toolbar_compose_cb                 (GtkWidget      *widget,
                                                 gpointer        data);
 
+static void toolbar_learn_cb                   (GtkWidget      *widget,
+                                                gpointer        data);
+
 static void toolbar_reply_cb                   (GtkWidget      *widget,
                                                 gpointer        data);
 
@@ -112,12 +119,17 @@ static void toolbar_reply_to_sender_cb            (GtkWidget      *widget,
 static void toolbar_forward_cb                 (GtkWidget      *widget,
                                                 gpointer        data);
 
+static void toolbar_prev_unread_cb             (GtkWidget      *widget,
+                                                gpointer        data);
 static void toolbar_next_unread_cb             (GtkWidget      *widget,
                                                 gpointer        data);
 
 static void toolbar_ignore_thread_cb           (GtkWidget      *widget,
                                                 gpointer        data);
 
+static void toolbar_watch_thread_cb            (GtkWidget      *widget,
+                                                gpointer        data);
+
 static void toolbar_print_cb                   (GtkWidget      *widget,
                                                 gpointer        data);
 
@@ -131,6 +143,10 @@ static void toolbar_send_later_cb          (GtkWidget      *widget,
                                                 gpointer        data);
 static void toolbar_draft_cb                   (GtkWidget      *widget,
                                                 gpointer        data);
+static void toolbar_close_cb                   (GtkWidget      *widget,
+                                                gpointer        data);
+static void toolbar_open_mail_cb               (GtkWidget      *widget,
+                                                gpointer        data);
 static void toolbar_insert_cb                  (GtkWidget      *widget,
                                                 gpointer        data);
 static void toolbar_attach_cb                  (GtkWidget      *widget,
@@ -139,46 +155,62 @@ 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,
+static void toolbar_linewrap_current_cb                (GtkWidget      *widget,
+                                                gpointer        data);
+static void toolbar_linewrap_all_cb            (GtkWidget      *widget,
                                                 gpointer        data);
 static void toolbar_addrbook_cb                (GtkWidget      *widget, 
                                                 gpointer        data);
+#ifdef USE_ASPELL
+static void toolbar_check_spelling_cb                  (GtkWidget      *widget, 
+                                                gpointer        data);
+#endif
+static void toolbar_cancel_inc_cb              (GtkWidget      *widget,
+                                                gpointer        data);
 
-static void toolbar_popup_cb                   (gpointer        data, 
-                                                guint           action, 
-                                                GtkWidget      *widget);
 struct {
        gchar *index_str;
        const gchar *descr;
 } toolbar_text [] = {
-       { "A_RECEIVE_ALL",   N_("Receive Mail on all Accounts")         },
-       { "A_RECEIVE_CUR",   N_("Receive Mail on current Account")      },
-       { "A_SEND_QUEUED",   N_("Send Queued Message(s)")               },
-       { "A_COMPOSE_EMAIL", N_("Compose Email")                        },
-       { "A_COMPOSE_NEWS",  N_("Compose News")                         },
-       { "A_REPLY_MESSAGE", N_("Reply to Message")                     },
-       { "A_REPLY_SENDER",  N_("Reply to Sender")                      },
-       { "A_REPLY_ALL",     N_("Reply to All")                         },
-       { "A_REPLY_ML",      N_("Reply to Mailing-list")                },
-       { "A_FORWARD",       N_("Forward Message")                      }, 
-       { "A_DELETE",        N_("Delete Message")                       },
-       { "A_EXECUTE",       N_("Execute")                              },
-       { "A_GOTO_NEXT",     N_("Goto Next Message")                    },
-       { "A_IGNORE_THREAD", N_("Ignore thread")                        },
-       { "A_PRINT",         N_("Print")                                },
-
-       { "A_SEND",          N_("Send Message")                         },
-       { "A_SENDL",         N_("Put into queue folder and send later") },
-       { "A_DRAFT",         N_("Save to draft folder")                 },
-       { "A_INSERT",        N_("Insert file")                          },   
-       { "A_ATTACH",        N_("Attach file")                          },
-       { "A_SIG",           N_("Insert signature")                     },
-       { "A_EXTEDITOR",     N_("Edit with external editor")            },
-       { "A_LINEWRAP",      N_("Wrap all long lines")                  }, 
-       { "A_ADDRBOOK",      N_("Address book")                         },
-
-       { "A_SYL_ACTIONS",   N_("Sylpheed Actions Feature")             }, 
-       { "A_SEPARATOR",     "Separator"                                }
+       { "A_RECEIVE_ALL",      N_("Receive Mail on all Accounts")         },
+       { "A_RECEIVE_CUR",      N_("Receive Mail on current Account")      },
+       { "A_SEND_QUEUED",      N_("Send Queued Messages")                 },
+       { "A_COMPOSE_EMAIL",    N_("Compose Email")                        },
+       { "A_COMPOSE_NEWS",     N_("Compose News")                         },
+       { "A_REPLY_MESSAGE",    N_("Reply to Message")                     },
+       { "A_REPLY_SENDER",     N_("Reply to Sender")                      },
+       { "A_REPLY_ALL",        N_("Reply to All")                         },
+       { "A_REPLY_ML",         N_("Reply to Mailing-list")                },
+       { "A_OPEN_MAIL",        N_("Open email")                           },
+       { "A_FORWARD",          N_("Forward Message")                      }, 
+       { "A_TRASH",            N_("Trash Message")                        },
+       { "A_DELETE_REAL",      N_("Delete Message")                       },
+       { "A_EXECUTE",          N_("Execute")                              },
+       { "A_GOTO_PREV",        N_("Go to Previous Unread Message")        },
+       { "A_GOTO_NEXT",        N_("Go to Next Unread Message")            },
+       { "A_IGNORE_THREAD",    N_("Ignore thread")                        },
+       { "A_WATCH_THREAD",     N_("Watch thread")                         },
+       { "A_PRINT",            N_("Print")                                },
+       { "A_LEARN_SPAM",       N_("Learn Spam or Ham")                    },
+       { "A_GO_FOLDERS",       N_("Open folder/Go to folder list")        },
+
+       { "A_SEND",             N_("Send Message")                         },
+       { "A_SENDL",            N_("Put into queue folder and send later") },
+       { "A_DRAFT",            N_("Save to draft folder")                 },
+       { "A_INSERT",           N_("Insert file")                          },   
+       { "A_ATTACH",           N_("Attach file")                          },
+       { "A_SIG",              N_("Insert signature")                     },
+       { "A_EXTEDITOR",        N_("Edit with external editor")            },
+       { "A_LINEWRAP_CURRENT", N_("Wrap long lines of current paragraph") }, 
+       { "A_LINEWRAP_ALL",     N_("Wrap all long lines")                  }, 
+       { "A_ADDRBOOK",         N_("Address book")                         },
+#ifdef USE_ASPELL
+       { "A_CHECK_SPELLING",   N_("Check spelling")                       },
+#endif
+       { "A_SYL_ACTIONS",      N_("Claws Mail Actions Feature")           }, 
+       { "A_CANCEL_INC",       N_("Cancel receiving")                     },
+       { "A_CLOSE",            N_("Close window")                         },
+       { "A_SEPARATOR",        "Separator"                             }
 };
 
 /* struct holds configuration files and a list of
@@ -195,30 +227,36 @@ struct {
        { "toolbar_msgview.xml", NULL}
 };
 
-static GtkItemFactoryEntry reply_popup_entries[] =
+static GtkItemFactoryEntry reply_entries[] =
+{
+       {N_("/Reply with _quote"), NULL,    toolbar_reply, COMPOSE_REPLY_WITH_QUOTE, NULL},
+       {N_("/_Reply without quote"), NULL, toolbar_reply, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
+};
+static GtkItemFactoryEntry replyall_entries[] =
 {
-       {N_("/Reply with _quote"), NULL, toolbar_popup_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
-       {N_("/_Reply without quote"), NULL, toolbar_popup_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
+       {N_("/Reply to all with _quote"), "<shift>A", toolbar_reply, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
+       {N_("/_Reply to all without quote"), "a",     toolbar_reply, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
 };
-static GtkItemFactoryEntry replyall_popup_entries[] =
+static GtkItemFactoryEntry replylist_entries[] =
 {
-       {N_("/Reply to all with _quote"), "<shift>A", toolbar_popup_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
-       {N_("/_Reply to all without quote"), "a", toolbar_popup_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
+       {N_("/Reply to list with _quote"),    NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
+       {N_("/_Reply to list without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
 };
-static GtkItemFactoryEntry replylist_popup_entries[] =
+static GtkItemFactoryEntry replysender_entries[] =
 {
-       {N_("/Reply to list with _quote"), NULL, toolbar_popup_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
-       {N_("/_Reply to list without quote"), NULL, toolbar_popup_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
+       {N_("/Reply to sender with _quote"),    NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
+       {N_("/_Reply to sender without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
 };
-static GtkItemFactoryEntry replysender_popup_entries[] =
+static GtkItemFactoryEntry forward_entries[] =
 {
-       {N_("/Reply to sender with _quote"), NULL, toolbar_popup_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
-       {N_("/_Reply to sender without quote"), NULL, toolbar_popup_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
+       {N_("/_Forward"),               "f",        toolbar_reply, COMPOSE_FORWARD_INLINE, NULL},
+       {N_("/For_ward as attachment"), "<shift>F", toolbar_reply, COMPOSE_FORWARD_AS_ATTACH, NULL},
+       {N_("/Redirec_t"),              NULL,       toolbar_reply, COMPOSE_REDIRECT, NULL}
 };
-static GtkItemFactoryEntry fwd_popup_entries[] =
+static GtkItemFactoryEntry learn_entries[] =
 {
-       {N_("/_Forward message (inline style)"), "f", toolbar_popup_cb, COMPOSE_FORWARD_INLINE, NULL},
-       {N_("/Forward message as _attachment"), "<shift>F", toolbar_popup_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
+       {N_("/Learn as _Spam"),         NULL,   toolbar_learn, TRUE, NULL},
+       {N_("/Learn as _Ham"),          NULL,   toolbar_learn, FALSE, NULL}
 };
 
 
@@ -227,7 +265,7 @@ gint toolbar_ret_val_from_descr(const gchar *descr)
        gint i;
 
        for (i = 0; i < N_ACTION_VAL; i++) {
-               if (g_strcasecmp(gettext(toolbar_text[i].descr), descr) == 0)
+               if (g_utf8_collate(gettext(toolbar_text[i].descr), descr) == 0)
                                return i;
        }
        
@@ -246,10 +284,10 @@ static gint toolbar_ret_val_from_text(const gchar *text)
        gint i;
        
        for (i = 0; i < N_ACTION_VAL; i++) {
-               if (g_strcasecmp(toolbar_text[i].index_str, text) == 0)
+               if (g_utf8_collate(toolbar_text[i].index_str, text) == 0)
                                return i;
        }
-       
+
        return -1;
 }
 
@@ -260,7 +298,7 @@ static gchar *toolbar_ret_text_from_val(gint val)
        return toolbar_text[val].index_str;
 }
 
-gboolean toolbar_is_duplicate(gint action, ToolbarType source)
+static gboolean toolbar_is_duplicate(gint action, ToolbarType source)
 {
        GSList *cur;
 
@@ -288,25 +326,25 @@ GList *toolbar_get_action_items(ToolbarType source)
        if (source == TOOLBAR_MAIN) {
                gint main_items[]   = { A_RECEIVE_ALL,   A_RECEIVE_CUR,   A_SEND_QUEUED,
                                        A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER, 
-                                       A_REPLY_ALL,     A_REPLY_ML,      A_FORWARD, 
-                                       A_DELETE,        A_EXECUTE,       A_GOTO_NEXT, 
-                                       A_IGNORE_THREAD, A_PRINT,  
-                                       A_ADDRBOOK,      A_SYL_ACTIONS };
+                                       A_REPLY_ALL,     A_REPLY_ML,      A_OPEN_MAIL,  A_FORWARD, 
+                                       A_TRASH , A_DELETE_REAL,       A_EXECUTE,       A_GOTO_PREV, 
+                                       A_GOTO_NEXT,    A_IGNORE_THREAD,  A_WATCH_THREAD,       A_PRINT,
+                                       A_ADDRBOOK,     A_LEARN_SPAM, A_GO_FOLDERS, 
+                                       A_CANCEL_INC };
 
                for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++)  {
                        items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
-                       if (main_items[i] == A_PRINT) {
-                               g_print("$$$ descr %s, trans %s\n",
-                                       toolbar_text[main_items[i]].descr,
-                                       gettext(toolbar_text[main_items[i]].descr));
-                       }
                }       
        }
        else if (source == TOOLBAR_COMPOSE) {
                gint comp_items[] =   { A_SEND,          A_SENDL,        A_DRAFT,
                                        A_INSERT,        A_ATTACH,       A_SIG,
-                                       A_EXTEDITOR,     A_LINEWRAP,     A_ADDRBOOK,
-                                       A_SYL_ACTIONS };        
+                                       A_EXTEDITOR,     A_LINEWRAP_CURRENT,     
+                                       A_LINEWRAP_ALL,  A_ADDRBOOK,
+#ifdef USE_ASPELL
+                                       A_CHECK_SPELLING, 
+#endif
+                                       A_CLOSE };      
 
                for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++) 
                        items = g_list_append(items, gettext(toolbar_text[comp_items[i]].descr));
@@ -314,8 +352,8 @@ GList *toolbar_get_action_items(ToolbarType source)
        else if (source == TOOLBAR_MSGVIEW) {
                gint msgv_items[] =   { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
                                        A_REPLY_ALL,     A_REPLY_ML,      A_FORWARD,
-                                       A_DELETE,        A_GOTO_NEXT,     A_ADDRBOOK,
-                                       A_SYL_ACTIONS };        
+                                       A_TRASH, A_DELETE_REAL,       A_GOTO_PREV,        A_GOTO_NEXT,
+                                       A_ADDRBOOK,      A_LEARN_SPAM, A_CLOSE };       
 
                for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++) 
                        items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
@@ -329,6 +367,7 @@ static void toolbar_parse_item(XMLFile *file, ToolbarType source)
        GList *attr;
        gchar *name, *value;
        ToolbarItem *item = NULL;
+       gboolean rewrite = FALSE;
 
        attr = xml_get_current_tag_attr(file);
        item = g_new0(ToolbarItem, 1);
@@ -336,13 +375,21 @@ static void toolbar_parse_item(XMLFile *file, ToolbarType source)
                name = ((XMLAttr *)attr->data)->name;
                value = ((XMLAttr *)attr->data)->value;
                
-               if (g_strcasecmp(name, TOOLBAR_ICON_FILE) == 0) 
+               if (g_utf8_collate(name, TOOLBAR_ICON_FILE) == 0) 
                        item->file = g_strdup (value);
-               else if (g_strcasecmp(name, TOOLBAR_ICON_TEXT) == 0)
-                       item->text = g_strdup (value);
-               else if (g_strcasecmp(name, TOOLBAR_ICON_ACTION) == 0)
+               else if (g_utf8_collate(name, TOOLBAR_ICON_TEXT) == 0)
+                       item->text = g_strdup (gettext(value));
+               else if (g_utf8_collate(name, TOOLBAR_ICON_ACTION) == 0)
                        item->index = toolbar_ret_val_from_text(value);
-
+               if (item->index == -1 && !strcmp(value, "A_DELETE")) {
+                       /* switch button */
+                       item->index = A_TRASH;
+                       g_free(item->file);
+                       item->file = g_strdup("trash_btn");
+                       g_free(item->text);
+                       item->text = g_strdup(_("Trash"));
+                       rewrite = TRUE;
+               }
                attr = g_list_next(attr);
        }
        if (item->index != -1) {
@@ -351,29 +398,125 @@ static void toolbar_parse_item(XMLFile *file, ToolbarType source)
                        toolbar_config[source].item_list = g_slist_append(toolbar_config[source].item_list,
                                                                         item);
        }
+       if (rewrite) {
+               toolbar_save_config_file(source);
+       }
+}
+
+const gchar *toolbar_get_short_text(int action) {
+       switch(action) {
+       case A_GO_FOLDERS:      return _("Folders");
+       case A_OPEN_MAIL:       return _("Open");
+       case A_RECEIVE_ALL:     return _("Get Mail");
+       case A_RECEIVE_CUR:     return _("Get");
+       case A_SEND_QUEUED:     return _("Send");
+       case A_COMPOSE_EMAIL:   return Q_("Toolbar|Compose");
+       case A_COMPOSE_NEWS:    return Q_("Toolbar|Compose");
+       case A_REPLY_MESSAGE:   return _("Reply");
+       case A_REPLY_ALL:       return _("All");
+       case A_REPLY_SENDER:    return _("Sender");
+       case A_REPLY_ML:        return _("List");
+       case A_FORWARD:         return _("Forward");
+       case A_TRASH:           return _("Trash");
+       case A_DELETE_REAL:     return _("Delete");
+       case A_LEARN_SPAM:      return _("Spam");
+       case A_GOTO_PREV:       return _("Prev");
+       case A_GOTO_NEXT:       return _("Next");
+       case A_IGNORE_THREAD:   return _("Ignore thread");
+       case A_WATCH_THREAD:    return _("Watch thread");
+       case A_PRINT:           return _("Print");
+       case A_CLOSE:           return _("Close");
+       case A_SEND:            return _("Send");
+       case A_SENDL:           return _("Send later");
+       case A_DRAFT:           return _("Draft");
+       case A_INSERT:          return _("Insert");
+       case A_ATTACH:          return _("Attach");
+       case A_SIG:             return _("Insert sig.");
+       case A_EXTEDITOR:       return _("Edit");
+       case A_LINEWRAP_CURRENT:return _("Wrap para.");
+       case A_LINEWRAP_ALL:    return _("Wrap all");
+       case A_ADDRBOOK:        return _("Address");
+       case A_CANCEL_INC:      return _("Stop");
+       case A_EXECUTE:         return _("Execute");
+       #ifdef USE_ASPELL
+       case A_CHECK_SPELLING:  return _("Check spelling");
+       #endif
+       default:                return "";
+       }
+}
+
+gint toolbar_get_icon(int action) {
+       switch(action) {
+       case A_GO_FOLDERS:      return STOCK_PIXMAP_GO_FOLDERS;
+       case A_OPEN_MAIL:       return STOCK_PIXMAP_OPEN_MAIL;
+       case A_RECEIVE_ALL:     return STOCK_PIXMAP_MAIL_RECEIVE_ALL;
+       case A_RECEIVE_CUR:     return STOCK_PIXMAP_MAIL_RECEIVE;
+       case A_SEND_QUEUED:     return STOCK_PIXMAP_MAIL_SEND_QUEUE;
+       case A_COMPOSE_EMAIL:   return STOCK_PIXMAP_MAIL_COMPOSE;
+       case A_COMPOSE_NEWS:    return STOCK_PIXMAP_NEWS_COMPOSE;
+       case A_REPLY_MESSAGE:   return STOCK_PIXMAP_MAIL_REPLY;
+       case A_REPLY_ALL:       return STOCK_PIXMAP_MAIL_REPLY_TO_ALL;
+       case A_REPLY_SENDER:    return STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR;
+       case A_REPLY_ML:        return STOCK_PIXMAP_MAIL_REPLY;
+       case A_FORWARD:         return STOCK_PIXMAP_MAIL_FORWARD;
+       case A_TRASH:           return STOCK_PIXMAP_TRASH;
+       case A_DELETE_REAL:     return STOCK_PIXMAP_DELETED;
+       case A_LEARN_SPAM:      return STOCK_PIXMAP_SPAM_BTN;
+       case A_GOTO_PREV:       return STOCK_PIXMAP_UP_ARROW;
+       case A_GOTO_NEXT:       return STOCK_PIXMAP_DOWN_ARROW;
+       case A_IGNORE_THREAD:   return STOCK_PIXMAP_IGNORETHREAD;
+       case A_WATCH_THREAD:    return STOCK_PIXMAP_WATCHTHREAD;
+       case A_PRINT:           return STOCK_PIXMAP_PRINTER;
+       case A_CLOSE:           return STOCK_PIXMAP_CLOSE;
+       case A_SEND:            return STOCK_PIXMAP_MAIL_SEND;
+       case A_SENDL:           return STOCK_PIXMAP_MAIL_SEND_QUEUE;
+       case A_DRAFT:           return STOCK_PIXMAP_MAIL;
+       case A_INSERT:          return STOCK_PIXMAP_INSERT_FILE;
+       case A_ATTACH:          return STOCK_PIXMAP_MAIL_ATTACH;
+       case A_SIG:             return STOCK_PIXMAP_MAIL_SIGN;
+       case A_EXTEDITOR:       return STOCK_PIXMAP_EDIT_EXTERN;
+       case A_LINEWRAP_CURRENT:return STOCK_PIXMAP_LINEWRAP_CURRENT;
+       case A_LINEWRAP_ALL:    return STOCK_PIXMAP_LINEWRAP_ALL;
+       case A_ADDRBOOK:        return STOCK_PIXMAP_ADDRESS_BOOK;
+       case A_CANCEL_INC:      return STOCK_PIXMAP_NOTICE_ERROR;
+       case A_EXECUTE:         return STOCK_PIXMAP_EXEC;
+       #ifdef USE_ASPELL
+       case A_CHECK_SPELLING:  return STOCK_PIXMAP_CHECK_SPELLING;
+       #endif
+       default:                return -1;
+       }
 }
 
 static void toolbar_set_default_main(void) 
 {
        struct {
                gint action;
-               gint icon;
-               gchar *text;
        } default_toolbar[] = {
-               { A_RECEIVE_CUR,   STOCK_PIXMAP_MAIL_RECEIVE,         _("Get")     },
-               { A_RECEIVE_ALL,   STOCK_PIXMAP_MAIL_RECEIVE_ALL,     _("Get All") },
-               { A_SEPARATOR,     0,                                 ("")         }, 
-               { A_SEND_QUEUED,   STOCK_PIXMAP_MAIL_SEND_QUEUE,      _("Send")    },
-               { A_COMPOSE_EMAIL, STOCK_PIXMAP_MAIL_COMPOSE,         _("Email")   },
-               { A_SEPARATOR,     0,                                 ("")         },
-               { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY,           _("Reply")   }, 
-               { A_REPLY_ALL,     STOCK_PIXMAP_MAIL_REPLY_TO_ALL,    _("All")     },
-               { A_REPLY_SENDER,  STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender")  },
-               { A_FORWARD,       STOCK_PIXMAP_MAIL_FORWARD,         _("Forward") },
-               { A_SEPARATOR,     0,                                 ("")         },
-               { A_DELETE,        STOCK_PIXMAP_CLOSE,                _("Delete")  },
-               { A_EXECUTE,       STOCK_PIXMAP_EXEC,                 _("Execute") },
-               { A_GOTO_NEXT,     STOCK_PIXMAP_DOWN_ARROW,           _("Next")    }
+#ifdef MAEMO
+               { A_GO_FOLDERS},
+               { A_OPEN_MAIL},         
+               { A_SEPARATOR}, 
+#endif
+               { A_RECEIVE_ALL},
+               { A_SEPARATOR}, 
+               { A_SEND_QUEUED},
+               { A_COMPOSE_EMAIL},
+               { A_SEPARATOR},
+               { A_REPLY_MESSAGE}, 
+#ifndef MAEMO
+               { A_REPLY_ALL},
+               { A_REPLY_SENDER},
+#endif
+               { A_FORWARD},
+               { A_SEPARATOR},
+               { A_TRASH},
+#ifndef MAEMO
+#if (defined(USE_SPAMASSASSIN_PLUGIN) || defined(USE_BOGOFILTER_PLUGIN))
+               { A_LEARN_SPAM},
+#endif
+#endif
+               { A_SEPARATOR},
+               { A_GOTO_NEXT}
        };
        
        gint i;
@@ -384,11 +527,11 @@ static void toolbar_set_default_main(void)
                
                if (default_toolbar[i].action != A_SEPARATOR) {
                        
-                       gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
+                       gchar *file = stock_pixmap_get_name((StockPixmap)toolbar_get_short_text(default_toolbar[i].action));
                        
                        toolbar_item->file  = g_strdup(file);
                        toolbar_item->index = default_toolbar[i].action;
-                       toolbar_item->text  = g_strdup(default_toolbar[i].text);
+                       toolbar_item->text  = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
                } else {
 
                        toolbar_item->file  = g_strdup(TOOLBAR_TAG_SEPARATOR);
@@ -407,21 +550,21 @@ static void toolbar_set_default_compose(void)
 {
        struct {
                gint action;
-               gint icon;
-               gchar *text;
        } default_toolbar[] = {
-               { A_SEND,      STOCK_PIXMAP_MAIL_SEND,         _("Send")       },
-               { A_SENDL,     STOCK_PIXMAP_MAIL_SEND_QUEUE,   _("Send later") },
-               { A_DRAFT,     STOCK_PIXMAP_MAIL,              _("Draft")      },
-               { A_SEPARATOR, 0,                               ("")           }, 
-               { A_INSERT,    STOCK_PIXMAP_INSERT_FILE,       _("Insert")     },
-               { A_ATTACH,    STOCK_PIXMAP_MAIL_ATTACH,       _("Attach")     },
-               { A_SIG,       STOCK_PIXMAP_MAIL_SIGN,         _("Signature")  },
-               { A_SEPARATOR, 0,                               ("")           },
-               { A_EXTEDITOR, STOCK_PIXMAP_EDIT_EXTERN,       _("Editor")     },
-               { A_LINEWRAP,  STOCK_PIXMAP_LINEWRAP,          _("Linewrap")   },
-               { A_SEPARATOR, 0,                               ("")           },
-               { A_ADDRBOOK,  STOCK_PIXMAP_ADDRESS_BOOK,      _("Address")    }
+#ifdef MAEMO
+               { A_CLOSE},
+               { A_SEPARATOR}, 
+#endif
+               { A_SEND},
+               { A_SENDL},
+               { A_DRAFT},
+               { A_SEPARATOR}, 
+#ifndef MAEMO
+               { A_INSERT},
+#endif
+               { A_ATTACH},
+               { A_SEPARATOR},
+               { A_ADDRBOOK}
        };
        
        gint i;
@@ -432,11 +575,11 @@ static void toolbar_set_default_compose(void)
                
                if (default_toolbar[i].action != A_SEPARATOR) {
                        
-                       gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
+                       gchar *file = stock_pixmap_get_name((StockPixmap)toolbar_get_short_text(default_toolbar[i].action));
                        
                        toolbar_item->file  = g_strdup(file);
                        toolbar_item->index = default_toolbar[i].action;
-                       toolbar_item->text  = g_strdup(default_toolbar[i].text);
+                       toolbar_item->text  = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
                } else {
 
                        toolbar_item->file  = g_strdup(TOOLBAR_TAG_SEPARATOR);
@@ -455,16 +598,23 @@ static void toolbar_set_default_msgview(void)
 {
        struct {
                gint action;
-               gint icon;
-               gchar *text;
        } default_toolbar[] = {
-               { A_REPLY_MESSAGE, STOCK_PIXMAP_MAIL_REPLY,           _("Reply")   }, 
-               { A_REPLY_ALL,     STOCK_PIXMAP_MAIL_REPLY_TO_ALL,    _("All")     },
-               { A_REPLY_SENDER,  STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR, _("Sender")  },
-               { A_FORWARD,       STOCK_PIXMAP_MAIL_FORWARD,         _("Forward") },
-               { A_SEPARATOR,     0,                                 ("")         },
-               { A_DELETE,        STOCK_PIXMAP_CLOSE,                _("Delete")  },
-               { A_GOTO_NEXT,     STOCK_PIXMAP_DOWN_ARROW,           _("Next")    }
+#ifdef MAEMO
+               { A_CLOSE},
+               { A_SEPARATOR}, 
+#endif
+               { A_REPLY_MESSAGE}, 
+               { A_REPLY_ALL},
+               { A_REPLY_SENDER},
+               { A_FORWARD},
+               { A_SEPARATOR},
+               { A_TRASH},
+#ifndef MAEMO
+#if (defined(USE_SPAMASSASSIN_PLUGIN) || defined(USE_BOGOFILTER_PLUGIN))
+               { A_LEARN_SPAM},
+#endif
+#endif
+               { A_GOTO_NEXT}
        };
        
        gint i;
@@ -475,11 +625,11 @@ static void toolbar_set_default_msgview(void)
                
                if (default_toolbar[i].action != A_SEPARATOR) {
                        
-                       gchar *file = stock_pixmap_get_name((StockPixmap)default_toolbar[i].icon);
+                       gchar *file = stock_pixmap_get_name((StockPixmap)toolbar_get_short_text(default_toolbar[i].action));
                        
                        toolbar_item->file  = g_strdup(file);
                        toolbar_item->index = default_toolbar[i].action;
-                       toolbar_item->text  = g_strdup(default_toolbar[i].text);
+                       toolbar_item->text  = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
                } else {
 
                        toolbar_item->file  = g_strdup(TOOLBAR_TAG_SEPARATOR);
@@ -515,36 +665,47 @@ void toolbar_save_config_file(ToolbarType source)
 
        fileSpec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, toolbar_config[source].conf_file, NULL );
        pfile = prefs_write_open(fileSpec);
-       g_free( fileSpec );
        if( pfile ) {
                fp = pfile->fp;
-               fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n",
-                       conv_get_current_charset_str());
+               if (fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL) < 0)
+                       goto fail;
 
-               fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX);
+               if (fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX) < 0)
+                       goto fail;
 
                for (cur = toolbar_config[source].item_list; cur != NULL; cur = cur->next) {
                        ToolbarItem *toolbar_item = (ToolbarItem*) cur->data;
                        
-#warning FIXME_GTK2
                        if (toolbar_item->index != A_SEPARATOR) {
-                               fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
+                               if (fprintf(fp, "\t<%s %s=\"%s\" %s=\"",
                                        TOOLBAR_TAG_ITEM, 
                                        TOOLBAR_ICON_FILE, toolbar_item->file,
-                                       TOOLBAR_ICON_TEXT);
-                               xml_file_put_escape_str(fp, toolbar_item->text);
-                               fprintf(fp, "\" %s=\"%s\"/>\n",
+                                       TOOLBAR_ICON_TEXT) < 0)
+                                       goto fail;
+                               if (xml_file_put_escape_str(fp, toolbar_item->text) < 0)
+                                       goto fail;
+                               if (fprintf(fp, "\" %s=\"%s\"/>\n",
                                        TOOLBAR_ICON_ACTION, 
-                                       toolbar_ret_text_from_val(toolbar_item->index));
+                                       toolbar_ret_text_from_val(toolbar_item->index)) < 0)
+                                       goto fail;
                        } else {
-                               fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR); 
+                               if (fprintf(fp, "\t<%s/>\n", TOOLBAR_TAG_SEPARATOR) < 0)
+                                       goto fail;
                        }
                }
 
-               fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX);      
+               if (fprintf(fp, "</%s>\n", TOOLBAR_TAG_INDEX) < 0)
+                       goto fail;
        
+               g_free( fileSpec );
                if (prefs_file_close (pfile) < 0 ) 
                        g_warning("failed to write toolbar configuration to file\n");
+               return;
+               
+fail:
+               FILE_OP_ERROR(fileSpec, "fprintf");
+               g_free( fileSpec );
+               prefs_file_close_revert (pfile);
        } else
                g_warning("failed to open toolbar configuration file for writing\n");
 }
@@ -628,10 +789,8 @@ void toolbar_clear_list(ToolbarType source)
                toolbar_config[source].item_list = 
                        g_slist_remove(toolbar_config[source].item_list, item);
 
-               if (item->file)
-                       g_free(item->file);
-               if (item->text)
-                       g_free(item->text);
+               g_free(item->file);
+               g_free(item->text);
                g_free(item);   
        }
        g_slist_free(toolbar_config[source].item_list);
@@ -684,7 +843,7 @@ void toolbar_action_execute(GtkWidget    *widget,
 
                                action_p = strstr(action, ": ");
                                action_p[0] = 0x00;
-                               if (g_strcasecmp(act->name, action) == 0) {
+                               if (g_utf8_collate(act->name, action) == 0) {
                                        found = TRUE;
                                        g_free(action);
                                        break;
@@ -700,21 +859,32 @@ void toolbar_action_execute(GtkWidget    *widget,
        if (found) 
                actions_execute(data, i, widget, source);
        else
-               g_warning ("Error: did not find Sylpheed Action to execute");
+               g_warning ("Error: did not find Claws Action to execute");
 }
 
 static void activate_compose_button (Toolbar           *toolbar,
                                     ToolbarStyle      style,
                                     ComposeButtonType type)
 {
-       if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
+       if ((!toolbar->compose_mail_btn))
                return;
 
-       gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn 
-                       : toolbar->compose_news_btn);
-       gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
-                       : toolbar->compose_mail_btn);
-       toolbar->compose_btn_type = type;       
+       if (type == COMPOSEBUTTON_NEWS) {
+               gtk_tool_button_set_icon_widget(
+                       GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
+                       toolbar->compose_news_icon);
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->compose_mail_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Compose News message"), NULL);       
+               gtk_widget_show(toolbar->compose_news_icon);
+       } else {
+               gtk_tool_button_set_icon_widget(
+                       GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
+                       toolbar->compose_mail_icon);
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->compose_mail_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Compose Email"), NULL);      
+               gtk_widget_show(toolbar->compose_mail_icon);
+       }
+       toolbar->compose_btn_type = type;
 }
 
 void toolbar_set_compose_button(Toolbar            *toolbar, 
@@ -726,6 +896,46 @@ void toolbar_set_compose_button(Toolbar            *toolbar,
                                        compose_btn_type);
 }
 
+static void activate_learn_button (Toolbar           *toolbar,
+                                    ToolbarStyle      style,
+                                    LearnButtonType type)
+{
+       if ((!toolbar->learn_spam_btn))
+               return;
+
+       if (type == LEARN_SPAM) {
+               gtk_tool_button_set_icon_widget(
+                       GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
+                       toolbar->learn_spam_icon);
+               gtk_tool_button_set_label(
+                       GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
+                       _("Spam"));
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->learn_spam_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Learn spam"), NULL); 
+               gtk_widget_show(toolbar->learn_spam_icon);
+       } else {
+               gtk_tool_button_set_icon_widget(
+                       GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
+                       toolbar->learn_ham_icon);
+               gtk_tool_button_set_label(
+                       GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
+                       _("Ham"));
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->learn_spam_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Learn ham"), NULL);  
+               gtk_widget_show(toolbar->learn_ham_icon);
+       }
+       toolbar->learn_btn_type = type; 
+}
+
+void toolbar_set_learn_button(Toolbar            *toolbar, 
+                               LearnButtonType  learn_btn_type)
+{
+       if (toolbar->learn_btn_type != learn_btn_type)
+               activate_learn_button(toolbar, 
+                                       prefs_common.toolbar_style,
+                                       learn_btn_type);
+}
+
 void toolbar_toggle(guint action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow*)data;
@@ -765,11 +975,17 @@ void toolbar_set_style(GtkWidget *toolbar_wid, GtkWidget *handlebox_wid, guint a
                gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
                                      GTK_TOOLBAR_BOTH);
                break;
+       case TOOLBAR_BOTH_HORIZ:
+               gtk_toolbar_set_style(GTK_TOOLBAR(toolbar_wid),
+                                     GTK_TOOLBAR_BOTH_HORIZ);
+               break;
        default:
                return;
        }
 
        prefs_common.toolbar_style = (ToolbarStyle)action;
+       gtk_widget_set_size_request(handlebox_wid, 1, -1);
+       
        if (prefs_common.toolbar_style != TOOLBAR_NONE) {
                gtk_widget_show(handlebox_wid);
                gtk_widget_queue_resize(handlebox_wid);
@@ -871,226 +1087,29 @@ static void toolbar_exec_cb(GtkWidget   *widget,
        summary_execute(mainwin->summaryview);
 }
 
-
-
-/* popup callback functions */
-static gboolean toolbar_reply_popup_cb(GtkWidget       *widget, 
-                                      GdkEventButton  *event, 
-                                      gpointer         data)
-{
-       Toolbar *toolbar_data = (Toolbar*)data;
-       
-       if (!event) return FALSE;
-       
-       if (event->button == 3) {
-               gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
-               gtk_menu_popup(GTK_MENU(toolbar_data->reply_popup), NULL, NULL,
-                      menu_button_position, widget,
-                      event->button, event->time);
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
+/*
+ * Delete current/selected(s) message(s)
+ */
+static void toolbar_trash_cb(GtkWidget *widget, gpointer data)
 {
        ToolbarItem *toolbar_item = (ToolbarItem*)data;
-       GtkWidget *window;
-       GtkWidget *reply_btn;
        MainWindow *mainwin;
-       MessageView *msgview;
 
        g_return_if_fail(toolbar_item != NULL);
-
-       switch(toolbar_item->type) {
-       case TOOLBAR_MAIN:
-               mainwin   = (MainWindow*)toolbar_item->parent;
-               reply_btn = mainwin->toolbar->reply_btn;
-               window    = mainwin->window;
-               break;
-       case TOOLBAR_MSGVIEW:
-               msgview   = (MessageView*)toolbar_item->parent;
-               reply_btn = msgview->toolbar->reply_btn;
-               window    = msgview->window;
-               break;
-       default:
-               return;
-       }
-
-       gtk_button_set_relief(GTK_BUTTON(reply_btn), GTK_RELIEF_NONE);
-       manage_window_focus_in(window, NULL, NULL);
-}
-
-static gboolean toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
-       Toolbar *toolbar_data = (Toolbar*)data;
-       
-       if (!event) return FALSE;
+       g_return_if_fail(toolbar_item->parent);
        
-       if (event->button == 3) {
-               gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
-               gtk_menu_popup(GTK_MENU(toolbar_data->replyall_popup), NULL, NULL,
-                      menu_button_position, widget,
-                      event->button, event->time);
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
-{
-       ToolbarItem *toolbar_item = (ToolbarItem*)data;
-       GtkWidget *window;
-       GtkWidget *replyall_btn;
-       MainWindow *mainwin;
-       MessageView *msgview;
-
-       g_return_if_fail(toolbar_item != NULL);
-
-       switch(toolbar_item->type) {
-       case TOOLBAR_MAIN:
-               mainwin      = (MainWindow*)toolbar_item->parent; 
-               replyall_btn = mainwin->toolbar->replyall_btn;
-               window       = mainwin->window;
-               break;
-       case TOOLBAR_MSGVIEW:
-               msgview      = (MessageView*)toolbar_item->parent;
-               replyall_btn = msgview->toolbar->replyall_btn;
-               window       = msgview->window;
-               break;
-       default:
-               return;
-       }
-
-       gtk_button_set_relief(GTK_BUTTON(replyall_btn), GTK_RELIEF_NONE);
-       manage_window_focus_in(window, NULL, NULL);
-}
-
-static gboolean toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
-       Toolbar *toolbar_data = (Toolbar*)data;
-
-       if (event->button == 3) {
-               gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
-               gtk_menu_popup(GTK_MENU(toolbar_data->replylist_popup), NULL, NULL,
-                      menu_button_position, widget,
-                      event->button, event->time);
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
-{
-       ToolbarItem *toolbar_item = (ToolbarItem*)data;
-       gpointer parent = toolbar_item->parent;
-       GtkWidget *window;
-       GtkWidget *replylist_btn;
-
-
-       g_return_if_fail(toolbar_item != NULL);
-
-       switch(toolbar_item->type) {
-       case TOOLBAR_MAIN:
-               replylist_btn = ((MainWindow*)parent)->toolbar->replylist_btn;
-               window        = ((MainWindow*)parent)->window;
-               break;
-       case TOOLBAR_MSGVIEW:
-               replylist_btn = ((MessageView*)parent)->toolbar->replylist_btn;
-               window        = ((MessageView*)parent)->window;
-               break;
-       default:
-               return;
-       }
-
-       gtk_button_set_relief(GTK_BUTTON(replylist_btn), GTK_RELIEF_NONE);
-       manage_window_focus_in(window, NULL, NULL);
-}
-
-static gboolean toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
-       Toolbar *toolbar_data = (Toolbar*)data;
-
-       if (event->button == 3) {
-               gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
-               gtk_menu_popup(GTK_MENU(toolbar_data->replysender_popup), NULL, NULL,
-                      menu_button_position, widget,
-                      event->button, event->time);
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
-{
-       ToolbarItem *toolbar_item = (ToolbarItem*)data;
-       gpointer parent = toolbar_item->parent;
-       GtkWidget *window;
-       GtkWidget *replysender_btn;
-
-       g_return_if_fail(toolbar_item != NULL);
-
-       switch(toolbar_item->type) {
-       case TOOLBAR_MAIN:
-               replysender_btn = ((MainWindow*)parent)->toolbar->replysender_btn;
-               window          = ((MainWindow*)parent)->window;
-               break;
-       case TOOLBAR_MSGVIEW:
-               replysender_btn = ((MessageView*)parent)->toolbar->replysender_btn;
-               window          = ((MessageView*)parent)->window;
-               break;
-       default:
-               return;
-       }
-
-       gtk_button_set_relief(GTK_BUTTON(replysender_btn), GTK_RELIEF_NONE);
-       manage_window_focus_in(window, NULL, NULL);
-}
-
-static gboolean toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
-       Toolbar *toolbar_data = (Toolbar*)data;
-
-       if (event->button == 3) {
-               gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
-               gtk_menu_popup(GTK_MENU(toolbar_data->fwd_popup), NULL, NULL,
-                              menu_button_position, widget,
-                              event->button, event->time);
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell, 
-                                            gpointer     data)
-{
-       ToolbarItem *toolbar_item = (ToolbarItem*)data;
-       gpointer parent = toolbar_item->parent;
-       GtkWidget *window;
-       GtkWidget *fwd_btn;
-
-       g_return_if_fail(toolbar_item != NULL);
-
-       switch(toolbar_item->type) {
-       case TOOLBAR_MAIN:
-               fwd_btn = ((MainWindow*)parent)->toolbar->fwd_btn;
-               window  = ((MainWindow*)parent)->window;
-               break;
+       switch (toolbar_item->type) {
        case TOOLBAR_MSGVIEW:
-               fwd_btn = ((MessageView*)parent)->toolbar->fwd_btn;
-               window  = ((MessageView*)parent)->window;
-               break;
-       default:
-               return;
+               messageview_delete((MessageView *)toolbar_item->parent);
+               break;
+        case TOOLBAR_MAIN:
+               mainwin = (MainWindow *)toolbar_item->parent;
+               summary_delete_trash(mainwin->summaryview);
+               break;
+        default: 
+               debug_print("toolbar event not supported\n");
+               break;
        }
-
-       gtk_button_set_relief(GTK_BUTTON(fwd_btn), GTK_RELIEF_NONE);
-       manage_window_focus_in(window, NULL, NULL);
 }
 
 /*
@@ -1100,17 +1119,16 @@ static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
 {
        ToolbarItem *toolbar_item = (ToolbarItem*)data;
        MainWindow *mainwin;
-       MessageView *msgview;
 
        g_return_if_fail(toolbar_item != NULL);
+       g_return_if_fail(toolbar_item->parent);
        
        switch (toolbar_item->type) {
        case TOOLBAR_MSGVIEW:
-               msgview = (MessageView*)toolbar_item->parent;
-               messageview_delete(msgview);
+               messageview_delete((MessageView *)toolbar_item->parent);
                break;
         case TOOLBAR_MAIN:
-               mainwin = (MainWindow*)toolbar_item->parent;
+               mainwin = (MainWindow *)toolbar_item->parent;
                summary_delete(mainwin->summaryview);
                break;
         default: 
@@ -1142,16 +1160,67 @@ static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
        case TOOLBAR_MSGVIEW:
                msgview = (MessageView*)toolbar_item->parent;
                compose_new_with_folderitem(NULL, 
-                                           msgview->msginfo->folder);
+                                           msgview->msginfo->folder, NULL);
                break;  
        default:
                debug_print("toolbar event not supported\n");
        }
 }
 
-static void toolbar_popup_cb(gpointer data, guint action, GtkWidget *widget)
+static void toolbar_learn(gpointer data, guint as_spam)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin;
+       MessageView *msgview;
+
+       g_return_if_fail(toolbar_item != NULL);
+
+       switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+               mainwin = (MainWindow*)toolbar_item->parent;
+               if (as_spam) 
+                       mainwindow_learn(mainwin, TRUE);
+               else
+                       mainwindow_learn(mainwin, FALSE);
+               break;
+       case TOOLBAR_MSGVIEW:
+               msgview = (MessageView*)toolbar_item->parent;
+               if (as_spam) 
+                       messageview_learn(msgview, TRUE);
+               else
+                       messageview_learn(msgview, FALSE);
+               break;
+       default:
+               debug_print("toolbar event not supported\n");
+       }
+}
+
+static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
 {
-       toolbar_reply(data, action);
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin;
+       MessageView *msgview;
+
+       g_return_if_fail(toolbar_item != NULL);
+
+       switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+               mainwin = (MainWindow*)toolbar_item->parent;
+               if (mainwin->toolbar->learn_btn_type == LEARN_SPAM) 
+                       mainwindow_learn(mainwin, TRUE);
+               else
+                       mainwindow_learn(mainwin, FALSE);
+               break;
+       case TOOLBAR_MSGVIEW:
+               msgview = (MessageView*)toolbar_item->parent;
+               if (msgview->toolbar->learn_btn_type == LEARN_SPAM) 
+                       messageview_learn(msgview, TRUE);
+               else
+                       messageview_learn(msgview, FALSE);
+               break;
+       default:
+               debug_print("toolbar event not supported\n");
+       }
 }
 
 
@@ -1230,6 +1299,52 @@ static void toolbar_forward_cb(GtkWidget *widget, gpointer data)
        toolbar_reply(data, COMPOSE_FORWARD);
 }
 
+/*
+ * Goto Prev Unread Message
+ */
+static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin;
+       MessageView *msgview;
+
+       g_return_if_fail(toolbar_item != NULL);
+
+       switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+               mainwin = (MainWindow*)toolbar_item->parent;
+               summary_select_prev_unread(mainwin->summaryview);
+               break;
+               
+       case TOOLBAR_MSGVIEW:
+               msgview = (MessageView*)toolbar_item->parent;
+               msgview->updating = TRUE;
+               summary_select_prev_unread(msgview->mainwin->summaryview);
+               msgview->updating = FALSE;
+
+               if (msgview->deferred_destroy) {
+                       debug_print("messageview got away!\n");
+                       messageview_destroy(msgview);
+                       return;
+               }
+               
+               /* Now we need to update the messageview window */
+               if (msgview->mainwin->summaryview->selected) {
+#ifndef MAEMO
+                       MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
+                      
+                       if (msginfo)
+                               messageview_show(msgview, msginfo, 
+                                        msgview->all_headers);
+#endif
+               } else {
+                       gtk_widget_destroy(msgview->window);
+               }
+               break;
+       default:
+               debug_print("toolbar event not supported\n");
+       }
+}
 
 /*
  * Goto Next Unread Message
@@ -1250,17 +1365,25 @@ static void toolbar_next_unread_cb(GtkWidget *widget, gpointer data)
                
        case TOOLBAR_MSGVIEW:
                msgview = (MessageView*)toolbar_item->parent;
+               msgview->updating = TRUE;
                summary_select_next_unread(msgview->mainwin->summaryview);
-               
+               msgview->updating = FALSE;
+
+               if (msgview->deferred_destroy) {
+                       debug_print("messageview got away!\n");
+                       messageview_destroy(msgview);
+                       return;
+               }
+
                /* Now we need to update the messageview window */
                if (msgview->mainwin->summaryview->selected) {
-                       GtkCTree *ctree = GTK_CTREE(msgview->mainwin->summaryview->ctree);
+#ifndef MAEMO
+                       MsgInfo * msginfo = summary_get_selected_msg(msgview->mainwin->summaryview);
                        
-                       MsgInfo * msginfo = gtk_ctree_node_get_row_data(ctree, 
-                                                                       msgview->mainwin->summaryview->selected);
-                      
-                       messageview_show(msgview, msginfo, 
+                       if (msginfo)
+                               messageview_show(msgview, msginfo, 
                                         msgview->all_headers);
+#endif
                } else {
                        gtk_widget_destroy(msgview->window);
                }
@@ -1292,6 +1415,38 @@ static void toolbar_ignore_thread_cb(GtkWidget *widget, gpointer data)
        }
 }
 
+static void toolbar_watch_thread_cb(GtkWidget *widget, gpointer data)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin;
+
+       g_return_if_fail(toolbar_item != NULL);
+
+       switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+               mainwin = (MainWindow *) toolbar_item->parent;
+               summary_toggle_watch_thread(mainwin->summaryview);
+               break;
+       case TOOLBAR_MSGVIEW:
+               /* TODO: see toolbar_next_unread_cb() if you need
+                * this in the message view */
+               break;
+       default:
+               debug_print("toolbar event not supported\n");
+               break;
+       }
+}
+
+static void toolbar_cancel_inc_cb(GtkWidget *widget, gpointer data)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+
+       g_return_if_fail(toolbar_item != NULL);
+       inc_cancel_all();
+       imap_cancel_all();
+}
+
+
 static void toolbar_print_cb(GtkWidget *widget, gpointer data)
 {
        ToolbarItem *toolbar_item = (ToolbarItem*)data;
@@ -1329,6 +1484,52 @@ static void toolbar_draft_cb(GtkWidget *widget, gpointer data)
        compose_toolbar_cb(A_DRAFT, data);
 }
 
+static void toolbar_close_cb(GtkWidget *widget, gpointer data)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin;
+       MessageView *messageview;
+       Compose *compose;
+
+       g_return_if_fail(toolbar_item != NULL);
+
+       switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+               mainwin = (MainWindow *) toolbar_item->parent;
+               app_will_exit(NULL, mainwin);
+               break;
+       case TOOLBAR_MSGVIEW:
+               messageview = (MessageView *)toolbar_item->parent;
+               messageview_destroy(messageview);
+               break;
+       case TOOLBAR_COMPOSE:
+               compose = (Compose *)toolbar_item->parent;
+               compose_close_toolbar(compose);
+               break;
+       }
+}
+
+static void toolbar_open_mail_cb(GtkWidget *widget, gpointer data)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin;
+
+       g_return_if_fail(toolbar_item != NULL);
+
+       switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+               mainwin = (MainWindow *) toolbar_item->parent;
+               summary_open_row(NULL, mainwin->summaryview);
+               break;
+       case TOOLBAR_MSGVIEW:
+               debug_print("toolbar event not supported\n");
+               break;
+       case TOOLBAR_COMPOSE:
+               debug_print("toolbar event not supported\n");
+               break;
+       }
+}
+
 static void toolbar_insert_cb(GtkWidget *widget, gpointer data)
 {
        compose_toolbar_cb(A_INSERT, data);
@@ -1349,11 +1550,22 @@ static void toolbar_ext_editor_cb(GtkWidget *widget, gpointer data)
        compose_toolbar_cb(A_EXTEDITOR, data);
 }
 
-static void toolbar_linewrap_cb(GtkWidget *widget, gpointer data)
+static void toolbar_linewrap_current_cb(GtkWidget *widget, gpointer data)
+{
+       compose_toolbar_cb(A_LINEWRAP_CURRENT, data);
+}
+
+static void toolbar_linewrap_all_cb(GtkWidget *widget, gpointer data)
 {
-       compose_toolbar_cb(A_LINEWRAP, data);
+       compose_toolbar_cb(A_LINEWRAP_ALL, data);
 }
 
+#ifdef USE_ASPELL
+static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
+{
+       compose_toolbar_cb(A_CHECK_SPELLING, data);
+}
+#endif
 /*
  * Execute actions from toolbar
  */
@@ -1411,24 +1623,28 @@ static MainWindow *get_mainwin(gpointer data)
        return mainwin;
 }
 
-static GtkWidget *get_window_widget(ToolbarType type, gpointer data)
+static void toolbar_go_folders_cb(GtkWidget *widget, gpointer data)
 {
-       MainWindow *mainwin;
-       MessageView *msgview;
-
-       switch (type) {
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin = NULL;
+       switch(toolbar_item->type) {
        case TOOLBAR_MAIN:
-               mainwin = (MainWindow*)data;
-               return mainwin->window;
-               break;
-       case TOOLBAR_MSGVIEW:
-               msgview = (MessageView*)data;
-               return msgview->vbox;
+               mainwin = (MainWindow*)toolbar_item->parent;
                break;
        default:
-               break;
+               g_warning("wrong toolbar type\n");
+               return;
+       }
+
+       if (!mainwin->in_folder) {
+               FolderItem *item = folderview_get_selected_item(mainwin->folderview);
+               if (item) {
+                       folderview_select(mainwin->folderview, item);
+               }
+       } else {
+               gtk_widget_grab_focus(mainwin->folderview->ctree);
+               mainwindow_exit_folder(mainwin);
        }
-       return NULL;
 }
 
 static void toolbar_buttons_cb(GtkWidget   *widget, 
@@ -1450,23 +1666,34 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
                { A_REPLY_ALL,          toolbar_reply_to_all_cb         },
                { A_REPLY_ML,           toolbar_reply_to_list_cb        },
                { A_FORWARD,            toolbar_forward_cb              },
-               { A_DELETE,             toolbar_delete_cb               },
+               { A_TRASH,              toolbar_trash_cb                },
+               { A_DELETE_REAL,        toolbar_delete_cb               },
                { A_EXECUTE,            toolbar_exec_cb                 },
+               { A_GOTO_PREV,          toolbar_prev_unread_cb          },
                { A_GOTO_NEXT,          toolbar_next_unread_cb          },
                { A_IGNORE_THREAD,      toolbar_ignore_thread_cb        },
+               { A_WATCH_THREAD,       toolbar_watch_thread_cb         },
                { A_PRINT,              toolbar_print_cb                },
+               { A_LEARN_SPAM,         toolbar_learn_cb                },
+               { A_GO_FOLDERS,         toolbar_go_folders_cb           },
 
                { A_SEND,               toolbar_send_cb                 },
                { A_SENDL,              toolbar_send_later_cb           },
                { A_DRAFT,              toolbar_draft_cb                },
+               { A_OPEN_MAIL,          toolbar_open_mail_cb            },
+               { A_CLOSE,              toolbar_close_cb                },
                { A_INSERT,             toolbar_insert_cb               },
                { A_ATTACH,             toolbar_attach_cb               },
                { A_SIG,                toolbar_sig_cb                  },
                { A_EXTEDITOR,          toolbar_ext_editor_cb           },
-               { A_LINEWRAP,           toolbar_linewrap_cb             },
+               { A_LINEWRAP_CURRENT,   toolbar_linewrap_current_cb     },
+               { A_LINEWRAP_ALL,       toolbar_linewrap_all_cb         },
                { A_ADDRBOOK,           toolbar_addrbook_cb             },
-
-               { A_SYL_ACTIONS,        toolbar_actions_execute_cb      }
+#ifdef USE_ASPELL
+               { A_CHECK_SPELLING,     toolbar_check_spelling_cb       },
+#endif
+               { A_SYL_ACTIONS,        toolbar_actions_execute_cb      },
+               { A_CANCEL_INC,         toolbar_cancel_inc_cb           }
        };
 
        num_items = sizeof(callbacks)/sizeof(callbacks[0]);
@@ -1479,6 +1706,46 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
        }
 }
 
+#define TOOLBAR_ITEM(item,icon,text,tooltip) {                                                         \
+       item = GTK_WIDGET(gtk_tool_button_new(icon, text));                                             \
+       gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE);                                      \
+       gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE);                                      \
+       g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item);     \
+       gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);                              \
+       gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(item), GTK_TOOLTIPS(toolbar_tips),                      \
+                       tooltip, NULL);                                                                 \
+}
+
+#define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) {                                             \
+       GtkWidget *child = NULL, *btn = NULL, *arr = NULL;                                              \
+       GList *gchild = NULL;                                                                           \
+       item = GTK_WIDGET(gtk_menu_tool_button_new(icon, text));                                        \
+       gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE);                              \
+       gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE);                                      \
+       g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item);     \
+       gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);                              \
+       gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(item), GTK_TOOLTIPS(toolbar_tips),                      \
+                       tooltip, NULL);                                                                 \
+       gtk_menu_tool_button_set_arrow_tooltip(GTK_MENU_TOOL_BUTTON(item),                              \
+                               GTK_TOOLTIPS(toolbar_tips), menutip, NULL);                             \
+       child = gtk_bin_get_child(GTK_BIN(item));                                                       \
+       gchild = gtk_container_get_children(                                                            \
+                       GTK_CONTAINER(child));                                                          \
+       btn = (GtkWidget *)gchild->data;                                                                \
+       arr = (GtkWidget *)(gchild->next?gchild->next->data:NULL);                                      \
+       g_list_free(gchild);                                                                            \
+       gchild = gtk_container_get_children(GTK_CONTAINER(arr));                                        \
+       gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1);                                   \
+       g_list_free(gchild);                                                                            \
+}
+
+#define MAKE_MENU(entries,path,btn) {                                                                  \
+       n_menu_entries = sizeof(entries) /                                                              \
+               sizeof(entries[0]);                                                                     \
+       menu = menu_create_items(entries, n_menu_entries, path, &factory, toolbar_item);                \
+       gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(btn), menu);                                 \
+}
+
 /**
  * Create a new toolbar with specified type
  * if a callback list is passed it will be used before the 
@@ -1493,17 +1760,11 @@ Toolbar *toolbar_create(ToolbarType      type,
        GtkWidget *toolbar;
        GtkWidget *icon_wid = NULL;
        GtkWidget *icon_news;
+       GtkWidget *icon_ham;
        GtkWidget *item;
-       GtkWidget *item_news;
-       GtkWidget *window_wid;
-
+       GtkWidget *menu;
        guint n_menu_entries;
-       GtkWidget *reply_popup;
-       GtkWidget *replyall_popup;
-       GtkWidget *replylist_popup;
-       GtkWidget *replysender_popup;
-       GtkWidget *fwd_popup;
-
+       GtkItemFactory *factory;
        GtkTooltips *toolbar_tips;
        ToolbarSylpheedActions *action_item;
        GSList *cur;
@@ -1519,15 +1780,15 @@ Toolbar *toolbar_create(ToolbarType      type,
        toolbar_data = g_new0(Toolbar, 1); 
 
        toolbar = gtk_toolbar_new();
-       gtk_container_add(GTK_CONTAINER(container), toolbar);
-       gtk_container_set_border_width(GTK_CONTAINER(container), 2);
+
        gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
        gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
+       gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
        
        for (cur = toolbar_list; cur != NULL; cur = cur->next) {
 
-               if (g_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
-                       gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
+               if (g_ascii_strcasecmp(((ToolbarItem*)cur->data)->file, TOOLBAR_TAG_SEPARATOR) == 0) {
+                       gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1);
                        continue;
                }
                
@@ -1542,233 +1803,213 @@ Toolbar *toolbar_create(ToolbarType    type,
                toolbar_data->item_list = 
                        g_slist_append(toolbar_data->item_list, 
                                       toolbar_item);
-
                icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
-               item  = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                               toolbar_item->text,
-                                               (""),
-                                               (""),
-                                               icon_wid, G_CALLBACK(toolbar_buttons_cb), 
-                                               toolbar_item);
-               
+                       
                switch (toolbar_item->index) {
 
+               case A_GO_FOLDERS:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to folder list"));
+                       toolbar_data->folders_btn = item;
+                       break;
                case A_RECEIVE_ALL:
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Receive Mail on all Accounts"),
+                               _("Receive Mail on selected Account"));
                        toolbar_data->getall_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->getall_btn, 
-                                          _("Receive Mail on all Accounts"), NULL);
                        break;
                case A_RECEIVE_CUR:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Receive Mail on current Account"));
                        toolbar_data->get_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->get_btn,
-                                          _("Receive Mail on current Account"), NULL);
                        break;
                case A_SEND_QUEUED:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Queued Messages"));
                        toolbar_data->send_btn = item; 
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->send_btn,
-                                          _("Send Queued Message(s)"), NULL);
+                       break;
+               case A_CLOSE:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Close window"));
+                       toolbar_data->close_window_btn = item; 
+                       break;
+               case A_OPEN_MAIL:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Open email"));
+                       toolbar_data->open_mail_btn = item; 
                        break;
                case A_COMPOSE_EMAIL:
+#ifndef MAEMO
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Compose Email"),
+                               _("Compose with selected Account"));
+                       toolbar_data->compose_mail_btn = item; 
+                       toolbar_data->compose_mail_icon = icon_wid; 
+                       g_object_ref(toolbar_data->compose_mail_icon);
+
                        icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
-                       item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                                           _("News"),
-                                                           (""),
-                                                           (""),
-                                                           icon_news, G_CALLBACK(toolbar_buttons_cb), 
-                                                           toolbar_item);
+                       toolbar_data->compose_news_icon = icon_news; 
+                       g_object_ref(toolbar_data->compose_news_icon);
+#else
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
+                               _("Compose Email"));
                        toolbar_data->compose_mail_btn = item; 
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->compose_mail_btn,
-                                          _("Compose Email"), NULL);
-                       toolbar_data->compose_news_btn = item_news;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->compose_news_btn,
-                                          _("Compose News"), NULL);
+                       toolbar_data->compose_mail_icon = icon_wid; 
+
+                       icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
+                       toolbar_data->compose_news_icon = icon_news; 
+#endif
+                       break;
+               case A_LEARN_SPAM:
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Spam"),
+                               _("Learn as..."));
+                       toolbar_data->learn_spam_btn = item; 
+                       toolbar_data->learn_spam_icon = icon_wid; 
+                       g_object_ref(toolbar_data->learn_spam_icon);
+
+                       icon_ham = stock_pixmap_widget(container, STOCK_PIXMAP_HAM_BTN);
+                       toolbar_data->learn_ham_icon = icon_ham; 
+                       g_object_ref(toolbar_data->learn_ham_icon);
+
+                       MAKE_MENU(learn_entries,"<LearnSpam>",toolbar_data->learn_spam_btn);
                        break;
                case A_REPLY_MESSAGE:
+#ifndef MAEMO
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to Message"),
+                               _("Reply to Message options"));
                        toolbar_data->reply_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->reply_btn,
-                                          _("Reply to Message"), NULL);
-                       gtk_signal_connect(GTK_OBJECT(toolbar_data->reply_btn), 
-                                          "button_press_event",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
-                                          toolbar_data);
-                       n_menu_entries = sizeof(reply_popup_entries) /
-                               sizeof(reply_popup_entries[0]);
-
-                       window_wid = get_window_widget(type, data);
-                       reply_popup = popupmenu_create(window_wid,
-                                                      reply_popup_entries, n_menu_entries,
-                                                      "<ReplyPopup>", (gpointer)toolbar_item);
-
-                       gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), toolbar_item);
-                       toolbar_data->reply_popup = reply_popup;
+
+                       MAKE_MENU(reply_entries,"<Reply>",toolbar_data->reply_btn);
+#else
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to Message"));
+                       toolbar_data->reply_btn = item;
+#endif
                        break;
                case A_REPLY_SENDER:
+#ifndef MAEMO
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to Sender"),
+                               _("Reply to Sender options"));
+                       toolbar_data->replysender_btn = item;
+
+                       MAKE_MENU(replysender_entries,"<ReplySender>",toolbar_data->replysender_btn);
+#else
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to Sender"));
                        toolbar_data->replysender_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->replysender_btn,
-                                          _("Reply to Sender"), NULL);
-                       gtk_signal_connect(GTK_OBJECT(toolbar_data->replysender_btn), 
-                                          "button_press_event",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
-                                          toolbar_data);
-                       n_menu_entries = sizeof(replysender_popup_entries) /
-                               sizeof(replysender_popup_entries[0]);
-
-                       window_wid = get_window_widget(type, data);
-                       replysender_popup = popupmenu_create(window_wid, 
-                                                            replysender_popup_entries, n_menu_entries,
-                                                            "<ReplySenderPopup>", (gpointer)toolbar_item);
-
-                       gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), toolbar_item);
-                       toolbar_data->replysender_popup = replysender_popup;
+#endif
                        break;
                case A_REPLY_ALL:
+#ifndef MAEMO
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to All"),
+                               _("Reply to All options"));
                        toolbar_data->replyall_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->replyall_btn,
-                                          _("Reply to All"), NULL);
-                       gtk_signal_connect(GTK_OBJECT(toolbar_data->replyall_btn), 
-                                          "button_press_event",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
-                                          toolbar_data);
-                       n_menu_entries = sizeof(replyall_popup_entries) /
-                               sizeof(replyall_popup_entries[0]);
-
-                       window_wid = get_window_widget(type, data);     
-                       replyall_popup = popupmenu_create(window_wid, 
-                                                         replyall_popup_entries, n_menu_entries,
-                                                         "<ReplyAllPopup>", (gpointer)toolbar_item);
-       
-                       gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), toolbar_item);
-                       toolbar_data->replyall_popup = replyall_popup;
+
+                       MAKE_MENU(replyall_entries,"<ReplyAll>",toolbar_data->replyall_btn);
+#else
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to All"));
+                       toolbar_data->replyall_btn = item;
+#endif
                        break;
                case A_REPLY_ML:
+#ifndef MAEMO
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to Mailing-list"),
+                               _("Reply to Mailing-list options"));
                        toolbar_data->replylist_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->replylist_btn,
-                                          _("Reply to Mailing-list"), NULL);
-                       gtk_signal_connect(GTK_OBJECT(toolbar_data->replylist_btn), 
-                                          "button_press_event",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
-                                          toolbar_data);
-                       n_menu_entries = sizeof(replylist_popup_entries) /
-                               sizeof(replylist_popup_entries[0]);
-
-                       window_wid = get_window_widget(type, data);
-                       replylist_popup = popupmenu_create(window_wid, 
-                                                          replylist_popup_entries, n_menu_entries,
-                                                          "<ReplyMlPopup>", (gpointer)toolbar_item);
-               
-                       gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
-                                          GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), toolbar_item);
-                       toolbar_data->replylist_popup = replylist_popup;
+
+                       MAKE_MENU(replylist_entries,"<ReplyList>",toolbar_data->replylist_btn);
+#else
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
+                               _("Reply to Mailing-list"));
+                       toolbar_data->replylist_btn = item;
+#endif
                        break;
                case A_FORWARD:
+#ifndef MAEMO
+                       TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+                               _("Forward Message"),
+                               _("Forward Message options"));
+                       toolbar_data->fwd_btn = item;
+
+                       MAKE_MENU(forward_entries,"<Forward>",toolbar_data->fwd_btn);
+#else
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
+                               _("Forward Message"));
                        toolbar_data->fwd_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->fwd_btn,
-                                            _("Forward Message"), NULL);
-                       gtk_signal_connect(GTK_OBJECT(toolbar_data->fwd_btn), 
-                                          "button_press_event",
-                                          GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
-                                          toolbar_data);
-                       n_menu_entries = sizeof(fwd_popup_entries) /
-                               sizeof(fwd_popup_entries[0]);
-
-                       window_wid = get_window_widget(type, data);
-                       fwd_popup = popupmenu_create(window_wid, 
-                                                    fwd_popup_entries, n_menu_entries,
-                                                    "<ForwardPopup>", (gpointer)toolbar_item);
-
-                       gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
-                                          GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), toolbar_item);
-                       toolbar_data->fwd_popup = fwd_popup;
+#endif
+                       break;
+               case A_TRASH:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Trash Message"));
+                       toolbar_data->trash_btn = item;
                        break;
-               case A_DELETE:
+               case A_DELETE_REAL:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete Message"));
                        toolbar_data->delete_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->delete_btn,
-                                            _("Delete Message"), NULL);
                        break;
                case A_EXECUTE:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Execute"));
                        toolbar_data->exec_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->exec_btn,
-                                          _("Execute"), NULL);
+                       break;
+               case A_GOTO_PREV:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Previous Unread Message"));
+                       toolbar_data->prev_btn = item;
                        break;
                case A_GOTO_NEXT:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Go to Next Unread Message"));
                        toolbar_data->next_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->next_btn,
-                                            _("Goto Next Message"), NULL);
                        break;
                
                /* Compose Toolbar */
                case A_SEND:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Send Message"));
                        toolbar_data->send_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->send_btn, 
-                                            _("Send Message"), NULL);
                        break;
                case A_SENDL:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Put into queue folder and send later"));
                        toolbar_data->sendl_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->sendl_btn,
-                                            _("Put into queue folder and send later"), NULL);
                        break;
                case A_DRAFT:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Save to draft folder"));
                        toolbar_data->draft_btn = item; 
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->draft_btn,
-                                            _("Save to draft folder"), NULL);
                        break;
                case A_INSERT:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert file"));
                        toolbar_data->insert_btn = item; 
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->insert_btn,
-                                            _("Insert file"), NULL);
                        break;
                case A_ATTACH:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Attach file"));
                        toolbar_data->attach_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->attach_btn,
-                                            _("Attach file"), NULL);
                        break;
                case A_SIG:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Insert signature"));
                        toolbar_data->sig_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->sig_btn,
-                                            _("Insert signature"), NULL);
                        break;
                case A_EXTEDITOR:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Edit with external editor"));
                        toolbar_data->exteditor_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->exteditor_btn,
-                                            _("Edit with external editor"), NULL);
                        break;
-               case A_LINEWRAP:
-                       toolbar_data->linewrap_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->linewrap_btn,
-                                            _("Wrap all long lines"), NULL);
+               case A_LINEWRAP_CURRENT:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap long lines of current paragraph"));
+                       toolbar_data->linewrap_current_btn = item;
+                       break;
+               case A_LINEWRAP_ALL:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Wrap all long lines"));
+                       toolbar_data->linewrap_all_btn = item;
                        break;
                case A_ADDRBOOK:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Address book"));
                        toolbar_data->addrbook_btn = item;
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            toolbar_data->addrbook_btn,
-                                            _("Address book"), NULL);
                        break;
+#ifdef USE_ASPELL
+               case A_CHECK_SPELLING:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Check spelling"));
+                       toolbar_data->spellcheck_btn = item;
+                       break;
+#endif
 
                case A_SYL_ACTIONS:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
                        action_item = g_new0(ToolbarSylpheedActions, 1);
                        action_item->widget = item;
                        action_item->name   = g_strdup(toolbar_item->text);
@@ -1776,32 +2017,55 @@ Toolbar *toolbar_create(ToolbarType      type,
                        toolbar_data->action_list = 
                                g_slist_append(toolbar_data->action_list,
                                               action_item);
-
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
-                                            item,
-                                            action_item->name, NULL);
-
-                       gtk_widget_show(item);
+                       break;
+               case A_CANCEL_INC:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Cancel receiving"));
+                       toolbar_data->cancel_inc_btn = item;
                        break;
                default:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,
+                               toolbar_ret_descr_from_val(toolbar_item->index));
                        /* find and set the tool tip text */
-                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
-                                            item,
-                                            toolbar_ret_descr_from_val
-                                               (toolbar_item->index),
-                                            NULL);
                        break;
                }
 
        }
        toolbar_data->toolbar = toolbar;
-       if (type == TOOLBAR_MAIN)
+       toolbar_data->tooltips = toolbar_tips;
+       gtk_widget_show_all(toolbar);
+
+       if (type == TOOLBAR_MAIN) {
+#ifdef MAEMO
+               MainWindow *mainwin = mainwindow_get_mainwindow();
+               GtkWidget *progressbar = gtk_progress_bar_new();
+               item = gtk_tool_item_new();
+               gtk_container_add (GTK_CONTAINER (item), progressbar);
+               gtk_widget_show(item);
+               gtk_widget_show(progressbar);
+               gtk_widget_set_size_request(progressbar, 70, -1);
+               gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);                              \
+               mainwin->progressbar = progressbar;
+#endif
                activate_compose_button(toolbar_data, 
                                        prefs_common.toolbar_style, 
                                        toolbar_data->compose_btn_type);
+       }
+       if (type != TOOLBAR_COMPOSE)
+               activate_learn_button(toolbar_data, prefs_common.toolbar_style,
+                               LEARN_SPAM);
        
-       gtk_widget_show_all(toolbar);
-       
+#ifndef MAEMO
+       gtk_container_add(GTK_CONTAINER(container), toolbar);
+       gtk_container_set_border_width(GTK_CONTAINER(container), 2);
+#else
+       if ( GTK_IS_WINDOW(container) ) {
+               hildon_window_add_toolbar (HILDON_WINDOW(container), GTK_TOOLBAR(toolbar));
+               gtk_widget_show_all (container);
+       } else {
+               gtk_container_add(GTK_CONTAINER(container), toolbar);
+               gtk_container_set_border_width(GTK_CONTAINER(container), 2);
+       }
+#endif
        return toolbar_data; 
 }
 
@@ -1822,6 +2086,7 @@ void toolbar_update(ToolbarType type, gpointer data)
        Compose    *compose = (Compose*)data;
        MessageView *msgview = (MessageView*)data;
 
+#ifndef MAEMO
        switch(type) {
        case TOOLBAR_MAIN:
                toolbar_data = mainwin->toolbar;
@@ -1844,6 +2109,30 @@ void toolbar_update(ToolbarType type, gpointer data)
 
        toolbar_init(toolbar_data);
        toolbar_data = toolbar_create(type, handlebox, data);
+#else
+       switch(type) {
+       case TOOLBAR_MAIN:
+               toolbar_data = mainwin->toolbar;
+               handlebox    = mainwin->window;
+               break;
+       case TOOLBAR_COMPOSE:
+               toolbar_data = compose->toolbar;
+               handlebox    = compose->window;
+               break;
+       case TOOLBAR_MSGVIEW:
+               toolbar_data = msgview->toolbar;
+               handlebox    = msgview->window;
+               break;
+       default:
+               return;
+       }
+
+       hildon_window_remove_toolbar(HILDON_WINDOW(handlebox), GTK_WIDGET(toolbar_data->toolbar));
+
+       toolbar_init(toolbar_data);
+       toolbar_data = toolbar_create(type, handlebox, data);
+#endif
+
        switch(type) {
        case TOOLBAR_MAIN:
                mainwin->toolbar = toolbar_data;
@@ -1858,8 +2147,59 @@ void toolbar_update(ToolbarType type, gpointer data)
 
        toolbar_style(type, prefs_common.toolbar_style, data);
 
-       if (type == TOOLBAR_MAIN)
+       if (type == TOOLBAR_MAIN) {
                toolbar_main_set_sensitive((MainWindow*)data);
+               account_set_menu_only_toolbar();
+       }
+}
+
+#define GTK_BUTTON_SET_SENSITIVE(widget,sensitive) {           \
+       gboolean in_btn1 = FALSE, in_btn2 = FALSE;              \
+       if (GTK_IS_BUTTON(widget))                              \
+               in_btn1 = GTK_BUTTON(widget)->in_button;        \
+       else if (GTK_IS_MENU_TOOL_BUTTON(widget)) {             \
+               GtkWidget *child = gtk_bin_get_child(           \
+                       GTK_BIN(widget));                       \
+               GList *gchild = gtk_container_get_children(     \
+                       GTK_CONTAINER(child));                  \
+               GtkWidget *btn = (GtkWidget *)gchild->data;     \
+               GtkWidget *arr = (GtkWidget *)                  \
+                       (gchild->next?gchild->next->data:NULL); \
+               g_list_free(gchild);                            \
+               if (GTK_IS_BUTTON(btn))                         \
+                       in_btn1 = GTK_BUTTON(btn)->in_button;   \
+               if (GTK_IS_BUTTON(arr))                         \
+                       in_btn2 = GTK_BUTTON(arr)->in_button;   \
+       }                                                       \
+       else if (GTK_IS_TOOL_ITEM(widget)) {                    \
+               GtkWidget *child = gtk_bin_get_child(           \
+                       GTK_BIN(widget));                       \
+               if (GTK_IS_BUTTON(child))                       \
+                       in_btn1 = GTK_BUTTON(child)->in_button; \
+       }                                                       \
+       gtk_widget_set_sensitive(widget, sensitive);            \
+       if (GTK_IS_BUTTON(widget))                              \
+               GTK_BUTTON(widget)->in_button = in_btn1;        \
+       else if (GTK_IS_MENU_TOOL_BUTTON(widget)) {             \
+               GtkWidget *child = gtk_bin_get_child(           \
+                       GTK_BIN(widget));                       \
+               GList *gchild = gtk_container_get_children(     \
+                       GTK_CONTAINER(child));                  \
+               GtkWidget *btn = (GtkWidget *)gchild->data;     \
+               GtkWidget *arr = (GtkWidget *)                  \
+                       (gchild->next?gchild->next->data:NULL); \
+               g_list_free(gchild);                            \
+               if (GTK_IS_BUTTON(btn))                         \
+                       GTK_BUTTON(btn)->in_button = in_btn1;   \
+               if (GTK_IS_BUTTON(arr))                         \
+                       GTK_BUTTON(arr)->in_button = in_btn2;   \
+       }                                                       \
+       else if (GTK_IS_TOOL_ITEM(widget)) {                    \
+               GtkWidget *child = gtk_bin_get_child(           \
+                       GTK_BIN(widget));                       \
+               if (GTK_IS_BUTTON(child))                       \
+                       GTK_BUTTON(child)->in_button = in_btn1; \
+       }                                                       \
 }
 
 void toolbar_main_set_sensitive(gpointer data)
@@ -1886,23 +2226,81 @@ void toolbar_main_set_sensitive(gpointer data)
        entry_list = g_slist_append(entry_list, e); \
 }
 
-       SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
-       SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
-       SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
-       SET_WIDGET_COND(toolbar->reply_btn,
-                       M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
-       SET_WIDGET_COND(toolbar->replyall_btn,
-                       M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
-       SET_WIDGET_COND(toolbar->replylist_btn,
-                       M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
-       SET_WIDGET_COND(toolbar->replysender_btn,
-                       M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
-       SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
-
-       SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
-       SET_WIDGET_COND(toolbar->delete_btn,
-                       M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
-       SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
+       
+       if (toolbar->get_btn)
+               SET_WIDGET_COND(toolbar->get_btn, 
+                       M_HAVE_ACCOUNT|M_UNLOCKED);
+
+       if (toolbar->getall_btn) {
+               SET_WIDGET_COND(toolbar->getall_btn, 
+                       M_HAVE_ACCOUNT|M_UNLOCKED);
+       }
+       if (toolbar->send_btn) {
+               SET_WIDGET_COND(toolbar->send_btn,
+                       M_HAVE_QUEUED_MAILS);
+       }
+       if (toolbar->compose_mail_btn) {
+               SET_WIDGET_COND(toolbar->compose_mail_btn, 
+                       M_HAVE_ACCOUNT);
+       }
+       if (toolbar->close_window_btn) {
+               SET_WIDGET_COND(toolbar->close_window_btn, 
+                       M_UNLOCKED);
+       }
+       if (toolbar->open_mail_btn) {
+               SET_WIDGET_COND(toolbar->open_mail_btn, 
+                       M_TARGET_EXIST);
+       }
+       if (toolbar->reply_btn) {
+               SET_WIDGET_COND(toolbar->reply_btn,
+                       M_HAVE_ACCOUNT|M_TARGET_EXIST);
+       }
+       if (toolbar->replyall_btn) {
+               SET_WIDGET_COND(toolbar->replyall_btn,
+                       M_HAVE_ACCOUNT|M_TARGET_EXIST);
+       }
+       if (toolbar->replylist_btn) {
+               SET_WIDGET_COND(toolbar->replylist_btn,
+                       M_HAVE_ACCOUNT|M_TARGET_EXIST);
+       }
+       if (toolbar->replysender_btn) {
+               SET_WIDGET_COND(toolbar->replysender_btn,
+                       M_HAVE_ACCOUNT|M_TARGET_EXIST);
+       }
+       if (toolbar->fwd_btn) {
+               SET_WIDGET_COND(toolbar->fwd_btn, 
+                       M_HAVE_ACCOUNT|M_TARGET_EXIST);
+       }
+
+       if (prefs_common.next_unread_msg_dialog == NEXTUNREADMSGDIALOG_ASSUME_NO) {
+               SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
+       } else {
+               SET_WIDGET_COND(toolbar->next_btn, 0);
+       }
+       
+       if (toolbar->trash_btn)
+               SET_WIDGET_COND(toolbar->trash_btn,
+                       M_TARGET_EXIST|M_ALLOW_DELETE);
+
+       if (toolbar->delete_btn)
+               SET_WIDGET_COND(toolbar->delete_btn,
+                       M_TARGET_EXIST|M_ALLOW_DELETE);
+
+       if (toolbar->exec_btn)
+               SET_WIDGET_COND(toolbar->exec_btn, 
+                       M_DELAY_EXEC);
+       
+/*     if (toolbar->learn_ham_btn)
+               SET_WIDGET_COND(toolbar->learn_ham_btn,
+                       M_TARGET_EXIST|M_CAN_LEARN_SPAM);
+*/
+       if (toolbar->learn_spam_btn)
+               SET_WIDGET_COND(toolbar->learn_spam_btn, 
+                       M_TARGET_EXIST|M_CAN_LEARN_SPAM);
+
+       if (toolbar->cancel_inc_btn)
+               SET_WIDGET_COND(toolbar->cancel_inc_btn,
+                               M_INC_ACTIVE);
 
        for (cur = toolbar->action_list; cur != NULL;  cur = cur->next) {
                ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
@@ -1919,15 +2317,14 @@ void toolbar_main_set_sensitive(gpointer data)
 
                if (e->widget != NULL) {
                        sensitive = ((e->cond & state) == e->cond);
-                       gtk_widget_set_sensitive(e->widget, sensitive); 
+                       GTK_BUTTON_SET_SENSITIVE(e->widget, sensitive); 
                }
        }
        
        while (entry_list != NULL) {
                Entry *e = (Entry*) entry_list->data;
 
-               if (e)
-                       g_free(e);
+               g_free(e);
                entry_list = g_slist_remove(entry_list, e);
        }
 
@@ -1936,6 +2333,7 @@ void toolbar_main_set_sensitive(gpointer data)
        activate_compose_button(toolbar, 
                                prefs_common.toolbar_style,
                                toolbar->compose_btn_type);
+       
 }
 
 void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
@@ -1944,26 +2342,32 @@ void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
        GSList *items = compose->toolbar->action_list;
 
        if (compose->toolbar->send_btn)
-               gtk_widget_set_sensitive(compose->toolbar->send_btn, sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->send_btn, sensitive);
        if (compose->toolbar->sendl_btn)
-               gtk_widget_set_sensitive(compose->toolbar->sendl_btn, sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sendl_btn, sensitive);
        if (compose->toolbar->draft_btn )
-               gtk_widget_set_sensitive(compose->toolbar->draft_btn , sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->draft_btn , sensitive);
        if (compose->toolbar->insert_btn )
-               gtk_widget_set_sensitive(compose->toolbar->insert_btn , sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->insert_btn , sensitive);
        if (compose->toolbar->attach_btn)
-               gtk_widget_set_sensitive(compose->toolbar->attach_btn, sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->attach_btn, sensitive);
        if (compose->toolbar->sig_btn)
-               gtk_widget_set_sensitive(compose->toolbar->sig_btn, sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->sig_btn, sensitive);
        if (compose->toolbar->exteditor_btn)
-               gtk_widget_set_sensitive(compose->toolbar->exteditor_btn, sensitive);
-       if (compose->toolbar->linewrap_btn)
-               gtk_widget_set_sensitive(compose->toolbar->linewrap_btn, sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->exteditor_btn, sensitive);
+       if (compose->toolbar->linewrap_current_btn)
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_current_btn, sensitive);
+       if (compose->toolbar->linewrap_all_btn)
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->linewrap_all_btn, sensitive);
        if (compose->toolbar->addrbook_btn)
-               gtk_widget_set_sensitive(compose->toolbar->addrbook_btn, sensitive);
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->addrbook_btn, sensitive);
+#ifdef USE_ASPELL
+       if (compose->toolbar->spellcheck_btn)
+               GTK_BUTTON_SET_SENSITIVE(compose->toolbar->spellcheck_btn, sensitive);
+#endif
        for (; items != NULL; items = g_slist_next(items)) {
                ToolbarSylpheedActions *item = (ToolbarSylpheedActions *)items->data;
-               gtk_widget_set_sensitive(item->widget, sensitive);
+               GTK_BUTTON_SET_SENSITIVE(item->widget, sensitive);
        }
 }
 
@@ -1972,30 +2376,39 @@ void toolbar_comp_set_sensitive(gpointer data, gboolean sensitive)
  **/
 void toolbar_init(Toolbar * toolbar) {
 
-       toolbar->toolbar          = NULL;
-       toolbar->get_btn          = NULL;
-       toolbar->getall_btn       = NULL;
-       toolbar->send_btn         = NULL;
-       toolbar->compose_mail_btn = NULL;
-       toolbar->compose_news_btn = NULL;
-       toolbar->reply_btn        = NULL;
-       toolbar->replysender_btn  = NULL;
-       toolbar->replyall_btn     = NULL;
-       toolbar->replylist_btn    = NULL;
-       toolbar->fwd_btn          = NULL;
-       toolbar->delete_btn       = NULL;
-       toolbar->next_btn         = NULL;
-       toolbar->exec_btn         = NULL;
-
+       toolbar->toolbar                = NULL;
+       toolbar->folders_btn            = NULL;
+       toolbar->get_btn                = NULL;
+       toolbar->getall_btn             = NULL;
+       toolbar->send_btn               = NULL;
+       toolbar->compose_mail_btn       = NULL;
+       toolbar->compose_mail_icon      = NULL;
+       toolbar->compose_news_icon      = NULL;
+       toolbar->reply_btn              = NULL;
+       toolbar->replysender_btn        = NULL;
+       toolbar->replyall_btn           = NULL;
+       toolbar->replylist_btn          = NULL;
+       toolbar->fwd_btn                = NULL;
+       toolbar->trash_btn              = NULL;
+       toolbar->delete_btn             = NULL;
+       toolbar->prev_btn               = NULL;
+       toolbar->next_btn               = NULL;
+       toolbar->exec_btn               = NULL;
+       toolbar->open_mail_btn          = NULL;
+       toolbar->close_window_btn       = NULL;
        /* compose buttons */ 
-       toolbar->sendl_btn        = NULL;
-       toolbar->draft_btn        = NULL;
-       toolbar->insert_btn       = NULL;
-       toolbar->attach_btn       = NULL;
-       toolbar->sig_btn          = NULL;       
-       toolbar->exteditor_btn    = NULL;       
-       toolbar->linewrap_btn     = NULL;       
-       toolbar->addrbook_btn     = NULL;       
+       toolbar->sendl_btn              = NULL;
+       toolbar->draft_btn              = NULL;
+       toolbar->insert_btn             = NULL;
+       toolbar->attach_btn             = NULL;
+       toolbar->sig_btn                = NULL; 
+       toolbar->exteditor_btn          = NULL; 
+       toolbar->linewrap_current_btn   = NULL; 
+       toolbar->linewrap_all_btn       = NULL; 
+       toolbar->addrbook_btn           = NULL; 
+#ifdef USE_ASPELL
+       toolbar->spellcheck_btn         = NULL;
+#endif
 
        toolbar_destroy(toolbar);
 }
@@ -2008,7 +2421,6 @@ static void toolbar_reply(gpointer data, guint action)
        MainWindow *mainwin;
        MessageView *msgview;
        GSList *msginfo_list = NULL;
-       gchar *body;
 
        g_return_if_fail(toolbar_item != NULL);
 
@@ -2020,6 +2432,7 @@ static void toolbar_reply(gpointer data, guint action)
                break;
        case TOOLBAR_MSGVIEW:
                msgview = (MessageView*)toolbar_item->parent;
+               g_return_if_fail(msgview != NULL);      
                msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
                break;
        default:
@@ -2027,12 +2440,8 @@ static void toolbar_reply(gpointer data, guint action)
        }
 
        g_return_if_fail(msgview != NULL);
-       body = messageview_get_selection(msgview);
-
        g_return_if_fail(msginfo_list != NULL);
-       compose_reply_mode((ComposeMode)action, msginfo_list, body);
-
-       g_free(body);
+       compose_reply_from_messageview(msgview, msginfo_list, action);
        g_slist_free(msginfo_list);
 
        /* TODO: update reply state ion summaryview */
@@ -2058,19 +2467,57 @@ void inc_all_account_mail_cb(gpointer data, guint action, GtkWidget *widget)
 void send_queue_cb(gpointer data, guint action, GtkWidget *widget)
 {
        GList *list;
+       gboolean found;
+       gboolean got_error = FALSE;
+       gchar *errstr = NULL;
 
        if (prefs_common.work_offline)
                if (alertpanel(_("Offline warning"), 
                               _("You're working offline. Override?"),
-                              _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+                              GTK_STOCK_NO, GTK_STOCK_YES,
+                              NULL) != G_ALERTALTERNATE)
                return;
 
+       /* ask for confirmation before sending queued messages only
+          in online mode and if there is at least one message queued
+          in any of the folder queue
+       */
+       if (prefs_common.confirm_send_queued_messages) {
+               found = FALSE;
+               /* check if there's a queued message */
+               for (list = folder_get_list(); !found && list != NULL; list = list->next) {
+                       Folder *folder = list->data;
+
+                       found = !procmsg_queue_is_empty(folder->queue);
+               }
+               /* if necessary, ask for confirmation before sending */
+               if (found && !prefs_common.work_offline) {
+                       if (alertpanel(_("Send queued messages"), 
+                                  _("Send all queued messages?"),
+                                  GTK_STOCK_CANCEL, _("_Send"),
+                                  NULL) != G_ALERTALTERNATE)
+                               return;
+               }
+       }
+
        for (list = folder_get_list(); list != NULL; list = list->next) {
                Folder *folder = list->data;
 
                if (folder->queue) {
-                       procmsg_send_queue(folder->queue, prefs_common.savemsg);
-                       folder_item_scan(folder->queue);
+                       if (procmsg_send_queue(folder->queue, 
+                                              prefs_common.savemsg,
+                                              &errstr) < 0)
+                               got_error = TRUE;
+               }
+       }
+       if (got_error) {
+               if (!errstr)
+                       alertpanel_error_log(_("Some errors occurred while "
+                                          "sending queued messages."));
+               else {
+                       alertpanel_error_log(_("Some errors occurred "
+                                       "while sending queued messages:\n%s"), errstr);
+                       g_free(errstr);
                }
        }
 }
@@ -2082,11 +2529,11 @@ void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
        FolderItem *item = mainwin->summaryview->folder_item;   
         GList * list;
         GList * cur;
-
+       
        if (item) {
                ac = account_find_from_item(item);
                if (ac && ac->protocol != A_NNTP) {
-                       compose_new_with_folderitem(ac, item);          /* CLAWS */
+                       compose_new_with_folderitem(ac, item, NULL);            /* CLAWS */
                        return;
                }
        }
@@ -2095,7 +2542,7 @@ void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
         * CLAWS - use current account
         */
        if (cur_account && (cur_account->protocol != A_NNTP)) {
-               compose_new_with_folderitem(cur_account, item);
+               compose_new_with_folderitem(cur_account, item, NULL);
                return;
        }
 
@@ -2106,7 +2553,7 @@ void compose_mail_cb(gpointer data, guint action, GtkWidget *widget)
        for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
                ac = (PrefsAccount *) cur->data;
                if (ac->protocol != A_NNTP) {
-                       compose_new_with_folderitem(ac, item);
+                       compose_new_with_folderitem(ac, item, NULL);
                        return;
                }
        }
@@ -2122,9 +2569,8 @@ void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
        if (mainwin->summaryview->folder_item) {
                ac = mainwin->summaryview->folder_item->folder->account;
                if (ac && ac->protocol == A_NNTP) {
-                       compose_new(ac,
-                                   mainwin->summaryview->folder_item->path,
-                                   NULL);
+                       compose_new_with_folderitem(ac,
+                                   mainwin->summaryview->folder_item, NULL);
                        return;
                }
        }
@@ -2133,7 +2579,8 @@ void compose_news_cb(gpointer data, guint action, GtkWidget *widget)
        for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
                ac = (PrefsAccount *) cur->data;
                if (ac->protocol == A_NNTP) {
-                       compose_new(ac, NULL, NULL);
+                       compose_new_with_folderitem(ac,
+                                   mainwin->summaryview->folder_item, NULL);
                        return;
                }
        }