summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-19 14:11:08 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-20 11:42:01 -0800
commita8d413551e3b6c7c2ab9d092b67e0976550e2115 (patch)
treea305ddc5fb8ee66a6c6ca44f4ccc929991493252 /gtk-gui.c
parentd1571ead2df6276ff8db06bd54d39b873b4ab9c9 (diff)
downloadsubsurface-a8d413551e3b6c7c2ab9d092b67e0976550e2115.tar.gz
Allow the user to cancel a dive computer download
The code pretended to support this for libdivecomputer based downloads, but it had never been hooked up when the native Uemis downloader was implemented. When I finally decided to close that feature gap I realized that the original code was, shall we say, "aspirational" or "completely bogus" and therefore never worked. So instead of just hooking up the code for the Uemis downloader I instead implemented this correctly for the first time for both libdivecomputer and the native Uemis downloader. In order not to have to mess with multithreaded Gtk development I simply opted for a helper function that fires on a 100ms timeout and have it end the dialog without a response. This way we can run the dialog while waiting for the download to finish, still update the progress bar and respond in a useful manner to the user clicking cancel. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 3e9a35f20..96dbfa320 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1678,7 +1678,7 @@ static GError *setup_uemis_import(device_data_t *data)
GError *error = NULL;
char *buf = NULL;
- error = uemis_download(data->devname, &uemis_max_dive_data, &buf, &data->progress, data->force_download);
+ error = uemis_download(data->devname, &uemis_max_dive_data, &buf, &data->progress, data->dialog, data->force_download);
if (buf && strlen(buf) > 1) {
#if UEMIS_DEBUG > 3
fprintf(debugfile, "xml buffer \"%s\"\n\n", buf);
@@ -1742,7 +1742,7 @@ void download_dialog(GtkWidget *w, gpointer data)
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
g_signal_connect(dialog, "delete-event", G_CALLBACK(download_dialog_delete), NULL);
@@ -1819,6 +1819,7 @@ repeat:
while (*(--ne) == ' ' || *ne == '\t')
*ne = '\0';
devicedata.devname = ns;
+ devicedata.dialog = GTK_DIALOG(dialog);
devicedata.force_download = force_download;
force_download = FALSE; /* when retrying we don't want to restart */
info = import_dive_computer(&devicedata, GTK_DIALOG(dialog));