X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-store.c;h=d0322204e413da1bb97de98c48203c6d1d76ad59;hb=93934145177c09e11deba0ad23bac34fe0fe9b97;hp=7b6aa7fb7f7fe0f85d1925d6b315b005afb17edd;hpb=e1c4d5d0f0c63ef20927ac2cd7f9ff4e7e4cf5c5;p=pspp diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 7b6aa7fb7f..d0322204e4 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -20,7 +20,7 @@ #include #include #define _(msgid) gettext (msgid) -#define N_(msgid) msgid +#define P_(msgid) msgid #include #include @@ -158,8 +158,15 @@ myreversefunc (GtkTreeModel *model, gint col, gint row, 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 ("???")); @@ -168,8 +175,32 @@ psppire_data_store_value_to_string (PsppireDataStore *store, gint col, gint row, 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; @@ -779,7 +810,10 @@ psppire_data_store_set_value (PsppireDataStore *ds, casenumber casenum, ok = datasheet_put_value (ds->datasheet, casenum, var_get_case_index (var), v); if (ok) - g_signal_emit (ds, signals [CASE_CHANGED], 0, casenum); + { + g_signal_emit (ds, signals [CASE_CHANGED], 0, casenum); + g_signal_emit (ds, signals [ITEMS_CHANGED], 0, casenum, 1, 1); + } return ok; }