2012-04-01 [colin] 3.8.0cvs36
[claws.git] / src / mainwindow.c
index 554ffa97ac55f15594fcc572a2fa931c0c3287d6..6d26837c7e3b3c80fa0021805d59db2138ae31e3 100644 (file)
@@ -1,17 +1,17 @@
 /*
    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
    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 "prefs_template.h"
 #include "action.h"
 #include "account.h"
-#include "addressbook.h"
+#ifndef USE_NEW_ADDRBOOK
+       #include "addressbook.h"
+#else
+       #include "addressbook-dbus.h"
+#endif
 #include "logwindow.h"
 #include "manage_window.h"
 #include "alertpanel.h"
@@ -81,6 +85,9 @@
 #include "imap.h"
 #include "socket.h"
 #include "printing.h"
+#ifdef G_OS_WIN32
+#include "w32lib.h"
+#endif
 
 #define AC_LABEL_WIDTH 240
 
@@ -144,10 +151,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,
@@ -187,6 +192,8 @@ static void view_source_cb          (GtkAction      *action,
 
 static void show_all_header_cb         (GtkAction      *action,
                                  gpointer       data);
+static void toggle_fullscreen_cb       (GtkAction      *action,
+                                 gpointer       data);
 
 static void hide_quotes_cb(GtkAction   *action,
                                  gpointer       data);
@@ -244,6 +251,10 @@ static void set_decode_cb          (GtkAction *action, GtkRadioAction *current, gpointer
 
 static void hide_read_messages   (GtkAction    *action,
                                  gpointer       data);
+static void hide_read_threads   (GtkAction     *action,
+                                 gpointer       data);
+static void hide_del_messages   (GtkAction     *action,
+                                 gpointer       data);
 
 static void thread_cb           (GtkAction     *action,
                                  gpointer       data);
@@ -273,6 +284,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);
 
@@ -297,7 +310,9 @@ static void prev_labeled_cb  (GtkAction     *action,
                                  gpointer       data);
 static void next_labeled_cb     (GtkAction     *action,
                                  gpointer       data);
-static void last_read_cb        (GtkAction     *action,
+static void prev_history_cb     (GtkAction     *action,
+                                 gpointer       data);
+static void next_history_cb     (GtkAction     *action,
                                  gpointer       data);
 static void parent_cb           (GtkAction     *action,
                                  gpointer       data);
@@ -307,6 +322,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,
@@ -340,7 +364,7 @@ static void prefs_post_processing_open_cb (GtkAction        *action,
 
 static void prefs_filtering_open_cb    (GtkAction      *action,
                                  gpointer       data);
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
 static void ssl_manager_open_cb        (GtkAction      *action,
                                  gpointer       data);
 #endif
@@ -371,6 +395,11 @@ static void manual_faq_open_cb      (GtkAction     *action,
 static void legend_open_cb      (GtkAction     *action,
                                  gpointer       data);
 
+#ifdef G_OS_WIN32
+static void set_default_client_cb (GtkAction   *action,
+                                 gpointer       data);
+#endif
+
 static void scan_tree_func      (Folder        *folder,
                                  FolderItem    *item,
                                  gpointer       data);
@@ -468,7 +497,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) },
@@ -480,9 +509,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) }, 
@@ -536,13 +563,22 @@ static GtkActionEntry mainwin_entries[] =
        {"View/Goto/PrevLabeled",               NULL, N_("Previous _labeled message"), NULL, NULL, G_CALLBACK(prev_labeled_cb) },
        {"View/Goto/NextLabeled",               NULL, N_("Next la_beled message"), NULL, NULL, G_CALLBACK(next_labeled_cb) },
        /* {"View/Goto/---",                    NULL, "---", NULL, NULL, NULL }, */
