X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-store.c;h=f97b8eaf1cdc5b246ec81685e590640b79686fd0;hb=4eb2e820b01d92ef662c741f5ac30f08bedd1de6;hp=7b6aa7fb7f7fe0f85d1925d6b315b005afb17edd;hpb=c779c0c9beb2e6b3bde870fdd2fd9cd8a86877fa;p=pspp diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 7b6aa7fb7f..f97b8eaf1c 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 @@ -130,11 +130,22 @@ __iter_nth_child (GtkTreeModel *tree_model, return TRUE; } +/* Set the contents of OUT to reflect the information provided by IN, COL, and + ROW, for MODEL. Returns TRUE if successful. */ gboolean -myreversefunc (GtkTreeModel *model, gint col, gint row, - const gchar *in, GValue *out) +psppire_data_store_string_to_value (GtkTreeModel *model, gint col, gint row, + const gchar *in, GValue *out) { - PsppireDataStore *store = PSPPIRE_DATA_STORE (model); + PsppireDataStore *store = PSPPIRE_DATA_STORE (model); + + while (col >= psppire_dict_get_var_cnt (store->dict)) + { + const struct variable *var = + psppire_dict_insert_variable (store->dict, + psppire_dict_get_var_cnt (store->dict), + NULL); + g_return_val_if_fail (var, FALSE); + } const struct variable *variable = psppire_dict_get_variable (store->dict, col); g_return_val_if_fail (variable, FALSE); @@ -158,8 +169,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 +186,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 +821,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; }