summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-12 07:25:28 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-12 07:25:28 -0800
commitaba65736eb8cb85fa9bfa953095eab21f0668904 (patch)
treea7f24ce89f7573b47bb6f545a347054a083182f1 /gtk-gui.c
parent597a3677e9025a41eb84fa1741721d9b0bd89f63 (diff)
downloadsubsurface-aba65736eb8cb85fa9bfa953095eab21f0668904.tar.gz
Change the empty product model to be index 0
A vendor of -1 indicates that we should have no product selection in the dive download dialog. Having the empty product model be the last made it hard to keep the correct index for that empty model around (and we got it wrong by default). With this change the product models are offset by one, so the unset vendor (-1) turns into index 0 which is where we now store the empty model. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 9104aef57..59e62948c 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1596,11 +1596,11 @@ static int fill_computer_list(GtkListStore *vendorstore, GtkListStore ***product
0, dcl->vendor,
-1);
pl = dcl->productlist;
- pstores[i] = gtk_list_store_new(1, G_TYPE_POINTER);
+ pstores[i + 1] = gtk_list_store_new(1, G_TYPE_POINTER);
j = 0;
while (pl) {
- gtk_list_store_append(pstores[i], &iter);
- gtk_list_store_set(pstores[i], &iter,
+ gtk_list_store_append(pstores[i + 1], &iter);
+ gtk_list_store_set(pstores[i + 1], &iter,
0, pl->descriptor,
-1);
if (is_default_dive_computer(dcl->vendor, pl->product)) {
@@ -1614,9 +1614,7 @@ static int fill_computer_list(GtkListStore *vendorstore, GtkListStore ***product
dcl = dcl->next;
}
/* now add the empty product list in case no vendor is selected */
- pstores[i] = gtk_list_store_new(1, G_TYPE_POINTER);
- if (*product_index == -1)
- *product_index = i;
+ pstores[0] = gtk_list_store_new(1, G_TYPE_POINTER);
return width;
}
@@ -1660,7 +1658,7 @@ static GtkListStore **product_model;
static void dive_computer_vendor_changed(GtkComboBox *vendorcombo, GtkComboBox *productcombo)
{
int vendor = gtk_combo_box_get_active(vendorcombo);
- gtk_combo_box_set_model(productcombo, GTK_TREE_MODEL(product_model[vendor]));
+ gtk_combo_box_set_model(productcombo, GTK_TREE_MODEL(product_model[vendor + 1]));
gtk_combo_box_set_active(productcombo, -1);
}
@@ -1685,7 +1683,7 @@ static GtkComboBox *dive_computer_selector(GtkWidget *vbox)
gtk_container_add(GTK_CONTAINER(frame), hbox);
vendor_combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(vendor_model));
- product_combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(product_model[vendor_default_index]));
+ 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);