-       {"View/Goto/LastRead",                  NULL, N_("Last read message"), NULL, NULL, G_CALLBACK(last_read_cb) },
+       {"View/Goto/PrevHistory",               NULL, N_("Previous opened message"), "<alt>Left", NULL, G_CALLBACK(prev_history_cb) },
+       {"View/Goto/NextHistory",               NULL, N_("Next opened message"), "<alt>Right", NULL, G_CALLBACK(next_history_cb) },
+       /* {"View/Goto/---",                    NULL, "---", NULL, NULL, NULL }, */
        {"View/Goto/ParentMessage",             NULL, N_("Parent message"), "<control>Up", NULL, G_CALLBACK(parent_cb) },
        /* {"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) \
@@ -619,7 +655,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 },
@@ -633,8 +669,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) },
@@ -687,7 +723,8 @@ static GtkActionEntry mainwin_entries[] =
        /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
 
        {"Tools/Execute",                       NULL, N_("E_xecute"), "X", NULL, G_CALLBACK(execute_summary_cb) }, 
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+       {"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) }, 
 #endif
@@ -721,6 +758,9 @@ static GtkActionEntry mainwin_entries[] =
        {"Help/Manual",                         NULL, N_("_Manual"), NULL, NULL, G_CALLBACK(manual_open_cb) }, 
        {"Help/FAQ",                            NULL, N_("_Online User-contributed FAQ"), NULL, NULL, G_CALLBACK(manual_faq_open_cb) }, 
        {"Help/IconLegend",                     NULL, N_("Icon _Legend"), NULL, NULL, G_CALLBACK(legend_open_cb) }, 
+#ifdef G_OS_WIN32
+       {"Help/SetDefault",                     NULL, N_("Set as default client"), NULL, NULL, G_CALLBACK(set_default_client_cb) }, 
+#endif
        {"Help/---",                            NULL, "---" }, 
        {"Help/About",                          NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_cb) }, 
 };
@@ -733,11 +773,16 @@ static GtkToggleActionEntry mainwin_toggle_entries[] = {
 #endif
        {"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/HideReadThreads",                NULL, N_("Hide read threads"), NULL, NULL, G_CALLBACK(hide_read_threads) }, /* 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 */
@@ -806,6 +851,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 */
@@ -857,17 +903,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);
 
@@ -877,7 +923,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);
@@ -886,6 +933,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 */
@@ -896,7 +945,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);
                        }
@@ -917,7 +966,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),
@@ -932,7 +981,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,
@@ -944,13 +993,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 */
@@ -958,7 +1007,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"));
@@ -970,13 +1020,14 @@ 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;
        for (; sel != NULL; sel = sel->next) {
                MsgInfo *msginfo;
                GSList *tags = NULL;
-               gint id;
                GtkCheckMenuItem *item;
                msginfo = (MsgInfo *)sel->data;
                sel_len++;
@@ -987,9 +1038,8 @@ static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
 
                        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 && !gtk_check_menu_item_get_active(item)) {
                                        gtk_check_menu_item_set_active
                                                (item, TRUE);
                                }
@@ -999,7 +1049,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"));
@@ -1010,6 +1061,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);
@@ -1026,7 +1078,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),
@@ -1038,6 +1090,29 @@ static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
        summary_set_tag(mainwin->summaryview, id, NULL);
 }
 
