X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-var-store.c;h=092de58cafa0ed89f827d61a617c9008a442e86a;hb=ae1be0785be76a86b0d0ace1ec820c2a4f3e313d;hp=1d6f465d437e5c2605bb8001a7ddce6fd720eb3c;hpb=0f70b0dd47b62dbefe87fb08ba8a8984aa5a50c4;p=pspp-builds.git diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index 1d6f465d..092de58c 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -21,7 +21,7 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid - +#include #include @@ -53,9 +53,6 @@ static void psppire_var_store_sheet_model_init (PsppireSheetModelIface * static void psppire_var_store_finalize (GObject *object); -gchar * missing_values_to_string (const struct variable *pv, GError **err); - - static gchar *psppire_var_store_get_string (const PsppireSheetModel *sheet_model, glong row, glong column); static gboolean psppire_var_store_clear (PsppireSheetModel *model, glong row, glong col); @@ -67,7 +64,8 @@ static gboolean psppire_var_store_set_string (PsppireSheetModel *model, static glong psppire_var_store_get_row_count (const PsppireSheetModel * model); static glong psppire_var_store_get_column_count (const PsppireSheetModel * model); -static gchar *text_for_column (const struct variable *pv, gint c, GError **err); +static gchar *text_for_column (PsppireVarStore *vs, const struct variable *pv, + gint c, GError **err); static GObjectClass *parent_class = NULL; @@ -399,7 +397,8 @@ psppire_var_store_finalize (GObject *object) } static gchar * -psppire_var_store_get_string (const PsppireSheetModel *model, glong row, glong column) +psppire_var_store_get_string (const PsppireSheetModel *model, + glong row, glong column) { PsppireVarStore *store = PSPPIRE_VAR_STORE (model); @@ -410,7 +409,7 @@ psppire_var_store_get_string (const PsppireSheetModel *model, glong row, glong c pv = psppire_dict_get_variable (store->dict, row); - return text_for_column (pv, column, 0); + return text_for_column (store, pv, column, 0); } @@ -468,14 +467,15 @@ psppire_var_store_set_string (PsppireSheetModel *model, { case PSPPIRE_VAR_STORE_COL_NAME: { - int i; - /* Until non-ascii in variable names is better managed, - simply refuse to allow them to be entered. */ - for (i = 0 ; i < strlen (text) ; ++i ) - if (!g_ascii_isprint (text[i])) - return FALSE; - return psppire_dict_rename_var (var_store->dict, pv, text); - break; + gboolean ok; + char *s = recode_string (psppire_dict_encoding (var_store->dict), + UTF8, + text, -1); + + ok = psppire_dict_rename_var (var_store->dict, pv, s); + + free (s); + return ok; } case PSPPIRE_VAR_STORE_COL_COLUMNS: if ( ! text) return FALSE; @@ -531,7 +531,9 @@ psppire_var_store_set_string (PsppireSheetModel *model, break; case PSPPIRE_VAR_STORE_COL_LABEL: { - gchar *s = utf8_to_pspp_locale (text, -1, NULL); + gchar *s = recode_string (psppire_dict_encoding (var_store->dict), + UTF8, + text, -1); var_set_label (pv, s); free (s); return TRUE; @@ -557,8 +559,10 @@ psppire_var_store_set_string (PsppireSheetModel *model, static const gchar none[] = N_("None"); static gchar * -text_for_column (const struct variable *pv, gint c, GError **err) +text_for_column (PsppireVarStore *vs, + const struct variable *pv, gint c, GError **err) { + PsppireDict *dict = vs->dict; static const gchar *const type_label[] = { N_("Numeric"), @@ -578,7 +582,8 @@ text_for_column (const struct variable *pv, gint c, GError **err) switch (c) { case PSPPIRE_VAR_STORE_COL_NAME: - return pspp_locale_to_utf8 ( var_get_name (pv), -1, err); + return recode_string (UTF8, psppire_dict_encoding (dict), + var_get_name (pv), -1); break; case PSPPIRE_VAR_STORE_COL_TYPE: { @@ -665,12 +670,13 @@ text_for_column (const struct variable *pv, gint c, GError **err) } break; case PSPPIRE_VAR_STORE_COL_LABEL: - return pspp_locale_to_utf8 (var_get_label (pv), -1, err); + return recode_string (UTF8, psppire_dict_encoding (dict), + var_get_label (pv), -1); break; case PSPPIRE_VAR_STORE_COL_MISSING: { - return missing_values_to_string (pv, err); + return missing_values_to_string (dict, pv, err); } break; case PSPPIRE_VAR_STORE_COL_VALUES: @@ -696,7 +702,8 @@ text_for_column (const struct variable *pv, gint c, GError **err) val_labs_done (&ip); - ss = pspp_locale_to_utf8 (gstr->str, gstr->len, err); + ss = recode_string (UTF8, psppire_dict_encoding (dict), + gstr->str, gstr->len); g_string_free (gstr, TRUE); return ss; }