X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-var-store.c;h=bc348efa22db9dfc2bb19a3e438d15c018225cc0;hb=50652d204ce6aae87f6a165a499cf5d460f1f557;hp=403eba84a58a11058addc781e415b3c733b20357;hpb=2dc7abd2a759dbb1230547aa032f65a95aa767ec;p=pspp diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index 403eba84a5..bc348efa22 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2006, 2009, 2010 Free Software Foundation + Copyright (C) 2006, 2009, 2010, 2011, 2012 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -52,7 +52,8 @@ var_change_callback (GtkWidget *w, gint n, gpointer data) static void -var_delete_callback (GtkWidget *w, gint dict_idx, gint case_idx, gint val_cnt, gpointer data) +var_delete_callback (GtkWidget *w, const struct variable *var UNUSED, + gint dict_idx, gint case_idx UNUSED, gpointer data) { PsppireSheetModel *model = PSPPIRE_SHEET_MODEL (data); @@ -279,7 +280,7 @@ static void psppire_var_store_init (PsppireVarStore *var_store) { if ( ! gdk_color_parse (DISABLED_COLOR, &var_store->disabled)) - g_critical ("Could not parse color \"%s\"", DISABLED_COLOR); + g_critical ("Could not parse color `%s'", DISABLED_COLOR); var_store->dictionary = NULL; var_store->format_type = PSPPIRE_VAR_STORE_OUTPUT_FORMATS; @@ -489,7 +490,7 @@ psppire_var_store_clear (PsppireSheetModel *model, glong row, glong col) switch (col) { case PSPPIRE_VAR_STORE_COL_LABEL: - var_set_label (pv, NULL); + var_clear_label (pv); return TRUE; break; } @@ -550,7 +551,7 @@ psppire_var_store_set_string (PsppireSheetModel *model, bool for_input = var_store->format_type == PSPPIRE_VAR_STORE_INPUT_FORMATS; struct fmt_spec fmt ; - fmt = *var_get_write_format (pv); + fmt = *var_get_print_format (pv); if ( width < fmt_min_width (fmt.type, for_input) || width > fmt_max_width (fmt.type, for_input)) @@ -573,7 +574,7 @@ psppire_var_store_set_string (PsppireSheetModel *model, struct fmt_spec fmt; if ( ! text) return FALSE; decimals = atoi (text); - fmt = *var_get_write_format (pv); + fmt = *var_get_print_format (pv); if ( decimals > fmt_max_decimals (fmt.type, fmt.w, @@ -588,7 +589,7 @@ psppire_var_store_set_string (PsppireSheetModel *model, break; case PSPPIRE_VAR_STORE_COL_LABEL: { - var_set_label (pv, text); + var_set_label (pv, text, true); return TRUE; } break; @@ -616,22 +617,8 @@ text_for_column (PsppireVarStore *vs, const struct variable *pv, gint c, GError **err) { PsppireDict *dict = vs->dictionary; - static const gchar *const type_label[] = - { - N_("Numeric"), - N_("Comma"), - N_("Dot"), - N_("Scientific"), - N_("Date"), - N_("Dollar"), - N_("Custom"), - N_("String") - }; - - enum {VT_NUMERIC, VT_COMMA, VT_DOT, VT_SCIENTIFIC, VT_DATE, VT_DOLLAR, - VT_CUSTOM, VT_STRING}; - const struct fmt_spec *write_spec = var_get_write_format (pv); + const struct fmt_spec *format = var_get_print_format (pv); switch (c) { @@ -639,64 +626,13 @@ text_for_column (PsppireVarStore *vs, return xstrdup (var_get_name (pv)); break; case PSPPIRE_VAR_STORE_COL_TYPE: - { - switch ( write_spec->type ) - { - case FMT_F: - return g_locale_to_utf8 (gettext (type_label[VT_NUMERIC]), -1, 0, 0, err); - break; - case FMT_COMMA: - return g_locale_to_utf8 (gettext (type_label[VT_COMMA]), -1, 0, 0, err); - break; - case FMT_DOT: - return g_locale_to_utf8 (gettext (type_label[VT_DOT]), -1, 0, 0, err); - break; - case FMT_E: - return g_locale_to_utf8 (gettext (type_label[VT_SCIENTIFIC]), -1, 0, 0, err); - break; - case FMT_DATE: - case FMT_EDATE: - case FMT_SDATE: - case FMT_ADATE: - case FMT_JDATE: - case FMT_QYR: - case FMT_MOYR: - case FMT_WKYR: - case FMT_DATETIME: - case FMT_TIME: - case FMT_DTIME: - case FMT_WKDAY: - case FMT_MONTH: - return g_locale_to_utf8 (gettext (type_label[VT_DATE]), -1, 0, 0, err); - break; - case FMT_DOLLAR: - return g_locale_to_utf8 (gettext (type_label[VT_DOLLAR]), -1, 0, 0, err); - break; - case FMT_CCA: - case FMT_CCB: - case FMT_CCC: - case FMT_CCD: - case FMT_CCE: - return g_locale_to_utf8 (gettext (type_label[VT_CUSTOM]), -1, 0, 0, err); - break; - case FMT_A: - return g_locale_to_utf8 (gettext (type_label[VT_STRING]), -1, 0, 0, err); - break; - default: - { - char str[FMT_STRING_LEN_MAX + 1]; - g_warning ("Unknown format: \"%s\"\n", - fmt_to_string (write_spec, str)); - } - break; - } - } + return xstrdup (fmt_gui_name (format->type)); break; case PSPPIRE_VAR_STORE_COL_WIDTH: { gchar *s; GString *gstr = g_string_sized_new (10); - g_string_printf (gstr, _("%d"), write_spec->w); + g_string_printf (gstr, _("%d"), format->w); s = g_locale_to_utf8 (gstr->str, gstr->len, 0, 0, err); g_string_free (gstr, TRUE); return s; @@ -706,7 +642,7 @@ text_for_column (PsppireVarStore *vs, { gchar *s; GString *gstr = g_string_sized_new (10); - g_string_printf (gstr, _("%d"), write_spec->d); + g_string_printf (gstr, _("%d"), format->d); s = g_locale_to_utf8 (gstr->str, gstr->len, 0, 0, err); g_string_free (gstr, TRUE); return s; @@ -739,7 +675,7 @@ text_for_column (PsppireVarStore *vs, case PSPPIRE_VAR_STORE_COL_VALUES: { if ( ! var_has_value_labels (pv)) - return g_locale_to_utf8 (gettext (none), -1, 0, 0, err); + return xstrdup (gettext (none)); else { const struct val_labs *vls = var_get_value_labels (pv); @@ -750,9 +686,10 @@ text_for_column (PsppireVarStore *vs, g_assert (vl); { - gchar *const vstr = value_to_text (vl->value, dict, *write_spec); + gchar *const vstr = value_to_text (vl->value, pv); - return g_strdup_printf ( "{%s,\"%s\"}_", vstr, val_lab_get_label (vl)); + return g_strdup_printf (_("{%s,`%s'}_"), vstr, + val_lab_get_escaped_label (vl)); } } } @@ -762,12 +699,12 @@ text_for_column (PsppireVarStore *vs, const gint align = var_get_alignment (pv); g_assert (align < n_ALIGNMENTS); - return g_locale_to_utf8 (gettext (alignments[align]), -1, 0, 0, err); + return xstrdup (alignment_to_string (align)); } break; case PSPPIRE_VAR_STORE_COL_MEASURE: { - return measure_to_string (pv, err); + return xstrdup (measure_to_string (var_get_measure (pv))); } break; }