}
}
+static GtkWidget *import_dive_computer(device_data_t *data, GtkBox *vbox)
+{
+ GError *error;
+ GtkWidget *info, *container, *label;
+
+ error = do_import(data);
+ if (!error)
+ return NULL;
+
+ info = gtk_info_bar_new();
+ container = gtk_info_bar_get_content_area(GTK_INFO_BAR(info));
+ label = gtk_label_new(error->message);
+ gtk_container_add(GTK_CONTAINER(container), label);
+ gtk_box_pack_start(vbox, info, FALSE, FALSE, 0);
+ return info;
+}
+
void import_dialog(GtkWidget *w, gpointer data)
{
int result;
- GtkWidget *dialog, *hbox, *vbox, *label;
+ GtkWidget *dialog, *hbox, *vbox, *label, *info = NULL;
GtkComboBox *computer;
GtkEntry *device;
GtkWidget *XMLchooser;
devicedata.progress.bar = gtk_progress_bar_new();
gtk_container_add(GTK_CONTAINER(hbox), devicedata.progress.bar);
+repeat:
gtk_widget_show_all(dialog);
result = gtk_dialog_run(GTK_DIALOG(dialog));
switch (result) {
case GTK_RESPONSE_ACCEPT:
/* what happened - did the user pick a file? In that case
* we ignore whether a dive computer model was picked */
+ if (info)
+ gtk_widget_destroy(info);
list = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(XMLchooser));
if (g_slist_length(list) == 0) {
if (!gtk_combo_box_get_active_iter(computer, &iter))
devicedata.name = comp;
devicedata.devname = gtk_entry_get_text(device);
set_default_dive_computer(devicedata.name);
- do_import(&devicedata);
+ info = import_dive_computer(&devicedata, GTK_BOX(vbox));
+ if (info)
+ goto repeat;
} else {
g_slist_foreach(list,do_import_file,NULL);
g_slist_free(list);
#define NOT_FROG
#endif
-static void error(const char *fmt, ...)
+static GError *error(const char *fmt, ...)
{
va_list args;
GError *error;
g_quark_from_string("subsurface"),
DIVE_ERROR_PARSE, fmt, args);
va_end(args);
- report_error(error);
- g_error_free(error);
+ return error;
}
static parser_status_t create_parser(device_data_t *devdata, parser_t **parser)
return (void *)err_string;
}
-void do_import(device_data_t *data)
+GError *do_import(device_data_t *data)
{
pthread_t pthread;
void *retval;
if (pthread_join(pthread, &retval) < 0)
retval = "Odd pthread error return";
if (retval)
- error(retval, data->name, data->devname);
+ return error(retval, data->name, data->devname);
+ return NULL;
}
/*