mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
d1571ead2d
commit
a8d413551e
5 changed files with 97 additions and 18 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue