From 2bd6d458b7b998bc2b0874f85774a9f8bce74d27 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 17 May 2013 16:24:31 +0200 Subject: [PATCH] Sort items in datasheets dropdown box. Before this change, the values in the data sheets dropdown box appeared in a non-deterministic order (the order in the underlying hash), which was inconvenient to users. This change produces the values in sorted order. Closes bug #38921 --- src/ui/gui/psppire-data-sheet.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ui/gui/psppire-data-sheet.c b/src/ui/gui/psppire-data-sheet.c index 01afb5ed87..279c36953e 100644 --- a/src/ui/gui/psppire-data-sheet.c +++ b/src/ui/gui/psppire-data-sheet.c @@ -337,13 +337,15 @@ on_data_column_editing_started (GtkCellRenderer *cell, if (var_has_value_labels (var) && GTK_IS_COMBO_BOX (editable)) { const struct val_labs *labels = var_get_value_labels (var); - const struct val_lab *vl; + const struct val_lab **vls = val_labs_sorted (labels); + size_t n_vls = val_labs_count (labels); GtkListStore *list_store; + int i; list_store = gtk_list_store_new (1, G_TYPE_STRING); - for (vl = val_labs_first (labels); vl != NULL; - vl = val_labs_next (labels, vl)) + for (i = 0; i < n_vls; ++i) { + const struct val_lab *vl = vls[i]; GtkTreeIter iter; gtk_list_store_append (list_store, &iter); @@ -351,6 +353,7 @@ on_data_column_editing_started (GtkCellRenderer *cell, 0, val_lab_get_label (vl), -1); } + free (vls); gtk_combo_box_set_model (GTK_COMBO_BOX (editable), GTK_TREE_MODEL (list_store)); -- 2.30.2