+void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModifierType modifier,
+                                 GClosure *closure, GtkMenuItem *item)
+{
+       GList *closures = gtk_widget_list_accel_closures(GTK_WIDGET(item));
+       GList *cur;
+       for (cur = closures; cur; cur = cur->next) {
+               if (closure == cur->data) {
+                       GtkLabel *label = g_object_get_data(G_OBJECT(item), "accel_label");
+                       gchar *new_accel;
+                       
+                       if (keyval == GDK_KEY_BackSpace) {
+                               const gchar *accel_path;
+                               accel_path = gtk_menu_item_get_accel_path(item);
+                               keyval = 0; modifier = 0;
+                               gtk_accel_map_change_entry (accel_path, keyval, modifier, TRUE);
+                       }
+                       new_accel = gtk_accelerator_get_label(keyval, modifier);
+                       gtk_label_set_text(label, new_accel);
+                       g_free(new_accel);
+               }
+       }
+}
+
 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
 {
        GtkWidget *label_menuitem;
@@ -1089,11 +1164,15 @@ static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refr
                g_object_set_data(G_OBJECT(item), "mainwin",
                                  mainwin);
                gtk_widget_show(item);
-               accel_path = g_strdup_printf("<ClawsColorLabels>/%d", i);
+               accel_path = g_strdup_printf("<ClawsColorLabels>/%d", i+1);
                gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
                if (i < 9)
                        gtk_accel_map_add_entry(accel_path, GDK_1+i, GDK_CONTROL_MASK);
                g_free(accel_path);
+               g_signal_connect (gtk_ui_manager_get_accel_group(mainwin->ui_manager), 
+                       "accel-changed", G_CALLBACK (mainwin_accel_changed_cb), item);
+
+
        }
        gtk_widget_show(menu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
@@ -1106,7 +1185,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),
@@ -1215,7 +1294,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;
 }
 
@@ -1223,7 +1302,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;
 }
 
@@ -1231,7 +1310,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
@@ -1264,15 +1343,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
@@ -1283,15 +1366,16 @@ 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;
@@ -1315,7 +1399,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;
@@ -1339,7 +1423,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 && 
@@ -1467,16 +1551,17 @@ MainWindow *main_window_create()
        GtkWidget *offline_pixmap;
        GtkWidget *warning_icon;
        GtkWidget *warning_btn;
-       CLAWS_TIP_DECL();
 #endif
        GtkWidget *online_switch;
        GtkWidget *offline_switch;
        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;
 
@@ -1557,7 +1642,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)
@@ -1566,9 +1651,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)
@@ -1606,6 +1689,9 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/SetColumns", "Messagelist", "View/SetColumns/Messagelist", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator1", "View/---", GTK_UI_MANAGER_SEPARATOR)
 
+#ifndef MAEMO
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "FullScreen", "View/FullScreen", GTK_UI_MANAGER_MENUITEM)
+#endif
 #ifndef GENERIC_UMPC
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Layout", "View/Layout", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Layout", "Standard", "View/Layout/Standard", GTK_UI_MANAGER_MENUITEM)
@@ -1641,7 +1727,9 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ThreadView", "View/ThreadView", GTK_UI_MANAGER_MENUITEM)
        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", "HideReadThreads", "View/HideReadThreads", 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)
@@ -1660,11 +1748,18 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevLabeled", "View/Goto/PrevLabeled", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextLabeled", "View/Goto/NextLabeled", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator5", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "LastRead", "View/Goto/LastRead", GTK_UI_MANAGER_MENUITEM)
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevHistory", "View/Goto/PrevHistory", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextHistory", "View/Goto/NextHistory", GTK_UI_MANAGER_MENUITEM)
        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", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator7", "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)
@@ -1710,6 +1805,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)
@@ -1736,9 +1832,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)
 
@@ -1849,7 +1945,8 @@ 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)
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+       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)
 #endif
@@ -1885,7 +1982,11 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Manual", "Help/Manual", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "FAQ", "Help/FAQ", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "IconLegend", "Help/IconLegend", GTK_UI_MANAGER_MENUITEM)
+#ifdef G_OS_WIN32
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator1", "Help/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "SetDefault", "Help/SetDefault", GTK_UI_MANAGER_MENUITEM)
+#endif
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator2", "Help/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM)
 
 
@@ -1899,7 +2000,6 @@ MainWindow *main_window_create()
        hildon_window_set_menu(HILDON_WINDOW(window), GTK_MENU(menubar));
 #endif
 
