X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=gtk-gui.c;h=98c0111eab530ef11de4027f54217f45eed45a27;hb=e7a70b6ae821e6a178957e2814406ac387b990ea;hp=ca033835d31630a9144fdbb3505a2a612f9ca267;hpb=c8f3dc3594aa850829ab87ac7d290776dfb846bd;p=ext%2Fsubsurface.git diff --git a/gtk-gui.c b/gtk-gui.c index ca03383..98c0111 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -624,13 +624,13 @@ static const gchar* ui_string = " \ \ \ \ - \ - \ \ - \ + \ \ \ \ + \ + \ \ \ \ @@ -1013,10 +1013,33 @@ static void do_import_file(gpointer data, gpointer user_data) } } +static GtkWidget *import_dive_computer(device_data_t *data, GtkDialog *dialog) +{ + GError *error; + GtkWidget *vbox, *info, *container, *label, *button; + + error = do_import(data); + if (!error) + return NULL; + + button = gtk_dialog_get_widget_for_response(dialog, GTK_RESPONSE_ACCEPT); + gtk_button_set_use_stock(GTK_BUTTON(button), 0); + gtk_button_set_label(GTK_BUTTON(button), "Retry"); + + vbox = gtk_dialog_get_content_area(dialog); + + 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(GTK_BOX(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; @@ -1042,6 +1065,7 @@ void import_dialog(GtkWidget *w, gpointer data) 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) { @@ -1053,6 +1077,8 @@ void import_dialog(GtkWidget *w, gpointer data) 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)) @@ -1066,7 +1092,9 @@ void import_dialog(GtkWidget *w, gpointer data) 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_DIALOG(dialog)); + if (info) + goto repeat; } else { g_slist_foreach(list,do_import_file,NULL); g_slist_free(list); @@ -1085,6 +1113,10 @@ void update_progressbar(progressbar_t *progress, double value) gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress->bar), value); } +void update_progressbar_text(progressbar_t *progress, const char *text) +{ + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress->bar), text); +} void set_filename(const char *filename) {