diff options
author | Jef Driesen <jefdriesen@telenet.be> | 2013-05-14 20:50:55 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-14 14:59:03 -0400 |
commit | e3b8d8ee70d6323113355175abb0bf34940bc5e4 (patch) | |
tree | e3aefc1aa0593e30a104d7dedbcf129e6f79af8c | |
parent | 41373e467abc6cffe45cafff4644e7b4185ef049 (diff) | |
download | subsurface-e3b8d8ee70d6323113355175abb0bf34940bc5e4.tar.gz |
Conditionally enable the device combo box.
The device combo box is only necessary for the Uemis Zurich, and dive
computers using serial communication. For dive computers using IrDA or
USB communication, this combo box causes only confusion for the users.
Starting with libdivecomputer version 0.4, there is an api to query the
transport type, which can be used to enable/disable the device combo box
based on the selected model.
Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | download-dialog.c | 15 | ||||
-rw-r--r-- | libdivecomputer.h | 1 |
2 files changed, 15 insertions, 1 deletions
diff --git a/download-dialog.c b/download-dialog.c index 5d5c1de04..c4b0c675d 100644 --- a/download-dialog.c +++ b/download-dialog.c @@ -109,6 +109,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); @@ -295,7 +307,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); @@ -375,6 +386,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(); diff --git a/libdivecomputer.h b/libdivecomputer.h index 0950d32ae..2fd42c91a 100644 --- a/libdivecomputer.h +++ b/libdivecomputer.h @@ -2,6 +2,7 @@ #define LIBDIVECOMPUTER_H /* libdivecomputer */ +#include <libdivecomputer/version.h> #include <libdivecomputer/device.h> #include <libdivecomputer/parser.h> |