Merge commit 'origin/stable'
[pspp-builds.git] / src / ui / gui / psppire-var-store.c
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2006  Free Software Foundation
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #include <config.h>
18 #include <string.h>
19 #include <stdlib.h>
20 #include <gettext.h>
21 #define _(msgid) gettext (msgid)
22 #define N_(msgid) msgid
23
24
25
26 #include <gobject/gvaluecollector.h>
27
28 #include <ui/gui/sheet/psppire-sheetmodel.h>
29
30 #include "psppire-var-store.h"
31 #include "helper.h"
32
33 #include <data/dictionary.h>
34 #include <data/variable.h>
35 #include <data/format.h>
36 #include <data/missing-values.h>
37
38 #include "val-labs-dialog.h"
39 #include "missing-val-dialog.h"
40 #include <data/value-labels.h>
41
42 #include "var-display.h"
43
44 enum
45   {
46     PROP_0,
47     PSPPIRE_VAR_STORE_FORMAT_TYPE
48   };
49
50 static void         psppire_var_store_init            (PsppireVarStore      *var_store);
51 static void         psppire_var_store_class_init      (PsppireVarStoreClass *class);
52 static void         psppire_var_store_sheet_model_init (PsppireSheetModelIface *iface);
53 static void         psppire_var_store_finalize        (GObject           *object);
54
55
56 gchar * missing_values_to_string (const struct variable *pv, GError **err);
57
58
59 static gchar *psppire_var_store_get_string (const PsppireSheetModel *sheet_model, glong row, glong column);
60
61 static gboolean  psppire_var_store_clear (PsppireSheetModel *model,  glong row, glong col);
62
63
64 static gboolean psppire_var_store_set_string (PsppireSheetModel *model,
65                                           const gchar *text, glong row, glong column);
66
67 static glong psppire_var_store_get_row_count (const PsppireSheetModel * model);
68 static glong psppire_var_store_get_column_count (const PsppireSheetModel * model);
69
70 static gchar *text_for_column (const struct variable *pv, gint c, GError **err);
71
72
73 static GObjectClass *parent_class = NULL;
74
75 GType
76 psppire_var_store_format_type_get_type (void)
77 {
78   static GType etype = 0;
79   if (etype == 0)
80     {
81       static const GEnumValue values[] =
82         {
83           { PSPPIRE_VAR_STORE_INPUT_FORMATS,
84             "PSPPIRE_VAR_STORE_INPUT_FORMATS",
85             "input" },
86           { PSPPIRE_VAR_STORE_OUTPUT_FORMATS,
87             "PSPPIRE_VAR_STORE_OUTPUT_FORMATS",
88             "output" },
89           { 0, NULL, NULL }
90         };
91
92       etype = g_enum_register_static
93         (g_intern_static_string ("PsppireVarStoreFormatType"), values);
94
95     }
96   return etype;
97 }
98
99 GType
100 psppire_var_store_get_type (void)
101 {
102   static GType var_store_type = 0;
103
104   if (!var_store_type)
105     {
106       static const GTypeInfo var_store_info =
107       {
108         sizeof (PsppireVarStoreClass),
109         NULL,           /* base_init */
110         NULL,           /* base_finalize */
111         (GClassInitFunc) psppire_var_store_class_init,
112         NULL,           /* class_finalize */
113         NULL,           /* class_data */
114         sizeof (PsppireVarStore),
115         0,
116         (GInstanceInitFunc) psppire_var_store_init,
117       };
118
119       static const GInterfaceInfo sheet_model_info =
120       {
121         (GInterfaceInitFunc) psppire_var_store_sheet_model_init,
122         NULL,
123         NULL
124       };
125
126       var_store_type = g_type_register_static (G_TYPE_OBJECT, "PsppireVarStore", &var_store_info, 0);
127
128       g_type_add_interface_static (var_store_type,
129                                    PSPPIRE_TYPE_SHEET_MODEL,
130                                    &sheet_model_info);
131     }
132
133   return var_store_type;
134 }
135
136 static void
137 psppire_var_store_set_property (GObject      *object,
138                                 guint         property_id,
139                                 const GValue *value,
140                                 GParamSpec   *pspec)
141 {
142   PsppireVarStore *self = (PsppireVarStore *) object;
143
144   switch (property_id)
145     {
146     case PSPPIRE_VAR_STORE_FORMAT_TYPE:
147       self->format_type = g_value_get_enum (value);
148       break;
149
150     default:
151       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
152       break;
153     }
154 }
155
156 static void
157 psppire_var_store_get_property (GObject      *object,
158                         guint         property_id,
159                         GValue       *value,
160                         GParamSpec   *pspec)
161 {
162   PsppireVarStore *self = (PsppireVarStore *) object;
163
164   switch (property_id)
165     {
166     case PSPPIRE_VAR_STORE_FORMAT_TYPE:
167       g_value_set_enum (value, self->format_type);
168       break;
169
170     default:
171       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
172       break;
173     }
174 }
175
176
177 static void
178 psppire_var_store_class_init (PsppireVarStoreClass *class)
179 {
180   GObjectClass *object_class;
181   GParamSpec *pspec;
182
183   parent_class = g_type_class_peek_parent (class);
184   object_class = (GObjectClass*) class;
185
186   object_class->finalize = psppire_var_store_finalize;
187   object_class->set_property = psppire_var_store_set_property;
188   object_class->get_property = psppire_var_store_get_property;
189
190   pspec = g_param_spec_enum ("format-type",
191                              "Variable format type",
192                              ("Whether variables have input or output "
193                               "formats"),
194                              PSPPIRE_TYPE_VAR_STORE_FORMAT_TYPE,
195                              PSPPIRE_VAR_STORE_OUTPUT_FORMATS,
196                              G_PARAM_READWRITE);
197
198   g_object_class_install_property (object_class,
199                                    PSPPIRE_VAR_STORE_FORMAT_TYPE,
200                                    pspec);
201 }
202
203 #define DISABLED_COLOR "gray"
204
205 static void
206 psppire_var_store_init (PsppireVarStore *var_store)
207 {
208   if ( ! gdk_color_parse (DISABLED_COLOR, &var_store->disabled))
209         g_critical ("Could not parse color \"%s\"", DISABLED_COLOR);
210
211   var_store->dict = 0;
212   var_store->format_type = PSPPIRE_VAR_STORE_OUTPUT_FORMATS;
213 }
214
215 static gboolean
216 psppire_var_store_item_editable (PsppireVarStore *var_store, glong row, glong column)
217 {
218   const struct fmt_spec *write_spec ;
219
220   struct variable *pv = psppire_var_store_get_var (var_store, row);
221
222   if ( !pv )
223     return TRUE;
224
225   if ( var_is_alpha (pv) && column == PSPPIRE_VAR_STORE_COL_DECIMALS )
226     return FALSE;
227
228   write_spec = var_get_print_format (pv);
229
230   switch ( write_spec->type )
231     {
232     case FMT_DATE:
233     case FMT_EDATE:
234     case FMT_SDATE:
235     case FMT_ADATE:
236     case FMT_JDATE:
237     case FMT_QYR:
238     case FMT_MOYR:
239     case FMT_WKYR:
240     case FMT_DATETIME:
241     case FMT_TIME:
242     case FMT_DTIME:
243     case FMT_WKDAY:
244     case FMT_MONTH:
245       if ( column == PSPPIRE_VAR_STORE_COL_DECIMALS || column == PSPPIRE_VAR_STORE_COL_WIDTH)
246         return FALSE;
247       break;
248     default:
249       break;
250     }
251
252   return TRUE;
253 }
254
255
256 struct variable *
257 psppire_var_store_get_var (PsppireVarStore *store, glong row)
258 {
259   return psppire_dict_get_variable (store->dict, row);
260 }
261
262 static gboolean
263 psppire_var_store_is_editable (const PsppireSheetModel *model, glong row, glong column)
264 {
265   PsppireVarStore *store = PSPPIRE_VAR_STORE (model);
266   return psppire_var_store_item_editable (store, row, column);
267 }
268
269
270 static GdkColor *
271 psppire_var_store_get_foreground (const PsppireSheetModel *model, glong row, glong column)
272 {
273   PsppireVarStore *store = PSPPIRE_VAR_STORE (model);
274
275   if ( ! psppire_var_store_item_editable (store, row, column) )
276     return &store->disabled;
277
278   return NULL;
279 }
280
281
282 static gchar *get_column_title (const PsppireSheetModel *model, gint col);
283 static gchar *get_row_title (const PsppireSheetModel *model, gint row);
284 static gboolean get_row_sensitivity (const PsppireSheetModel *model, gint row);
285
286 static void
287 psppire_var_store_sheet_model_init (PsppireSheetModelIface *iface)
288 {
289   iface->get_row_count = psppire_var_store_get_row_count;
290   iface->get_column_count = psppire_var_store_get_column_count;
291   iface->free_strings = TRUE;
292   iface->get_string = psppire_var_store_get_string;
293   iface->set_string = psppire_var_store_set_string;
294   iface->clear_datum = psppire_var_store_clear;
295   iface->is_editable = psppire_var_store_is_editable;
296   iface->get_foreground = psppire_var_store_get_foreground;
297   iface->get_background = NULL;
298   iface->get_justification = NULL;
299
300   iface->get_column_title = get_column_title;
301
302   iface->get_row_title = get_row_title;
303   iface->get_row_sensitivity = get_row_sensitivity;
304
305   iface->get_row_overstrike = NULL;
306 }
307
308 /**
309  * psppire_var_store_new:
310  * @dict: The dictionary for this var_store.
311  *
312  *
313  * Return value: a new #PsppireVarStore
314  **/
315 PsppireVarStore *
316 psppire_var_store_new (PsppireDict *dict)
317 {
318   PsppireVarStore *retval;
319
320   retval = g_object_new (GTK_TYPE_VAR_STORE, NULL);
321
322   psppire_var_store_set_dictionary (retval, dict);
323
324   return retval;
325 }
326
327 static void
328 var_change_callback (GtkWidget *w, gint n, gpointer data)
329 {
330   PsppireSheetModel *model = PSPPIRE_SHEET_MODEL (data);
331
332   psppire_sheet_model_range_changed (model,
333                                  n, 0, n, PSPPIRE_VAR_STORE_n_COLS);
334 }
335
336
337 static void
338 var_delete_callback (GtkWidget *w, gint dict_idx, gint case_idx, gint val_cnt, gpointer data)
339 {
340   PsppireSheetModel *model = PSPPIRE_SHEET_MODEL (data);
341
342   psppire_sheet_model_rows_deleted (model, dict_idx, 1);
343 }
344
345
346
347 static void
348 var_insert_callback (GtkWidget *w, glong row, gpointer data)
349 {
350   PsppireSheetModel *model = PSPPIRE_SHEET_MODEL (data);
351
352   psppire_sheet_model_rows_inserted (model, row, 1);
353 }
354
355 static void
356 refresh (PsppireDict  *d, gpointer data)
357 {
358   PsppireVarStore *vs = data;
359
360   psppire_sheet_model_range_changed (PSPPIRE_SHEET_MODEL (vs), -1, -1, -1, -1);
361 }
362
363 /**
364  * psppire_var_store_replace_set_dictionary:
365  * @var_store: The variable store
366  * @dict: The dictionary to set
367  *
368  * If a dictionary is already associated with the var-store, then it will be
369  * destroyed.
370  **/
371 void
372 psppire_var_store_set_dictionary (PsppireVarStore *var_store, PsppireDict *dict)
373 {
374   if ( var_store->dict ) g_object_unref (var_store->dict);
375
376   var_store->dict = dict;
377
378   g_signal_connect (dict, "variable-changed", G_CALLBACK (var_change_callback),
379                    var_store);
380
381   g_signal_connect (dict, "variable-deleted", G_CALLBACK (var_delete_callback),
382                    var_store);
383
384   g_signal_connect (dict, "variable-inserted",
385                     G_CALLBACK (var_insert_callback), var_store);
386
387   g_signal_connect (dict, "backend-changed", G_CALLBACK (refresh),
388                     var_store);
389
390   /* The entire model has changed */
391   psppire_sheet_model_range_changed (PSPPIRE_SHEET_MODEL (var_store), -1, -1, -1, -1);
392 }
393
394 static void
395 psppire_var_store_finalize (GObject *object)
396 {
397   /* must chain up */
398   (* parent_class->finalize) (object);
399 }
400
401 static gchar *
402 psppire_var_store_get_string (const PsppireSheetModel *model, glong row, glong column)
403 {
404   PsppireVarStore *store = PSPPIRE_VAR_STORE (model);
405
406   struct variable *pv;
407
408   if ( row >= psppire_dict_get_var_cnt (store->dict))
409     return 0;
410
411   pv = psppire_dict_get_variable (store->dict, row);
412
413   return text_for_column (pv, column, 0);
414 }
415
416
417 /* Clears that part of the variable store, if possible, which corresponds
418    to ROW, COL.
419    Returns true if anything was updated, false otherwise.
420 */
421 static gboolean
422 psppire_var_store_clear (PsppireSheetModel *model,  glong row, glong col)
423 {
424   struct variable *pv ;
425
426   PsppireVarStore *var_store = PSPPIRE_VAR_STORE (model);
427
428   if ( row >= psppire_dict_get_var_cnt (var_store->dict))
429       return FALSE;
430
431   pv = psppire_var_store_get_var (var_store, row);
432
433   if ( !pv )
434     return FALSE;
435
436   switch (col)
437     {
438     case PSPPIRE_VAR_STORE_COL_LABEL:
439       var_set_label (pv, 0);
440       return TRUE;
441       break;
442     }
443
444   return FALSE;
445 }
446
447 /* Attempts to update that part of the variable store which corresponds
448    to ROW, COL with  the value TEXT.
449    Returns true if anything was updated, false otherwise.
450 */
451 static gboolean
452 psppire_var_store_set_string (PsppireSheetModel *model,
453                           const gchar *text, glong row, glong col)
454 {
455   struct variable *pv ;
456
457   PsppireVarStore *var_store = PSPPIRE_VAR_STORE (model);
458
459   if ( row >= psppire_dict_get_var_cnt (var_store->dict))
460       return FALSE;
461
462   pv = psppire_var_store_get_var (var_store, row);
463
464   if ( !pv )
465     return FALSE;
466
467   switch (col)
468     {
469     case PSPPIRE_VAR_STORE_COL_NAME:
470       {
471         int i;
472         /* Until non-ascii in variable names is better managed,
473            simply refuse to allow them to be entered. */
474         for (i = 0 ; i < strlen (text) ; ++i )
475           if (!g_ascii_isprint (text[i]))
476             return FALSE;
477         return psppire_dict_rename_var (var_store->dict, pv, text);
478         break;
479       }
480     case PSPPIRE_VAR_STORE_COL_COLUMNS:
481       if ( ! text) return FALSE;
482       var_set_display_width (pv, atoi (text));
483       return TRUE;
484       break;
485     case PSPPIRE_VAR_STORE_COL_WIDTH:
486       {
487         int width = atoi (text);
488         if ( ! text) return FALSE;
489         if ( var_is_alpha (pv))
490             var_set_width (pv, width);
491         else
492           {
493             bool for_input
494               = var_store->format_type == PSPPIRE_VAR_STORE_INPUT_FORMATS;
495             struct fmt_spec fmt ;
496             fmt = *var_get_write_format (pv);
497             if ( width < fmt_min_width (fmt.type, for_input)
498                  ||
499                  width > fmt_max_width (fmt.type, for_input))
500               return FALSE;
501
502             fmt.w = width;
503             fmt.d = MIN (fmt_max_decimals (fmt.type, width, for_input), fmt.d);
504
505             var_set_both_formats (pv, &fmt);
506           }
507
508         return TRUE;
509       }
510       break;
511     case PSPPIRE_VAR_STORE_COL_DECIMALS:
512       {
513         bool for_input
514           = var_store->format_type == PSPPIRE_VAR_STORE_INPUT_FORMATS;
515         int decimals;
516         struct fmt_spec fmt;
517         if ( ! text) return FALSE;
518         decimals = atoi (text);
519         fmt = *var_get_write_format (pv);
520         if ( decimals >
521              fmt_max_decimals (fmt.type,
522                                fmt.w,
523                                for_input
524                                ))
525           return FALSE;
526
527         fmt.d = decimals;
528         var_set_both_formats (pv, &fmt);
529         return TRUE;
530       }
531       break;
532     case PSPPIRE_VAR_STORE_COL_LABEL:
533       {
534         gchar *s = utf8_to_pspp_locale (text, -1, NULL);
535         var_set_label (pv, s);
536         free (s);
537         return TRUE;
538       }
539       break;
540     case PSPPIRE_VAR_STORE_COL_TYPE:
541     case PSPPIRE_VAR_STORE_COL_VALUES:
542     case PSPPIRE_VAR_STORE_COL_MISSING:
543     case PSPPIRE_VAR_STORE_COL_ALIGN:
544     case PSPPIRE_VAR_STORE_COL_MEASURE:
545       /* These can be modified only by their respective dialog boxes */
546       return FALSE;
547       break;
548     default:
549       g_assert_not_reached ();
550       return FALSE;
551     }
552
553   return TRUE;
554 }
555
556
557 static const gchar none[] = N_("None");
558
559 static  gchar *
560 text_for_column (const struct variable *pv, gint c, GError **err)
561 {
562   static const gchar *const type_label[] =
563     {
564       N_("Numeric"),
565       N_("Comma"),
566       N_("Dot"),
567       N_("Scientific"),
568       N_("Date"),
569       N_("Dollar"),
570       N_("Custom"),
571       N_("String")
572     };
573   enum {VT_NUMERIC, VT_COMMA, VT_DOT, VT_SCIENTIFIC, VT_DATE, VT_DOLLAR,
574         VT_CUSTOM, VT_STRING};
575
576   const struct fmt_spec *write_spec = var_get_write_format (pv);
577
578   switch (c)
579     {
580     case PSPPIRE_VAR_STORE_COL_NAME:
581       return pspp_locale_to_utf8 ( var_get_name (pv), -1, err);
582       break;
583     case PSPPIRE_VAR_STORE_COL_TYPE:
584       {
585         switch ( write_spec->type )
586           {
587           case FMT_F:
588             return g_locale_to_utf8 (gettext (type_label[VT_NUMERIC]), -1, 0, 0, err);
589             break;
590           case FMT_COMMA:
591             return g_locale_to_utf8 (gettext (type_label[VT_COMMA]), -1, 0, 0, err);
592             break;
593           case FMT_DOT:
594             return g_locale_to_utf8 (gettext (type_label[VT_DOT]), -1, 0, 0, err);
595             break;
596           case FMT_E:
597             return g_locale_to_utf8 (gettext (type_label[VT_SCIENTIFIC]), -1, 0, 0, err);
598             break;
599           case FMT_DATE:
600           case FMT_EDATE:
601           case FMT_SDATE:
602           case FMT_ADATE:
603           case FMT_JDATE:
604           case FMT_QYR:
605           case FMT_MOYR:
606           case FMT_WKYR:
607           case FMT_DATETIME:
608           case FMT_TIME:
609           case FMT_DTIME:
610           case FMT_WKDAY:
611           case FMT_MONTH:
612             return g_locale_to_utf8 (type_label[VT_DATE], -1, 0, 0, err);
613             break;
614           case FMT_DOLLAR:
615             return g_locale_to_utf8 (type_label[VT_DOLLAR], -1, 0, 0, err);
616             break;
617           case FMT_CCA:
618           case FMT_CCB:
619           case FMT_CCC:
620           case FMT_CCD:
621           case FMT_CCE:
622             return g_locale_to_utf8 (gettext (type_label[VT_CUSTOM]), -1, 0, 0, err);
623             break;
624           case FMT_A:
625             return g_locale_to_utf8 (gettext (type_label[VT_STRING]), -1, 0, 0, err);
626             break;
627           default:
628             {
629               char str[FMT_STRING_LEN_MAX + 1];
630               g_warning ("Unknown format: \"%s\"\n",
631                         fmt_to_string (write_spec, str));
632             }
633             break;
634           }
635       }
636       break;
637     case PSPPIRE_VAR_STORE_COL_WIDTH:
638       {
639         gchar *s;
640         GString *gstr = g_string_sized_new (10);
641         g_string_printf (gstr, _("%d"), write_spec->w);
642         s = g_locale_to_utf8 (gstr->str, gstr->len, 0, 0, err);
643         g_string_free (gstr, TRUE);
644         return s;
645       }
646       break;
647     case PSPPIRE_VAR_STORE_COL_DECIMALS:
648       {
649         gchar *s;
650         GString *gstr = g_string_sized_new (10);
651         g_string_printf (gstr, _("%d"), write_spec->d);
652         s = g_locale_to_utf8 (gstr->str, gstr->len, 0, 0, err);
653         g_string_free (gstr, TRUE);
654         return s;
655       }
656       break;
657     case PSPPIRE_VAR_STORE_COL_COLUMNS:
658       {
659         gchar *s;
660         GString *gstr = g_string_sized_new (10);
661         g_string_printf (gstr, _("%d"), var_get_display_width (pv));
662         s = g_locale_to_utf8 (gstr->str, gstr->len, 0, 0, err);
663         g_string_free (gstr, TRUE);
664         return s;
665       }
666       break;
667     case PSPPIRE_VAR_STORE_COL_LABEL:
668       return pspp_locale_to_utf8 (var_get_label (pv), -1, err);
669       break;
670
671     case PSPPIRE_VAR_STORE_COL_MISSING:
672       {
673         return missing_values_to_string (pv, err);
674       }
675       break;
676     case PSPPIRE_VAR_STORE_COL_VALUES:
677       {
678         if ( ! var_has_value_labels (pv))
679           return g_locale_to_utf8 (gettext (none), -1, 0, 0, err);
680         else
681           {
682             gchar *ss;
683             GString *gstr = g_string_sized_new (10);
684             const struct val_labs *vls = var_get_value_labels (pv);
685             struct val_labs_iterator *ip = 0;
686             struct val_lab *vl = val_labs_first_sorted (vls, &ip);
687
688             g_assert (vl);
689
690             {
691               gchar *const vstr = value_to_text (vl->value, *write_spec);
692
693               g_string_printf (gstr, "{%s,\"%s\"}_", vstr, vl->label);
694               g_free (vstr);
695             }
696
697             val_labs_done (&ip);
698
699             ss = pspp_locale_to_utf8 (gstr->str, gstr->len, err);
700             g_string_free (gstr, TRUE);
701             return ss;
702           }
703       }
704       break;
705     case PSPPIRE_VAR_STORE_COL_ALIGN:
706       {
707         const gint align = var_get_alignment (pv);
708
709         g_assert (align < n_ALIGNMENTS);
710         return g_locale_to_utf8 (gettext (alignments[align]), -1, 0, 0, err);
711       }
712       break;
713     case PSPPIRE_VAR_STORE_COL_MEASURE:
714       {
715         return measure_to_string (pv, err);
716       }
717       break;
718     }
719   return 0;
720 }
721
722
723
724 /* Return the number of variables */
725 gint
726 psppire_var_store_get_var_cnt (PsppireVarStore  *store)
727 {
728   return psppire_dict_get_var_cnt (store->dict);
729 }
730
731
732 static glong
733 psppire_var_store_get_row_count (const PsppireSheetModel * model)
734 {
735   gint rows = 0;
736   PsppireVarStore *vs = PSPPIRE_VAR_STORE (model);
737
738   if (vs->dict)
739     rows =  psppire_dict_get_var_cnt (vs->dict);
740
741   return rows ;
742 }
743
744 static glong
745 psppire_var_store_get_column_count (const PsppireSheetModel * model)
746 {
747   return PSPPIRE_VAR_STORE_n_COLS ;
748 }
749
750 \f
751
752 /* Row related funcs */
753
754
755 static gboolean
756 get_row_sensitivity (const PsppireSheetModel *model, gint row)
757 {
758   PsppireVarStore *vs = PSPPIRE_VAR_STORE (model);
759
760   if ( ! vs->dict)
761     return FALSE;
762
763   return  row < psppire_dict_get_var_cnt (vs->dict);
764 }
765
766
767 static gchar *
768 get_row_title (const PsppireSheetModel *model, gint unit)
769 {
770   return g_strdup_printf (_("%d"), unit + 1);
771 }
772
773
774 \f
775
776 static const gchar *column_titles[] = {
777   N_("Name"),
778   N_("Type"),
779   N_("Width"),
780   N_("Decimals"),
781   N_("Label"),
782   N_("Values"),
783   N_("Missing"),
784   N_("Columns"),
785   N_("Align"),
786   N_("Measure"),
787 };
788
789
790 static gchar *
791 get_column_title (const PsppireSheetModel *model, gint col)
792 {
793   if ( col >= 10)
794     return NULL;
795   return g_strdup (gettext (column_titles[col]));
796 }