fix some menu sensitivity issues
[claws.git] / src / mainwindow.c
index 95f93e468f56d0a36a62d0eeb1ab27f29cf4b874..e03c55e2a10b73e56558f5c21df41a7d3e8be532 100644 (file)
@@ -1,6 +1,6 @@
 /*
    Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
-   Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail team
+   Copyright (C) 1999-2016 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
@@ -46,6 +46,7 @@
 #include "import.h"
 #include "export.h"
 #include "edittags.h"
+#include "password.h"
 #include "prefs_common.h"
 #include "prefs_actions.h"
 #include "prefs_filtering.h"
@@ -55,7 +56,7 @@
 #include "prefs_template.h"
 #include "action.h"
 #include "account.h"
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        #include "addressbook.h"
 #else
        #include "addressbook-dbus.h"
@@ -201,6 +202,8 @@ static void show_all_header_cb              (GtkAction      *action,
                                  gpointer       data);
 static void toggle_fullscreen_cb       (GtkAction      *action,
                                  gpointer       data);
+static void toggle_menubar_cb  (GtkAction      *action,
+                                 gpointer       data);
 
 static void hide_quotes_cb(GtkAction   *action,
                                  gpointer       data);
@@ -344,6 +347,8 @@ static void allsel_cb                (GtkAction     *action,
                                  gpointer       data);
 static void select_thread_cb    (GtkAction     *action,
                                  gpointer       data);
+static void trash_thread_cb     (GtkAction     *action,
+                                 gpointer       data);
 static void delete_thread_cb    (GtkAction     *action,
                                  gpointer       data);
 
@@ -424,7 +429,10 @@ static void sync_cb                 ( GtkAction    *action,
 
 static void forget_session_passwords_cb        (GtkAction      *action,
                                         gpointer        data );
-
+#ifndef PASSWORD_CRYPTO_OLD
+static void forget_master_passphrase_cb        (GtkAction      *action,
+                                        gpointer        data );
+#endif
 static gboolean mainwindow_focus_in_event      (GtkWidget      *widget, 
                                                 GdkEventFocus  *focus,
                                                 gpointer        data);
@@ -538,7 +546,6 @@ static GtkActionEntry mainwin_entries[] =
        {"Edit/Copy",                           NULL, N_("_Copy"), "<control>C", NULL, G_CALLBACK(copy_cb) }, 
        {"Edit/SelectAll",                      NULL, N_("Select _all"), "<control>A", NULL, G_CALLBACK(allsel_cb) }, 
        {"Edit/SelectThread",                   NULL, N_("Select _thread"), NULL, NULL, G_CALLBACK(select_thread_cb) }, 
-       {"Edit/DeleteThread",                   NULL, N_("_Delete thread"), NULL, NULL, G_CALLBACK(delete_thread_cb) }, 
        {"Edit/---",                            NULL, "---" },
        {"Edit/Find",                           NULL, N_("_Find in current message..."), "<control>F", NULL, G_CALLBACK(search_cb) },
        {"Edit/SearchFolder",                   NULL, N_("_Search folder..."), "<shift><control>F", NULL, G_CALLBACK(search_folder_cb) },
@@ -587,7 +594,7 @@ static GtkActionEntry mainwin_entries[] =
        {"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/Goto/Folder",                    NULL, N_("F_older..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
        /* {"View/Goto/---",                    NULL, "---", NULL, NULL, NULL }, */
        {"View/Goto/NextPart",                  NULL, N_("Next part"), "A", NULL, G_CALLBACK(goto_next_part_cb) },
        {"View/Goto/PrevPart",                  NULL, N_("Previous part"), "Z", NULL, G_CALLBACK(goto_prev_part_cb) },
@@ -683,6 +690,8 @@ static GtkActionEntry mainwin_entries[] =
        {"Message/Copy",                        NULL, N_("_Copy..."), "<shift><control>O", NULL, G_CALLBACK(copy_to_cb) },
        {"Message/Trash",                       NULL, N_("Move to _trash"), "<control>D", NULL, G_CALLBACK(delete_trash_cb) },
        {"Message/Delete",                      NULL, N_("_Delete..."), NULL, NULL, G_CALLBACK(delete_cb) },
+       {"Message/TrashThread",                 NULL, N_("Move thread to tr_ash"), NULL, NULL, G_CALLBACK(trash_thread_cb) }, 
+       {"Message/DeleteThread",                NULL, N_("Delete t_hread"), NULL, NULL, G_CALLBACK(delete_thread_cb) }, 
        {"Message/CancelNews",                  NULL, N_("Cancel a news message"), NULL, NULL, G_CALLBACK(cancel_cb) },
        /* separation */
        
@@ -762,7 +771,7 @@ static GtkActionEntry mainwin_entries[] =
        {"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) }, 
+       {"Tools/SSLCertificates",               NULL, N_("SSL/TLS cer_tificates"), NULL, NULL, G_CALLBACK(ssl_manager_open_cb) }, 
 #endif
        /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
 #ifndef G_OS_WIN32
@@ -771,6 +780,9 @@ static GtkActionEntry mainwin_entries[] =
        {"Tools/NetworkLog",                    NULL, N_("Network _Log"), "<shift><control>L", NULL, G_CALLBACK(log_window_show_cb) }, 
        /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
        {"Tools/ForgetSessionPasswords",                NULL, N_("_Forget all session passwords"), NULL, NULL, G_CALLBACK(forget_session_passwords_cb) }, 
+#ifndef PASSWORD_CRYPTO_OLD
+       {"Tools/ForgetMasterPassphrase",                NULL, N_("Forget _master passphrase"), NULL, NULL, G_CALLBACK(forget_master_passphrase_cb) },
+#endif
 
 /* Configuration menu */       
        {"Configuration/ChangeAccount",         NULL, N_("C_hange current account") },
@@ -803,6 +815,7 @@ static GtkActionEntry mainwin_entries[] =
 
 static GtkToggleActionEntry mainwin_toggle_entries[] = {
        {"File/OfflineMode",                    NULL, N_("Offline _mode"), "<control>W", NULL, G_CALLBACK(toggle_work_offline_cb) }, /*toggle*/
+       {"View/ShowHide/MenuBar",               NULL, N_("Men_ubar"), "<control>F12", NULL, G_CALLBACK(toggle_menubar_cb) }, /* toggle */
        {"View/ShowHide/MessageView",           NULL, N_("_Message view"), "V", NULL, G_CALLBACK(toggle_message_cb) }, /* toggle */
 #ifndef GENERIC_UMPC
        {"View/ShowHide/StatusBar",             NULL, N_("Status _bar"), NULL, NULL, G_CALLBACK(toggle_statusbar_cb) }, /* toggle */
@@ -879,6 +892,7 @@ static GtkRadioActionEntry mainwin_radio_enc_entries[] =
        ENC_ACTION(CS_ISO_8859_9, C_ISO_8859_9, N_("Turkish (ISO-8859-_9)")), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_ISO_8859_5, C_ISO_8859_5, "ISO-8859-_5"), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_KOI8_R, C_KOI8_R, "KOI8-_R"), /* RADIO set_charset_cb */
+       ENC_ACTION("Cyrillic/"CS_MACCYR, C_MACCYR, "_Mac-Cyrillic"), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_KOI8_U, C_KOI8_U, "KOI8-_U"), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_WINDOWS_1251, C_WINDOWS_1251, "Windows-1251"), /* RADIO set_charset_cb */
        ENC_ACTION("Japanese/"CS_ISO_2022_JP, C_ISO_2022_JP, "ISO-2022-_JP"), /* RADIO set_charset_cb */
@@ -985,7 +999,7 @@ static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_i
                        }
                }
        } else
-               g_warning("invalid number of color elements (%d)\n", n);
+               g_warning("invalid number of color elements (%d)", n);
 
        g_slist_free(sel);
        /* reset "dont_toggle" state */
@@ -1145,6 +1159,7 @@ void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModif
                        g_free(new_accel);
                }
        }
+       g_list_free(closures);
 }
 
 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
@@ -1240,7 +1255,7 @@ static gint mainwin_tag_cmp_list(gconstpointer a, gconstpointer b)
                return tag_b == NULL ? 0:1;
        
        if (tag_b == NULL)
