Rename procedure.[ch] to dataset.[ch].
[pspp-builds.git] / src / ui / gui / psppire-data-window.c
index c17e6e794448005fdd4c16721230315340dd1127..24798cecfd197b7d997902a3309cdeabfcf46e2a 100644 (file)
 #include <stdlib.h>
 
 #include "data/any-reader.h"
-#include "data/procedure.h"
-#include "language/syntax-string-source.h"
+#include "data/dataset.h"
+#include "language/lexer/lexer.h"
 #include "libpspp/message.h"
-#include "ui/gui/help-menu.h"
+#include "ui/gui/aggregate-dialog.h"
+#include "ui/gui/binomial-dialog.h"
+#include "ui/gui/chi-square-dialog.h"
 #include "ui/gui/comments-dialog.h"
 #include "ui/gui/compute-dialog.h"
 #include "ui/gui/correlation-dialog.h"
@@ -36,7 +38,9 @@
 #include "ui/gui/find-dialog.h"
 #include "ui/gui/frequencies-dialog.h"
 #include "ui/gui/goto-case-dialog.h"
+#include "ui/gui/help-menu.h"
 #include "ui/gui/helper.h"
+#include "ui/gui/k-related-dialog.h"
 #include "ui/gui/oneway-anova-dialog.h"
 #include "ui/gui/psppire-data-window.h"
 #include "ui/gui/psppire-syntax-window.h"
@@ -183,9 +187,7 @@ set_cut_copy_menuitem_sensitivity (PsppireDataWindow *de, gboolean x)
 static void
 execute (void)
 {
-  struct getl_interface *sss = create_syntax_string_source ("EXECUTE.");
-
-  execute_syntax (sss);
+  execute_const_syntax_string ("EXECUTE.");
 }
 
 static void
@@ -350,8 +352,9 @@ static gboolean
 load_file (PsppireWindow *de, const gchar *file_name)
 {
   gchar *native_file_name;
-  struct getl_interface *sss;
   struct string filename;
+  gchar *syntax;
+  bool ok;
 
   ds_init_empty (&filename);
 
@@ -362,15 +365,12 @@ load_file (PsppireWindow *de, const gchar *file_name)
 
   g_free (native_file_name);
 
-  sss = create_syntax_string_source ("GET FILE=%s.",
-                                    ds_cstr (&filename));
-
+  syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
   ds_destroy (&filename);
 
-  if (execute_syntax (sss) )
-    return TRUE;
-
-  return FALSE;
+  ok = execute_syntax (lex_reader_for_string (syntax));
+  g_free (syntax);
+  return ok;
 }
 
 static GtkWidget *
@@ -457,11 +457,14 @@ open_window (PsppireWindow *de)
        gchar *name =
          gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
 
-       if (any_reader_may_open (name))
+       gchar *sysname = convert_glib_filename_to_system_filename (name, NULL);
+
+       if (any_reader_may_open (sysname))
          psppire_window_load (de, name);
        else
          open_syntax_window (name);
 
+       g_free (sysname);
        g_free (name);
       }
       break;
@@ -496,9 +499,9 @@ save_file (PsppireWindow *w)
   gchar *native_file_name = NULL;
   gchar *file_name = NULL;
   GString *fnx;
-  struct getl_interface *sss;
   struct string filename ;
   PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (w);
+  gchar *syntax;
 
   g_object_get (w, "filename", &file_name, NULL);
 
@@ -522,20 +525,13 @@ save_file (PsppireWindow *w)
   syntax_gen_string (&filename, ss_cstr (native_file_name));
   g_free (native_file_name);
 
-  if ( de->save_as_portable )
-    {
-      sss = create_syntax_string_source ("EXPORT OUTFILE=%s.",
-                                        ds_cstr (&filename));
-    }
-  else
-    {
-      sss = create_syntax_string_source ("SAVE OUTFILE=%s.",
-                                        ds_cstr (&filename));
-    }
+  syntax = g_strdup_printf ("%s OUTFILE=%s.",
+                            de->save_as_portable ? "EXPORT" : "SAVE",
+                            ds_cstr (&filename));
 
   ds_destroy (&filename);
 
