# include "config.h"
#endif
+#include <stddef.h>
#include <glib.h>
+#include <glib/gi18n.h>
#include <gtk/gtkstatusbar.h>
-#include "intl.h"
#include "inputdialog.h"
#include "alertpanel.h"
#include "mainwindow.h"
#include "gtkutils.h"
-
+#include "mh.h"
+#include "wizard.h"
#define SETUP_DIALOG_WIDTH 540
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data);
void setup(MainWindow *mainwin)
{
gchar *path;
- Folder *folder;
-
+
path = input_dialog
(_("Mailbox setting"),
_("First, you have to set the location of mailbox.\n"
"if you have the one.\n"
"If you're not sure, just select OK."),
"Mail");
- if (!path) return;
+ setup_write_mailbox_path(mainwin, path);
+ g_free(path);
+}
+
+gboolean setup_write_mailbox_path(MainWindow *mainwin, const gchar *path)
+{
+ Folder *folder;
+ gchar *base;
+
+ if (!path) return FALSE;
if (folder_find_from_path(path)) {
g_warning("The mailbox already exists.\n");
- g_free(path);
- return;
+ return FALSE;
}
- if (!strcmp(path, "Mail"))
- folder = folder_new(F_MH, _("Mailbox"), path);
- else
- folder = folder_new(F_MH, g_basename(path), path);
- g_free(path);
+ base = g_path_get_basename(path);
+ folder = folder_new(mh_get_class(), !strcmp(path, "Mail") ? _("Mailbox") : base, path);
- if (folder->create_tree(folder) < 0) {
+ if (folder->klass->create_tree(folder) < 0) {
alertpanel_error(_("Creation of the mailbox failed.\n"
"Maybe some files already exist, or you don't have the permission to write there."));
folder_destroy(folder);
- return;
+ g_free(base);
+ return FALSE;
}
folder_add(folder);
folder_set_ui_func(folder, scan_tree_func, mainwin);
folder_scan_tree(folder);
folder_set_ui_func(folder, NULL, NULL);
+ g_free(base);
+ return TRUE;
}
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar),
mainwin->mainwin_cid, str);
- gtkut_widget_wait_for_draw(mainwin->hbox_stat);
+ gtkut_widget_draw_now(mainwin->hbox_stat);
gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar),
mainwin->mainwin_cid);
g_free(str);