[LV2] [PATCH 2/3] jalv make enum index independent from value.
Robin Gareus
robin at gareus.org
Sat May 25 03:30:59 PDT 2013
---
jalv/src/jalv_gtk.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/jalv/src/jalv_gtk.c b/jalv/src/jalv_gtk.c
index ebec756..e301e33 100644
--- a/jalv/src/jalv_gtk.c
+++ b/jalv/src/jalv_gtk.c
@@ -420,18 +420,20 @@ 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 (port->control == *(double*)cur->data) 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();
@@ -658,7 +660,7 @@ build_control_widget(Jalv* jalv, GtkWidget* window)
LILV_FOREACH(scale_points, s, sp) {
const LilvScalePoint* p = lilv_scale_points_get(sp, s);
values[idx] = lilv_node_as_float(lilv_scale_point_get_value(p));
- char* label = g_strdup(
+ gchar* label = g_strdup(
lilv_node_as_string(lilv_scale_point_get_label(p)));
g_hash_table_insert(points, values + idx, label);
++idx;
--
1.7.10.4
More information about the Devel
mailing list