-  execute_syntax (sss);
+  g_free (execute_syntax_string (syntax));
 }
 
 
@@ -555,11 +551,7 @@ on_insert_variable (PsppireDataWindow *dw)
 static void
 display_dict (PsppireDataWindow *de)
 {
-
-  struct getl_interface *sss =
-    create_syntax_string_source ("DISPLAY DICTIONARY.");
-
-  execute_syntax (sss);
+  execute_const_syntax_string ("DISPLAY DICTIONARY.");
 }
 
 static void
@@ -570,22 +562,22 @@ sysfile_info (PsppireDataWindow *de)
   if  ( GTK_RESPONSE_ACCEPT == gtk_dialog_run (GTK_DIALOG (dialog)))
     {
       struct string filename;
-      struct getl_interface *sss;
       gchar *file_name =
        gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
 
       gchar *native_file_name =
        convert_glib_filename_to_system_filename (file_name, NULL);
 
+      gchar *syntax;
+
       ds_init_empty (&filename);
 
       syntax_gen_string (&filename, ss_cstr (native_file_name));
 
       g_free (native_file_name);
 
-      sss = create_syntax_string_source ("SYSFILE INFO %s.",
-                                        ds_cstr (&filename));
-      execute_syntax (sss);
+      syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename));
+      g_free (execute_syntax_string (syntax));
     }
 
   gtk_widget_destroy (dialog);
@@ -696,11 +688,7 @@ data_save (PsppireWindow *de)
 static void
 new_file (PsppireDataWindow *de)
 {
-  struct getl_interface *sss =
-    create_syntax_string_source ("NEW FILE.");
-
-  execute_syntax (sss);
-
+  execute_const_syntax_string ("NEW FILE.");
   psppire_window_set_filename (PSPPIRE_WINDOW (de), NULL);
 }
 
@@ -1072,8 +1060,12 @@ psppire_data_window_init (PsppireDataWindow *de)
 
   connect_action (de, "data_transpose", G_CALLBACK (transpose_dialog));
 
+  connect_action (de, "data_select-cases", G_CALLBACK (select_cases_dialog));
   connect_action (de, "data_sort-cases", G_CALLBACK (sort_cases_dialog));
 
+  connect_action (de, "data_aggregate", G_CALLBACK (aggregate_dialog));
+
   connect_action (de, "transform_compute", G_CALLBACK (compute_dialog));
 
   connect_action (de, "edit_find", G_CALLBACK (find_dialog));
@@ -1082,6 +1074,7 @@ psppire_data_window_init (PsppireDataWindow *de)
 
   connect_action (de, "data_weight-cases", G_CALLBACK (weight_cases_dialog));
 
+
   connect_action (de, "utilities_variables", G_CALLBACK (variable_info_dialog));
  
   connect_action (de, "oneway-anova", G_CALLBACK (oneway_anova_dialog));
@@ -1113,10 +1106,16 @@ psppire_data_window_init (PsppireDataWindow *de)
   connect_action (de, "reliability", G_CALLBACK (reliability_dialog));
  
   connect_action (de, "roc-curve", G_CALLBACK (roc_dialog));
+
   connect_action (de, "correlation", G_CALLBACK (correlation_dialog));
  
   connect_action (de, "factor-analysis", G_CALLBACK (factor_dialog));
+
+  connect_action (de, "chi-square", G_CALLBACK (chisquare_dialog));
+
+  connect_action (de, "binomial", G_CALLBACK (binomial_dialog));
+
+  connect_action (de, "k-related-samples", G_CALLBACK (k_related_dialog));
  
 
   {
@@ -1252,6 +1251,8 @@ GtkWidget*
 psppire_data_window_new (void)
 {
   return GTK_WIDGET (g_object_new (psppire_data_window_get_type (),
+                                  /* TRANSLATORS: This will form a filename.  Please avoid whitespace. */
+                                  "filename", _("PSPP-data"),
                                   "description", _("Data Editor"),
                                   NULL));
 }