summaryrefslogtreecommitdiffstats
path: root/download-dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'download-dialog.c')
-rw-r--r--download-dialog.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/download-dialog.c b/download-dialog.c
index e12b07abd..8f6220e31 100644
--- a/download-dialog.c
+++ b/download-dialog.c
@@ -116,6 +116,18 @@ static void dive_computer_selector_changed(GtkWidget *combo, gpointer data)
{
GtkWidget *import, *button;
+#if DC_VERSION_CHECK(0, 4, 0)
+ GtkTreeIter iter;
+ if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) {
+ GtkTreeModel *model;
+ dc_descriptor_t *descriptor;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(combo));
+ gtk_tree_model_get(model, &iter, 0, &descriptor, -1);
+ gtk_widget_set_sensitive(GTK_WIDGET(data), dc_descriptor_get_transport (descriptor) == DC_TRANSPORT_SERIAL);
+ }
+#endif
+
import = gtk_widget_get_ancestor(combo, GTK_TYPE_DIALOG);
button = gtk_dialog_get_widget_for_response(GTK_DIALOG(import), GTK_RESPONSE_ACCEPT);
gtk_widget_set_sensitive(button, TRUE);
@@ -303,7 +315,6 @@ static GtkComboBox *dive_computer_selector(GtkWidget *vbox)
product_combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(product_model[vendor_default_index + 1]));
g_signal_connect(G_OBJECT(vendor_combo_box), "changed", G_CALLBACK(dive_computer_vendor_changed), product_combo_box);
- g_signal_connect(G_OBJECT(product_combo_box), "changed", G_CALLBACK(dive_computer_selector_changed), NULL);
gtk_box_pack_start(GTK_BOX(hbox), vendor_combo_box, FALSE, FALSE, 3);
gtk_box_pack_start(GTK_BOX(hbox), product_combo_box, FALSE, FALSE, 3);
@@ -363,7 +374,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 = {
@@ -383,6 +394,8 @@ void download_dialog(GtkWidget *w, gpointer data)
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 3);
computer = dive_computer_selector(vbox);
device = dc_device_selector(vbox);
+ g_signal_connect(G_OBJECT(computer), "changed", G_CALLBACK(dive_computer_selector_changed), device);
+
hbox = gtk_hbox_new(FALSE, 6);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 3);
devicedata.progress.bar = gtk_progress_bar_new();
@@ -400,12 +413,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;
@@ -422,6 +436,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,