1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2007 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "psppire-conf.h"
23 #include "dict-display.h"
25 #include "psppire-dict.h"
27 #include <data/variable.h>
28 #include <data/format.h>
30 #define _(msgid) gettext (msgid)
31 #define N_(msgid) msgid
34 get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
35 GtkTreeModel **model, GtkTreeIter *iter
40 while (GTK_IS_TREE_MODEL_FILTER (*model))
42 GtkTreeIter parent_iter = *iter;
43 GtkTreeModelFilter *parent_model = GTK_TREE_MODEL_FILTER (*model);
45 *model = gtk_tree_model_filter_get_model (parent_model);
47 gtk_tree_model_filter_convert_iter_to_child_iter (parent_model,
52 g_assert (PSPPIRE_IS_DICT (*model));
58 insert_source_row_into_entry (GtkTreeIter iter,
68 GtkTreeIter dict_iter;
71 g_return_if_fail (GTK_IS_ENTRY(dest));
73 get_base_model (model, &iter, &dict, &dict_iter);
75 path = gtk_tree_model_get_path (GTK_TREE_MODEL (dict), &dict_iter);
77 idx = gtk_tree_path_get_indices (path);
79 var = psppire_dict_get_variable (PSPPIRE_DICT (dict), *idx);
81 gtk_tree_path_free (path);
83 name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL);
84 gtk_entry_set_text (GTK_ENTRY (dest), name);
91 insert_source_row_into_tree_view (GtkTreeIter iter,
98 GtkTreeIter dest_iter;
99 GtkTreeIter dict_iter;
101 GtkTreeModel *destmodel = gtk_tree_view_get_model ( GTK_TREE_VIEW (dest));
106 get_base_model (model, &iter, &dict, &dict_iter);
108 path = gtk_tree_model_get_path (dict, &dict_iter);
110 row = gtk_tree_path_get_indices (path);
112 gtk_list_store_append (GTK_LIST_STORE (destmodel), &dest_iter);
113 gtk_list_store_set (GTK_LIST_STORE (destmodel), &dest_iter, 0, *row, -1);
115 gtk_tree_path_free (path);
120 is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter,
121 PsppireSelector *selector)
125 GtkTreeIter dict_iter;
127 struct variable *var;
131 const gchar *text = gtk_entry_get_text (GTK_ENTRY (selector->dest));
133 get_base_model (model, iter, &dict, &dict_iter);
135 path = gtk_tree_model_get_path (dict, &dict_iter);
137 indeces = gtk_tree_path_get_indices (path);
139 dict_index = indeces [0];
141 var = psppire_dict_get_variable (PSPPIRE_DICT (dict), dict_index);
143 gtk_tree_path_free (path);
145 name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL);
146 result = ( 0 == strcmp (text, name));