2008-10-07 [colin] 3.6.0cvs10
[claws.git] / src / mainwindow.c
index 681ff55abb5ed31299d73c45b6f45216fa029c6b..9fca790c3203b00aa4db05a86e5dda70859a4f62 100644 (file)
@@ -187,6 +187,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);
@@ -386,6 +388,9 @@ static void addr_harvest_msg_cb      ( GtkAction    *action,
 static void sync_cb             ( GtkAction    *action,
                                  gpointer       data );
 
+static void forget_session_passwords_cb        (GtkAction      *action,
+                                        gpointer        data );
+
 static gboolean mainwindow_focus_in_event      (GtkWidget      *widget, 
                                                 GdkEventFocus  *focus,
                                                 gpointer        data);
@@ -689,8 +694,12 @@ static GtkActionEntry mainwin_entries[] =
        {"Tools/SSLCertificates",               NULL, N_("SSL cer_tificates"), NULL, NULL, G_CALLBACK(ssl_manager_open_cb) }, 
 #endif
        /* {"Tools/---",                        NULL, "---", NULL, NULL, NULL }, */
+#ifndef G_OS_WIN32
        {"Tools/FilteringLog",                  NULL, N_("Filtering Lo_g"), NULL, NULL, G_CALLBACK(filtering_debug_window_show_cb) }, 
+#endif
        {"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) }, 
 
 /* Configuration menu */       
        {"Configuration/ChangeAccount",         NULL, N_("C_hange current account") },
@@ -727,6 +736,9 @@ static GtkToggleActionEntry mainwin_toggle_entries[] = {
        {"View/ShowHide/ColumnHeaders",         NULL, N_("Column headers"), NULL, NULL, G_CALLBACK(toggle_col_headers_cb) }, /* toggle */
        {"View/ThreadView",                     NULL, N_("Th_read view"), "<control>T", NULL, G_CALLBACK(thread_cb) }, /* toggle */
        {"View/HideReadMessages",               NULL, N_("_Hide read messages"), NULL, NULL, G_CALLBACK(hide_read_messages) }, /* toggle */
+#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 */
@@ -742,7 +754,7 @@ static GtkRadioActionEntry mainwin_showhide_radio_entries[] = { /* toggle_toolba
        {"View/ShowHide/Toolbar/Hide",          NULL, N_("_Hide"), NULL, NULL, TOOLBAR_NONE }, /* radio TOOLBAR_NONE */
 #endif
 };
-
+#ifndef GENERIC_UMPC
 static GtkRadioActionEntry mainwin_layout_radio_entries[] = { /* set_layout_cb */
        {"View/Layout/Standard",                NULL, N_("_Standard"), NULL, NULL, NORMAL_LAYOUT }, /* radio NORMAL_LAYOUT */
        {"View/Layout/ThreeColumns",            NULL, N_("_Three columns"), NULL, NULL, VERTICAL_LAYOUT }, /* radio VERTICAL_LAYOUT */
@@ -750,7 +762,7 @@ static GtkRadioActionEntry mainwin_layout_radio_entries[] = { /* set_layout_cb *
        {"View/Layout/WideMessageList",         NULL, N_("W_ide message list"), NULL, NULL, WIDE_MSGLIST_LAYOUT }, /* radio WIDE_MSGLIST_LAYOUT */
        {"View/Layout/SmallScreen",             NULL, N_("S_mall screen"), NULL, NULL, SMALL_LAYOUT }, /* radio SMALL_LAYOUT */
 };
-
+#endif
 static GtkRadioActionEntry mainwin_sort_radio_entries[] = { /* sort_summary_cb */
        {"View/Sort/Number",                    NULL, N_("by _Number"), NULL, NULL, SORT_BY_NUMBER }, /* radio SORT_BY_NUMBER */
        {"View/Sort/Size",                      NULL, N_("by S_ize"), NULL, NULL, SORT_BY_SIZE }, /* radio SORT_BY_SIZE */
@@ -776,21 +788,21 @@ static GtkRadioActionEntry mainwin_sorttype_radio_entries[] = { /* sort_summary_
 
 static GtkRadioActionEntry mainwin_radio_enc_entries[] =
 {
-       ENC_ACTION(CS_AUTO, C_AUTO, "_Automatic"), /* RADIO set_charset_cb */
-       ENC_ACTION(CS_US_ASCII, C_US_ASCII, "7bit ASCII (US-ASC_II)"), /* RADIO set_charset_cb */
-       ENC_ACTION(CS_UTF_8, C_UTF_8, "Unicode (_UTF-8)"), /* RADIO set_charset_cb */
+       ENC_ACTION(CS_AUTO, C_AUTO, N_("_Automatic")), /* RADIO set_charset_cb */
+       ENC_ACTION(CS_US_ASCII, C_US_ASCII, N_("7bit ASCII (US-ASC_II)")), /* RADIO set_charset_cb */
+       ENC_ACTION(CS_UTF_8, C_UTF_8, N_("Unicode (_UTF-8)")), /* RADIO set_charset_cb */
        ENC_ACTION("Western/"CS_ISO_8859_1, C_ISO_8859_1, "ISO-8859-_1"), /* RADIO set_charset_cb */
        ENC_ACTION("Western/"CS_ISO_8859_15, C_ISO_8859_15, "ISO-8859-15"), /* RADIO set_charset_cb */
        ENC_ACTION("Western/"CS_WINDOWS_1252, C_WINDOWS_1252, "Windows-1252"), /* RADIO set_charset_cb */
-       ENC_ACTION(CS_ISO_8859_2, C_ISO_8859_2, "Central European (ISO-8859-_2)"), /* RADIO set_charset_cb */
+       ENC_ACTION(CS_ISO_8859_2, C_ISO_8859_2, N_("Central European (ISO-8859-_2)")), /* RADIO set_charset_cb */
        ENC_ACTION("Baltic/"CS_ISO_8859_13, C_ISO_8859_13, "ISO-8859-13"), /* RADIO set_charset_cb */
        ENC_ACTION("Baltic/"CS_ISO_8859_4, C_ISO_8859_14, "ISO-8859-_4"), /* RADIO set_charset_cb */
-       ENC_ACTION(CS_ISO_8859_7, C_ISO_8859_7, "Greek (ISO-8859-_7)"), /* RADIO set_charset_cb */
+       ENC_ACTION(CS_ISO_8859_7, C_ISO_8859_7, N_("Greek (ISO-8859-_7)")), /* RADIO set_charset_cb */
        ENC_ACTION("Hebrew/"CS_ISO_8859_8, C_ISO_8859_8, "ISO-8859-_8"), /* RADIO set_charset_cb */
        ENC_ACTION("Hebrew/"CS_WINDOWS_1255, C_WINDOWS_1255, "Windows-1255"), /* RADIO set_charset_cb */
        ENC_ACTION("Arabic/"CS_ISO_8859_6, C_ISO_8859_6, "ISO-8859-_6"), /* RADIO set_charset_cb */
        ENC_ACTION("Arabic/"CS_WINDOWS_1256, C_WINDOWS_1256, "Windows-1256"), /* RADIO set_charset_cb */
-       ENC_ACTION(CS_ISO_8859_9, C_ISO_8859_9, "Turkish (ISO-8859-_9)"), /* RADIO set_charset_cb */
+       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_KOI8_U, C_KOI8_U, "KOI8-_U"), /* RADIO set_charset_cb */
@@ -811,7 +823,7 @@ static GtkRadioActionEntry mainwin_radio_enc_entries[] =
 
 static GtkRadioActionEntry mainwin_radio_dec_entries[] =
 {
-       DEC_ACTION("AutoDetect", 0, "_Auto detect"),    /* set_decode_cb */
+       DEC_ACTION("AutoDetect", 0, N_("_Auto detect")),        /* set_decode_cb */
        /* --- */
        DEC_ACTION("8bit", ENC_8BIT, "_8bit"),
        DEC_ACTION("QP", ENC_QUOTED_PRINTABLE, "_Quoted printable"),
@@ -865,7 +877,7 @@ static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_i
        Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
 
        /* NOTE: don't return prematurely because we set the "dont_toggle"
-        * state for check menu items */
+        * state for check menu items. This would be bad! */
        g_object_set_data(G_OBJECT(menu), "dont_toggle",
                          GINT_TO_POINTER(1));
 
@@ -1062,10 +1074,10 @@ static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refr
        g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
        gtk_widget_show(item);
 
-       gtk_widget_add_accelerator(item, "activate", 
-                                  gtk_ui_manager_get_accel_group(mainwin->ui_manager), 
-                                  GDK_0, GDK_CONTROL_MASK,
-                                  GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
+       accel_path = g_strdup_printf("<ClawsColorLabels>/None");
+       gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
+       g_free(accel_path);
+       gtk_accel_map_add_entry("<ClawsColorLabels>/None", GDK_0, GDK_CONTROL_MASK);
 
        item = gtk_menu_item_new();
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
@@ -1084,12 +1096,9 @@ static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refr
                gtk_widget_show(item);
                accel_path = g_strdup_printf("<ClawsColorLabels>/%d", i);
                gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
-               g_free(accel_path);
                if (i < 9)
-                       gtk_widget_add_accelerator(item, "activate", 
-                                  gtk_ui_manager_get_accel_group(mainwin->ui_manager), 
-                                  GDK_1+i, GDK_CONTROL_MASK,
-                                  GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
+                       gtk_accel_map_add_entry(accel_path, GDK_1+i, GDK_CONTROL_MASK);
+               g_free(accel_path);
        }
        gtk_widget_show(menu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
@@ -1179,10 +1188,6 @@ static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
        }
 
        item = gtk_menu_item_new_with_label(_("Apply tags..."));
-       gtk_widget_add_accelerator(item, "activate", 
-                  gtk_ui_manager_get_accel_group(mainwin->ui_manager), 
-                  GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
-                  GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
        g_signal_connect(G_OBJECT(item), "activate",
                         G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
@@ -1190,6 +1195,10 @@ static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
        g_object_set_data(G_OBJECT(item), "mainwin",
                          mainwin);
        gtk_widget_show(item);
+       accel_path = g_strdup_printf("<ClawsTags>/ApplyTags");
+       gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
+       g_free(accel_path);
+       gtk_accel_map_add_entry("<ClawsTags>/ApplyTags", GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK);
 
        g_slist_free(orig);
        gtk_widget_show(menu);
@@ -1279,6 +1288,7 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                        }
                }
                break;
+
 #ifdef MAEMO
        case GDK_F6:
                if (maemo_mainwindow_is_fullscreen(widget)) {
@@ -1523,8 +1533,10 @@ MainWindow *main_window_create()
                        G_N_ELEMENTS(mainwin_toggle_entries), (gpointer)mainwin);
        gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_showhide_radio_entries,
                        G_N_ELEMENTS(mainwin_showhide_radio_entries), C_AUTO, G_CALLBACK(toggle_toolbar_cb), (gpointer)mainwin);
+#ifndef GENERIC_UMPC
        gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_layout_radio_entries,
                        G_N_ELEMENTS(mainwin_layout_radio_entries), C_AUTO, G_CALLBACK(set_layout_cb), (gpointer)mainwin);
+#endif
        gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_sort_radio_entries,
                        G_N_ELEMENTS(mainwin_sort_radio_entries), C_AUTO, G_CALLBACK(sort_summary_cb), (gpointer)mainwin);
        gtk_action_group_add_radio_actions(mainwin->action_group, mainwin_sorttype_radio_entries,
@@ -1537,7 +1549,7 @@ MainWindow *main_window_create()
 #ifndef MAEMO
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_MENUBAR)
 #else
-       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_MENU)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_POPUP)
 #endif
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "File", "File", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU)
@@ -1600,6 +1612,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)
@@ -1848,9 +1863,13 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "SSLCertificates", "Tools/SSLCertificates", GTK_UI_MANAGER_MENUITEM)
 #endif
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator7", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
+#ifndef G_OS_WIN32
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "FilteringLog", "Tools/FilteringLog", GTK_UI_MANAGER_MENUITEM)
+#endif
        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", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetSessionPasswords", "Tools/ForgetSessionPasswords", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator9", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
 
 /* Configuration menu */
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Configuration", "ChangeAccount", "Configuration/ChangeAccount", GTK_UI_MANAGER_MENU)
@@ -2144,6 +2163,9 @@ MainWindow *main_window_create()
        }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
 
