g_object_set (de->var_sheet, "data-model", de->dict, NULL);
break;
+
case PROP_VALUE_LABELS:
+ {
+ gboolean l = g_value_get_boolean (value);
+ g_object_set (de->data_sheet, "forward-conversion",
+ l ?
+ psppire_data_store_value_to_string_with_labels :
+ psppire_data_store_value_to_string,
+ NULL);
+ }
break;
default:
value_destroy_from_variant (&v, vrnt);
}
-static gchar *
-data_store_value_to_string (SswSheet *data_sheet, PsppireDataStore *store, gint col, gint row, const GValue *v)
-{
- return psppire_data_store_value_to_string (store, col, row, v);
-}
-
gboolean myreversefunc (GtkTreeModel *model, gint col, gint row, const gchar *in,
GValue *out);
-
\f
static void
{
GObject *obj =
g_object_new (PSPPIRE_TYPE_DATA_SHEET,
- "forward-conversion", data_store_value_to_string,
+ "forward-conversion", psppire_data_store_value_to_string,
"reverse-conversion", myreversefunc,
NULL);
#include <stdlib.h>
#include <gettext.h>
#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
+#define P_(msgid) msgid
#include <data/datasheet.h>
#include <data/data-out.h>
return TRUE;
}
+static char *
+unlabeled_value (PsppireDataStore *store, const struct variable *variable, const union value *val)
+{
+ const struct fmt_spec *fmt = var_get_print_format (variable);
+ return data_out (val, psppire_dict_encoding (store->dict), fmt);
+}
+
gchar *
-psppire_data_store_value_to_string (PsppireDataStore *store, gint col, gint row, const GValue *v)
+psppire_data_store_value_to_string (gpointer unused, PsppireDataStore *store, gint col, gint row, const GValue *v)
{
const struct variable *variable = psppire_dict_get_variable (store->dict, col);
g_return_val_if_fail (variable, g_strdup ("???"));
union value val;
value_variant_get (&val, vrnt);
- const struct fmt_spec *fmt = var_get_print_format (variable);
- char *out = data_out (&val, psppire_dict_encoding (store->dict), fmt);
+ char *out = unlabeled_value (store, variable, &val);
+
+ value_destroy_from_variant (&val, vrnt);
+
+ return out;
+}
+
+gchar *
+psppire_data_store_value_to_string_with_labels (gpointer unused, PsppireDataStore *store, gint col, gint row, const GValue *v)
+{
+ const struct variable *variable = psppire_dict_get_variable (store->dict, col);
+ g_return_val_if_fail (variable, g_strdup ("???"));
+
+ GVariant *vrnt = g_value_get_variant (v);
+ union value val;
+ value_variant_get (&val, vrnt);
+
+ char *out = NULL;
+
+ const struct val_labs *vls = var_get_value_labels (variable);
+ struct val_lab *vl = val_labs_lookup (vls, &val);
+ if (vl != NULL)
+ out = strdup (val_lab_get_label (vl));
+ else
+ out = unlabeled_value (store, variable, &val);
+
value_destroy_from_variant (&val, vrnt);
return out;
glong row, const struct variable *,
bool use_value_label);
-gchar * psppire_data_store_value_to_string (PsppireDataStore *store,
+gchar * psppire_data_store_value_to_string (gpointer unused, PsppireDataStore *store,
+ gint col, gint row,
+ const GValue *v);
+
+gchar * psppire_data_store_value_to_string_with_labels (gpointer unused, PsppireDataStore *store,
gint col, gint row,
const GValue *v);