dataset: Use similar form to dictionary code for callbacks, and document.
[pspp-builds.git] / src / ui / gui / psppire-data-window.c
index b01582bb8f0969be2352b2614babcfd132e1ff86..9a3470ae4df8e90fea20069019d638ae3d95b39c 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2008, 2009, 2010  Free Software Foundation
+   Copyright (C) 2008, 2009, 2010, 2011  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
 #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"
-#include "ui/gui/chi-square-dialog.h"
 #include "ui/gui/crosstabs-dialog.h"
 #include "ui/gui/descriptives-dialog.h"
 #include "ui/gui/examine-dialog.h"
 #include "ui/gui/factor-dialog.h"
 #include "ui/gui/find-dialog.h"
 #include "ui/gui/frequencies-dialog.h"
-#include "ui/gui/k-related-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"
@@ -58,7 +59,6 @@
 #include "ui/gui/t-test-paired-samples.h"
 #include "ui/gui/text-data-import-dialog.h"
 #include "ui/gui/transpose-dialog.h"
-#include "ui/gui/aggregate-dialog.h"
 #include "ui/gui/variable-info-dialog.h"
 #include "ui/gui/weight-cases-dialog.h"
 #include "ui/syntax-gen.h"
@@ -352,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);
 
@@ -364,15 +365,12 @@ load_file (PsppireWindow *de, const gchar *file_name)
 
   g_free (native_file_name);
 
-  sss = create_syntax_format_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 *
@@ -942,6 +940,12 @@ connect_action (PsppireDataWindow *dw, const char *action_name,
 static void
 psppire_data_window_init (PsppireDataWindow *de)
 {
+  static const struct dataset_callbacks cbs =
+    {
+      set_unsaved,                    /* changed */
+      transformation_change_callback, /* transformations_changed */
+    };
+
   PsppireVarStore *vs;
   PsppireDict *dict = NULL;
 
@@ -968,7 +972,7 @@ psppire_data_window_init (PsppireDataWindow *de)
   g_signal_connect_swapped (the_data_store, "cases-deleted",
                            G_CALLBACK (set_unsaved), de);
 
-  dataset_set_callback (the_dataset, set_unsaved, de);
+  dataset_set_callbacks (the_dataset, &cbs, de);
 
   connect_help (de->builder);
 
@@ -990,11 +994,6 @@ psppire_data_window_init (PsppireDataWindow *de)
   g_signal_connect_swapped (de->data_editor, "data-available-changed",
                            G_CALLBACK (set_paste_menuitem_sensitivity), de);
 
-  dataset_add_transform_change_callback (the_dataset,
-                                        transformation_change_callback,
-                                        de);
-
-
   vs = the_var_store;
 
   g_assert(vs); /* Traps a possible bug in w32 build */