+       toolbar_set_style(mainwin->toolbar->toolbar, 
+                         mainwin->handlebox, 
+                         prefs_common.toolbar_style);
 #ifndef GENERIC_UMPC
        gtk_widget_hide(mainwin->hbox_stat);
        menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/ShowHide/StatusBar");
@@ -2224,6 +2246,8 @@ MainWindow *main_window_create()
 #ifdef MAEMO
        main_window_install_maemo_hooks(mainwin);
 #endif
+        mainwin->fullscreen = FALSE;
+
        return mainwin;
 }
 
@@ -2800,8 +2824,12 @@ void main_window_get_size(MainWindow *mainwin)
        }
 
        allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
-
-       if (allocation->width > 1 && allocation->height > 1) {
+       
+       if (mainwin->fullscreen) {
+               debug_print("mainwin in full screen state. "
+                           "Keeping original settings\n");
+       }
+       if (allocation->width > 1 && allocation->height > 1 && !mainwin->fullscreen) {
                prefs_common.summaryview_width = allocation->width;
 
                if (messageview_is_visible(mainwin->messageview))
@@ -2812,20 +2840,22 @@ void main_window_get_size(MainWindow *mainwin)
 
        allocation = &mainwin->window->allocation;
        if (allocation->width > 1 && allocation->height > 1 &&
-           !prefs_common.mainwin_maximised) {
+           !prefs_common.mainwin_maximised && !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) {
+       if (allocation->width > 1 && allocation->height > 1 &&
+           !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) {
+       if (allocation->width > 1 && allocation->height > 1 &&
+           !mainwin->fullscreen) {
                prefs_common.msgview_width = allocation->width;
                prefs_common.msgview_height = allocation->height;
        }
@@ -2845,7 +2875,7 @@ void main_window_get_position(MainWindow *mainwin)
 {
        gint x, y;
 
-       if (prefs_common.mainwin_maximised)
+       if (prefs_common.mainwin_maximised || mainwin->fullscreen)
                return;
 
        gtkut_widget_get_uposition(mainwin->window, &x, &y);
@@ -3039,6 +3069,14 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (prefs_common.layout_mode != SMALL_LAYOUT || mainwin->in_folder)
                state |= M_IN_MSGLIST;
 
+       for (account_list = account_get_list(); account_list != NULL; account_list = account_list->next) {
+               PrefsAccount *account = account_list->data;
+               if (account->session_passwd || account->session_smtp_passwd) {
+                       state |= M_SESSION_PASSWORDS;
+                       break;
+               }
+       }
+
        return state;
 }
 
@@ -3133,6 +3171,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/ForgetSessionPasswords"       , M_SESSION_PASSWORDS},
                {"Menu/Tools/DeleteDuplicates/SelFolder"   , M_MSG_EXIST|M_ALLOW_DELETE},
 
                {"Menu/Configuration", M_UNLOCKED},
@@ -3763,14 +3802,15 @@ static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event
                                    gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-
+       GtkWidget *menu = NULL;
+       
        if (!event) return FALSE;
 
        gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
-       g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
-                         widget);
+       
+       menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(mainwin->ac_menu));
 
-       gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
+       gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
                       menu_button_position, widget,
                       event->button, event->time);
 
@@ -4209,6 +4249,20 @@ static void show_all_header_cb(GtkAction *action, gpointer data)
                                     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));
