+/* When during import the variable type is changed, the reader is reinitialized
+ based on the new dictionary with a fresh caseprototype. The default behaviour
+ when a variable type is changed and the column is resized is that the union
+ value is interpreted with new variable type and an overlay for that column
+ is generated. Here we reinit to the original reader based on strings.
+ As a result you can switch from string to numeric to string without loosing
+ the string information. */
+static void
+ia_variable_changed_cb (GObject *obj, gint var_num, guint what,
+ const struct variable *oldvar, gpointer data)
+{
+ PsppireImportAssistant *ia = PSPPIRE_IMPORT_ASSISTANT (data);
+
+ struct caseproto *proto = caseproto_create();
+ for (int i = 0; i < dict_get_var_cnt (ia->dict); i++)
+ {
+ const struct variable *var = dict_get_var (ia->dict, i);
+ int width = var_get_width (var);
+ proto = caseproto_add_width (proto, width);
+ }
+
+ gint n_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (ia->delimiters_model), NULL);
+
+ PsppireDataStore *store = NULL;
+ g_object_get (ia->data_sheet, "data-model", &store, NULL);
+
+ struct casereader *cr = casereader_create_random (proto, n_rows,
+ &my_casereader_class, ia);
+ psppire_data_store_set_reader (store, cr);
+ dict_unref (ia->casereader_dict);
+ ia->casereader_dict = dict_clone (ia->dict);
+}