2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2007 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include "dialog-common.h"
25 append_variable_names (GString *string,
26 PsppireDict *dict, GtkTreeView *treeview)
31 GtkTreeModel *list_store =
32 gtk_tree_view_get_model (treeview);
34 if ( gtk_tree_model_get_iter_first (list_store, &iter) )
40 GtkTreePath *path = gtk_tree_model_get_path (list_store, &iter);
42 gtk_tree_model_get_value (list_store, &iter, 0, &value);
44 var = psppire_dict_get_variable (dict, g_value_get_int (&value));
45 g_value_unset (&value);
47 g_string_append (string, " ");
48 g_string_append (string, var_get_name (var));
50 gtk_tree_path_free (path);
53 while (gtk_tree_model_iter_next (list_store, &iter));
62 get_selected_variable (GtkTreeModel *treemodel,
69 GtkTreePath *path = gtk_tree_model_get_path (treemodel, iter);
71 gtk_tree_model_get_value (treemodel, iter, 0, &value);
73 gtk_tree_path_free (path);
75 var = psppire_dict_get_variable (dict, g_value_get_int (&value));
77 g_value_unset (&value);
85 /* A (*GtkTreeCellDataFunc) function.
86 This function expects TREEMODEL to hold G_TYPE_INT. The ints it holds
87 are the indices of the variables in the dictionary, which DATA points to.
88 It renders the name of the variable into CELL.
91 cell_var_name (GtkTreeViewColumn *tree_column,
92 GtkCellRenderer *cell,
93 GtkTreeModel *tree_model,
97 PsppireDict *dict = data;
101 var = get_selected_variable (tree_model, iter, dict);
103 name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL);
104 g_object_set (cell, "text", name, NULL);
110 /* Set a model for DEST, which is an GtkListStore of g_int's
111 whose values are the indices into DICT */
113 set_dest_model (GtkTreeView *dest, PsppireDict *dict)
115 GtkTreeViewColumn *col;
116 GtkListStore *dest_list = gtk_list_store_new (1, G_TYPE_INT);
117 GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
119 gtk_tree_view_set_model (GTK_TREE_VIEW (dest), GTK_TREE_MODEL (dest_list));
121 col = gtk_tree_view_column_new_with_attributes ("Var",
127 gtk_tree_view_column_set_cell_data_func (col, renderer,
131 /* FIXME: make this a value in terms of character widths */
132 g_object_set (col, "min-width", 100, NULL);
134 gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
136 gtk_tree_view_append_column (GTK_TREE_VIEW(dest), col);