2011-10-07 [colin] 3.7.10cvs21
[claws.git] / src / mainwindow.c
index 8ca4be2ff22c1ca0c1a03ce95c22bd61a03a0ff5..6b6ea7d83ffc69850f605ab6347d6257165532be 100644 (file)
@@ -1,6 +1,6 @@
 /*
    Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
-   Copyright (C) 1999-2008 Hiroyuki Yamamoto and the Claws Mail team
+   Copyright (C) 1999-2011 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
@@ -147,10 +147,8 @@ static void empty_trash_cb  (GtkAction     *action,
                                  gpointer       data);
 static void save_as_cb          (GtkAction     *action,
                                  gpointer       data);
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
 static void page_setup_cb       (GtkAction     *action,
                                  gpointer       data);
-#endif
 static void print_cb            (GtkAction     *action,
                                  gpointer       data);
 static void app_exit_cb                 (GtkAction     *action,
@@ -249,6 +247,8 @@ static void set_decode_cb           (GtkAction *action, GtkRadioAction *current, gpointer
 
 static void hide_read_messages   (GtkAction    *action,
                                  gpointer       data);
+static void hide_del_messages   (GtkAction     *action,
+                                 gpointer       data);
 
 static void thread_cb           (GtkAction     *action,
                                  gpointer       data);
@@ -278,6 +278,8 @@ static void process_cb               (GtkAction     *action,
                                  gpointer       data);
 static void execute_summary_cb  (GtkAction     *action,
                                  gpointer       data);
+static void expunge_summary_cb  (GtkAction     *action,
+                                 gpointer       data);
 static void update_summary_cb   (GtkAction     *action,
                                  gpointer       data);
 
@@ -312,6 +314,15 @@ static void goto_folder_cb  (GtkAction     *action,
 static void goto_unread_folder_cb(GtkAction    *action,
                                  gpointer       data);
 
+static void scroll_prev_line_cb  (GtkAction      *action,
+                                  gpointer        data);
+static void scroll_next_line_cb  (GtkAction      *action,
+                                  gpointer        data);
+static void scroll_prev_page_cb  (GtkAction      *action,
+                                  gpointer        data);
+static void scroll_next_page_cb  (GtkAction      *action,
+                                  gpointer        data);
+
 static void copy_cb             (GtkAction     *action,
                                  gpointer       data);
 static void allsel_cb           (GtkAction     *action,
@@ -478,7 +489,7 @@ static GtkActionEntry mainwin_entries[] =
        {"File/AddMailbox/MH",                  NULL, N_("MH..."), NULL, NULL, G_CALLBACK(add_mailbox_cb) },
        {"File/---",                            NULL, "---" },
 
-       {"File/SortFolders",                    NULL, N_("Change folder order..."), NULL, NULL, G_CALLBACK(foldersort_cb) },
+       {"File/SortMailboxes",                  NULL, N_("Change mailbox order..."), NULL, NULL, G_CALLBACK(foldersort_cb) },
 
        /* {"File/---",                         NULL, "---" }, */
        {"File/ImportMbox",                     NULL, N_("_Import mbox file..."), NULL, NULL, G_CALLBACK(import_mbox_cb) },
@@ -490,9 +501,7 @@ static GtkActionEntry mainwin_entries[] =
 
        {"File/SaveAs",                         NULL, N_("_Save as..."), "<control>S", NULL, G_CALLBACK(save_as_cb) },
 
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
        {"File/PageSetup",                      NULL, N_("Page setup..."), NULL, NULL, G_CALLBACK(page_setup_cb) },
-#endif
        {"File/Print",                          NULL, N_("_Print..."), "<control>P", NULL, G_CALLBACK(print_cb) },
        /* {"File/---",                         NULL, "---" }, */
        {"File/SynchroniseFolders",             NULL, N_("Synchronise folders"), "<control><shift>S", NULL, G_CALLBACK(sync_cb) }, 
