Statistics
| Revision:

root / src / setup.c @ 1

History | View | Annotate | Download (2.72 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999,2000 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 <gtk/gtkstatusbar.h>
26

    
27
#include "intl.h"
28
#include "inputdialog.h"
29
#include "alertpanel.h"
30
#include "mainwindow.h"
31
#include "gtkutils.h"
32

    
33
#define SETUP_DIALOG_WIDTH        540
34

    
35
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data);
36

    
37
void setup(MainWindow *mainwin)
38
{
39
        gchar *path;
40
        Folder *folder;
41

    
42
        path = input_dialog
43
                (_("Mailbox setting"),
44
                 _("First, you have to set the location of mailbox.\n"
45
                   "You can use existing mailbox in MH format\n"
46
                   "if you have the one.\n"
47
                   "If you're not sure, just select OK."),
48
                 "Mail");
49
        if (!path) return;
50
        if (folder_find_from_path(path)) {
51
                g_warning("The mailbox already exists.\n");
52
                g_free(path);
53
                return;
54
        }
55

    
56
        if (!strcmp(path, "Mail"))
57
                folder = folder_new(F_MH, _("Mailbox"), path);
58
        else
59
                folder = folder_new(F_MH, g_basename(path), path);
60
        g_free(path);
61

    
62
        if (folder->klass->create_tree(folder) < 0) {
63
                alertpanel_error(_("Creation of the mailbox failed.\n"
64
                                   "Maybe some files already exist, or you don't have the permission to write there."));
65
                folder_destroy(folder);
66
                return;
67
        }
68

    
69
        folder_add(folder);
70
        folder_set_ui_func(folder, scan_tree_func, mainwin);
71
        folder->klass->scan_tree(folder);
72
        folder_set_ui_func(folder, NULL, NULL);
73
}
74

    
75
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
76
{
77
        MainWindow *mainwin = (MainWindow *)data;
78
        gchar *str;
79

    
80
        if (item->path)
81
                str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
82
                                      LOCAL_FOLDER(folder)->rootpath,
83
                                      G_DIR_SEPARATOR,
84
                                      item->path);
85
        else
86
                str = g_strdup_printf(_("Scanning folder %s ..."),
87
                                      LOCAL_FOLDER(folder)->rootpath);
88

    
89
        gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar),
90
                           mainwin->mainwin_cid, str);
91
        gtkut_widget_wait_for_draw(mainwin->hbox_stat);
92
        gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar),
93
                          mainwin->mainwin_cid);
94
        g_free(str);
95
}