2007-07-27 [paul] 2.10.0cvs74
[claws.git] / src / mainwindow.c
index a025a84fdaa06d514bb53e9d2392006f93a16d64..ef829dfa39b34122e2be9e869139792103a30c14 100644 (file)
@@ -1,20 +1,19 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+   Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+   Copyright (C) 1999-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 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.
  */
 
 #include "defs.h"
@@ -188,13 +187,17 @@ static void toggle_message_cb      (MainWindow    *mainwin,
 static void toggle_toolbar_cb   (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+static void toggle_col_headers_cb(MainWindow   *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
+#ifndef MAEMO
 static void toggle_statusbar_cb         (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
 static void set_layout_cb       (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
-
+#endif
 static void addressbook_open_cb        (MainWindow     *mainwin,
                                 guint           action,
                                 GtkWidget      *widget);
@@ -268,6 +271,12 @@ static void ignore_thread_cb               (MainWindow     *mainwin,
 static void unignore_thread_cb         (MainWindow     *mainwin, 
                                         guint           action,
                                         GtkWidget      *widget);
+static void watch_thread_cb            (MainWindow     *mainwin, 
+                                        guint           action,
+                                        GtkWidget      *widget);
+static void unwatch_thread_cb          (MainWindow     *mainwin, 
+                                        guint           action,
+                                        GtkWidget      *widget);
 static void lock_msgs_cb               (MainWindow     *mainwin, 
                                         guint           action,
                                         GtkWidget      *widget);
@@ -558,13 +567,18 @@ static GtkItemFactoryEntry mainwin_entries[] =
                                                NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
        {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
                                                NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
+#ifndef MAEMO
        {N_("/_View/Show or hi_de/Status _bar"),
                                                NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
+#endif
+       {N_("/_View/Show or hi_de/Column headers"),
+                                               NULL, toggle_col_headers_cb, 0, "<ToggleItem>"},
        {N_("/_View/Set displayed _columns"),   NULL, NULL, 0, "<Branch>"},
        {N_("/_View/Set displayed _columns/in _Folder list..."),        NULL, set_folder_display_item_cb, 0, NULL},
        {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
 
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
+#ifndef MAEMO
        {N_("/_View/La_yout"),                  NULL, NULL, 0, "<Branch>"},
        {N_("/_View/Layout/_Standard"),         NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
        {N_("/_View/Layout/_Three columns"),    NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
@@ -572,6 +586,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
        {N_("/_View/Layout/S_mall screen"),     NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
+#endif
        {N_("/_View/_Sort"),                    NULL, NULL, 0, "<Branch>"},
        {N_("/_View/_Sort/by _number"),         NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
        {N_("/_View/_Sort/by S_ize"),           NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
@@ -580,10 +595,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/_Sort/by _From"),           NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
        {N_("/_View/_Sort/by _To"),             NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
        {N_("/_View/_Sort/by S_ubject"),        NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
-       {N_("/_View/_Sort/by _color label"),
-                                               NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
-       {N_("/_View/_Sort/by tag"),
-                                               NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
+       {N_("/_View/_Sort/by _color label"),    NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
+       {N_("/_View/_Sort/by tag"),             NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
        {N_("/_View/_Sort/by _mark"),           NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
        {N_("/_View/_Sort/by _status"),         NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
        {N_("/_View/_Sort/by a_ttachment"),
@@ -809,6 +822,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Message/_Mark/Mark all _read"),  NULL, mark_all_read_cb, 0, NULL},
        {N_("/_Message/_Mark/Ignore thread"),   NULL, ignore_thread_cb, 0, NULL},
        {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
+       {N_("/_Message/_Mark/Watch thread"),    NULL, watch_thread_cb, 0, NULL},
+       {N_("/_Message/_Mark/Unwatch thread"),  NULL, unwatch_thread_cb, 0, NULL},
        {N_("/_Message/_Mark/---"),             NULL, NULL, 0, "<Separator>"},
        {N_("/_Message/_Mark/Mark as _spam"),   NULL, mark_as_spam_cb, 1, NULL},
        {N_("/_Message/_Mark/Mark as _ham"),    NULL, mark_as_spam_cb, 0, NULL},
@@ -1021,7 +1036,11 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                                        g_direct_hash,
                                        g_direct_equal,
                                        NULL, NULL);
-
+       GHashTable *menu_allsel_table = g_hash_table_new_full(
+                                       g_direct_hash,
+                                       g_direct_equal,
+                                       NULL, NULL);
+       gint sel_len;
        mainwin = (MainWindow *)data;
        g_return_if_fail(mainwin != NULL);
 
@@ -1045,34 +1064,53 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                                (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
                                
                        g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
+                       g_hash_table_insert(menu_allsel_table, GINT_TO_POINTER(id), GINT_TO_POINTER(0));
                }
        }
 
        /* iterate all messages and set the state of the appropriate
         * items */
+       sel_len = 0;
        for (; sel != NULL; sel = sel->next) {
                MsgInfo *msginfo;
                GSList *tags = NULL;
                gint id;
                GtkCheckMenuItem *item;
                msginfo = (MsgInfo *)sel->data;
+               sel_len++;
                if (msginfo) {
                        tags =  msginfo->tags;
                        if (!tags)
                                continue;
 
                        for (; tags; tags = tags->next) {
+                               gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
                                id = GPOINTER_TO_INT(tags->data);
                                item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
-                               if (item && !item->active)
+                               if (item && !item->active) {
                                        gtk_check_menu_item_set_active
                                                (item, TRUE);
+                               }
+                               num_checked++;
+                               g_hash_table_replace(menu_allsel_table, tags->data, GINT_TO_POINTER(num_checked));
                        }
                }
        }
 
+       for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+               if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
+                       gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
+                               "tag_id"));
+                       gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, GINT_TO_POINTER(id)));
+                       if (num_checked < sel_len && num_checked > 0)
+                               gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), TRUE);
+                       else
+                               gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
+               }
+       }
        g_slist_free(sel);
        g_hash_table_destroy(menu_table);
+       g_hash_table_destroy(menu_allsel_table);
        /* reset "dont_toggle" state */
        g_object_set_data(G_OBJECT(menu), "dont_toggle",
                          GINT_TO_POINTER(0));
@@ -1158,11 +1196,11 @@ static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refr
        mainwin->colorlabel_menu = menu;
 }
 
-static void mainwindow_tags_menu_item_new_tag_activate_cb(GtkWidget *widget,
+static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
                                                     gpointer data)
 {
        MainWindow *mainwin;
-       gint id;
+
        mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
        g_return_if_fail(mainwin != NULL);
 
@@ -1171,11 +1209,7 @@ static void mainwindow_tags_menu_item_new_tag_activate_cb(GtkWidget *widget,
                                "dont_toggle"))
                return;
        
-       id = prefs_tags_create_new(mainwin);
-       if (id != -1) {
-               summary_set_tag(mainwin->summaryview, id, NULL);
-               main_window_reflect_tags_changes(mainwindow_get_mainwindow());
-       }
+       tag_apply_open(summary_get_selection(mainwin->summaryview));    
 }
 
 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
@@ -1220,14 +1254,20 @@ static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
                gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
                gtk_widget_show(item);
        }
-       item = gtk_menu_item_new_with_label(_("New tag..."));
+
+       item = gtk_menu_item_new_with_label(_("Apply tags..."));
+       gtk_widget_add_accelerator(item, "activate", 
+                  mainwin->menu_factory->accel_group, 
+                  GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
+                  GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
        g_signal_connect(G_OBJECT(item), "activate",
-                        G_CALLBACK(mainwindow_tags_menu_item_new_tag_activate_cb),
+                        G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
                         NULL);
        g_object_set_data(G_OBJECT(item), "mainwin",
                          mainwin);
        gtk_widget_show(item);
+
        g_slist_free(orig);
        gtk_widget_show(menu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
@@ -1287,6 +1327,7 @@ MainWindow *main_window_create()
        GtkWidget *menubar;
        GtkWidget *handlebox;
        GtkWidget *vbox_body;
+#ifndef MAEMO
        GtkWidget *hbox_stat;
        GtkWidget *statusbar;
        GtkWidget *progressbar;
@@ -1295,12 +1336,12 @@ MainWindow *main_window_create()
        GtkWidget *ac_label;
        GtkWidget *online_pixmap;
        GtkWidget *offline_pixmap;
-       GtkWidget *online_switch;
-       GtkWidget *offline_switch;
        GtkTooltips *tips;
        GtkWidget *warning_icon;
        GtkWidget *warning_btn;
-
+#endif
+       GtkWidget *online_switch;
+       GtkWidget *offline_switch;
        FolderView *folderview;
        SummaryView *summaryview;
        MessageView *messageview;
@@ -1319,10 +1360,12 @@ MainWindow *main_window_create()
        mainwin = g_new0(MainWindow, 1);
 
        /* main window */
-       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
+       window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
        gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
-
+#ifdef MAEMO
+       prefs_common.layout_mode = SMALL_LAYOUT;
+#endif
        if (!geometry.min_height) {
                geometry.min_width = 320;
                geometry.min_height = 200;
@@ -1354,7 +1397,11 @@ MainWindow *main_window_create()
        menubar = menubar_create(window, mainwin_entries, 
                                 n_menu_entries, "<Main>", mainwin);
        gtk_widget_show(menubar);
+
+#ifndef MAEMO
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
+#endif
+
        ifactory = gtk_item_factory_from_widget(menubar);
 
 /*     gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
@@ -1377,11 +1424,17 @@ MainWindow *main_window_create()
        }
        /* link window to mainwin->window to avoid gdk warnings */
        mainwin->window       = window;
+       mainwin_list = g_list_append(mainwin_list, mainwin);
        
-       /* create toolbar */
+#ifdef MAEMO
+       mainwin->toolbar = toolbar_create(TOOLBAR_MAIN, 
+                                         window, 
+                                         (gpointer)mainwin);
+#else
        mainwin->toolbar = toolbar_create(TOOLBAR_MAIN, 
                                          handlebox, 
                                          (gpointer)mainwin);
+#endif
        toolbar_set_learn_button
                (mainwin->toolbar,
                 LEARN_SPAM);
@@ -1392,6 +1445,7 @@ MainWindow *main_window_create()
        gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
        gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
 
+#ifndef MAEMO
        hbox_stat = gtk_hbox_new(FALSE, 2);
        gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
 
@@ -1466,7 +1520,12 @@ MainWindow *main_window_create()
 
        gtk_widget_hide(offline_switch);
        gtk_widget_hide(warning_btn);
-
+#else
+       online_switch = gtk_button_new ();
+       offline_switch = gtk_button_new ();
+       g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
+       g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
+#endif
        /* create views */
        mainwin->folderview  = folderview  = folderview_create();
        mainwin->summaryview = summaryview = summary_create();
@@ -1508,23 +1567,23 @@ MainWindow *main_window_create()
        summaryview->messageview = messageview;
        summaryview->window      = window;
 
-       messageview->statusbar   = statusbar;
        mainwin->vbox           = vbox;
        mainwin->menubar        = menubar;
        mainwin->menu_factory   = ifactory;
        mainwin->handlebox      = handlebox;
        mainwin->vbox_body      = vbox_body;
-       mainwin->hbox_stat      = hbox_stat;
+       mainwin->online_switch  = online_switch;
+       mainwin->offline_switch    = offline_switch;
+#ifndef MAEMO
+       messageview->statusbar  = statusbar;
        mainwin->statusbar      = statusbar;
+       mainwin->hbox_stat      = hbox_stat;
        mainwin->progressbar    = progressbar;
        mainwin->statuslabel    = statuslabel;
-       mainwin->online_switch  = online_switch;
        mainwin->online_pixmap  = online_pixmap;
        mainwin->offline_pixmap = offline_pixmap;
        mainwin->ac_button      = ac_button;
        mainwin->ac_label       = ac_label;
-       mainwin->offline_switch    = offline_switch;
-       
        /* set context IDs for status bar */
        mainwin->mainwin_cid = gtk_statusbar_get_context_id
                (GTK_STATUSBAR(statusbar), "Main Window");
@@ -1534,9 +1593,20 @@ MainWindow *main_window_create()
                (GTK_STATUSBAR(statusbar), "Summary View");
        mainwin->messageview_cid = gtk_statusbar_get_context_id
                (GTK_STATUSBAR(statusbar), "Message View");
-
        messageview->statusbar_cid = mainwin->messageview_cid;
 
+#else
+       messageview->statusbar  = NULL;
+       mainwin->statusbar      = NULL;
+       mainwin->hbox_stat      = NULL;
+       /* mainwin->progressbar is set in toolbar.c */
+       mainwin->statuslabel    = NULL;
+       mainwin->online_pixmap  = NULL;
+       mainwin->offline_pixmap = NULL;
+       mainwin->ac_button      = NULL;
+       mainwin->ac_label       = NULL;
+#endif
+       
        /* allocate colors for summary view and folder view */
        summaryview->color_marked.red = summaryview->color_marked.green = 0;
        summaryview->color_marked.blue = (guint16)65535;
@@ -1605,12 +1675,17 @@ MainWindow *main_window_create()
        }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
 
+#ifndef MAEMO
        gtk_widget_hide(mainwin->hbox_stat);
        menuitem = gtk_item_factory_get_item
                (ifactory, "/View/Show or hide/Status bar");
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
                                       prefs_common.show_statusbar);
-       
+#endif 
+       menuitem = gtk_item_factory_get_item
+               (ifactory, "/View/Show or hide/Column headers");
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+                                      prefs_common.show_col_headers);
        /* set account selection menu */
        ac_menu = gtk_item_factory_get_widget
                (ifactory, "/Configuration/Change current account");
@@ -1639,7 +1714,9 @@ MainWindow *main_window_create()
           menu items in different menus             */
        menu_connect_identical_items();
 
+#ifndef MAEMO
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
+#endif
 
        g_signal_connect(G_OBJECT(window), "window_state_event",
                         G_CALLBACK(mainwindow_state_event_cb), mainwin);
@@ -1674,8 +1751,6 @@ MainWindow *main_window_create()
        if (!hand_cursor)
                hand_cursor = gdk_cursor_new(GDK_HAND2);
 
-       mainwin_list = g_list_append(mainwin_list, mainwin);
-
        /* init work_offline */
        if (prefs_common.work_offline)
                online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
@@ -1729,7 +1804,7 @@ void main_window_cursor_normal(MainWindow *mainwin)
 /* lock / unlock the user-interface */
 void main_window_lock(MainWindow *mainwin)
 {
-       if (mainwin->lock_count == 0)
+       if (mainwin->lock_count == 0 && mainwin->ac_button)
                gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
 
        mainwin->lock_count++;
@@ -1746,7 +1821,7 @@ void main_window_unlock(MainWindow *mainwin)
        main_window_set_menu_sensitive(mainwin);
        toolbar_main_set_sensitive(mainwin);
 
-       if (mainwin->lock_count == 0)
+       if (mainwin->lock_count == 0 && mainwin->ac_button)
                gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
 }
 
@@ -1789,7 +1864,7 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        compose_reflect_prefs_pixmap_theme();
                        folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
-
+#ifndef MAEMO
                        pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
                        gtk_container_remove(GTK_CONTAINER(mainwin->online_switch), 
                                             mainwin->online_pixmap);
@@ -1802,6 +1877,7 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
                        gtk_widget_show(pixmap);
                        mainwin->offline_pixmap = pixmap;
+#endif
                }
                
                headerview_set_font(mainwin->messageview->headerview);
@@ -1810,7 +1886,16 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                textview_reflect_prefs(mainwin->messageview->mimeview->textview);
                folderview_reflect_prefs();
                summary_reflect_prefs();
+#ifndef MAEMO
                summary_redisplay_msg(mainwin->summaryview);
+#endif
+               if (prefs_common.layout_mode == SMALL_LAYOUT) {
+                       if (mainwin->in_folder) {
+                               mainwindow_enter_folder(mainwin);
+                       } else {
+                               mainwindow_exit_folder(mainwin);
+                       }
+               }
        }
        prefs_tag = 0;
        return FALSE;
@@ -1960,24 +2045,18 @@ static void main_window_set_account_receive_menu(MainWindow *mainwin,
 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
                                                       GList *account_list)
 {
-       GList *cur_ac, *cur_item;
+       GList *cur_ac;
        GtkWidget *menuitem;
        PrefsAccount *ac_prefs;
        GtkWidget *menu = NULL;
 
-       if (mainwin->toolbar->getall_btn == NULL
-       ||  mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
+       if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
                return;
 
-       menu = mainwin->toolbar->getall_combo->menu;
-
-       /* destroy all previous menu item */
-       cur_item = GTK_MENU_SHELL(menu)->children;
-       while (cur_item != NULL) {
-               GList *next = cur_item->next;
-               gtk_widget_destroy(GTK_WIDGET(cur_item->data));
-               cur_item = next;
-       }
+       menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
+       if (menu)
+               gtk_widget_destroy(menu);
+       menu = gtk_menu_new();
 
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
                ac_prefs = (PrefsAccount *)cur_ac->data;
@@ -1991,29 +2070,25 @@ static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
                                 G_CALLBACK(account_receive_menu_cb),
                                 ac_prefs);
        }
+       gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
 }
 
 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
                                                       GList *account_list)
 {
-       GList *cur_ac, *cur_item;
+#ifndef MAEMO
+       GList *cur_ac;
        GtkWidget *menuitem;
        PrefsAccount *ac_prefs;
        GtkWidget *menu = NULL;
 
-       if (mainwin->toolbar->compose_mail_btn == NULL
-       ||  mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
+       if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
                return;
 
-       menu = mainwin->toolbar->compose_combo->menu;
-
-       /* destroy all previous menu item */
-       cur_item = GTK_MENU_SHELL(menu)->children;
-       while (cur_item != NULL) {
-               GList *next = cur_item->next;
-               gtk_widget_destroy(GTK_WIDGET(cur_item->data));
-               cur_item = next;
-       }
+       menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
+       if (menu)
+               gtk_widget_destroy(menu);
+       menu = gtk_menu_new();
 
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
                ac_prefs = (PrefsAccount *)cur_ac->data;
@@ -2027,6 +2102,8 @@ static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
                                 G_CALLBACK(account_compose_menu_cb),
                                 ac_prefs);
        }
+       gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
+#endif
 }
 
 void main_window_set_account_menu(GList *account_list)
@@ -2074,7 +2151,8 @@ static void main_window_show_cur_account(MainWindow *mainwin)
        g_free(buf);
 
        gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
-       gtk_widget_queue_resize(mainwin->ac_button);
+       if (mainwin->ac_button)
+               gtk_widget_queue_resize(mainwin->ac_button);
 
        g_free(ac_name);
 }
@@ -2932,9 +3010,10 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                                    prefs_common.msgview_height);
        }
 
+#ifndef MAEMO
        mainwin->messageview->statusbar = mainwin->statusbar;
        mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
-
+#endif
        /* clean top-most container */
        if (mainwin->hpaned) {
                if (mainwin->hpaned->parent == mainwin->vpaned)
@@ -3078,7 +3157,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
        if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview)) 
                gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
-       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
+       if (mainwin->messageview->mimeview->ctree_mode)
                gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
        else 
                gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
@@ -3097,6 +3176,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
 }
 
+#ifndef MAEMO
        switch (prefs_common.layout_mode) {
        case NORMAL_LAYOUT:
                SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
@@ -3114,6 +3194,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
                break;
        }
+#endif
 #undef SET_CHECK_MENU_ACTIVE
 
        if (folderwin) {
@@ -3344,7 +3425,24 @@ static void main_window_reply_cb(MainWindow *mainwin, guint action,
        g_slist_free(msginfo_list);
 }
 
+static void toggle_col_headers_cb(MainWindow *mainwin, guint action,
+                               GtkWidget *widget)
+{
+       FolderView *folderview = mainwin->folderview;
+       SummaryView *summaryview = mainwin->summaryview;
 
+       if (GTK_CHECK_MENU_ITEM(widget)->active) {
+               gtk_clist_column_titles_show(GTK_CLIST(folderview->ctree));
+               gtk_clist_column_titles_show(GTK_CLIST(summaryview->ctree));
+               prefs_common.show_col_headers = TRUE;
+       } else {
+               gtk_clist_column_titles_hide(GTK_CLIST(folderview->ctree));
+               gtk_clist_column_titles_hide(GTK_CLIST(summaryview->ctree));
+               prefs_common.show_col_headers = FALSE;
+       }
+}
+
+#ifndef MAEMO
 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
                                GtkWidget *widget)
 {
@@ -3390,6 +3488,7 @@ static void set_layout_cb(MainWindow *mainwin, guint action,
        summary_relayout(mainwin->summaryview); 
        summary_update_unread(mainwin->summaryview, NULL);
 }
+#endif
 
 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
                                        gboolean ask_sync)
@@ -3452,8 +3551,10 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
        g_return_if_fail(menuitem != NULL);
        
        if (btn == GTK_BUTTON(mainwin->online_switch)) {
+#ifndef MAEMO
                gtk_widget_hide (mainwin->online_switch);
                gtk_widget_show (mainwin->offline_switch);
+#endif
                menuitem->active = TRUE;
                inc_autocheck_timer_remove();
                        
@@ -3468,8 +3569,10 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                /*go online */
                if (!prefs_common.work_offline)
                        return;
+#ifndef MAEMO
                gtk_widget_hide (mainwin->offline_switch);
                gtk_widget_show (mainwin->online_switch);
+#endif
                menuitem->active = FALSE;
                prefs_common.work_offline = FALSE;
                inc_autocheck_timer_set();
@@ -3622,6 +3725,18 @@ static void unignore_thread_cb(MainWindow *mainwin, guint action,
        summary_unignore_thread(mainwin->summaryview);
 }
 
+static void watch_thread_cb(MainWindow *mainwin, guint action,
+                           GtkWidget *widget)
+{
+       summary_watch_thread(mainwin->summaryview);
+}
+
+static void unwatch_thread_cb(MainWindow *mainwin, guint action,
+                           GtkWidget *widget)
+{
+       summary_unwatch_thread(mainwin->summaryview);
+}
+
 static void lock_msgs_cb(MainWindow *mainwin, guint action,
                            GtkWidget *widget)
 {