@@ -551,8 +560,15 @@ static GtkActionEntry mainwin_entries[] =
        /* {"View/Goto/---",                    NULL, "---", NULL, NULL, NULL }, */
        {"View/Goto/NextUnreadFolder",          NULL, N_("Next unread _folder"), "<shift>G", NULL, G_CALLBACK(goto_unread_folder_cb) },
        {"View/Goto/OtherFolder",               NULL, N_("_Other folder..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
-       /* {"View/---",                         NULL, "---", NULL, NULL, NULL }, */
 
+        /* {"View/Scroll/---",                  NULL, "---", NULL, NULL, NULL }, */
+        {"View/Scroll",                         NULL, N_("Message Scroll") },
+        {"View/Scroll/PrevLine",                NULL, N_("Previous line"), NULL, NULL, G_CALLBACK(scroll_prev_line_cb) },
+        {"View/Scroll/NextLine",                NULL, N_("Next line"), NULL, NULL, G_CALLBACK(scroll_next_line_cb) },
+        {"View/Scroll/PrevPage",                NULL, N_("Previous page"), NULL, NULL, G_CALLBACK(scroll_prev_page_cb) },
+        {"View/Scroll/NextPage",                NULL, N_("Next page"), NULL, NULL, G_CALLBACK(scroll_next_page_cb) },
+
+       /* {"View/---",                         NULL, "---", NULL, NULL, NULL }, */
        {"View/Encoding",                       NULL, N_("Character _encoding") }, /* set_charset_cb */
        {"View/Encoding/---",                   NULL, "---" },
 #define ENC_ACTION(cs_char,c_char,string) \
@@ -629,7 +645,7 @@ static GtkActionEntry mainwin_entries[] =
        {"Message/CancelNews",                  NULL, N_("Cancel a news message"), NULL, NULL, G_CALLBACK(cancel_cb) },
        /*{"Message/---",                       NULL, "---" },*/
        
-       {"Message/Mark",                        NULL, "_Mark" },
+       {"Message/Mark",                        NULL, N_("_Mark") },
        {"Message/Mark/Mark",                   NULL, N_("_Mark"), "<shift>asterisk", NULL, G_CALLBACK(mark_cb) },
        {"Message/Mark/Unmark",                 NULL, N_("_Unmark"), "U", NULL, G_CALLBACK(unmark_cb) },
        {"Message/Mark/---",                    NULL, "---", NULL, NULL, NULL },
@@ -643,8 +659,8 @@ static GtkActionEntry mainwin_entries[] =
        {"Message/Mark/UnwatchThread",          NULL, N_("Unwatch thread"), NULL, NULL, G_CALLBACK(unwatch_thread_cb) },
        /* separation */
 
-       {"Message/Mark/MarkSpam",               NULL, N_("Mark as spam"), NULL, NULL, G_CALLBACK(mark_as_spam_cb) },
-       {"Message/Mark/MarkHam",                NULL, N_("Mark as ham"), NULL, NULL, G_CALLBACK(mark_as_ham_cb) },
+       {"Message/Mark/MarkSpam",               NULL, N_("Mark as _spam"), NULL, NULL, G_CALLBACK(mark_as_spam_cb) },
+       {"Message/Mark/MarkHam",                NULL, N_("Mark as _ham"), NULL, NULL, G_CALLBACK(mark_as_ham_cb) },
        /* separation */
 
        {"Message/Mark/Lock",                   NULL, N_("Lock"), NULL, NULL, G_CALLBACK(lock_msgs_cb) },
@@ -697,6 +713,7 @@ static GtkActionEntry mainwin_entries[] =
        /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
 
        {"Tools/Execute",                       NULL, N_("E_xecute"), "X", NULL, G_CALLBACK(execute_summary_cb) }, 
+       {"Tools/Expunge",                       NULL, N_("Exp_unge"), "<control>E", NULL, G_CALLBACK(expunge_summary_cb) }, 
 #ifdef USE_GNUTLS
        /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
        {"Tools/SSLCertificates",               NULL, N_("SSL cer_tificates"), NULL, NULL, G_CALLBACK(ssl_manager_open_cb) }, 
@@ -747,13 +764,14 @@ static GtkToggleActionEntry mainwin_toggle_entries[] = {
        {"View/ShowHide/ColumnHeaders",         NULL, N_("Column headers"), NULL, NULL, G_CALLBACK(toggle_col_headers_cb) }, /* toggle */
        {"View/ThreadView",                     NULL, N_("Th_read view"), "<control>T", NULL, G_CALLBACK(thread_cb) }, /* toggle */
        {"View/HideReadMessages",               NULL, N_("_Hide read messages"), NULL, NULL, G_CALLBACK(hide_read_messages) }, /* toggle */
+       {"View/HideDelMessages",                NULL, N_("Hide deleted messages"), NULL, NULL, G_CALLBACK(hide_del_messages) }, /* toggle */
 #ifndef MAEMO
        {"View/FullScreen",                     NULL, N_("_Fullscreen"), "F11", NULL, G_CALLBACK(toggle_fullscreen_cb) }, /* toggle */
 #endif
        {"View/AllHeaders",                     NULL, N_("Show all _headers"), "<control>H", NULL, G_CALLBACK(show_all_header_cb) }, /* toggle */
-       {"View/Quotes/FoldAll",                 NULL, N_("_Fold all"), "<control><shift>Q", NULL, G_CALLBACK(hide_quotes_cb) }, /* 1 toggle */
-       {"View/Quotes/Fold2",                   NULL, N_("Fold from level _2"), NULL, NULL, G_CALLBACK(hide_quotes_cb) }, /* 2 toggle */
-       {"View/Quotes/Fold3",                   NULL, N_("Fold from level _3"), NULL, NULL, G_CALLBACK(hide_quotes_cb) }, /* 3 toggle */
+       {"View/Quotes/CollapseAll",             NULL, N_("_Collapse all"), "<control><shift>Q", NULL, G_CALLBACK(hide_quotes_cb) }, /* 1 toggle */
+       {"View/Quotes/Collapse2",               NULL, N_("Collapse from level _2"), NULL, NULL, G_CALLBACK(hide_quotes_cb) }, /* 2 toggle */
+       {"View/Quotes/Collapse3",               NULL, N_("Collapse from level _3"), NULL, NULL, G_CALLBACK(hide_quotes_cb) }, /* 3 toggle */
 };
 
 static GtkRadioActionEntry mainwin_showhide_radio_entries[] = { /* toggle_toolbar_cb */
@@ -822,6 +840,7 @@ static GtkRadioActionEntry mainwin_radio_enc_entries[] =
        ENC_ACTION("Japanese/"CS_ISO_2022_JP_2, C_ISO_2022_JP_2, "ISO-2022-JP-_2"), /* RADIO set_charset_cb */
        ENC_ACTION("Japanese/"CS_EUC_JP, C_EUC_JP, "_EUC-JP"), /* RADIO set_charset_cb */
        ENC_ACTION("Japanese/"CS_SHIFT_JIS, C_SHIFT_JIS, "_Shift-JIS"), /* RADIO set_charset_cb */
+       ENC_ACTION("Chinese/"CS_GB18030, C_GB18030, "_GB18030"), /* RADIO set_charset_cb */
        ENC_ACTION("Chinese/"CS_GB2312, C_GB2312, "_GB2312"), /* RADIO set_charset_cb */
        ENC_ACTION("Chinese/"CS_GBK, C_GBK, "GB_K"), /* RADIO set_charset_cb */
        ENC_ACTION("Chinese/"CS_BIG5, C_BIG5, "_Big5-JP"), /* RADIO set_charset_cb */
@@ -873,17 +892,17 @@ static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_i
        GtkMenuShell *menu;
        GtkCheckMenuItem **items;
        gint n;
-       GList *cur;
+       GList *children, *cur;
        GSList *sel;
 
        mainwin = (MainWindow *)data;
-       g_return_if_fail(mainwin != NULL);
+       cm_return_if_fail(mainwin != NULL);
 
        sel = summary_get_selection(mainwin->summaryview);
        if (!sel) return;
 
        menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
-       g_return_if_fail(menu != NULL);
+       cm_return_if_fail(menu != NULL);
 
        Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
 
@@ -893,7 +912,8 @@ static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_i
                          GINT_TO_POINTER(1));
 
        /* clear items. get item pointers. */
-       for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (n = 0, cur = children; cur != NULL && cur->data != NULL; cur = cur->next) {
                if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
                        gtk_check_menu_item_set_active
                                (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
@@ -902,6 +922,8 @@ static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_i
                }
        }
 
+       g_list_free(children);
+
        if (n == (N_COLOR_LABELS + 1)) {
                /* iterate all messages and set the state of the appropriate
                 * items */
@@ -912,7 +934,7 @@ static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_i
                        msginfo = (MsgInfo *)sel->data;
                        if (msginfo) {
                                clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
-                               if (!items[clabel]->active)
+                               if (!gtk_check_menu_item_get_active(items[clabel]))
                                        gtk_check_menu_item_set_active
                                                (items[clabel], TRUE);
                        }
@@ -933,7 +955,7 @@ static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
        MainWindow *mainwin;
 
        mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
-       g_return_if_fail(mainwin != NULL);
+       cm_return_if_fail(mainwin != NULL);
 
        /* "dont_toggle" state set? */
        if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
@@ -948,7 +970,7 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
 {
        MainWindow *mainwin;
        GtkMenuShell *menu;
-       GList *cur;
+       GList *children, *cur;
        GSList *sel;
        GHashTable *menu_table = g_hash_table_new_full(
                                        g_direct_hash,
@@ -960,13 +982,13 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                                        NULL, NULL);
        gint sel_len;
        mainwin = (MainWindow *)data;
-       g_return_if_fail(mainwin != NULL);
+       cm_return_if_fail(mainwin != NULL);
 
        sel = summary_get_selection(mainwin->summaryview);
        if (!sel) return;
 
        menu = GTK_MENU_SHELL(mainwin->tags_menu);
-       g_return_if_fail(menu != NULL);
+       cm_return_if_fail(menu != NULL);
 
        /* NOTE: don't return prematurely because we set the "dont_toggle"
         * state for check menu items */
@@ -974,7 +996,8 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                          GINT_TO_POINTER(1));
 
        /* clear items. get item pointers. */
-       for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (cur = 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"));
@@ -986,6 +1009,8 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                }
        }
 
+       g_list_free(children);
+
        /* iterate all messages and set the state of the appropriate
         * items */
        sel_len = 0;
@@ -1005,7 +1030,7 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                                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 && !gtk_check_menu_item_get_active(item)) {
                                        gtk_check_menu_item_set_active
                                                (item, TRUE);
                                }
@@ -1015,7 +1040,8 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                }
        }
 
