Updated French translations
[claws.git] / src / setup.c
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 #include "mh.h"
33
34 #define SETUP_DIALOG_WIDTH      540
35
36 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data);
37
38 void setup(MainWindow *mainwin)
39 {
40         gchar *path;
41         Folder *folder;
42
43         path = input_dialog
44                 (_("Mailbox setting"),
45                  _("First, you have to set the location of mailbox.\n"
46                    "You can use existing mailbox in MH format\n"
47                    "if you have the one.\n"
48                    "If you're not sure, just select OK."),
49                  "Mail");
50         if (!path) return;
51         if (folder_find_from_path(path)) {
52                 g_warning("The mailbox already exists.\n");
53                 g_free(path);
54                 return;
55         }
56
57         folder = folder_new(mh_get_class(), !strcmp(path, "Mail") ? _("Mailbox") : g_basename(path), path);
58         g_free(path);
59
60         if (folder->klass->create_tree(folder) < 0) {
61                 alertpanel_error(_("Creation of the mailbox failed.\n"
62                                    "Maybe some files already exist, or you don't have the permission to write there."));
63                 folder_destroy(folder);
64                 return;
65         }
66
67         folder_add(folder);
68         folder_set_ui_func(folder, scan_tree_func, mainwin);
69         folder_scan_tree(folder);
70         folder_set_ui_func(folder, NULL, NULL);
71 }
72
73 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
74 {
75         MainWindow *mainwin = (MainWindow *)data;
76         gchar *str;
77
78         if (item->path)
79                 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
80                                       LOCAL_FOLDER(folder)->rootpath,
81                                       G_DIR_SEPARATOR,
82                                       item->path);
83         else
84                 str = g_strdup_printf(_("Scanning folder %s ..."),
85                                       LOCAL_FOLDER(folder)->rootpath);
86
87         gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar),
88                            mainwin->mainwin_cid, str);
89         gtkut_widget_wait_for_draw(mainwin->hbox_stat);
90         gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar),
91                           mainwin->mainwin_cid);
92         g_free(str);
93 }