X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-store.c;h=74677259f72ed65d0ab03744f810681ab82cac7f;hb=7293c1a383d325c371bd708401e5a1d7586a4d90;hp=c4414138ff3acfdec3d1dfa5e387fac49fb9a830;hpb=0892eff00b3bdfa3f22c2a86ae7428df8c5b17cd;p=pspp diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index c4414138ff..74677259f7 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -138,23 +138,48 @@ __get_value (GtkTreeModel *tree_model, { PsppireDataStore *store = PSPPIRE_DATA_STORE (tree_model); - g_value_init (value, G_TYPE_DOUBLE); + const struct variable *variable = psppire_dict_get_variable (store->dict, column); + + if (var_is_numeric (variable)) + g_value_init (value, G_TYPE_DOUBLE); + else + g_value_init (value, G_TYPE_STRING); gint row = GPOINTER_TO_INT (iter->user_data); struct ccase *cc = datasheet_get_row (store->datasheet, row); - g_value_set_double (value, case_data_idx (cc, column)->f); + if (var_is_numeric (variable)) + g_value_set_double (value, case_data_idx (cc, column)->f); + else + { + const gchar *ss = value_str (case_data_idx (cc, column), + var_get_width (variable)); + g_value_set_string (value, ss); + } case_unref (cc); } +static GType +__get_type (GtkTreeModel *tree_model, gint idx) +{ + PsppireDataStore *store = PSPPIRE_DATA_STORE (tree_model); + + const struct variable *variable = psppire_dict_get_variable (store->dict, idx); + + if (var_is_numeric (variable)) + return G_TYPE_DOUBLE; + + return G_TYPE_STRING; +} + static void __tree_model_init (GtkTreeModelIface *iface) { iface->get_flags = __tree_model_get_flags; iface->get_n_columns = __tree_model_get_n_columns ; - iface->get_column_type = NULL; + iface->get_column_type = __get_type; iface->get_iter = NULL; iface->iter_next = NULL; iface->get_path = NULL;