Improved the encapsulation of PsppireCaseFile
[pspp-builds.git] / src / ui / gui / psppire-data-store.c
1 /* psppire-data-store.c
2
3    PSPPIRE --- A Graphical User Interface for PSPP
4    Copyright (C) 2006  Free Software Foundation
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19    02110-1301, USA. */
20
21 #include <config.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <gettext.h>
25 #define _(msgid) gettext (msgid)
26 #define N_(msgid) msgid
27
28 #include <data/casewriter.h>
29 #include <data/datasheet.h>
30 #include <data/data-out.h>
31 #include <data/variable.h>
32
33 #include <gtksheet/gtksheet.h>
34 #include <gtksheet/gsheetmodel.h>
35 #include <gtksheet/gsheet-column-iface.h>
36
37 #include <pango/pango-context.h>
38
39 #include "psppire-data-store.h"
40 #include "psppire-case-file.h"
41 #include "helper.h"
42
43 #include <data/dictionary.h>
44 #include <data/missing-values.h>
45 #include <data/value-labels.h>
46 #include <data/data-in.h>
47
48 #include <data/file-handle-def.h>
49 #include <data/sys-file-writer.h>
50
51
52
53 static void psppire_data_store_init            (PsppireDataStore      *data_store);
54 static void psppire_data_store_class_init      (PsppireDataStoreClass *class);
55 static void psppire_data_store_sheet_model_init (GSheetModelIface *iface);
56 static void psppire_data_store_sheet_column_init (GSheetColumnIface *iface);
57 static void psppire_data_store_sheet_row_init (GSheetRowIface *iface);
58
59 static void psppire_data_store_finalize        (GObject           *object);
60
61 static gchar *psppire_data_store_get_string (const GSheetModel *sheet_model, gint row, gint column);
62
63 static gboolean psppire_data_store_set_string (GSheetModel *model,
64                                           const gchar *text, gint row, gint column);
65
66 static gboolean psppire_data_store_clear_datum (GSheetModel *model,
67                                           gint row, gint column);
68
69
70 #define MIN_COLUMNS 10
71
72 #define TRAILING_ROWS 10
73
74 static GObjectClass *parent_class = NULL;
75
76
77 enum  {FONT_CHANGED,
78        n_SIGNALS};
79
80 static guint signals [n_SIGNALS];
81
82
83 inline GType
84 psppire_data_store_get_type (void)
85 {
86   static GType data_store_type = 0;
87
88   if (!data_store_type)
89     {
90       static const GTypeInfo data_store_info =
91       {
92         sizeof (PsppireDataStoreClass),
93         NULL,           /* base_init */
94         NULL,           /* base_finalize */
95         (GClassInitFunc) psppire_data_store_class_init,
96         NULL,           /* class_finalize */
97         NULL,           /* class_data */
98         sizeof (PsppireDataStore),
99         0,
100         (GInstanceInitFunc) psppire_data_store_init,
101       };
102
103       static const GInterfaceInfo sheet_model_info =
104       {
105         (GInterfaceInitFunc) psppire_data_store_sheet_model_init,
106         NULL,
107         NULL
108       };
109
110       static const GInterfaceInfo sheet_column_info =
111       {
112         (GInterfaceInitFunc) psppire_data_store_sheet_column_init,
113         NULL,
114         NULL
115       };
116
117       static const GInterfaceInfo sheet_row_info =
118       {
119         (GInterfaceInitFunc) psppire_data_store_sheet_row_init,
120         NULL,
121         NULL
122       };
123
124
125       data_store_type = g_type_register_static (G_TYPE_OBJECT, "PsppireDataStore",
126                                                 &data_store_info, 0);
127
128       g_type_add_interface_static (data_store_type,
129                                    G_TYPE_SHEET_MODEL,
130                                    &sheet_model_info);
131
132       g_type_add_interface_static (data_store_type,
133                                    G_TYPE_SHEET_COLUMN,
134                                    &sheet_column_info);
135
136       g_type_add_interface_static (data_store_type,
137                                    G_TYPE_SHEET_ROW,
138                                    &sheet_row_info);
139     }
140
141   return data_store_type;
142 }
143
144
145 static void
146 psppire_data_store_class_init (PsppireDataStoreClass *class)
147 {
148   GObjectClass *object_class;
149
150   parent_class = g_type_class_peek_parent (class);
151   object_class = (GObjectClass*) class;
152
153   object_class->finalize = psppire_data_store_finalize;
154
155   signals [FONT_CHANGED] =
156     g_signal_new ("font_changed",
157                   G_TYPE_FROM_CLASS (class),
158                   G_SIGNAL_RUN_FIRST,
159                   0,
160                   NULL, NULL,
161                   g_cclosure_marshal_VOID__VOID,
162                   G_TYPE_NONE,
163                   0);
164 }
165
166
167
168 static gint
169 psppire_data_store_get_var_count (const GSheetModel *model)
170 {
171   const PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
172
173   return psppire_dict_get_var_cnt (store->dict);
174 }
175
176 static gint
177 psppire_data_store_get_case_count (const GSheetModel *model)
178 {
179   const PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
180
181   return psppire_case_file_get_case_count (store->case_file);
182 }
183
184
185 static void
186 psppire_data_store_init (PsppireDataStore *data_store)
187 {
188   data_store->dict = 0;
189   data_store->case_file = 0;
190   data_store->width_of_m = 10;
191 }
192
193 const PangoFontDescription *
194 psppire_data_store_get_font_desc (const GSheetModel *model,
195                               gint row, gint column)
196 {
197   PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
198
199   return store->font_desc;
200 }
201
202
203 static void
204 psppire_data_store_sheet_model_init (GSheetModelIface *iface)
205 {
206   iface->free_strings = TRUE;
207   iface->get_string = psppire_data_store_get_string;
208   iface->set_string = psppire_data_store_set_string;
209   iface->clear_datum = psppire_data_store_clear_datum;
210   iface->is_editable = NULL;
211   iface->is_visible = NULL;
212   iface->get_foreground = NULL;
213   iface->get_background = NULL;
214   iface->get_font_desc = psppire_data_store_get_font_desc;
215   iface->get_cell_border = NULL;
216   iface->get_column_count = psppire_data_store_get_var_count;
217   iface->get_row_count = psppire_data_store_get_case_count;
218 }
219
220 static
221 gboolean always_true ()
222 {
223   return TRUE;
224 }
225
226
227 static void
228 delete_cases_callback (GtkWidget *w, gint first, gint n_cases, gpointer data)
229 {
230   PsppireDataStore *store  ;
231
232   g_return_if_fail (data);
233
234   store  = PSPPIRE_DATA_STORE (data);
235
236   g_assert (first >= 0);
237
238   g_sheet_model_rows_deleted (G_SHEET_MODEL (store), first, n_cases);
239 }
240
241
242 static void
243 insert_case_callback (GtkWidget *w, gint casenum, gpointer data)
244 {
245   PsppireDataStore *store  ;
246
247   g_return_if_fail (data);
248
249   store  = PSPPIRE_DATA_STORE (data);
250
251   g_sheet_model_range_changed (G_SHEET_MODEL (store),
252                                casenum, -1,
253                                psppire_case_file_get_case_count (store->case_file),
254                                -1);
255
256   g_sheet_model_rows_inserted (G_SHEET_MODEL (store), casenum, 1);
257 }
258
259
260 static void
261 changed_case_callback (GtkWidget *w, gint casenum, gpointer data)
262 {
263   PsppireDataStore *store  ;
264   g_return_if_fail (data);
265
266   store  = PSPPIRE_DATA_STORE (data);
267
268   g_sheet_model_range_changed (G_SHEET_MODEL (store),
269                                  casenum, -1,
270                                  casenum, -1);
271 }
272
273
274 static void
275 delete_variables_callback (GObject *obj, gint var_num, gint n_vars, gpointer data)
276 {
277   PsppireDataStore *store ;
278
279   g_return_if_fail (data);
280
281   store  = PSPPIRE_DATA_STORE (data);
282
283   g_sheet_model_columns_deleted (G_SHEET_MODEL (store), var_num, n_vars);
284
285   g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
286                                    var_num, -1);
287 }
288
289
290 static void
291 variable_changed_callback (GObject *obj, gint var_num, gpointer data)
292 {
293   PsppireDataStore *store;
294
295   g_return_if_fail (data);
296
297   store  = PSPPIRE_DATA_STORE (data);
298
299   g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
300                                   var_num, 1);
301
302
303   g_sheet_model_range_changed (G_SHEET_MODEL (store),
304                                -1, var_num,
305                                -1, var_num);
306 }
307
308 static void
309 insert_variable_callback (GObject *obj, gint var_num, gpointer data)
310 {
311   PsppireDataStore *store;
312   gint posn;
313
314   g_return_if_fail (data);
315
316   store  = PSPPIRE_DATA_STORE (data);
317
318   if ( var_num > 0 )
319     {
320       struct variable *variable =
321         psppire_dict_get_variable (store->dict, var_num);
322
323       g_assert (variable != NULL);
324
325       posn = var_get_case_index (variable);
326     }
327   else
328     {
329       posn = 0;
330     }
331
332   psppire_case_file_insert_values (store->case_file, 1, posn);
333
334   g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
335                                   var_num, 1);
336
337   g_sheet_model_columns_inserted (G_SHEET_MODEL (store), var_num, 1);
338 }
339
340
341 static void
342 dict_size_change_callback (GObject *obj,
343                           gint posn, gint adjustment, gpointer data)
344 {
345   PsppireDataStore *store ;
346
347   g_return_if_fail (data);
348
349   store  = PSPPIRE_DATA_STORE (data);
350
351   psppire_case_file_insert_values (store->case_file, adjustment, posn);
352 }
353
354
355
356 /**
357  * psppire_data_store_new:
358  * @dict: The dictionary for this data_store.
359  *
360  *
361  * Return value: a new #PsppireDataStore
362  **/
363 PsppireDataStore *
364 psppire_data_store_new (PsppireDict *dict)
365 {
366   PsppireDataStore *retval;
367
368   retval = g_object_new (GTK_TYPE_DATA_STORE, NULL);
369
370   psppire_data_store_set_dictionary (retval, dict);
371
372   return retval;
373 }
374
375
376 void
377 psppire_data_store_set_case_file (PsppireDataStore *data_store,
378                                   PsppireCaseFile *cf)
379 {
380   if ( data_store->case_file)
381     {
382       g_object_unref (data_store->case_file);
383     }
384
385   data_store->case_file = cf;
386
387   g_signal_connect (data_store->case_file, "cases-deleted",
388                    G_CALLBACK (delete_cases_callback),
389                    data_store);
390
391   g_signal_connect (data_store->case_file, "case-inserted",
392                    G_CALLBACK (insert_case_callback),
393                    data_store);
394
395
396   g_signal_connect (data_store->case_file, "case-changed",
397                    G_CALLBACK (changed_case_callback),
398                    data_store);
399 }
400
401
402
403 /**
404  * psppire_data_store_replace_set_dictionary:
405  * @data_store: The variable store
406  * @dict: The dictionary to set
407  *
408  * If a dictionary is already associated with the data-store, then it will be
409  * destroyed.
410  **/
411 void
412 psppire_data_store_set_dictionary (PsppireDataStore *data_store, PsppireDict *dict)
413 {
414   data_store->dict = dict;
415
416   g_signal_connect (dict, "variable-inserted",
417                    G_CALLBACK (insert_variable_callback),
418                    data_store);
419
420   g_signal_connect (dict, "variables-deleted",
421                    G_CALLBACK (delete_variables_callback),
422                    data_store);
423
424   g_signal_connect (dict, "variable-changed",
425                    G_CALLBACK (variable_changed_callback),
426                    data_store);
427
428
429   g_signal_connect (dict, "dict-size-changed",
430                     G_CALLBACK (dict_size_change_callback),
431                     data_store);
432
433   /* The entire model has changed */
434   g_sheet_model_range_changed (G_SHEET_MODEL (data_store), -1, -1, -1, -1);
435
436   g_sheet_column_columns_changed (G_SHEET_COLUMN (data_store), 0, -1);
437 }
438
439 static void
440 psppire_data_store_finalize (GObject *object)
441 {
442
443   /* must chain up */
444   (* parent_class->finalize) (object);
445 }
446
447
448
449 /* Insert a blank case before POSN */
450 gboolean
451 psppire_data_store_insert_new_case (PsppireDataStore *ds, gint posn)
452 {
453   gboolean result;
454   gint val_cnt, v;
455   struct ccase cc;
456   g_return_val_if_fail (ds, FALSE);
457
458
459   /* Opportunity for optimisation exists here when creating a blank case */
460   val_cnt = datasheet_get_column_cnt (ds->case_file->datasheet) ;
461
462   case_create (&cc, val_cnt);
463
464   memset ( case_data_rw_idx (&cc, 0), 0, val_cnt * MAX_SHORT_STRING);
465
466   for (v = 0 ; v < psppire_dict_get_var_cnt (ds->dict) ; ++v)
467     {
468       const struct variable *pv = psppire_dict_get_variable (ds->dict, v);
469       if ( var_is_alpha (pv))
470         continue;
471
472       case_data_rw (&cc, pv)->f = SYSMIS;
473     }
474
475   result = psppire_case_file_insert_case (ds->case_file, &cc, posn);
476
477   case_destroy (&cc);
478
479   return result;
480 }
481
482
483 static gchar *
484 psppire_data_store_get_string (const GSheetModel *model, gint row, gint column)
485 {
486   gint idx;
487   char *text;
488   const struct fmt_spec *fp ;
489   const struct variable *pv ;
490   union value *v ;
491   GString *s;
492   PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
493
494   g_return_val_if_fail (store->dict, NULL);
495   g_return_val_if_fail (store->case_file, NULL);
496
497   if (column >= psppire_dict_get_var_cnt (store->dict))
498     return NULL;
499
500   if ( row >= psppire_case_file_get_case_count (store->case_file))
501     return NULL;
502
503   pv = psppire_dict_get_variable (store->dict, column);
504
505   g_assert (pv);
506
507   idx = var_get_case_index (pv);
508
509   g_assert (idx >= 0);
510
511   v = psppire_case_file_get_value (store->case_file, row, idx, NULL,
512                                    var_get_width (pv));
513
514   g_return_val_if_fail (v, NULL);
515
516   if ( store->show_labels)
517     {
518       const gchar *label = var_lookup_value_label (pv, v);
519       if (label)
520         {
521           free (v);
522           return pspp_locale_to_utf8 (label, -1, 0);
523         }
524     }
525
526   fp = var_get_write_format (pv);
527
528   s = g_string_sized_new (fp->w + 1);
529   g_string_set_size (s, fp->w);
530
531   memset (s->str, 0, fp->w);
532
533   g_assert (fp->w == s->len);
534
535   /* Converts binary value V into printable form in the exactly
536      FP->W character in buffer S according to format specification
537      FP.  No null terminator is appended to the buffer.  */
538   data_out (v, fp, s->str);
539
540   text = pspp_locale_to_utf8 (s->str, fp->w, 0);
541   g_string_free (s, TRUE);
542
543   g_strchomp (text);
544
545   free (v);
546   return text;
547 }
548
549
550 static gboolean
551 psppire_data_store_clear_datum (GSheetModel *model,
552                                           gint row, gint col)
553
554 {
555   PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
556
557   union value v;
558   const struct variable *pv = psppire_dict_get_variable (store->dict, col);
559
560   const gint index = var_get_case_index (pv) ;
561
562   if ( var_is_numeric (pv))
563     v.f = SYSMIS;
564   else
565     memcpy (v.s, "", MAX_SHORT_STRING);
566
567   psppire_case_file_set_value (store->case_file, row, index, &v,
568                               var_get_width (pv));
569
570   return TRUE;
571 }
572
573
574 /* Attempts to update that part of the variable store which corresponds
575    to ROW, COL with  the value TEXT.
576    Returns true if anything was updated, false otherwise.
577 */
578 static gboolean
579 psppire_data_store_set_string (GSheetModel *model,
580                           const gchar *text, gint row, gint col)
581 {
582   PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
583
584   const struct variable *pv = psppire_dict_get_variable (store->dict, col);
585   g_return_val_if_fail (pv, FALSE);
586
587 #if 0
588   /* Allow the user to insert a lot of blank cases, simply by skipping rows */
589   for (r = psppire_case_file_get_case_count (store->case_file); r <= row ; ++r)
590     {
591
592       gint c;
593
594       psppire_case_array_insert_case (store->cases, r, 0, 0);
595
596
597       for (c = 0 ; c < psppire_dict_get_var_cnt (store->dict); ++c )
598         psppire_data_store_clear_datum (model, r, c);
599     }
600 #endif
601
602   psppire_case_file_data_in (store->case_file, row,
603                              var_get_case_index (pv), ss_cstr (text),
604                              var_get_write_format (pv));
605
606   return TRUE;
607 }
608
609
610 void
611 psppire_data_store_set_font (PsppireDataStore *store,
612                             const PangoFontDescription *fd)
613 {
614   g_return_if_fail (store);
615   g_return_if_fail (PSPPIRE_IS_DATA_STORE (store));
616
617   store->font_desc = fd;
618 #if 0
619   store->width_of_m = calc_m_width (fd);
620 #endif
621   g_signal_emit (store, signals [FONT_CHANGED], 0);
622
623
624   g_sheet_model_range_changed (G_SHEET_MODEL (store),
625                                  -1, -1, -1, -1);
626 }
627
628
629 void
630 psppire_data_store_show_labels (PsppireDataStore *store, gboolean show_labels)
631 {
632   g_return_if_fail (store);
633   g_return_if_fail (PSPPIRE_IS_DATA_STORE (store));
634
635   store->show_labels = show_labels;
636
637   g_sheet_model_range_changed (G_SHEET_MODEL (store),
638                                  -1, -1, -1, -1);
639 }
640
641
642
643 /* FIXME: There's no reason to actually have this function.
644    It should be done by a procedure */
645 void
646 psppire_data_store_create_system_file (PsppireDataStore *store,
647                               struct file_handle *handle)
648 {
649   gint i, var_cnt;
650   const struct sfm_write_options wo = {
651     true, /* writeable */
652     false, /* dont compress */
653     3 /* version */
654   };
655
656   struct casewriter *writer;
657
658   g_assert (handle);
659
660   writer = sfm_open_writer (handle, store->dict->dict, wo);
661
662   if ( ! writer)
663     return;
664
665
666   var_cnt = psppire_data_store_get_var_count (G_SHEET_MODEL (store));
667
668   for (i = 0 ; i < psppire_case_file_get_case_count (store->case_file); ++i )
669     {
670       struct ccase c;
671       psppire_case_file_get_case (store->case_file, i, &c);
672       casewriter_write (writer, &c);
673     }
674   casewriter_destroy (writer);
675 }
676
677
678
679 void
680 psppire_data_store_clear (PsppireDataStore *data_store)
681 {
682   psppire_case_file_clear (data_store->case_file);
683
684   psppire_dict_clear (data_store->dict);
685 }
686
687
688
689
690 /* Column related funcs */
691
692 static gint
693 geometry_get_column_count (const GSheetColumn *geom)
694 {
695   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
696
697   return MAX (MIN_COLUMNS, psppire_dict_get_var_cnt (ds->dict));
698 }
699
700
701
702 static gint
703 geometry_get_width (const GSheetColumn *geom, gint unit)
704 {
705   const struct variable *pv ;
706   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
707
708   if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
709     return ds->width_of_m * 8 ;
710
711   pv = psppire_dict_get_variable (ds->dict, unit);
712
713   if ( pv == NULL )
714     return ds->width_of_m * 8 ;
715
716   return ds->width_of_m * var_get_display_width (pv);
717 }
718
719 static void
720 geometry_set_width (GSheetColumn *geom, gint unit, gint width)
721 {
722   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
723
724   struct variable *pv = psppire_dict_get_variable (ds->dict, unit);
725
726   var_set_display_width (pv, width / ds->width_of_m );
727 }
728
729
730
731 static GtkJustification
732 geometry_get_justification (const GSheetColumn *geom, gint unit)
733 {
734   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
735   const struct variable *pv ;
736
737
738   if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
739     return GTK_JUSTIFY_LEFT;
740
741   pv = psppire_dict_get_variable (ds->dict, unit);
742
743   return (var_get_alignment (pv) == ALIGN_LEFT ? GTK_JUSTIFY_LEFT
744           : var_get_alignment (pv) == ALIGN_RIGHT ? GTK_JUSTIFY_RIGHT
745           : GTK_JUSTIFY_CENTER);
746 }
747
748
749 static const gchar null_var_name[]=N_("var");
750
751 static gchar *
752 geometry_get_column_button_label (const GSheetColumn *geom, gint unit)
753 {
754   gchar *text;
755   struct variable *pv ;
756   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
757
758   if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
759     return g_locale_to_utf8 (null_var_name, -1, 0, 0, 0);
760
761   pv = psppire_dict_get_variable (ds->dict, unit);
762
763   text =  pspp_locale_to_utf8 (var_get_name (pv), -1, 0);
764
765   return text;
766 }
767
768
769 static gboolean
770 geometry_get_sensitivity (const GSheetColumn *geom, gint unit)
771 {
772   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
773
774   return (unit < psppire_dict_get_var_cnt (ds->dict));
775 }
776
777
778 static void
779 psppire_data_store_sheet_column_init (GSheetColumnIface *iface)
780 {
781   iface->get_column_count = geometry_get_column_count;
782   iface->get_width = geometry_get_width;
783   iface->set_width = geometry_set_width;
784   iface->get_visibility = always_true;
785   iface->get_sensitivity = geometry_get_sensitivity;
786   iface->get_justification = geometry_get_justification;
787   iface->get_button_label = geometry_get_column_button_label;
788 }
789
790
791 /* Row related funcs */
792
793 static gint
794 geometry_get_row_count (const GSheetRow *geom, gpointer data)
795 {
796   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
797
798   return TRAILING_ROWS + psppire_case_file_get_case_count (ds->case_file);
799 }
800
801
802 static gint
803 geometry_get_height (const GSheetRow *geom, gint unit, gpointer data)
804 {
805   return 25;
806 }
807
808
809 static gboolean
810 geometry_get_row_sensitivity (const GSheetRow *geom, gint unit, gpointer data)
811 {
812   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
813
814
815   return (unit < psppire_case_file_get_case_count (ds->case_file));
816 }
817
818
819 static gchar *
820 geometry_get_row_button_label (const GSheetRow *geom, gint unit, gpointer data)
821 {
822   gchar *text;
823   gchar *s;
824   PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
825
826   if ( unit >
827        TRAILING_ROWS + psppire_case_file_get_case_count (ds->case_file))
828     return 0;
829
830   s = g_strdup_printf (_("%d"), unit);
831
832   text =  pspp_locale_to_utf8 (s, -1, 0);
833
834   g_free (s);
835
836   return text;
837 }
838
839
840 static void
841 psppire_data_store_sheet_row_init (GSheetRowIface *iface)
842 {
843   iface->get_row_count = geometry_get_row_count;
844
845   iface->get_height = geometry_get_height;
846   iface->set_height = 0;
847   iface->get_visibility = always_true;
848   iface->get_sensitivity = geometry_get_row_sensitivity;
849
850   iface->get_button_label = geometry_get_row_button_label;
851 }
852