-               return tag_a == NULL ? 0:1;
+               return 1;
  
        return g_utf8_collate(tag_a, tag_b);
 }
@@ -1392,7 +1407,7 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                                    && mainwin->summaryview->folder_item->total_msgs == 0))) {
                                g_signal_stop_emission_by_name(G_OBJECT(widget), 
                                               "key_press_event");
-                               folderview_select_next_unread(mainwin->folderview, TRUE);
+                               folderview_select_next_with_flag(mainwin->folderview, MSG_UNREAD);
                        }
                }
                break;
@@ -1534,7 +1549,6 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "Copy", "Edit/Copy", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "SelectAll", "Edit/SelectAll", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "SelectThread", "Edit/SelectThread", GTK_UI_MANAGER_MENUITEM)
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "DeleteThread", "Edit/DeleteThread", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "Separator1", "Edit/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "Find", "Edit/Find", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Edit", "SearchFolder", "Edit/SearchFolder", GTK_UI_MANAGER_MENUITEM)
@@ -1542,6 +1556,7 @@ MainWindow *main_window_create()
 
 /* View menu */
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ShowHide", "View/ShowHide", GTK_UI_MANAGER_MENU)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide", "MenuBar", "View/ShowHide/MenuBar", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide", "Toolbar", "View/ShowHide/Toolbar", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar", "TextBelowIcon", "View/ShowHide/Toolbar/TextBelowIcon", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/ShowHide/Toolbar", "TextBesideIcon", "View/ShowHide/Toolbar/TextBesideIcon", GTK_UI_MANAGER_MENUITEM)
@@ -1623,7 +1638,7 @@ MainWindow *main_window_create()
        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/Goto", "Folder", "View/Goto/Folder", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator8", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextPart", "View/Goto/NextPart", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevPart", "View/Goto/PrevPart", GTK_UI_MANAGER_MENUITEM)
@@ -1667,6 +1682,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Cyrillic", "View/Encoding/Cyrillic", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_ISO_8859_5, "View/Encoding/Cyrillic/"CS_ISO_8859_5, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_KOI8_R, "View/Encoding/Cyrillic/"CS_KOI8_R, GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_MACCYR, "View/Encoding/Cyrillic/"CS_MACCYR, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_KOI8_U, "View/Encoding/Cyrillic/"CS_KOI8_U, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_WINDOWS_1251, "View/Encoding/Cyrillic/"CS_WINDOWS_1251, GTK_UI_MANAGER_MENUITEM)
 
@@ -1759,6 +1775,8 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Copy", "Message/Copy", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Trash", "Message/Trash", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Delete", "Message/Delete", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "TrashThread", "Message/TrashThread", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "DeleteThread", "Message/DeleteThread", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "CancelNews", "Message/CancelNews", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Message", "Separator4", "Message/---", GTK_UI_MANAGER_SEPARATOR)
 
@@ -1839,6 +1857,9 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "NetworkLog", "Tools/NetworkLog", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetSessionPasswords", "Tools/ForgetSessionPasswords", GTK_UI_MANAGER_MENUITEM)
+#ifndef PASSWORD_CRYPTO_OLD
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetMasterPassphrase", "Tools/ForgetMasterPassphrase", GTK_UI_MANAGER_MENUITEM)
+#endif
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator9", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
 
 /* Configuration menu */
@@ -1873,7 +1894,10 @@ MainWindow *main_window_create()
 
 
        menubar = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu");
-       gtk_widget_show_all(menubar);
+       if (prefs_common.mainwin_menubar)
+               gtk_widget_show_all(menubar);
+       else
+               gtk_widget_hide(menubar);
        gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(mainwin->ui_manager));
 
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
@@ -1942,8 +1966,8 @@ MainWindow *main_window_create()
        gtk_widget_set_size_request(progressbar, 120, 1);
        gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
 
-       online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
-       offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
+       online_pixmap = stock_pixmap_widget(STOCK_PIXMAP_ONLINE);
+       offline_pixmap = stock_pixmap_widget(STOCK_PIXMAP_OFFLINE);
        online_switch = gtk_button_new ();
        gtkut_widget_set_can_focus(online_switch, FALSE);
        CLAWS_SET_TIP(online_switch, 
@@ -2092,7 +2116,7 @@ MainWindow *main_window_create()
        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);
