gui: Make syntax execution functions take a PsppireDataWindow argument.
[pspp-builds.git] / src / ui / gui / psppire-data-window.c
index e7506d261d05595ea33bfa569aa8a7900f400787..74c4ca695b62a7ff27c621505133c9f4decb8f12 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <config.h>
 
-#include <gtk/gtksignal.h>
-#include <gtk/gtkbox.h>
+#include <gtk/gtk.h>
 #include <stdlib.h>
 
 #include "data/any-reader.h"
 
 
 
-static void psppire_data_window_base_init     (PsppireDataWindowClass *class);
 static void psppire_data_window_class_init    (PsppireDataWindowClass *class);
 static void psppire_data_window_init          (PsppireDataWindow      *data_editor);
 
 
 static void psppire_data_window_iface_init (PsppireWindowIface *iface);
 
+static void psppire_data_window_dispose (GObject *object);
 
 GType
 psppire_data_window_get_type (void)
@@ -87,7 +86,7 @@ psppire_data_window_get_type (void)
       static const GTypeInfo psppire_data_window_info =
        {
          sizeof (PsppireDataWindowClass),
-         (GBaseInitFunc) psppire_data_window_base_init,
+         NULL,
          NULL,
          (GClassInitFunc)psppire_data_window_class_init,
          (GClassFinalizeFunc) NULL,
@@ -119,31 +118,14 @@ psppire_data_window_get_type (void)
 
 static GObjectClass *parent_class ;
 
-static void
-psppire_data_window_finalize (GObject *object)
-{
-  PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (object);
-
-  g_object_unref (de->builder);
-
-  if (G_OBJECT_CLASS (parent_class)->finalize)
-    (*G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
 static void
 psppire_data_window_class_init (PsppireDataWindowClass *class)
-{
-  parent_class = g_type_class_peek_parent (class);
-}
-
-
-static void
-psppire_data_window_base_init (PsppireDataWindowClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-  object_class->finalize = psppire_data_window_finalize;
+  parent_class = g_type_class_peek_parent (class);
+
+  object_class->dispose = psppire_data_window_dispose;
 }
 \f
 
@@ -174,9 +156,9 @@ set_cut_copy_menuitem_sensitivity (PsppireDataWindow *de, gboolean x)
 
 /* Run the EXECUTE command. */
 static void
-execute (void)
+execute (PsppireDataWindow *dw)
 {
-  execute_const_syntax_string ("EXECUTE.");
+  execute_const_syntax_string (dw, "EXECUTE.");
 }
 
 static void
@@ -356,7 +338,8 @@ load_file (PsppireWindow *de, const gchar *file_name)
   syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
   ds_destroy (&filename);
 
-  ok = execute_syntax (lex_reader_for_string (syntax));
+  ok = execute_syntax (PSPPIRE_DATA_WINDOW (de),
+                       lex_reader_for_string (syntax));
   g_free (syntax);
   return ok;
 }
@@ -518,7 +501,7 @@ save_file (PsppireWindow *w)
 
   ds_destroy (&filename);
 
-  g_free (execute_syntax_string (syntax));
+  g_free (execute_syntax_string (de, syntax));
 }
 
 
@@ -538,7 +521,7 @@ on_insert_variable (PsppireDataWindow *dw)
 static void
 display_dict (PsppireDataWindow *de)
 {
-  execute_const_syntax_string ("DISPLAY DICTIONARY.");
+  execute_const_syntax_string (de, "DISPLAY DICTIONARY.");
 }
 
 static void
@@ -564,7 +547,7 @@ sysfile_info (PsppireDataWindow *de)
       g_free (utf8_file_name);
 
       syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename));
-      g_free (execute_syntax_string (syntax));
+      g_free (execute_syntax_string (de, syntax));
     }
 
   gtk_widget_destroy (dialog);
@@ -675,7 +658,7 @@ data_save (PsppireWindow *de)
 static void
 new_file (PsppireDataWindow *de)
 {
-  execute_const_syntax_string ("NEW FILE.");
+  execute_const_syntax_string (de, "NEW FILE.");
   psppire_window_set_filename (PSPPIRE_WINDOW (de), NULL);
 }
 
@@ -1234,6 +1217,19 @@ psppire_data_window_init (PsppireDataWindow *de)
   gtk_widget_show (box);
 }
 
+static void
+psppire_data_window_dispose (GObject *object)
+{
+  PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (object);
+
+  if (dw->builder != NULL)
+    {
+      g_object_unref (dw->builder);
+      dw->builder = NULL;
+    }
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
 
 GtkWidget*
 psppire_data_window_new (void)