+
+static GtkTreePath *
+tree_model_get_path (GtkTreeModel *model, GtkTreeIter *iter)
+{
+ GtkTreePath *path;
+ struct variable *var;
+ PsppireDict *dict = PSPPIRE_DICT (model);
+
+ g_return_val_if_fail (iter->stamp == dict->stamp, FALSE);
+
+ var = iter->user_data;
+
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, var_get_dict_index (var));
+
+ return path;
+}
+
+
+static void
+tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter,
+ gint column, GValue *value)
+{
+ struct variable *var;
+ PsppireDict *dict = PSPPIRE_DICT (model);
+
+ g_return_if_fail (iter->stamp == dict->stamp);
+
+ var = iter->user_data;
+
+ switch (column)
+ {
+ case DICT_TVM_COL_NAME:
+ {
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, var_get_name (var));
+ }
+ break;
+ case DICT_TVM_COL_VAR:
+ g_value_init (value, G_TYPE_POINTER);
+ g_value_set_pointer (value, var);
+ break;
+ default:
+ g_return_if_reached ();
+ break;
+ }
+}
+
+static gboolean
+tree_model_iter_children (GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ GtkTreeIter *parent)
+{
+ return FALSE;
+}
+
+static gint
+tree_model_n_children (GtkTreeModel *model,
+ GtkTreeIter *iter)
+{
+ PsppireDict *dict = PSPPIRE_DICT (model);
+
+ if ( iter == NULL )
+ return psppire_dict_get_var_cnt (dict);
+
+ return 0;
+}
+
+static gboolean
+tree_model_nth_child (GtkTreeModel *model, GtkTreeIter *iter,
+ GtkTreeIter *parent, gint n)
+{
+ PsppireDict *dict;
+
+ g_return_val_if_fail (PSPPIRE_IS_DICT (model), FALSE);
+
+ dict = PSPPIRE_DICT (model);
+
+ if ( parent )
+ return FALSE;
+
+ if ( n >= psppire_dict_get_var_cnt (dict) )
+ return FALSE;
+
+ iter->stamp = dict->stamp;
+ iter->user_data = psppire_dict_get_variable (dict, n);
+
+ if ( !iter->user_data)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+gboolean
+psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
+ const gchar *name)
+{
+ if ( ! var_is_valid_name (name, false))
+ return FALSE;
+
+ /* Make sure no other variable has this name */
+ if ( NULL != psppire_dict_lookup_var (dict, name))
+ return FALSE;
+
+ dict_rename_var (dict->dict, v, name);
+
+ return TRUE;
+}
+
+
+struct variable *
+psppire_dict_get_weight_variable (const PsppireDict *dict)
+{
+ return dict_get_weight (dict->dict);
+}
+
+
+
+#if DEBUGGING
+void
+psppire_dict_dump (const PsppireDict *dict)
+{
+ gint i;
+ const struct dictionary *d = dict->dict;
+
+ for (i = 0; i < dict_get_var_cnt (d); ++i)
+ {
+ const struct variable *v = psppire_dict_get_variable (dict, i);
+ int di = var_get_dict_index (v);
+ g_print ("\"%s\" idx=%d, fv=%d\n",
+ var_get_name(v),
+ di,
+ var_get_case_index(v));
+
+ }
+}
+#endif
+
+
+
+
+const gchar *
+psppire_dict_encoding (const PsppireDict *dict)
+{
+ return dict_get_encoding (dict->dict);
+}