gui: Include only <gtk/gtk.h> to use GTK+.
[pspp-builds.git] / src / ui / gui / psppire-data-editor.c
index 58aa0b8f91f740ba2630763ac7703cad8a243148..23af0e5a80562438cbe2b9ad29c32bf309345372 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
    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
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
-#include <gtk/gtksignal.h>
 #include <gtk/gtk.h>
 #include <gtk-contrib/gtkextra-sheet.h>
 #include "psppire-data-editor.h"
 #include "psppire-var-sheet.h"
 
-#include <language/syntax-string-source.h>
 #include "psppire-data-store.h"
 #include <libpspp/i18n.h>
 #include <ui/gui/sheet/psppire-axis.h>
@@ -1249,21 +1247,13 @@ popup_cases_menu (PsppireSheet *sheet, gint row,
 static void
 do_sort (PsppireDataStore *ds, int var, gboolean descend)
 {
-  GString *string = g_string_new ("SORT CASES BY ");
-
   const struct variable *v =
     psppire_dict_get_variable (ds->dict, var);
+  gchar *syntax;
 
-  g_string_append_printf (string, "%s", var_get_name (v));
-
-  if ( descend )
-    g_string_append (string, " (D)");
-
-  g_string_append (string, ".");
-
-  execute_syntax (create_syntax_string_source (string->str));
-
-  g_string_free (string, TRUE);
+  syntax = g_strdup_printf ("SORT CASES BY %s%s.",
+                            var_get_name (v), descend ? " (D)" : "");
+  g_free (execute_syntax_string (syntax));
 }
 
 
@@ -1621,13 +1611,9 @@ data_sheet_set_clip (PsppireSheet *sheet)
     }
 
   /* Construct clip dictionary. */
-  clip_dict = dict_create ();
-  dict_set_encoding (clip_dict, dict_get_encoding (ds->dict->dict));
+  clip_dict = dict_create (dict_get_encoding (ds->dict->dict));
   for (i = col0; i <= coli; i++)
-    {
-      const struct variable *old = dict_get_var (ds->dict->dict, i);
-      dict_clone_var_assert (clip_dict, old, var_get_name (old));
-    }
+    dict_clone_var_assert (clip_dict, dict_get_var (ds->dict->dict, i));
 
   /* Construct clip data. */
   map = case_map_by_name (ds->dict->dict, clip_dict);
@@ -1656,14 +1642,13 @@ enum {
 
 /* Perform data_out for case CC, variable V, appending to STRING */
 static void
-data_out_g_string (GString *string, const struct dictionary *dict, 
-                  const struct variable *v,
+data_out_g_string (GString *string, const struct variable *v,
                   const struct ccase *cc)
 {
   const struct fmt_spec *fs = var_get_print_format (v);
   const union value *val = case_data (cc, v);
 
-  char *s = data_out (val, dict_get_encoding (dict), fs);
+  char *s = data_out (val, var_get_encoding (v), fs);
 
   g_string_append (string, s);
 
@@ -1697,7 +1682,7 @@ clip_to_text (void)
       for (c = 0 ; c < var_cnt ; ++c)
        {
          const struct variable *v = dict_get_var (clip_dict, c);
-         data_out_g_string (string, clip_dict, v, cc);
+         data_out_g_string (string, v, cc);
          if ( c < val_cnt - 1 )
            g_string_append (string, "\t");
        }
@@ -1744,7 +1729,7 @@ clip_to_html (void)
        {
          const struct variable *v = dict_get_var (clip_dict, c);
          g_string_append (string, "<td>");
-         data_out_g_string (string, clip_dict, v, cc);
+         data_out_g_string (string, v, cc);
          g_string_append (string, "</td>\n");
        }