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"
26 #include <libpspp/i18n.h>
28 #include <data/variable.h>
29 #include <data/format.h>
31 #define _(msgid) gettext (msgid)
32 #define N_(msgid) msgid
35 get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
36 GtkTreeModel **model, GtkTreeIter *iter
41 while (GTK_IS_TREE_MODEL_FILTER (*model))
43 GtkTreeIter parent_iter = *iter;
44 GtkTreeModelFilter *parent_model = GTK_TREE_MODEL_FILTER (*model);
46 *model = gtk_tree_model_filter_get_model (parent_model);
48 gtk_tree_model_filter_convert_iter_to_child_iter (parent_model,
53 g_assert (PSPPIRE_IS_DICT (*model));
59 insert_source_row_into_entry (GtkTreeIter iter,
69 GtkTreeIter dict_iter;
72 g_return_if_fail (GTK_IS_ENTRY(dest));
74 get_base_model (model, &iter, &dict, &dict_iter);
76 path = gtk_tree_model_get_path (GTK_TREE_MODEL (dict), &dict_iter);
78 idx = gtk_tree_path_get_indices (path);
80 var = psppire_dict_get_variable (PSPPIRE_DICT (dict), *idx);
82 gtk_tree_path_free (path);
84 name = recode_string (UTF8, psppire_dict_encoding (PSPPIRE_DICT (dict)),
85 var_get_name (var), -1);
86 gtk_entry_set_text (GTK_ENTRY (dest), name);
93 insert_source_row_into_tree_view (GtkTreeIter iter,
100 GtkTreeIter dest_iter;
101 GtkTreeIter dict_iter;
103 GtkTreeModel *destmodel = gtk_tree_view_get_model ( GTK_TREE_VIEW (dest));
108 get_base_model (model, &iter, &dict, &dict_iter);
110 path = gtk_tree_model_get_path (dict, &dict_iter);
112 row = gtk_tree_path_get_indices (path);
114 gtk_list_store_append (GTK_LIST_STORE (destmodel), &dest_iter);
115 gtk_list_store_set (GTK_LIST_STORE (destmodel), &dest_iter, 0, *row, -1);
117 gtk_tree_path_free (path);
122 is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter,
123 PsppireSelector *selector)
127 GtkTreeIter dict_iter;
129 struct variable *var;
133 const gchar *text = gtk_entry_get_text (GTK_ENTRY (selector->dest));
135 get_base_model (model, iter, &dict, &dict_iter);
137 path = gtk_tree_model_get_path (dict, &dict_iter);
139 indeces = gtk_tree_path_get_indices (path);
141 dict_index = indeces [0];
143 var = psppire_dict_get_variable (PSPPIRE_DICT (dict), dict_index);
145 gtk_tree_path_free (path);
147 name = recode_string (UTF8, psppire_dict_encoding (PSPPIRE_DICT (dict)),
148 var_get_name (var), -1);
149 result = ( 0 == strcmp (text, name));