-
        if (prefs_common.toolbar_detachable) {
                handlebox = gtk_handle_box_new();
                gtk_widget_show(handlebox);
@@ -1950,8 +2050,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",
@@ -1975,6 +2073,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 ();
@@ -1994,7 +2093,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",
@@ -2006,6 +2105,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 ();
@@ -2015,7 +2115,7 @@ MainWindow *main_window_create()
 #endif
        /* create views */
        mainwin->folderview  = folderview  = folderview_create();
-       mainwin->summaryview = summaryview = summary_create();
+       mainwin->summaryview = summaryview = summary_create(mainwin);
        mainwin->messageview = messageview = messageview_create(mainwin);
 
        /* init log instances data before creating log views */
@@ -2115,12 +2215,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");
 
@@ -2188,12 +2290,6 @@ MainWindow *main_window_create()
 
        ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
        
-/* FIXME       menu_connect_identical_items(); */
-
-#ifndef GENERIC_UMPC
-       gtk_window_iconify(GTK_WINDOW(mainwin->window));
-#endif
-
        g_signal_connect(G_OBJECT(window), "window_state_event",
                         G_CALLBACK(mainwindow_state_event_cb), mainwin);
        g_signal_connect(G_OBJECT(window), "visibility_notify_event",
@@ -2206,13 +2302,11 @@ MainWindow *main_window_create()
        }
        summary_update_unread(mainwin->summaryview, NULL);
        
-       gtk_widget_show(mainwin->window);
-
        /* initialize views */
        folderview_init(folderview);
        summary_init(summaryview);
        messageview_init(messageview);
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
        sslcertwindow_register_hook();
 #endif
        mainwin->lock_count = 0;
@@ -2236,6 +2330,13 @@ MainWindow *main_window_create()
 
 #ifdef MAEMO
        main_window_install_maemo_hooks(mainwin);
+#endif
+#ifndef MAEMO
+       if (prefs_common.mainwin_fullscreen) {
+               cm_toggle_menu_set_active_full(mainwin->ui_manager, 
+                       "Menu/View/FullScreen",
+                       TRUE);
+       }
 #endif
        return mainwin;
 }
@@ -2249,7 +2350,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);
        }
        
@@ -2264,7 +2365,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();
@@ -2332,8 +2433,12 @@ 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();
+#ifndef USE_NEW_ADDRBOOK
+                       addressbook_reflect_prefs_pixmap_theme();
+#endif
 #ifndef GENERIC_UMPC
                        pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
                        gtk_container_remove(GTK_CONTAINER(mainwin->online_switch), 
@@ -2380,26 +2485,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)) {
@@ -2408,12 +2519,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);
        
@@ -2494,7 +2607,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;
@@ -2503,23 +2616,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;
@@ -2671,11 +2785,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);
@@ -2739,14 +2853,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);
@@ -2762,7 +2876,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);
@@ -2804,7 +2918,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 "
@@ -2812,35 +2926,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.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 &&
-           !prefs_common.mainwin_maximised) {
-               prefs_common.mainview_height = allocation->height;
-               prefs_common.mainwin_width   = allocation->width;
-               prefs_common.mainwin_height  = allocation->height;
+       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;
        }
 
-       allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
-       if (allocation->width > 1 && allocation->height > 1) {
-               prefs_common.folderview_width  = allocation->width;
-               prefs_common.folderview_height = allocation->height;
+       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;
        }