+                       g_warning("MainWindow: color allocation %d failed", i);
        }
 #endif
 
@@ -2205,6 +2229,9 @@ MainWindow *main_window_create()
                        "Menu/View/FullScreen",
                        TRUE);
        }
+       if (prefs_common.mainwin_menubar)
+               cm_toggle_menu_set_active_full(mainwin->ui_manager,"Menu/View/ShowHide/MenuBar", TRUE);
+       
        return mainwin;
 }
 
@@ -2303,17 +2330,17 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        folderview_reinit_fonts(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
                        foldersel_reflect_prefs_pixmap_theme();
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
                        addressbook_reflect_prefs_pixmap_theme();
 #endif
 #ifndef GENERIC_UMPC
-                       pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
+                       pixmap = stock_pixmap_widget(STOCK_PIXMAP_ONLINE);
                        gtk_container_remove(GTK_CONTAINER(mainwin->online_switch), 
                                             mainwin->online_pixmap);
                        gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
                        gtk_widget_show(pixmap);
                        mainwin->online_pixmap = pixmap;
-                       pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
+                       pixmap = stock_pixmap_widget(STOCK_PIXMAP_OFFLINE);
                        gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch), 
                                             mainwin->offline_pixmap);
                        gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
@@ -2381,7 +2408,6 @@ static gboolean main_window_reflect_tags_changes_real(gpointer data)
        MainWindow *mainwin = (MainWindow *)data;
 
        if (summary_is_locked(mainwin->summaryview)) {
-               tags_tag = 0;
                return TRUE;
        }
        /* re-create tags submenu */
@@ -2896,7 +2922,7 @@ gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean
 
        if (mainwin->summaryview->folder_item &&
            mainwin->summaryview->folder_item->stype == F_TRASH)
-               gtk_widget_grab_focus(mainwin->folderview->ctree);
+               folderview_grab_focus(mainwin->folderview);
        return TRUE;
 }
 
@@ -2951,7 +2977,7 @@ SensitiveCondMask main_window_get_current_state(MainWindow *mainwin)
 
        if (mainwin->lock_count == 0 && !claws_is_starting())
                UPDATE_STATE(M_UNLOCKED);
-       if (selection != SUMMARY_NONE)
+       if (selection != SUMMARY_NONE && selection != SUMMARY_SELECTED_NONE)
                UPDATE_STATE(M_MSG_EXIST);
        if (item && item->path && folder_item_parent(item) && !item->no_select) {
                UPDATE_STATE(M_EXEC);
@@ -2989,6 +3015,10 @@ SensitiveCondMask main_window_get_current_state(MainWindow *mainwin)
             !folder_has_parent_of_type(mainwin->summaryview->folder_item, F_TRASH)))
                UPDATE_STATE(M_NOT_TRASH);
 
+       if (mainwin->summaryview->folder_item
+           && mainwin->summaryview->folder_item->stype != F_DRAFT)
+               UPDATE_STATE(M_NOT_DRAFT);
+
        if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
                UPDATE_STATE(M_ACTIONS_EXIST);
 
@@ -3075,6 +3105,12 @@ SensitiveCondMask main_window_get_current_state(MainWindow *mainwin)
                        break;
                }
        }
+
+#ifndef PASSWORD_CRYPTO_OLD
+       if (master_passphrase_is_entered()) {
+               UPDATE_STATE(M_MASTER_PASSPHRASE);
+       }
+#endif
 #undef UPDATE_STATE
 
        return state;
@@ -3115,7 +3151,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        gint i;
        gboolean mimepart_selected = FALSE;
 
