Remove unused #include directives
[pspp] / src / ui / gui / psppire-data-store.c
index c0843b1a6729496ee445c954c72b3da3055c4436..c91e589dfcb848a53f05b47856aef7c4dcf25283 100644 (file)
@@ -42,7 +42,6 @@
 
 #include <math/sort.h>
 
-#include "xalloc.h"
 #include "xmalloca.h"
 
 #include "value-variant.h"
@@ -130,11 +129,22 @@ __iter_nth_child (GtkTreeModel *tree_model,
   return TRUE;
 }
 
+/* Set the contents of OUT to reflect the information provided by IN, COL, and
+   ROW, for MODEL.  Returns TRUE if successful. */
 gboolean
-myreversefunc (GtkTreeModel *model, gint col, gint row,
-              const gchar *in, GValue *out)
+psppire_data_store_string_to_value (GtkTreeModel *model, gint col, gint row,
+                                   const gchar *in, GValue *out)
 {
-  PsppireDataStore *store  = PSPPIRE_DATA_STORE (model);
+  PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
+
+  while (col >= psppire_dict_get_var_cnt (store->dict))
+    {
+      const struct variable *var =
+       psppire_dict_insert_variable (store->dict,
+                                     psppire_dict_get_var_cnt (store->dict),
+                                     NULL);
+      g_return_val_if_fail (var, FALSE);
+    }
 
   const struct variable *variable = psppire_dict_get_variable (store->dict, col);
   g_return_val_if_fail (variable, FALSE);
@@ -172,6 +182,8 @@ psppire_data_store_value_to_string (gpointer unused, PsppireDataStore *store, gi
   g_return_val_if_fail (variable, g_strdup ("???"));
 
   GVariant *vrnt = g_value_get_variant (v);
+  g_return_val_if_fail (vrnt, g_strdup ("???"));
+
   union value val;
   value_variant_get (&val, vrnt);
 
@@ -220,12 +232,14 @@ __get_value (GtkTreeModel *tree_model,
   if (NULL == variable)
     return;
 
-  g_value_init (value, G_TYPE_VARIANT);
-
   gint row = GPOINTER_TO_INT (iter->user_data);
 
   struct ccase *cc = datasheet_get_row (store->datasheet, row);
 
+  g_return_if_fail (cc);
+
+  g_value_init (value, G_TYPE_VARIANT);
+
   const union value *val = case_data_idx (cc, var_get_case_index (variable));
 
   GVariant *vv = value_variant_new (val, var_get_width (variable));
@@ -810,7 +824,10 @@ psppire_data_store_set_value (PsppireDataStore *ds, casenumber casenum,
   ok = datasheet_put_value (ds->datasheet, casenum, var_get_case_index (var),
                             v);
   if (ok)
-    g_signal_emit (ds, signals [CASE_CHANGED], 0, casenum);
+    {
+      g_signal_emit (ds, signals [CASE_CHANGED], 0, casenum);
+      g_signal_emit (ds, signals [ITEMS_CHANGED], 0, casenum, 1, 1);
+    }
 
   return ok;
 }