From 3f2b8f817b22c36317b4b24ad98f6f142b220f81 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 26 May 2013 19:20:56 +0000 Subject: Fix default setting for non-sequential enumeration ports (patch from Robin Gareus). git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5109 a436a847-0d15-0410-975c-d299462d15a1 --- NEWS | 4 +++- src/jalv_gtk.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index a58deb3..d56e7e8 100644 --- a/NEWS +++ b/NEWS @@ -2,8 +2,10 @@ jalv (1.4.1) unstable; * Fix crash when running "jalv" with bad command line arguments * Add command-line option to control UI update frequency + * Fix default setting for non-sequential enumeration ports + (patch from Robin Gareus) - -- David Robillard Sun, 24 Mar 2013 18:18:08 -0400 + -- David Robillard Sun, 26 May 2013 15:15:09 -0400 jalv (1.4.0) stable; diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c index 45d1080..00cbf27 100644 --- a/src/jalv_gtk.c +++ b/src/jalv_gtk.c @@ -420,18 +420,22 @@ make_combo(struct Port* port, GHashTable* points) GList* list = g_hash_table_get_keys(points); GtkListStore* list_store = gtk_list_store_new( 2, G_TYPE_DOUBLE, G_TYPE_STRING); - for (GList* cur = g_list_sort(list, dcmp); cur; cur = cur->next) { + gint active = -1, count = 0; + for (GList* cur = g_list_sort(list, dcmp); cur; cur = cur->next, ++count) { GtkTreeIter iter; gtk_list_store_append(list_store, &iter); gtk_list_store_set(list_store, &iter, 0, *(double*)cur->data, 1, g_hash_table_lookup(points, cur->data), -1); + if (fabs(port->control - *(double*)cur->data) < FLT_EPSILON) { + active = count; + } } g_list_free(list); GtkWidget* combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list_store)); - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), lrintf(port->control)); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), active); g_object_unref(list_store); GtkCellRenderer* cell = gtk_cell_renderer_text_new(); -- cgit v1.2.1