-#define N_ENTRIES 83
+#define N_ENTRIES 88
        static struct {
                const gchar *entry;
                SensitiveCondMask cond;
@@ -3134,7 +3170,6 @@ do { \
        FILL_TABLE("Menu/File/Exit", M_UNLOCKED);
 
        FILL_TABLE("Menu/Edit/SelectThread", M_TARGET_EXIST, M_SUMMARY_ISLIST);
-       FILL_TABLE("Menu/Edit/DeleteThread", M_TARGET_EXIST, M_SUMMARY_ISLIST);
        FILL_TABLE("Menu/Edit/Find", M_SINGLE_TARGET_EXIST);
        FILL_TABLE("Menu/Edit/QuickSearch", M_IN_MSGLIST);
        FILL_TABLE("Menu/Edit/SearchFolder", M_TARGET_EXIST, M_SUMMARY_ISLIST);
@@ -3144,14 +3179,17 @@ do { \
        FILL_TABLE("Menu/View/ThreadView", M_EXEC, M_SUMMARY_ISLIST);
        FILL_TABLE("Menu/View/ExpandThreads", M_MSG_EXIST, M_SUMMARY_ISLIST);
        FILL_TABLE("Menu/View/CollapseThreads", M_MSG_EXIST, M_SUMMARY_ISLIST);
-       FILL_TABLE("Menu/View/HideReadThreads", M_HIDE_READ_THREADS, M_SUMMARY_ISLIST);
-       FILL_TABLE("Menu/View/HideReadMessages", M_HIDE_READ_MSG, M_SUMMARY_ISLIST);
-       FILL_TABLE("Menu/View/HideDelMessages", M_SUMMARY_ISLIST);
+       FILL_TABLE("Menu/View/HideReadThreads", M_HIDE_READ_THREADS, M_SUMMARY_ISLIST, M_NOT_DRAFT);
+       FILL_TABLE("Menu/View/HideReadMessages", M_HIDE_READ_MSG, M_SUMMARY_ISLIST, M_NOT_DRAFT);
+       FILL_TABLE("Menu/View/HideDelMessages", M_SUMMARY_ISLIST, M_NOT_DRAFT);
        FILL_TABLE("Menu/View/Goto/Prev", M_MSG_EXIST);
        FILL_TABLE("Menu/View/Goto/Next", M_MSG_EXIST);
        FILL_TABLE("Menu/View/Goto/PrevUnread", M_MSG_EXIST);
+       FILL_TABLE("Menu/View/Goto/NextUnread", M_MSG_EXIST);
        FILL_TABLE("Menu/View/Goto/PrevNew", M_MSG_EXIST);
+       FILL_TABLE("Menu/View/Goto/NextNew", M_MSG_EXIST);
        FILL_TABLE("Menu/View/Goto/PrevMarked", M_MSG_EXIST);
+       FILL_TABLE("Menu/View/Goto/NextMarked", M_MSG_EXIST);
        FILL_TABLE("Menu/View/Goto/PrevLabeled", M_MSG_EXIST);
        FILL_TABLE("Menu/View/Goto/NextLabeled", M_MSG_EXIST);
        FILL_TABLE("Menu/View/Goto/ParentMessage", M_SINGLE_TARGET_EXIST);
@@ -3180,6 +3218,8 @@ do { \
        FILL_TABLE("Menu/Message/Copy", M_TARGET_EXIST, M_EXEC);
        FILL_TABLE("Menu/Message/Trash", M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS, M_NOT_TRASH);
        FILL_TABLE("Menu/Message/Delete", M_TARGET_EXIST, M_ALLOW_DELETE);
+       FILL_TABLE("Menu/Message/TrashThread", M_TARGET_EXIST, M_SUMMARY_ISLIST);
+       FILL_TABLE("Menu/Message/DeleteThread", M_TARGET_EXIST, M_SUMMARY_ISLIST);
        FILL_TABLE("Menu/Message/CancelNews", M_TARGET_EXIST, M_ALLOW_DELETE, M_NEWS);
        FILL_TABLE("Menu/Message/Mark", M_TARGET_EXIST, M_SUMMARY_ISLIST);
        FILL_TABLE("Menu/Message/Mark/MarkSpam", M_TARGET_EXIST, M_CAN_LEARN_SPAM);
@@ -3207,6 +3247,9 @@ do { \
        FILL_TABLE("Menu/Tools/Execute", M_DELAY_EXEC);
        FILL_TABLE("Menu/Tools/Expunge", M_DELETED_EXISTS);
        FILL_TABLE("Menu/Tools/ForgetSessionPasswords", M_SESSION_PASSWORDS);
+#ifndef PASSWORD_CRYPTO_OLD
+       FILL_TABLE("Menu/Tools/ForgetMasterPassphrase", M_MASTER_PASSPHRASE);
+#endif
        FILL_TABLE("Menu/Tools/DeleteDuplicates/SelFolder", M_MSG_EXIST, M_ALLOW_DELETE);
 
        FILL_TABLE("Menu/Configuration", M_UNLOCKED);
@@ -3301,7 +3344,7 @@ do { \
                cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Sort/Descending", FALSE);
        }
 
-       if (mainwin->messageview 
+       if (mainwin->messageview
        &&  mainwin->messageview->mimeview
        &&  mainwin->messageview->mimeview->textview)
                cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/AllHeaders",
@@ -3309,17 +3352,21 @@ do { \
        cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/ThreadView", (state & main_window_get_mask(M_THREADED, -1)) != 0);
        cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/ExpandThreads", (state & main_window_get_mask(M_THREADED, -1)) != 0);
        cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/CollapseThreads", (state & main_window_get_mask(M_THREADED, -1)) != 0);
-       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", (state & main_window_get_mask(M_THREADED, -1)) != 0);
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", (state & main_window_get_mask(M_THREADED, -1)) != 0 && (state & main_window_get_mask(M_NOT_DRAFT, -1)) != 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->threaded)
                cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/HideReadThreads", FALSE);
-       if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_msgs)
+       if ((mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_msgs) ||
+           quicksearch_has_sat_predicate(mainwin->summaryview->quicksearch))
                cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", FALSE);
-       if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_threads)
+       if ((mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_threads) ||
+           quicksearch_has_sat_predicate(mainwin->summaryview->quicksearch))
                cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadMessages", FALSE);
+       if (quicksearch_has_sat_predicate(mainwin->summaryview->quicksearch))
+               cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideDelMessages", FALSE);
 
        cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/PrevHistory",
                messageview_nav_has_prev(mainwin->messageview));
@@ -3482,6 +3529,11 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded)
                for (i = 0;
                     *buf != '>' && *buf != 0x00 && i < BUFFSIZE;
                        tmp[i++] = *(buf++));
+               if (*buf == 0) {
+                       *buffer = NULL;
+                       *url_decoded = '\0';
+                       return;
+               }
                buf++;
        }
        else  {
@@ -3622,7 +3674,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        GtkWidget *vpaned;
        GtkWidget *vbox_body = mainwin->vbox_body;
        gboolean first_set = (mainwin->hpaned == NULL);
-       debug_print("Setting widgets... ");
+       debug_print("Setting widgets...\n");
 
 #ifndef GENERIC_UMPC
        mainwin->messageview->statusbar = mainwin->statusbar;
@@ -3827,7 +3879,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                         mainwin);
        }
 
-       debug_print("done.\n");
+       debug_print("Setting widgets done.\n");
 }
 
 void main_window_destroy_all(void)