-       for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (cur = 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"));
@@ -1026,6 +1052,7 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
                                gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
                }
        }
+       g_list_free(children);
        g_slist_free(sel);
        g_hash_table_destroy(menu_table);
        g_hash_table_destroy(menu_allsel_table);
@@ -1042,7 +1069,7 @@ static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
        MainWindow *mainwin;
 
        mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
-       g_return_if_fail(mainwin != NULL);
+       cm_return_if_fail(mainwin != NULL);
 
        /* "dont_toggle" state set? */
        if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
@@ -1064,7 +1091,7 @@ void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModif
                        GtkLabel *label = g_object_get_data(G_OBJECT(item), "accel_label");
                        gchar *new_accel;
                        
-                       if (keyval == GDK_BackSpace) {
+                       if (keyval == GDK_KEY_BackSpace) {
                                const gchar *accel_path;
 #if GTK_CHECK_VERSION(2,14,0)
                                accel_path = gtk_menu_item_get_accel_path(item);
@@ -1153,7 +1180,7 @@ static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
        MainWindow *mainwin;
 
        mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
-       g_return_if_fail(mainwin != NULL);
+       cm_return_if_fail(mainwin != NULL);
 
        /* "dont_toggle" state set? */
        if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
@@ -1262,7 +1289,7 @@ static gboolean warning_visi_notify(GtkWidget *widget,
                                       GdkEventVisibility *event,
                                       MainWindow *mainwindow)
 {
-       gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
+       gdk_window_set_cursor(gtk_widget_get_window(mainwindow->warning_btn), hand_cursor);
        return FALSE;
 }
 
@@ -1270,7 +1297,7 @@ static gboolean warning_leave_notify(GtkWidget *widget,
                                      GdkEventCrossing *event,
                                      MainWindow *mainwindow)
 {
-       gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
+       gdk_window_set_cursor(gtk_widget_get_window(mainwindow->warning_btn), NULL);
        return FALSE;
 }
 
@@ -1278,7 +1305,7 @@ static gboolean warning_enter_notify(GtkWidget *widget,
                                      GdkEventCrossing *event,
                                      MainWindow *mainwindow)
 {
-       gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
+       gdk_window_set_cursor(gtk_widget_get_window(mainwindow->warning_btn), hand_cursor);
        return FALSE;
 }
 #endif
@@ -1311,15 +1338,19 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
        }
 
        switch (event->keyval) {
-       case GDK_Q:             /* Quit */
+       case GDK_KEY_Q:             /* Quit */
+#ifndef MAEMO
                BREAK_ON_MODIFIER_KEY();
 
-               app_exit_cb(NULL, mainwin);
+               if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
+                       app_exit_cb(NULL, mainwin);
+               }
+#endif
                return FALSE;
-       case GDK_space:
+       case GDK_KEY_space:
                BREAK_ON_MODIFIER_KEY();
                if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
-                       if (mainwin->folderview && mainwin->summaryview
+                       if (mainwin->folderview != NULL && mainwin->summaryview != NULL
                            && ((!mainwin->summaryview->displayed
                                && !mainwin->summaryview->selected) 
                                || (mainwin->summaryview->folder_item
@@ -1332,14 +1363,14 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                break;
 
 #ifdef MAEMO
-       case GDK_F6:
+       case GDK_KEY_F6:
                if (maemo_mainwindow_is_fullscreen(widget)) {
                        gtk_window_unfullscreen(GTK_WINDOW(widget));
                 } else {
                        gtk_window_fullscreen(GTK_WINDOW(widget));
                 }
                break;
-       case GDK_F7:
+       case GDK_KEY_F7:
                {
                        PangoFontDescription *font_desc;
                        int size;
@@ -1363,7 +1394,7 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                        pango_font_description_free(font_desc);
                }
                break;
-       case GDK_F8:
+       case GDK_KEY_F8:
                {
                        PangoFontDescription *font_desc;
                        int size;
@@ -1387,7 +1418,7 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                        pango_font_description_free(font_desc);
                }
                break;
-       case GDK_Escape:
+       case GDK_KEY_Escape:
                if (mainwin->summaryview && 
                    mainwin->summaryview->ext_messageview && 
                    mainwin->summaryview->ext_messageview->window && 
@@ -1522,9 +1553,11 @@ MainWindow *main_window_create()
        FolderView *folderview;
        SummaryView *summaryview;
        MessageView *messageview;
+#if !GTK_CHECK_VERSION(3, 0, 0)
        GdkColormap *colormap;
-       GdkColor color[4];
        gboolean success[4];
+#endif
+       GdkColor color[4];
        GtkWidget *ac_menu;
        gint i;
 
@@ -1605,7 +1638,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "AddMailbox", "File/AddMailbox", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File/AddMailbox", "MH", "File/AddMailbox/MH", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator1", "File/---", GTK_UI_MANAGER_SEPARATOR)
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SortFolders", "File/SortFolders", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SortMailboxes", "File/SortMailboxes", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator2", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "ImportMbox", "File/ImportMbox", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "ExportMbox", "File/ExportMbox", GTK_UI_MANAGER_MENUITEM)
@@ -1614,9 +1647,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "EmptyTrashes", "File/EmptyTrashes", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator4", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM)
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "PageSetup", "File/PageSetup", GTK_UI_MANAGER_MENUITEM)
-#endif
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator5", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "OfflineMode", "File/OfflineMode", GTK_UI_MANAGER_MENUITEM)
@@ -1693,6 +1724,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ExpandThreads", "View/ExpandThreads", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "CollapseThreads", "View/CollapseThreads", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideReadMessages", "View/HideReadMessages", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideDelMessages", "View/HideDelMessages", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator3", "View/---", GTK_UI_MANAGER_SEPARATOR)
 
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Goto", "View/Goto", GTK_UI_MANAGER_MENU)
@@ -1716,6 +1748,11 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator6", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "OtherFolder", "View/Goto/OtherFolder", GTK_UI_MANAGER_MENUITEM)
+        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Scroll", "View/Scroll", GTK_UI_MANAGER_MENU)
+        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Scroll", "PrevLine", "View/Scroll/PrevLine", GTK_UI_MANAGER_MENUITEM)
+        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Scroll", "NextLine", "View/Scroll/NextLine", GTK_UI_MANAGER_MENUITEM)
+        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Scroll", "PrevPage", "View/Scroll/PrevPage", GTK_UI_MANAGER_MENUITEM)
+        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Scroll", "NextPage", "View/Scroll/NextPage", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator4", "View/---", GTK_UI_MANAGER_SEPARATOR)
 
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Encoding", "View/Encoding", GTK_UI_MANAGER_MENU)
@@ -1761,6 +1798,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Japanese", CS_SHIFT_JIS, "View/Encoding/Japanese/"CS_SHIFT_JIS, GTK_UI_MANAGER_MENUITEM)
 
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Chinese", "View/Encoding/Chinese", GTK_UI_MANAGER_MENU)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GB18030, "View/Encoding/Chinese/"CS_GB18030, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GB2312, "View/Encoding/Chinese/"CS_GB2312, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GBK, "View/Encoding/Chinese/"CS_GBK, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_BIG5, "View/Encoding/Chinese/"CS_BIG5, GTK_UI_MANAGER_MENUITEM)
@@ -1787,9 +1825,9 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "MessageSource", "View/MessageSource", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "AllHeaders", "View/AllHeaders", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Quotes", "View/Quotes", GTK_UI_MANAGER_MENU)
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "FoldAll", "View/Quotes/FoldAll", GTK_UI_MANAGER_MENUITEM)
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "Fold2", "View/Quotes/Fold2", GTK_UI_MANAGER_MENUITEM)
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "Fold3", "View/Quotes/Fold3", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "CollapseAll", "View/Quotes/CollapseAll", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "Collapse2", "View/Quotes/Collapse2", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Quotes", "Collapse3", "View/Quotes/Collapse3", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator6", "View/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "UpdateSummary", "View/UpdateSummary", GTK_UI_MANAGER_MENUITEM)
 
@@ -1900,6 +1938,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator5", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
 
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Execute", "Tools/Execute", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Expunge", "Tools/Expunge", GTK_UI_MANAGER_MENUITEM)
 #ifdef USE_GNUTLS
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator6", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "SSLCertificates", "Tools/SSLCertificates", GTK_UI_MANAGER_MENUITEM)
@@ -2004,8 +2043,6 @@ MainWindow *main_window_create()
        g_signal_connect(G_OBJECT(warning_btn), "button-press-event", 
                         G_CALLBACK(warning_icon_pressed),
                         (gpointer) mainwin);
-       g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
-                        G_CALLBACK(warning_visi_notify), mainwin);
        g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
                         G_CALLBACK(warning_visi_notify), mainwin);
        g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
@@ -2029,6 +2066,7 @@ MainWindow *main_window_create()
        online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
        offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
        online_switch = gtk_button_new ();
+       gtkut_widget_set_can_focus(online_switch, FALSE);
        CLAWS_SET_TIP(online_switch, 
                             _("You are online. Click the icon to go offline"));
        offline_switch = gtk_button_new ();
@@ -2048,7 +2086,7 @@ MainWindow *main_window_create()
 
        ac_button = gtk_button_new();
        CLAWS_SET_TIP(ac_button, _("Select account"));
