+static void
+move_variable (PsppireDataSheet *sheet, gint from, gint to, gpointer ud)
+{
+ PsppireDataStore *data_store = NULL;
+ g_object_get (sheet, "data-model", &data_store, NULL);
+
+ if (data_store == NULL)
+ return;
+
+ PsppireDict *dict = data_store->dict;
+ struct variable *var = psppire_dict_get_variable (dict, from);
+
+ if (var == NULL)
+ return;
+ gint new_pos = to;
+ /* The index refers to the final position, so if the source
+ is less than the destination, then we must subtract 1, to
+ account for the position vacated by the source */
+ if (from < to)
+ new_pos--;
+ dict_reorder_var (dict->dict, var, new_pos);
+}
+