@@ -4139,6 +4191,8 @@ static void set_layout_cb(GtkAction *action, GtkRadioAction *current, gpointer d
        mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
        if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
                mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
+               if (layout_mode == VERTICAL_LAYOUT)
+                       mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
        }
        if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
                mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
@@ -4198,7 +4252,7 @@ static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
 
        if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
                        _("Do you want to synchronise your folders now?"),
-                       GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
+                       GTK_STOCK_CANCEL, g_strconcat("+", _("_Synchronise"), NULL), NULL) != G_ALERTALTERNATE)
                return;
        
        if (offline_ask_sync)
@@ -4257,15 +4311,14 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
 
 static void addressbook_open_cb(GtkAction *action, gpointer data)
 {
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_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_warning("Failed to open address book: %s", error->message);
                g_error_free(error);
        }
 #endif
@@ -4360,6 +4413,19 @@ static void toggle_fullscreen_cb(GtkAction *action, gpointer data)
        }
 }
 
+static void toggle_menubar_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_widget_hide(GTK_WIDGET(mainwin->menubar));
+               prefs_common.mainwin_menubar = FALSE;
+       } else {
+               gtk_widget_show(GTK_WIDGET(mainwin->menubar));
+               prefs_common.mainwin_menubar = TRUE;
+       }
+}
+
 static void hide_quotes_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4712,14 +4778,9 @@ static void update_summary_cb(GtkAction *action, gpointer data)
        FolderView *folderview = mainwin->folderview;
 
        if (!mainwin->summaryview->folder_item) return;