-
-       allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
-       if (allocation->width > 1 && allocation->height > 1) {
-               prefs_common.msgview_width = allocation->width;
-               prefs_common.msgview_height = allocation->height;
+       
+       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;
        }
 
 /*     debug_print("summaryview size: %d x %d\n",
@@ -2858,7 +2978,7 @@ void main_window_get_position(MainWindow *mainwin)
 {
        gint x, y;
 
-       if (prefs_common.mainwin_maximised)
+       if (prefs_common.mainwin_maximised || prefs_common.mainwin_fullscreen)
                return;
 
        gtkut_widget_get_uposition(mainwin->window, &x, &y);
@@ -2882,7 +3002,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;
@@ -2974,6 +3094,10 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
                if ((selection == SUMMARY_NONE && item->hide_read_msgs)
                    || selection != SUMMARY_NONE)
                        state |= M_HIDE_READ_MSG;
+
+               if ((selection == SUMMARY_NONE && item->hide_read_threads)
+                   || selection != SUMMARY_NONE)
+                       state |= M_HIDE_READ_THREADS;
        }               
        if (mainwin->summaryview->threaded)
                state |= M_THREADED;
@@ -2989,6 +3113,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;
 
@@ -3009,6 +3138,9 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (cur_account)
                state |= M_HAVE_ACCOUNT;
        
+       if (cur_account && cur_account->protocol != A_NONE)
+               state |= M_HAVE_RETRIEVABLE_ACCOUNT;
+
        if (any_folder_want_synchronise())
                state |= M_WANT_SYNC;
 
@@ -3018,6 +3150,13 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (g_list_length(account_list) > 1)
                state |= M_HAVE_MULTI_ACCOUNT;
 
+       for ( ; account_list != NULL; account_list = account_list->next) {
+               if (((PrefsAccount*)account_list->data)->protocol != A_NONE) {
+                       state |= M_HAVE_ANY_RETRIEVABLE_ACCOUNT;
+                       break;
+               }
+       }
+
        for ( ; account_list != NULL; account_list = account_list->next) {
                if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
                        state |= M_HAVE_NEWS_ACCOUNT;
@@ -3041,6 +3180,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)
@@ -3072,7 +3214,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 {
@@ -3094,7 +3236,9 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/View/ThreadView"               , M_EXEC|M_SUMMARY_ISLIST},
                {"Menu/View/ExpandThreads"        , M_MSG_EXIST|M_SUMMARY_ISLIST},
                {"Menu/View/CollapseThreads"      , M_MSG_EXIST|M_SUMMARY_ISLIST},
+               {"Menu/View/HideReadThreads"       , M_HIDE_READ_THREADS|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},
@@ -3102,7 +3246,6 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/View/Goto/PrevMarked" , M_MSG_EXIST},
                {"Menu/View/Goto/PrevLabeled", M_MSG_EXIST},
                {"Menu/View/Goto/NextLabeled", M_MSG_EXIST},
-               {"Menu/View/Goto/LastRead"   , M_SINGLE_TARGET_EXIST},
                {"Menu/View/Goto/ParentMessage"      , M_SINGLE_TARGET_EXIST},
                {"Menu/View/OpenNewWindow"        , M_SINGLE_TARGET_EXIST},
                {"Menu/View/MessageSource"            , M_SINGLE_TARGET_EXIST},
@@ -3110,9 +3253,9 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/View/Quotes"                    , M_SINGLE_TARGET_EXIST},
 
                {"Menu/Message/Receive/CurrentAccount"
-                                                , M_HAVE_ACCOUNT|M_UNLOCKED},
+                                                , M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_RETRIEVABLE_ACCOUNT},
                {"Menu/Message/Receive/AllAccounts"
-                                                , M_HAVE_ACCOUNT|M_UNLOCKED},
+                                                , M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_ANY_RETRIEVABLE_ACCOUNT},
                {"Menu/Message/Receive/CancelReceiving"
                                                 , M_INC_ACTIVE},
                {"Menu/Message/SendQueue"  , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
@@ -3124,9 +3267,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},
@@ -3154,6 +3297,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},
 
@@ -3176,8 +3320,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;
@@ -3189,6 +3333,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",
@@ -3250,11 +3396,24 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        &&  mainwin->messageview->mimeview
        &&  mainwin->messageview->mimeview->textview)
                cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/AllHeaders",
-                             mainwin->messageview->mimeview->textview->show_all_headers);
+                                               prefs_common.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_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/ExpandThreads", (state & M_THREADED) != 0);
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/CollapseThreads", (state & M_THREADED) != 0);
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", (state & M_THREADED) != 0);
+       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));
+
+       if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_msgs)
+               cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", FALSE);
+       if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_threads)
+               cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadMessages", FALSE);
+
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/PrevHistory",
+               messageview_nav_has_prev(mainwin->messageview));
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/NextHistory",
+               messageview_nav_has_next(mainwin->messageview));
 
        main_window_menu_callback_unblock(mainwin);
 }
@@ -3328,19 +3487,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);
@@ -3438,10 +3597,19 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
 static void mailing_list_compose (GtkWidget *w, gpointer *data)
 {
        const gchar *mailto;
+       PrefsAccount *account = NULL;
+       FolderItem   *folder_item = NULL;
 
        mailto = gtk_label_get_text(GTK_LABEL (gtk_bin_get_child(GTK_BIN((w)))));
+       if (mainwindow_get_mainwindow()) {
+               folder_item = mainwindow_get_mainwindow()->summaryview->folder_item;
+               if (folder_item && folder_item->prefs && folder_item->prefs->enable_default_account)
+                       account = account_find_from_id(folder_item->prefs->default_account);
+               if (folder_item && !account)
+                       account = account_find_from_item(folder_item);
+       }
        if (mailto)
-               compose_new(NULL, mailto+7, NULL);
+               compose_new_with_folderitem(account, folder_item, mailto+7);
 }
  
  static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
@@ -3470,18 +3638,18 @@ void main_window_popup(MainWindow *mainwin)
 {
        static gboolean first_start = TRUE;
 
-       if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
+       if (!gtk_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) {
-               gtk_window_deiconify(GTK_WINDOW(mainwin->window));
                first_start = FALSE;
        } else {
                gtkut_window_popup(mainwin->window);
        }
+
        if (prefs_common.layout_mode == SMALL_LAYOUT) {
                if (mainwin->in_folder) {
                        mainwindow_enter_folder(mainwin);
@@ -3500,7 +3668,7 @@ void main_window_show(MainWindow *mainwin)
         gtk_window_move(GTK_WINDOW(mainwin->window),
                                  prefs_common.mainwin_x,
                                  prefs_common.mainwin_y);
-
+       
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
                             prefs_common.folderview_width,
                             prefs_common.folderview_height);
@@ -3532,33 +3700,13 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        gboolean first_set = (mainwin->hpaned == NULL);
        debug_print("Setting widgets... ");
 
-       if (layout_mode == SMALL_LAYOUT && first_set) {
-               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
-                                   prefs_common.folderview_width,
-                                   prefs_common.folderview_height);
-               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
-                                   0,0);
-               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
-                                   0,0);
-       } else {
-               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
-                                   prefs_common.folderview_width,
-                                   prefs_common.folderview_height);
-               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
-                                   prefs_common.summaryview_width,
-                                   prefs_common.summaryview_height);
-               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
-                                   prefs_common.msgview_width,
-                                   prefs_common.msgview_height);
-       }
-
 #ifndef GENERIC_UMPC
        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)
+               if (gtk_widget_get_parent(mainwin->hpaned) == mainwin->vpaned)
                        gtk_widget_destroy(mainwin->vpaned);
                else
                        gtk_widget_destroy(mainwin->hpaned);
@@ -3583,8 +3731,8 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
 
                if (messageview_is_visible(mainwin->messageview)) {
                        gtk_paned_add2(GTK_PANED(hpaned), vpaned);
-                       gtk_paned_add1(GTK_PANED(vpaned),
-                                      GTK_WIDGET_PTR(mainwin->summaryview));
+                       gtk_paned_pack1(GTK_PANED(vpaned),
+                                      GTK_WIDGET_PTR(mainwin->summaryview), TRUE, TRUE);
                } else {
                        gtk_paned_add2(GTK_PANED(hpaned),
                                       GTK_WIDGET_PTR(mainwin->summaryview));
@@ -3674,6 +3822,19 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                                prefs_common.mainwin_width,
                                prefs_common.mainwin_height);
                gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
+       } else {
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
+                                   prefs_common.folderview_width,
+                                   prefs_common.folderview_height);
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
+                                   prefs_common.summaryview_width,
+                                   prefs_common.summaryview_height);
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
+                                   prefs_common.msgview_width,
+                                   prefs_common.msgview_height);
+               gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
+                                   prefs_common.mainwin_width,
+                                   prefs_common.mainwin_height);
        } 
        /* remove headerview if not in prefs */
        headerview_set_visibility(mainwin->messageview->headerview,
@@ -3749,7 +3910,7 @@ void main_window_destroy_all(void)
 {
        while (mainwin_list != NULL) {
                MainWindow *mainwin = (MainWindow*)mainwin_list->data;
-               
+
                /* free toolbar stuff */
                toolbar_clear_list(TOOLBAR_MAIN);
                TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
@@ -3903,7 +4064,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;
@@ -3913,7 +4073,6 @@ static void page_setup_cb(GtkAction *action, gpointer data)
 
        printing_page_setup(win);
 }
-#endif
 
 static void app_exit_cb(GtkAction *action, gpointer data)
 {
@@ -3987,10 +4146,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);
 }
@@ -4000,14 +4159,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_tree_view_set_headers_visible(GTK_TREE_VIEW(mimeview->ctree), TRUE);
                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_tree_view_set_headers_visible(GTK_TREE_VIEW(mimeview->ctree), FALSE);               
                prefs_common.show_col_headers = FALSE;
        }
 }
