+struct resize_datum_aux
+ {
+ int old_width;
+ int new_width;
+ };
+
+
+void
+resize_datum (const union value *old, union value *new, void *aux_)
+{
+ struct resize_datum_aux *aux = aux_;
+
+ if (aux->new_width == 0)
+ {
+ /* FIXME: try to parse string as number. */
+ new->f = SYSMIS;
+ }
+ else if (aux->old_width == 0)
+ {
+ /* FIXME: format number as string. */
+ value_set_missing (new, aux->new_width);
+ }
+ else
+ value_copy_rpad (new, aux->new_width, old, aux->old_width, ' ');
+}
+
+static void
+dict_size_change_callback (GObject *obj,
+ gint var_num, gint old_width, gpointer data)
+{
+ PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
+ struct variable *variable;
+ int posn;
+
+ variable = psppire_dict_get_variable (store->dict, var_num);
+ posn = var_get_case_index (variable);
+
+ if (old_width != var_get_width (variable))
+ {
+ struct resize_datum_aux aux;
+ aux.old_width = old_width;
+ aux.new_width = var_get_width (variable);
+ datasheet_resize_column (store->datasheet, posn, aux.new_width,
+ resize_datum, &aux);
+ }
+}