Merge branch 'master' of ssh://john@cellform.com/home/john/Development/pspp-selector
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 13 Dec 2009 19:40:38 +0000 (20:40 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 13 Dec 2009 19:40:38 +0000 (20:40 +0100)
perl-module/PSPP.xs
perl-module/lib/PSPP.pm
src/ui/gui/psppire-dict.c
src/ui/gui/psppire-var-view.c
src/ui/gui/psppire-var-view.h

index 77a720caabf69cc17a172ab2c0b1233b7baa9987..fef855106de4347ba324e59434e2e4dd94941b54 100644 (file)
@@ -584,6 +584,7 @@ CODE:
  struct file_handle *fh =
   fh_create_file (NULL, name, fh_default_properties () );
  struct sysfile_info *sfi = xmalloc (sizeof (*sfi));
+ dict_set_encoding (dict, "UTF-8");
  sfi->writer = sfm_open_writer (fh, dict, opts);
  sfi->dict = dict;
  sfi->opened = true;
index e5599908b683f7b6e6bde716fbfa9f74d3460338..2dccd10a36973e560e8be7d267b92f9bdb918ac1 100644 (file)
@@ -197,7 +197,7 @@ package PSPP::Var;
 =head3 new ($dict, $name, %input_fmt)
 
 Creates and returns a new variable in the dictionary C<dict>.  The 
-new variable will have the name C<name>.
+new variable will have the name C<name>.  C<name> must be a valid UTF8 string.
 The input format is set by the C<input_fmt> parameter 
 (See L</PSPP::Fmt>).
 By default, the write and print formats are the same as the input format.
@@ -226,7 +226,7 @@ sub new
 
 =head3 set_label ($label)
 
-Sets the variable label to C<label>.
+Sets the variable label to C<label>, which must be a valid UTF8 string.
 
 
 =cut
@@ -322,6 +322,7 @@ Removes all value labels from the variable.
 =head3 add_value_label ($key, $label)
 
 Adds the value label C<label> to the variable for the value C<key>.
+C<label> must be a valid UTF8 string.
 On error the subroutine returns zero.
 
 =head3 add_value_labels (@array)
@@ -348,7 +349,7 @@ sub add_value_labels
 
 =pod
 
-=head3 set_value_labels ($key, $value)
+=head3 set_value_labels ($key, $label)
 
 C<Set_value_labels> is identical to calling L</clear_value_labels>
 followed by L</add_value_labels>.
@@ -414,6 +415,7 @@ On error, undef is returned.
 Appends a case to the system file.
 C<Case> is an array of scalars, each of which are the values of 
 the variables in the dictionary corresponding to the system file.
+If the case contains strings, then the strings must be UTF8 encoded.
 The special value C<PSPP::SYSMIS> may be used to indicate that a value
 is system missing.
 If the array contains less elements than variables in the dictionary,
@@ -522,7 +524,7 @@ values retrieved from a reader.
 
 Returns a scalar containing a string representing C<value> formatted according 
 to the print format of C<variable>.
-In the most common ussage,  C<value> should be a value of C<variable>.
+In the most common usage,  C<value> should be a value of C<variable>.
 
 
 =head3 PSPP::value_is_missing ($value, $variable)
index c82395f2ebdc047e1f8678b9e9d6873df2452207..9e2190b2909e181475309ed1c58e10b3ce304872 100644 (file)
@@ -21,6 +21,7 @@
 #include <gtk/gtk.h>
 #include <ui/gui/psppire-marshal.h>
 
+#include "psppire-var-ptr.h"
 #include "psppire-dict.h"
 #include <data/dictionary.h>
 #include <data/missing-values.h>
@@ -648,7 +649,7 @@ tree_model_column_type (GtkTreeModel *model, gint index)
       return G_TYPE_STRING;
       break;
     case DICT_TVM_COL_VAR:
-      return G_TYPE_POINTER;
+      return PSPPIRE_VAR_PTR_TYPE;
       break;
     default:
       g_return_val_if_reached ((GType)0);
@@ -765,8 +766,8 @@ tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter,
       }
       break;
     case DICT_TVM_COL_VAR:
-      g_value_init (value, G_TYPE_POINTER);
-      g_value_set_pointer (value, var);
+      g_value_init (value, PSPPIRE_VAR_PTR_TYPE);
+      g_value_set_boxed (value, var);
       break;
     default:
       g_return_if_reached ();
index 97a5aec1d2a102c1a91e47689d9cecac3769c60c..2a9ebf2e33a7c7a9a65e4d54338e8afb98a1167a 100644 (file)
@@ -201,7 +201,6 @@ psppire_var_view_class_init (PsppireVarViewClass *class)
   g_object_class_install_property (object_class,
                                    PROP_N_COLS,
                                    n_cols_spec);
-
 }
 
 
@@ -292,4 +291,26 @@ psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string)
   return n_vars;
 }
 
+/* Returns TRUE iff VV contains the item V.
+   V must be an initialised value containing a
+   PSPPIRE_VAR_PTR_TYPE.
+*/
+gboolean
+psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v)
+{
+  gboolean ok;
+  GtkTreeIter iter;
+  g_return_val_if_fail (G_VALUE_HOLDS (v, PSPPIRE_VAR_PTR_TYPE), FALSE);
+
+  for (ok = psppire_var_view_get_iter_first (vv, &iter);
+       ok;
+       ok = psppire_var_view_get_iter_next (vv, &iter))
+    {
+      const struct variable *var = psppire_var_view_get_variable (vv, 0, &iter);
+      if (var == g_value_get_boxed (v))
+       return TRUE;
+    }
+
+  return FALSE;
+}
 
index f2696072a9a70f2c426373a37cb8d4d66d61afbf..3509a46b09f4098a34c70a7b3b4839daeaecc5e5 100644 (file)
@@ -58,9 +58,14 @@ struct _PsppireVarViewClass
 
 GType      psppire_var_view_get_type        (void);
 
+gboolean psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v);
+
 gint psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string);
+
 gboolean psppire_var_view_get_iter_first (PsppireVarView *vv, GtkTreeIter *iter);
+
 gboolean psppire_var_view_get_iter_next (PsppireVarView *vv, GtkTreeIter *iter);
+
 const struct variable * psppire_var_view_get_variable (PsppireVarView *vv, gint column, GtkTreeIter *iter);