Added option to warn about queued messages on exit.
[claws.git] / src / mainwindow.c
index 79892c193c5966f5461dd346d094754bf6a40e98..d9508fbfed6178cb4386d7a795c2f5ba2991e8f7 100644 (file)
@@ -54,6 +54,7 @@
 #include "compose.h"
 #include "procmsg.h"
 #include "import.h"
+#include "export.h"
 #include "prefs_common.h"
 #include "prefs_filter.h"
 #include "prefs_account.h"
@@ -157,6 +158,9 @@ static void delete_folder_cb         (MainWindow    *mainwin,
 static void import_mbox_cb      (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+static void export_mbox_cb      (MainWindow    *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
 static void empty_trash_cb      (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
@@ -335,6 +339,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
        {N_("/_File/_Folder/_Delete folder"),   NULL, delete_folder_cb, 0, NULL},
        {N_("/_File/_Import mbox file..."),     NULL, import_mbox_cb, 0, NULL},
+       {N_("/_File/_Export to mbox file..."),  NULL, export_mbox_cb, 0, NULL},
        {N_("/_File/Empty _trash"),             NULL, empty_trash_cb, 0, NULL},
        {N_("/_File/---"),                      NULL, NULL, 0, "<Separator>"},
        {N_("/_File/_Save as..."),              NULL, save_as_cb, 0, NULL},
@@ -1616,7 +1621,13 @@ static void delete_folder_cb(MainWindow *mainwin, guint action,
 static void import_mbox_cb(MainWindow *mainwin, guint action,
                           GtkWidget *widget)
 {
-       import_mbox();
+       import_mbox(mainwin->summaryview->folder_item);
+}
+
+static void export_mbox_cb(MainWindow *mainwin, guint action,
+                          GtkWidget *widget)
+{
+       export_mbox(mainwin->summaryview->folder_item);
 }
 
 static void empty_trash_cb(MainWindow *mainwin, guint action,
@@ -1635,6 +1646,13 @@ static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
        summary_print(mainwin->summaryview);
 }
 
+static gint queued_messages(void)
+{
+       FolderItem *queue = folder_get_default_queue();
+       folder_item_scan(queue);
+       return queue->total;
+}
+
 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        if (prefs_common.confirm_on_exit) {
@@ -1643,6 +1661,13 @@ static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
                        return;
        }
 
+       if (prefs_common.warn_queued_on_exit && queued_messages() > 0) {
+               if (alertpanel(_("Queued messages"), 
+                              _("Some unsent messages are queued. Exit now?"),
+                              _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
+                       return;
+       }
+
        manage_window_focus_in(mainwin->window, NULL, NULL);
        app_will_exit(widget, mainwin);
 }