+               mainwin->fullscreen = FALSE;
+       }
+       else {
+               mainwin->fullscreen = TRUE;
+               gtk_window_fullscreen(GTK_WINDOW(mainwin->window));
+       }
+}
+
 static void hide_quotes_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4943,6 +4997,34 @@ static void sync_cb(GtkAction *action, gpointer data)
        mainwindow_check_synchronise(mainwin, FALSE);
 }
 
+static void forget_session_passwords_cb(GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       GList *list = NULL;
+        gint fgtn = 0;
+       gint accs = 0;
+
+       main_window_lock(mainwin);
+       for (list = account_get_list(); list != NULL; list = list->next) {
+               PrefsAccount *account = list->data;
+               if (account->session_passwd) {
+                       g_free(account->session_passwd);
+                       account->session_passwd = NULL;
+                       ++fgtn;
+               }
+               if (account->session_smtp_passwd) {
+                       g_free(account->session_smtp_passwd);
+                       account->session_smtp_passwd = NULL;
+                       ++fgtn;
+               }
+               ++accs;
+       }
+       main_window_unlock(mainwin);
+       alertpanel_notice(ngettext("Forgotten %d password in %d accounts.\n",
+                                  "Forgotten %d passwords in %d accounts.\n",
+                                  fgtn), fgtn, accs);  
+}
+
 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
 {
        summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);