@@ -4113,7 +4275,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;
@@ -4121,7 +4283,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
@@ -4139,7 +4301,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 */
@@ -4159,7 +4321,18 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
 
 static void addressbook_open_cb(GtkAction *action, gpointer data)
 {
+#ifndef USE_NEW_ADDRBOOK
        addressbook_open(NULL);
+#else
+       GError* error = NULL;
+       
+       addressbook_dbus_open(FALSE, &error);
+       if (error) {
+               g_warning("Failed to open address book");
+               g_warning("%s", error->message);
+               g_error_free(error);
+       }
+#endif
 }
 
 static void log_window_show_cb(GtkAction *action, gpointer data)
@@ -4226,12 +4399,26 @@ static void show_all_header_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
        if (mainwin->menu_lock_count) return;
-       mainwin->summaryview->messageview->all_headers = 
+       prefs_common.show_all_headers = 
                        gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
        summary_display_msg_selected(mainwin->summaryview,
                                     gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
 }
 
+static void toggle_fullscreen_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       if (mainwin->menu_lock_count) return;
+       if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+               gtk_window_unfullscreen(GTK_WINDOW(mainwin->window));
+               prefs_common.mainwin_fullscreen = FALSE;
+       }
+       else {
+               prefs_common.mainwin_fullscreen = TRUE;
+               gtk_window_fullscreen(GTK_WINDOW(mainwin->window));
+       }
+}
+
 static void hide_quotes_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4240,16 +4427,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);
