root / src / setup.c @ 2196
History | View | Annotate | Download (2.7 kB)
| 1 | /*
|
|---|---|
| 2 | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | * Copyright (C) 1999-2005 Hiroyuki Yamamoto |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifdef HAVE_CONFIG_H
|
| 21 | # include "config.h" |
| 22 | #endif
|
| 23 | |
| 24 | #include <glib.h> |
| 25 | #include <glib/gi18n.h> |
| 26 | #include <gtk/gtkstatusbar.h> |
| 27 | |
| 28 | #include "inputdialog.h" |
| 29 | #include "alertpanel.h" |
| 30 | #include "mainwindow.h" |
| 31 | #include "manage_window.h" |
| 32 | #include "gtkutils.h" |
| 33 | |
| 34 | static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data); |
| 35 | |
| 36 | void setup(MainWindow *mainwin)
|
| 37 | {
|
| 38 | gchar *path; |
| 39 | Folder *folder; |
| 40 | |
| 41 | manage_window_focus_in(mainwin->window, NULL, NULL); |
| 42 | path = input_dialog |
| 43 | (_("Mailbox setting"),
|
| 44 | _("Specify the location of mailbox.\n"
|
| 45 | "If you are unsure, just select OK."),
|
| 46 | "Mail");
|
| 47 | if (!path) return; |
| 48 | if (folder_find_from_path(path)) {
|
| 49 | alertpanel_error(_("The mailbox `%s' already exists."), path);
|
| 50 | g_warning("The mailbox already exists.\n");
|
| 51 | g_free(path); |
| 52 | return;
|
| 53 | } |
| 54 | |
| 55 | if (!strcmp(path, "Mail")) |
| 56 | folder = folder_new(F_MH, _("Mailbox"), path);
|
| 57 | else
|
| 58 | folder = folder_new(F_MH, g_basename(path), path); |
| 59 | g_free(path); |
| 60 | |
| 61 | if (folder->klass->create_tree(folder) < 0) { |
| 62 | alertpanel_error(_("Creation of the mailbox failed.\n"
|
| 63 | "Maybe some files already exist, or you don't have the permission to write there."));
|
| 64 | folder_destroy(folder); |
| 65 | return;
|
| 66 | } |
| 67 | |
| 68 | folder_add(folder); |
| 69 | folder_set_ui_func(folder, scan_tree_func, mainwin); |
| 70 | folder->klass->scan_tree(folder); |
| 71 | folder_set_ui_func(folder, NULL, NULL); |
| 72 | } |
| 73 | |
| 74 | static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data) |
| 75 | {
|
| 76 | MainWindow *mainwin = (MainWindow *)data; |
| 77 | gchar *str; |
| 78 | |
| 79 | if (item->path)
|
| 80 | str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
|
| 81 | LOCAL_FOLDER(folder)->rootpath, |
| 82 | G_DIR_SEPARATOR, |
| 83 | item->path); |
| 84 | else
|
| 85 | str = g_strdup_printf(_("Scanning folder %s ..."),
|
| 86 | LOCAL_FOLDER(folder)->rootpath); |
| 87 | |
| 88 | gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), |
| 89 | mainwin->mainwin_cid, str); |
| 90 | gtkut_widget_draw_now(mainwin->statusbar); |
| 91 | gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), |
| 92 | mainwin->mainwin_cid); |
| 93 | g_free(str); |
| 94 | } |