[PATCH] Disable OK button in download dialog when downloading

subsurface at henrik.synth.no subsurface at henrik.synth.no
Wed May 15 12:56:18 PDT 2013


From: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>

The button was active while downloading, and that was
confusing.

Signed-off-by: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
---
 download-dialog.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/download-dialog.c b/download-dialog.c
index c4b0c67..5066a9c 100644
--- a/download-dialog.c
+++ b/download-dialog.c
@@ -366,7 +366,7 @@ void download_dialog(GtkWidget *w, gpointer data)
 {
 	int result;
 	char *devname, *ns, *ne;
-	GtkWidget *dialog, *button, *hbox, *vbox, *label, *info = NULL;
+	GtkWidget *dialog, *button, *okbutton, *hbox, *vbox, *label, *info = NULL;
 	GtkComboBox *computer, *device;
 	GtkTreeIter iter;
 	device_data_t devicedata = {
@@ -405,12 +405,13 @@ void download_dialog(GtkWidget *w, gpointer data)
 	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 6);
 	g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(prefer_dl_toggle), NULL);
 
-	button = gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+	okbutton = gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
 	if (!gtk_combo_box_get_active_iter(computer, &iter))
-		gtk_widget_set_sensitive(button, FALSE);
+		gtk_widget_set_sensitive(okbutton, FALSE);
 
 repeat:
 	gtk_widget_show_all(dialog);
+	gtk_widget_set_sensitive(okbutton, TRUE);
 	result = gtk_dialog_run(GTK_DIALOG(dialog));
 	switch (result) {
 		dc_descriptor_t *descriptor;
@@ -427,6 +428,8 @@ repeat:
 		if (!gtk_combo_box_get_active_iter(computer, &iter))
 			break;
 
+		gtk_widget_set_sensitive(okbutton, FALSE);
+
 		model = gtk_combo_box_get_model(computer);
 		gtk_tree_model_get(model, &iter,
 				0, &descriptor,
@@ -459,13 +462,16 @@ repeat:
 		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));
 		free((void *)devname);
 		if (info)
 			goto repeat;
 		report_dives(TRUE, prefer_downloaded);
 		break;
 	default:
 		/* it's possible that some dives were downloaded */
 		report_dives(TRUE, prefer_downloaded);
 		break;
-- 
1.8.1.3



More information about the subsurface mailing list