@@ -4345,7 +4532,7 @@ static void open_urls_cb(GtkAction *action, gpointer data)
        MainWindow *mainwin = (MainWindow *)data;
        if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
                summary_display_msg_selected(mainwin->summaryview, 
-                       mainwin->messageview->mimeview->textview->show_all_headers);
+                                            prefs_common.show_all_headers);
        }
        messageview_list_urls(mainwin->messageview);
 }
@@ -4398,6 +4585,26 @@ 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 hide_read_threads (GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       GtkWidget *menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/HideReadThreads");
+       if (!mainwin->summaryview->folder_item
+           || g_object_get_data(G_OBJECT(menuitem), "dont_toggle"))
+               return;
+       summary_toggle_show_read_threads(mainwin->summaryview);
+}
+
 static void thread_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4538,7 +4745,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);     
@@ -4551,6 +4758,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;
@@ -4630,10 +4843,33 @@ static void next_labeled_cb(GtkAction *action, gpointer data)
        summary_select_next_labeled(mainwin->summaryview);
 }
 
-static void last_read_cb(GtkAction *action, gpointer data)
+static void prev_history_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       MsgInfo *info = messageview_nav_get_prev(mainwin->messageview);
+       if (info) {
+               if (info->folder != mainwin->summaryview->folder_item)
+                       folderview_select(mainwin->folderview, info->folder);
+               summary_display_by_msgnum(mainwin->summaryview, info->msgnum);
+               summary_display_msg_selected(mainwin->summaryview, FALSE);
+               procmsg_msginfo_free(info);
+               main_window_set_menu_sensitive(mainwindow_get_mainwindow());
+               toolbar_main_set_sensitive(mainwindow_get_mainwindow());
+       }
+}
+
+static void next_history_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_select_last_read(mainwin->summaryview);
+       MsgInfo *info = messageview_nav_get_next(mainwin->messageview);
+       if (info) {
+               if (info->folder != mainwin->summaryview->folder_item)
+                       folderview_select(mainwin->folderview, info->folder);
+               summary_display_by_msgnum(mainwin->summaryview, info->msgnum);
+               procmsg_msginfo_free(info);
+               main_window_set_menu_sensitive(mainwindow_get_mainwindow());
+               toolbar_main_set_sensitive(mainwindow_get_mainwindow());
+       }
 }
 
 static void parent_cb(GtkAction *action, gpointer data)
