(map_case): Create destination case instead of leaving it
[pspp] / src / ui / gui / psppire-dict.c
index 42025f2dc7598fe50f9cdb5dcff30f816ab14952..3e37343b7d10b141bb5aebcf7a1d13b27897b466 100644 (file)
@@ -1,21 +1,18 @@
-/*
-  PSPPIRE --- A Graphical User Interface for PSPP
-  Copyright (C) 2004, 2006, 2007  Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2004, 2006, 2007  Free Software Foundation
 
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-  02110-1301, USA. */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
 #include <string.h>
@@ -281,7 +278,17 @@ psppire_dict_new_from_dict (struct dictionary *d)
 void
 psppire_dict_replace_dictionary (PsppireDict *dict, struct dictionary *d)
 {
+  struct variable *var =  dict_get_weight (d);
   dict->dict = d;
+
+  weight_changed_callback (d, var ? var_get_dict_index (var) : -1, dict);
+
+  var = dict_get_filter (d);
+  filter_changed_callback (d, var ? var_get_dict_index (var) : -1, dict);
+
+  split_changed_callback (d, dict);
+
+  dict_set_callbacks (dict->dict, &gui_callbacks, dict);
 }
 
 
@@ -343,13 +350,15 @@ psppire_dict_delete_variables (PsppireDict *d, gint first, gint n)
 }
 
 
-void
+gboolean
 psppire_dict_set_name (PsppireDict* d, gint idx, const gchar *name)
 {
   struct variable *var;
   g_assert (d);
   g_assert (PSPPIRE_IS_DICT (d));
 
+  if ( ! var_is_valid_name (name, false))
+    return FALSE;
 
   if ( idx < dict_get_var_cnt (d->dict))
     {
@@ -362,6 +371,8 @@ psppire_dict_set_name (PsppireDict* d, gint idx, const gchar *name)
       /* new variable */
       dict_create_var (d->dict, name, 0);
     }
+
+  return TRUE;
 }
 
 
@@ -735,11 +746,16 @@ tree_model_nth_child (GtkTreeModel *model, GtkTreeIter *iter,
 }
 
 
-void
+gboolean
 psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
-                        const gchar *text)
+                        const gchar *name)
 {
-  dict_rename_var (dict->dict, v, text);
+  if ( ! var_is_valid_name (name, false))
+    return FALSE;
+
+  dict_rename_var (dict->dict, v, name);
+
+  return TRUE;
 }