-       GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
+       gtkut_widget_set_can_focus(ac_button, FALSE);
        gtk_widget_set_size_request(ac_button, -1, 0);
        gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
        g_signal_connect(G_OBJECT(ac_button), "button_press_event",
@@ -2060,6 +2098,7 @@ MainWindow *main_window_create()
        gtk_widget_show_all(hbox_stat);
 
        gtk_widget_hide(offline_switch);
+       gtk_widget_hide(progressbar);
        gtk_widget_hide(warning_btn);
 #else
        online_switch = gtk_button_new ();
@@ -2169,12 +2208,14 @@ MainWindow *main_window_create()
        color[2] = folderview->color_new;
        color[3] = folderview->color_op;
 
-       colormap = gdk_drawable_get_colormap(window->window);
+#if !GTK_CHECK_VERSION(3, 0, 0)
+       colormap = gdk_drawable_get_colormap(gtk_widget_get_window(window));
        gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
        for (i = 0; i < 4; i++) {
                if (success[i] == FALSE)
                        g_warning("MainWindow: color allocation %d failed\n", i);
        }
+#endif
 
        debug_print("done.\n");
 
@@ -2243,7 +2284,9 @@ MainWindow *main_window_create()
        ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
        
 #ifndef GENERIC_UMPC
+#ifdef G_OS_UNIX
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
+#endif
 #endif
 
        g_signal_connect(G_OBJECT(window), "window_state_event",
@@ -2308,7 +2351,7 @@ void main_window_cursor_wait(MainWindow *mainwin)
 {
 
        if (mainwin->cursor_count == 0) {
-               gdk_window_set_cursor(mainwin->window->window, watch_cursor);
+               gdk_window_set_cursor(gtk_widget_get_window(mainwin->window), watch_cursor);
                textview_cursor_wait(mainwin->messageview->mimeview->textview);
        }
        
@@ -2323,7 +2366,7 @@ void main_window_cursor_normal(MainWindow *mainwin)
                mainwin->cursor_count--;
 
        if (mainwin->cursor_count == 0) {
-               gdk_window_set_cursor(mainwin->window->window, NULL);
+               gdk_window_set_cursor(gtk_widget_get_window(mainwin->window), NULL);
                textview_cursor_normal(mainwin->messageview->mimeview->textview);
        }
        gdk_flush();
@@ -2391,8 +2434,10 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        toolbar_update(TOOLBAR_MAIN, mainwin);
                        messageview_reflect_prefs_pixmap_theme();
                        compose_reflect_prefs_pixmap_theme();
-                       folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
+                       folderview_reinit_fonts(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
+                       foldersel_reflect_prefs_pixmap_theme();
+                       addressbook_reflect_prefs_pixmap_theme();
 #ifndef GENERIC_UMPC
                        pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
                        gtk_container_remove(GTK_CONTAINER(mainwin->online_switch), 
@@ -2439,30 +2484,32 @@ void main_window_reflect_prefs_all_now(void)
 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
 {
        GtkMenuShell *menu;
-       GList *cur;
+       GList *children, *cur;
 
        /* re-create colorlabel submenu */
        menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
-       g_return_if_fail(menu != NULL);
+       cm_return_if_fail(menu != NULL);
 
        /* clear items. get item pointers. */
-       for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (cur = children; cur != NULL && cur->data != NULL; cur = cur->next) {
                g_signal_handlers_disconnect_matched
                         (gtk_ui_manager_get_accel_group(mainwin->ui_manager), 
                         G_SIGNAL_MATCH_DATA|G_SIGNAL_MATCH_FUNC,
                         0, 0, NULL, mainwin_accel_changed_cb, cur->data);
                gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur->data), NULL);
        }
+       g_list_free(children);
        mainwindow_colorlabel_menu_create(mainwin, TRUE);
        summary_reflect_prefs_custom_colors(mainwin->summaryview);
-
+       folderview_reinit_fonts(mainwin->folderview);
 }
 
 static gint tags_tag = 0;
 static gboolean main_window_reflect_tags_changes_real(gpointer data)
 {
        GtkMenuShell *menu;
-       GList *cur;
+       GList *children, *cur;
        MainWindow *mainwin = (MainWindow *)data;
 
        if (summary_is_locked(mainwin->summaryview)) {
@@ -2471,12 +2518,14 @@ static gboolean main_window_reflect_tags_changes_real(gpointer data)
        }
        /* re-create tags submenu */
        menu = GTK_MENU_SHELL(mainwin->tags_menu);
-       g_return_val_if_fail(menu != NULL, FALSE);
+       cm_return_val_if_fail(menu != NULL, FALSE);
 
        /* clear items. get item pointers. */
-       for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (cur = children; cur != NULL && cur->data != NULL; cur = cur->next) {
                gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur->data), NULL);
        }
+       g_list_free(children);
        mainwindow_tags_menu_create(mainwin, TRUE);
        summary_reflect_tags_changes(mainwin->summaryview);
        
@@ -2557,7 +2606,7 @@ static void main_window_set_account_selector_menu(MainWindow *mainwin,
 static void main_window_set_account_receive_menu(MainWindow *mainwin,
                                                 GList *account_list)
 {
-       GList *cur_ac, *cur_item;
+       GList *children, *child;
        GtkWidget *menu;
        GtkWidget *menuitem;
        PrefsAccount *ac_prefs;
@@ -2566,23 +2615,24 @@ static void main_window_set_account_receive_menu(MainWindow *mainwin,
                gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive")));
 
        /* search for separator */
-       for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
-            cur_item = cur_item->next) {
-               if (cur_item->data == gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive/Separator1")) {
-                       cur_item = cur_item->next;
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (child = children; child != NULL; child = child->next) {
+               if (child->data == gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive/Separator1")) {
+                       child = child->next;
                        break;
                }
        }
 
        /* destroy all previous menu item */
-       while (cur_item != NULL) {
-               GList *next = cur_item->next;
-               gtk_widget_destroy(GTK_WIDGET(cur_item->data));
-               cur_item = next;
+       while (child != NULL) {
+               gtk_widget_destroy(GTK_WIDGET(child->data));
+               child = child->next;
        }
 
-       for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
-               ac_prefs = (PrefsAccount *)cur_ac->data;
+       g_list_free(children);
+
+       for (child = account_list; child != NULL; child = child->next) {
+               ac_prefs = (PrefsAccount *)child->data;
 
                if (ac_prefs->protocol == A_NONE)
                        continue;
@@ -2734,11 +2784,11 @@ static void main_window_separation_change(MainWindow *mainwin, LayoutType layout
        g_object_ref(summary_wid);
        g_object_ref(message_wid);
        gtkut_container_remove
-               (GTK_CONTAINER(folder_wid->parent), folder_wid);
+               (GTK_CONTAINER(gtk_widget_get_parent(folder_wid)), folder_wid);
        gtkut_container_remove
-               (GTK_CONTAINER(summary_wid->parent), summary_wid);
+               (GTK_CONTAINER(gtk_widget_get_parent(summary_wid)), summary_wid);
        gtkut_container_remove
-               (GTK_CONTAINER(message_wid->parent), message_wid);
+               (GTK_CONTAINER(gtk_widget_get_parent(message_wid)), message_wid);
 
        gtk_widget_hide(mainwin->window);
        main_window_set_widgets(mainwin, layout_mode);
@@ -2802,14 +2852,14 @@ void main_window_toggle_message_view(MainWindow *mainwin)
        SummaryView *summaryview = mainwin->summaryview;
        GtkWidget *ppaned = NULL;
        GtkWidget *container = NULL;
-       
+
        switch (prefs_common.layout_mode) {
        case NORMAL_LAYOUT:
        case VERTICAL_LAYOUT:
        case SMALL_LAYOUT:
                ppaned = mainwin->vpaned;
                container = mainwin->hpaned;
-               if (ppaned->parent != NULL) {
+               if (gtk_widget_get_parent(ppaned) != NULL) {
                        mainwin->messageview->visible = FALSE;
                        summaryview->displayed = NULL;
                        g_object_ref(ppaned);
@@ -2825,7 +2875,7 @@ void main_window_toggle_message_view(MainWindow *mainwin)
        case WIDE_LAYOUT:
                ppaned = mainwin->hpaned;
                container = mainwin->vpaned;
-               if (mainwin->messageview->vbox->parent != NULL) {
+               if (gtk_widget_get_parent(mainwin->messageview->vbox) != NULL) {
                        mainwin->messageview->visible = FALSE;
                        summaryview->displayed = NULL;
                        g_object_ref(mainwin->messageview->vbox);
@@ -2867,7 +2917,7 @@ void main_window_toggle_message_view(MainWindow *mainwin)
 
 void main_window_get_size(MainWindow *mainwin)
 {
-       GtkAllocation *allocation;
+       GtkAllocation allocation;
 
        if (mainwin_list == NULL || mainwin->messageview == NULL) {
                debug_print("called after messageview "
@@ -2875,41 +2925,41 @@ void main_window_get_size(MainWindow *mainwin)
                return;
        }
 
-       allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
-       
        if (prefs_common.mainwin_fullscreen) {
                debug_print("mainwin in full screen state. "
                            "Keeping original settings\n");
        }
-       if (allocation->width > 1 && allocation->height > 1 && !prefs_common.mainwin_fullscreen) {
-               prefs_common.summaryview_width = allocation->width;
+
+       gtk_widget_get_allocation(GTK_WIDGET_PTR(mainwin->summaryview), &allocation);
+       if (allocation.width > 1 && allocation.height > 1 && !prefs_common.mainwin_fullscreen) {
+               prefs_common.summaryview_width = allocation.width;
 
                if (messageview_is_visible(mainwin->messageview))
-                       prefs_common.summaryview_height = allocation->height;
+                       prefs_common.summaryview_height = allocation.height;
 
-               prefs_common.mainview_width = allocation->width;
+               prefs_common.mainview_width = allocation.width;
        }
 
-       allocation = &mainwin->window->allocation;
-       if (allocation->width > 1 && allocation->height > 1 &&
+       gtk_widget_get_allocation(mainwin->window, &allocation);
+       if (allocation.width > 1 && allocation.height > 1 &&
            !prefs_common.mainwin_maximised && !prefs_common.mainwin_fullscreen) {
-               prefs_common.mainview_height = allocation->height;
-               prefs_common.mainwin_width   = allocation->width;
-               prefs_common.mainwin_height  = allocation->height;
+               prefs_common.mainview_height = allocation.height;
+               prefs_common.mainwin_width   = allocation.width;
+               prefs_common.mainwin_height  = allocation.height;
        }
 
-       allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
-       if (allocation->width > 1 && allocation->height > 1 &&
+       gtk_widget_get_allocation(GTK_WIDGET_PTR(mainwin->folderview), &allocation);
+       if (allocation.width > 1 && allocation.height > 1 &&
            !prefs_common.mainwin_fullscreen) {
-               prefs_common.folderview_width  = allocation->width;
-               prefs_common.folderview_height = allocation->height;
+               prefs_common.folderview_width  = allocation.width;
+               prefs_common.folderview_height = allocation.height;
        }
 
-       allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
-       if (allocation->width > 1 && allocation->height > 1 &&
+       gtk_widget_get_allocation(GTK_WIDGET_PTR(mainwin->messageview), &allocation);
+       if (allocation.width > 1 && allocation.height > 1 &&
            !prefs_common.mainwin_fullscreen) {
-               prefs_common.msgview_width = allocation->width;
-               prefs_common.msgview_height = allocation->height;
+               prefs_common.msgview_width = allocation.width;
+               prefs_common.msgview_height = allocation.height;
        }
 
 /*     debug_print("summaryview size: %d x %d\n",
@@ -2951,7 +3001,7 @@ void main_window_progress_off(MainWindow *mainwin)
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
 }
 
-static gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean for_quit)
+gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean for_quit)
 {
        if (confirm && procmsg_have_trashed_mails_fast()) {
                AlertValue val;
@@ -3058,6 +3108,11 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
                state |= M_NEWS;
        else
                state |= M_NOT_NEWS;
+       if (mainwin->summaryview->folder_item &&
+           (mainwin->summaryview->folder_item->stype != F_TRASH ||
+            !folder_has_parent_of_type(mainwin->summaryview->folder_item, F_TRASH)))
+               state |= M_NOT_TRASH;
+
        if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
                state |= M_ACTIONS_EXIST;
 
@@ -3110,6 +3165,9 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (imap_cancel_all_enabled())
                state |= M_INC_ACTIVE;
 
+       if (mainwin->summaryview->deleted > 0)
+               state |= M_DELETED_EXISTS;
+
        if (mainwin->summaryview->deleted > 0 ||
            mainwin->summaryview->moved > 0 ||
            mainwin->summaryview->copied > 0)
@@ -3141,7 +3199,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        SummaryView *summaryview;
        gchar *menu_path;
        GtkWidget *menu;
-       GList *cur_item;
+       GList *children, *cur_item;
        gint i;
 
        static const struct {
@@ -3164,6 +3222,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/View/ExpandThreads"        , M_MSG_EXIST|M_SUMMARY_ISLIST},
                {"Menu/View/CollapseThreads"      , M_MSG_EXIST|M_SUMMARY_ISLIST},
                {"Menu/View/HideReadMessages"      , M_HIDE_READ_MSG|M_SUMMARY_ISLIST},
+               {"Menu/View/HideDelMessages"       , M_SUMMARY_ISLIST},
                {"Menu/View/Goto/Prev"        , M_MSG_EXIST},
                {"Menu/View/Goto/Next"        , M_MSG_EXIST},
                {"Menu/View/Goto/PrevUnread" , M_MSG_EXIST},
@@ -3193,9 +3252,9 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/Message/Forward"               , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
                {"Menu/Message/ForwardAtt" , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
                {"Menu/Message/Redirect"                  , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
-               {"Menu/Message/Move"              , M_TARGET_EXIST|M_ALLOW_DELETE},
+               {"Menu/Message/Move"              , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
                {"Menu/Message/Copy"              , M_TARGET_EXIST|M_EXEC},
-               {"Menu/Message/Trash"     , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
+               {"Menu/Message/Trash"     , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS|M_NOT_TRASH},
                {"Menu/Message/Delete"            , M_TARGET_EXIST|M_ALLOW_DELETE},
                {"Menu/Message/CancelNews" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
                {"Menu/Message/Mark"              , M_TARGET_EXIST|M_SUMMARY_ISLIST},
@@ -3223,6 +3282,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/Tools/ListUrls"                 , M_TARGET_EXIST},
                {"Menu/Tools/Actions"                      , M_TARGET_EXIST|M_ACTIONS_EXIST},
                {"Menu/Tools/Execute"                      , M_DELAY_EXEC},
+               {"Menu/Tools/Expunge"                      , M_DELETED_EXISTS},
                {"Menu/Tools/ForgetSessionPasswords"       , M_SESSION_PASSWORDS},
                {"Menu/Tools/DeleteDuplicates/SelFolder"   , M_MSG_EXIST|M_ALLOW_DELETE},
 
@@ -3245,8 +3305,8 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
                gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive")));
 
-       for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
-            cur_item = cur_item->next) {
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (cur_item = children; cur_item != NULL; cur_item = cur_item->next) {
                if (cur_item->data == gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/Message/Receive/Separator1")) {
                        cur_item = cur_item->next;
                        break;
@@ -3258,6 +3318,8 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                                         (M_UNLOCKED & state) != 0);
        }
 
+       g_list_free(children);
+
        main_window_menu_callback_block(mainwin);
 
        cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/ShowHide/MessageView",
@@ -3321,9 +3383,9 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/AllHeaders",
                              mainwin->messageview->mimeview->textview->show_all_headers);
        cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/ThreadView", (state & M_THREADED) != 0);
-       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/FoldAll", (prefs_common.hide_quotes == 1));
-       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Fold2", (prefs_common.hide_quotes == 2));
-       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Fold3", (prefs_common.hide_quotes == 3));
+       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/CollapseAll", (prefs_common.hide_quotes == 1));
+       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse2", (prefs_common.hide_quotes == 2));
+       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse3", (prefs_common.hide_quotes == 3));
 
        main_window_menu_callback_unblock(mainwin);
 }
@@ -3397,19 +3459,19 @@ static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * li
        GtkWidget *item, *menu;
        const gchar *url_pt ;
        gchar url_decoded[BUFFSIZE];
-       GList *amenu, *alist;
+       GList *children, *amenu;
        gint menu_nb = 0;
        
        menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
        
        /* First delete old submenu */
        /* FIXME: we can optimize this, and only change/add/delete necessary items */
-       for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
-               alist = amenu->next;
+       children = gtk_container_get_children(GTK_CONTAINER(menu));
+       for (amenu = children; amenu; amenu = amenu->next) {
                item = GTK_WIDGET (amenu->data);
                gtk_widget_destroy (item);
-               amenu = alist;
        }
+       g_list_free(children);
        if (list_header) {
                for (url_pt = list_header; url_pt && *url_pt;) {
                        get_url_part (&url_pt, url_decoded, BUFFSIZE);
@@ -3548,14 +3610,16 @@ void main_window_popup(MainWindow *mainwin)
 {
        static gboolean first_start = TRUE;
 
-       if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
+       if (!gtkut_widget_get_visible(GTK_WIDGET(mainwin->window)))
                main_window_show(mainwin);
 
        if (prefs_common.mainwin_maximised)
                gtk_window_maximize(GTK_WINDOW(mainwin->window));
 
        if (first_start) {
+#ifdef G_OS_UNIX
                gtk_window_deiconify(GTK_WINDOW(mainwin->window));
+#endif
                first_start = FALSE;
        } else {
                gtkut_window_popup(mainwin->window);
@@ -3636,7 +3700,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
 #endif
        /* clean top-most container */
        if (mainwin->hpaned) {
-               if (mainwin->hpaned->parent == mainwin->vpaned)
+               if (gtk_widget_get_parent(mainwin->hpaned) == mainwin->vpaned)
                        gtk_widget_destroy(mainwin->vpaned);
                else
                        gtk_widget_destroy(mainwin->hpaned);
@@ -3981,7 +4045,6 @@ static void print_cb(GtkAction *action, gpointer data)
        summary_print(mainwin->summaryview);
 }
 
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
 static void page_setup_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -3991,7 +4054,6 @@ static void page_setup_cb(GtkAction *action, gpointer data)
 
        printing_page_setup(win);
 }
-#endif
 
 static void app_exit_cb(GtkAction *action, gpointer data)
 {
@@ -4065,10 +4127,10 @@ static void main_window_reply_cb(GtkAction *gaction, gpointer data)
        DO_ACTION("Message/Redirect", COMPOSE_REDIRECT);
        DO_ACTION("Message/FollowupReply", COMPOSE_FOLLOWUP_AND_REPLY_TO);
 
-       g_return_if_fail(msgview != NULL);
+       cm_return_if_fail(msgview != NULL);
 
        msginfo_list = summary_get_selection(mainwin->summaryview);
-       g_return_if_fail(msginfo_list != NULL);
+       cm_return_if_fail(msginfo_list != NULL);
        compose_reply_from_messageview(msgview, msginfo_list, action);
        g_slist_free(msginfo_list);
 }
@@ -4078,14 +4140,17 @@ static void toggle_col_headers_cb(GtkAction *gaction, gpointer data)
        MainWindow *mainwin = (MainWindow *)data;
        FolderView *folderview = mainwin->folderview;
        SummaryView *summaryview = mainwin->summaryview;
+       MimeView *mimeview = mainwin->messageview->mimeview;
 
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (gaction))) {
                gtk_cmclist_column_titles_show(GTK_CMCLIST(folderview->ctree));
                gtk_cmclist_column_titles_show(GTK_CMCLIST(summaryview->ctree));
+               gtk_cmclist_column_titles_show(GTK_CMCLIST(mimeview->ctree));
                prefs_common.show_col_headers = TRUE;
        } else {
                gtk_cmclist_column_titles_hide(GTK_CMCLIST(folderview->ctree));
                gtk_cmclist_column_titles_hide(GTK_CMCLIST(summaryview->ctree));
+               gtk_cmclist_column_titles_hide(GTK_CMCLIST(mimeview->ctree));           
                prefs_common.show_col_headers = FALSE;
        }
 }
@@ -4191,7 +4256,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
        MainWindow *mainwin;
        gboolean have_connectivity;
 
-#ifdef HAVE_NETWORKMANAGER
+#ifdef HAVE_NETWORKMANAGER_SUPPORT
        have_connectivity = networkmanager_is_online(NULL); 
 #else
        have_connectivity = TRUE;
@@ -4199,7 +4264,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
 
        mainwin = (MainWindow *) data;
        
-       g_return_if_fail(mainwin != NULL);
+       cm_return_if_fail(mainwin != NULL);
        
        if (btn == GTK_BUTTON(mainwin->online_switch)) {
 #ifndef GENERIC_UMPC
@@ -4217,7 +4282,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                if(have_connectivity)
                        mainwindow_check_synchronise(mainwin, TRUE);
                prefs_common.work_offline = TRUE;
-               imap_disconnect_all();
+               imap_disconnect_all(have_connectivity);
                hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
        } else {
                /*go online */
@@ -4332,16 +4397,16 @@ static void hide_quotes_cb(GtkAction *action, gpointer data)
 
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
                const gchar *a_name = gtk_action_get_name(GTK_ACTION(action));
-               if (!strcmp(a_name, "View/Quotes/FoldAll")) prefs_common.hide_quotes = 1;
-               else if (!strcmp(a_name, "View/Quotes/Fold2")) prefs_common.hide_quotes = 2;
-               else if (!strcmp(a_name, "View/Quotes/Fold3")) prefs_common.hide_quotes = 3;
+               if (!strcmp(a_name, "View/Quotes/CollapseAll")) prefs_common.hide_quotes = 1;
+               else if (!strcmp(a_name, "View/Quotes/Collapse2")) prefs_common.hide_quotes = 2;
+               else if (!strcmp(a_name, "View/Quotes/Collapse3")) prefs_common.hide_quotes = 3;
        } else
                prefs_common.hide_quotes = 0;
 
        mainwin->menu_lock_count++;
-       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/FoldAll", (prefs_common.hide_quotes == 1));
-       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Fold2", (prefs_common.hide_quotes == 2));
-       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Fold3", (prefs_common.hide_quotes == 3));
+       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/CollapseAll", (prefs_common.hide_quotes == 1));
+       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse2", (prefs_common.hide_quotes == 2));
+       cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse3", (prefs_common.hide_quotes == 3));
        mainwin->menu_lock_count--;
 
        summary_redisplay_msg(mainwin->summaryview);
@@ -4490,6 +4555,16 @@ static void hide_read_messages (GtkAction *action, gpointer data)
        summary_toggle_show_read_messages(mainwin->summaryview);
 }
 
+static void hide_del_messages (GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       GtkWidget *menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/HideDelMessages");
+       if (!mainwin->summaryview->folder_item
+           || g_object_get_data(G_OBJECT(menuitem), "dont_toggle"))
+               return;
+       summary_toggle_show_del_messages(mainwin->summaryview);
+}
+
 static void thread_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4630,7 +4705,7 @@ static void process_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
        FolderItem *item = mainwin->summaryview->folder_item;   
-       g_return_if_fail(item != NULL);
+       cm_return_if_fail(item != NULL);
 
        item->processing_pending = TRUE;
        folder_item_apply_processing(item);     
@@ -4643,6 +4718,12 @@ static void execute_summary_cb(GtkAction *action, gpointer data)
        summary_execute(mainwin->summaryview);
 }
 
+static void expunge_summary_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       summary_expunge(mainwin->summaryview);
+}
+
 static void update_summary_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4751,6 +4832,30 @@ static void goto_unread_folder_cb(GtkAction *action, gpointer data)
        folderview_select_next_unread(mainwin->folderview, FALSE);
 }
 
+static void scroll_prev_line_cb(GtkAction *action, gpointer data)
+{
+        MainWindow *mainwin = (MainWindow *)data;
+        mimeview_scroll_one_line(mainwin->messageview->mimeview,TRUE);
+}
+
+static void scroll_next_line_cb(GtkAction *action, gpointer data)
+{
+        MainWindow *mainwin = (MainWindow *)data;
+        mimeview_scroll_one_line(mainwin->messageview->mimeview,FALSE);
+}
+
+static void scroll_prev_page_cb(GtkAction *action, gpointer data)
+{
+        MainWindow *mainwin = (MainWindow *)data;
+        mimeview_scroll_page(mainwin->messageview->mimeview,TRUE);
+}
+
+static void scroll_next_page_cb(GtkAction *action, gpointer data)
+{
+        MainWindow *mainwin = (MainWindow *)data;
+        mimeview_scroll_page(mainwin->messageview->mimeview,FALSE);
+}
+
 static void copy_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4763,7 +4868,7 @@ static void allsel_cb(GtkAction *action, gpointer data)
        MessageView *msgview = mainwin->messageview;
 
        if (messageview_is_visible(msgview) &&
-                (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
+                (gtkut_widget_has_focus(msgview->mimeview->textview->text)))
                messageview_select_all(mainwin->messageview);
        else
                summary_select_all(mainwin->summaryview);
@@ -4966,6 +5071,9 @@ static void set_default_client_cb(GtkAction *action, gpointer data)
        if (!r)
                r = write_w32_registry_dword ("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", 
                                "EditFlags", 2);
+       if (!r)
+               r = write_w32_registry_string ("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", 
+                               "FriendlyTypeName", "Claws-Mail URL");
        if (!r)
                r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto\\DefaultIcon", 
                                "", binary_icon);
@@ -4985,6 +5093,9 @@ static void set_default_client_cb(GtkAction *action, gpointer data)
        if (!r)
                r = write_w32_registry_dword ("HKCU", "Software\\Classes\\mailto", 
                                "EditFlags", 2);
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto", 
+                               "FriendlyTypeName", "Claws-Mail URL");
        if (!r)
                r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto\\DefaultIcon", 
                                "", binary_icon);
@@ -5028,11 +5139,11 @@ static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focu
 {
        SummaryView *summary;
 
-       g_return_val_if_fail(data, FALSE);
+       cm_return_val_if_fail(data, FALSE);
        if (!g_list_find(mainwin_list, data))
                return TRUE;
        summary = ((MainWindow *)data)->summaryview;
-       g_return_val_if_fail(summary, FALSE);
+       cm_return_val_if_fail(summary, FALSE);
 
        if (GTK_CMCLIST(summary->ctree)->selection && 
            g_list_length(GTK_CMCLIST(summary->ctree)->selection) > 1)