-       if (!folderview->opened) return;
+       if ((fitem = folderview_get_opened_item(folderview)) == NULL) return;
 
        folder_update_op_count();
-
-       fitem = gtk_cmctree_node_get_row_data(GTK_CMCTREE(folderview->ctree),
-                                           folderview->opened);
-       if (!fitem) return;
-
        folder_item_scan(fitem);
        summary_show(mainwin->summaryview, fitem);
 }
@@ -4727,13 +4788,13 @@ static void update_summary_cb(GtkAction *action, gpointer data)
 static void prev_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
+       summary_select_prev(mainwin->summaryview);
 }
 
 static void next_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
+       summary_select_next(mainwin->summaryview);
 }
 
 static void prev_unread_cb(GtkAction *action, gpointer data)
@@ -4793,7 +4854,7 @@ static void prev_history_cb(GtkAction *action, gpointer data)
                        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);
+               procmsg_msginfo_free(&info);
                main_window_set_menu_sensitive(mainwindow_get_mainwindow());
                toolbar_main_set_sensitive(mainwindow_get_mainwindow());
        }
@@ -4807,7 +4868,7 @@ static void next_history_cb(GtkAction *action, gpointer data)
                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);
+               procmsg_msginfo_free(&info);
                main_window_set_menu_sensitive(mainwindow_get_mainwindow());
                toolbar_main_set_sensitive(mainwindow_get_mainwindow());
        }
@@ -4833,7 +4894,7 @@ static void goto_folder_cb(GtkAction *action, gpointer data)
 static void goto_unread_folder_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       folderview_select_next_unread(mainwin->folderview, FALSE);
+       folderview_select_next_with_flag(mainwin->folderview, MSG_UNREAD);
 }
 
 static void scroll_prev_line_cb(GtkAction *action, gpointer data)
@@ -4881,13 +4942,19 @@ static void allsel_cb(GtkAction *action, gpointer data)
 static void select_thread_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_select_thread(mainwin->summaryview, FALSE);
+       summary_select_thread(mainwin->summaryview, FALSE, FALSE);
+}
+
+static void trash_thread_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       summary_select_thread(mainwin->summaryview, FALSE, TRUE);
 }
 
 static void delete_thread_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_select_thread(mainwin->summaryview, TRUE);
+       summary_select_thread(mainwin->summaryview, TRUE, FALSE);
 }
 
 static void create_filter_cb(GtkAction *gaction, gpointer data)
@@ -5274,6 +5341,17 @@ static void forget_session_passwords_cb(GtkAction *action, gpointer data)
                                   fgtn), fgtn, accs);  
 }
 
+#ifndef PASSWORD_CRYPTO_OLD
+static void forget_master_passphrase_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+
+       main_window_lock(mainwin);
+       master_passphrase_forget();
+       main_window_unlock(mainwin);
+}
+#endif
+
 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
 {
        summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
@@ -5314,7 +5392,7 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
                return;
        }
        
-       msg = strrchr(tmp, G_DIR_SEPARATOR);
+       msg = strrchr(tmp, '/');
        if (msg) {
                *msg++ = '\0';
                if ((item = folder_find_item_from_identifier(tmp))) {
@@ -5346,7 +5424,7 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
                                if (popup)
                                        main_window_popup(mainwin);
                                g_free(tmp);
-                               procmsg_msginfo_free(msginfo);
+                               procmsg_msginfo_free(&msginfo);
                                return;
                        } else {
                                g_print("'%s' not found\n", msg);
@@ -5363,9 +5441,9 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
 
 void mainwindow_exit_folder(MainWindow *mainwin) {
        if (prefs_common.layout_mode == SMALL_LAYOUT) {
-               folderview_close_opened(mainwin->folderview);
+               folderview_close_opened(mainwin->folderview, FALSE);
                mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
-               gtk_widget_grab_focus(mainwin->folderview->ctree);
+               folderview_grab_focus(mainwin->folderview);
        }
        mainwin->in_folder = FALSE;
        main_window_set_menu_sensitive(mainwin);