2 * This file is part of mapper
4 * Copyright (C) 2007 Kaj-Michael Lang
6 * Default map data provided by http://www.openstreetmap.org/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <glib/gstdio.h>
35 #include "hildon-mapper.h"
37 #include "osm-db-import.h"
39 #include "import-gui.h"
41 static GtkWidget *progress;
42 static GtkWidget *import_dialog;
45 osm_import_progress_cb(gpointer data)
47 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress));
52 osm_import_done_cb(gpointer data)
56 ret=osm_import_join_bg();
59 popup_error(import_dialog, _("OSM Data import failed!"));
61 progress_dialog_remove(import_dialog);
66 osm_import_dialog(GtkWidget *window)
70 GtkWidget *picker_planet;
73 dialog = gtk_dialog_new_with_buttons(_("OSM Data import"),
75 GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
76 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
78 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox = gtk_vbox_new (FALSE, 3), TRUE, TRUE, 0);
80 picker_planet=gtk_file_chooser_button_new(_("OSM Planet file"), GTK_FILE_CHOOSER_ACTION_OPEN);
81 entry_db=gtk_entry_new();
83 gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new("OSM Planet"), TRUE, TRUE, 0);
84 gtk_box_pack_start(GTK_BOX(vbox), picker_planet, TRUE, TRUE, 0);
86 gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new("Destination database"), TRUE, TRUE, 0);
87 gtk_box_pack_start(GTK_BOX(vbox), entry_db, TRUE, TRUE, 0);
89 gtk_widget_show_all(dialog);
91 while (GTK_RESPONSE_ACCEPT==gtk_dialog_run(GTK_DIALOG(dialog))) {
94 planet=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(picker_planet));
95 db=gtk_entry_get_text(GTK_ENTRY(entry_db));
98 progress=gtk_progress_bar_new();
99 import_dialog=progress_dialog(window, "Importing OSM data...", progress);
100 gtk_widget_show_all(import_dialog);
102 if (osm_import_bg(planet, db, osm_import_progress_cb, osm_import_done_cb)==TRUE) {
105 popup_error(dialog, _("Failed to start import."));
107 popup_error(dialog, _("Missing file selection!"));
110 gtk_widget_destroy(dialog);