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