@@ -4659,6 +4895,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;
@@ -4671,7 +4931,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)))
+                (gtk_widget_has_focus(msgview->mimeview->textview->text)))
                messageview_select_all(mainwin->messageview);
        else
                summary_select_all(mainwin->summaryview);
@@ -4756,7 +5016,7 @@ static void prefs_tags_open_cb(GtkAction *action, gpointer data)
        GSList * list = summary_get_selected_msg_list(mainwin->summaryview);
        tag_apply_open(list);
 }
-#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
+#ifdef USE_GNUTLS
 static void ssl_manager_open_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4840,6 +5100,84 @@ static void legend_open_cb(GtkAction *action, gpointer data)
        legend_show();
 }
 
+#ifdef G_OS_WIN32
+static void set_default_client_cb(GtkAction *action, gpointer data)
+{
+       char exename[MAX_PATH];
+       gchar *binary_icon = NULL;
+       gchar *binary_compose = NULL;
+       gchar *binary_run = NULL;
+       int r = 0;
+       if ( !GetModuleFileNameA (0, exename, sizeof (exename)) ) {
+               alertpanel_error(_("Can not register as default client: impossible to get executable path."));
+               return;
+       }
+       binary_icon = g_strconcat(exename, ",0", NULL);
+       binary_compose = g_strconcat(exename, " --compose %1", NULL);
+       binary_run = g_strconcat(exename, NULL);
+
+       /* Try to set the Mail Start menu item to Claws. It may fail if we're not root; we don't care */
+       r = write_w32_registry_string("HKLM", "Software\\Clients\\Mail", 
+                       "", "Claws Mail");
+       
+       r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail", 
+                               "", "Claws Mail");
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail", 
+                               "DLLPath", "");
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", 
+                               "", "URL:MailTo-Protocol");
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", 
+                               "URL Protocol", "");
+       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);
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto\\shell\\open\\command", 
+                               "", binary_compose);
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\shell\\open\\command", 
+                               "", binary_run);
+       
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto", 
+                               "", "URL:MailTo-Protocol");
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto", 
+                               "URL Protocol", "");
+       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);
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto\\shell\\open\\command", 
+                               "", binary_compose);
+       
+       if (!r) {
+               SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Software\\Clients\\Mail");
+               alertpanel_notice(_("Claws Mail has been registered as default client."));
+       } else {
+               alertpanel_error(_("Can not register as default client: impossible to write to the registry."));
+       }
+       g_free(binary_icon);
+       g_free(binary_compose);
+       g_free(binary_run);
+}
+#endif
+
 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4864,11 +5202,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)
@@ -4914,6 +5252,7 @@ gboolean mainwindow_is_obscured(void)
 static void addr_harvest_cb( GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
+
        addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
 }