gui: Include only <gtk/gtk.h> to use GTK+.
[pspp-builds.git] / src / ui / gui / psppire-data-window.c
index 6dcb8c69c10f4ddc1cfe0586c5177ded574eaba3..ff17ed32bf0ca7810a57be73746fd462023953a9 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 <config.h>
 
-#include <gtk/gtksignal.h>
-#include <gtk/gtkbox.h>
+#include <gtk/gtk.h>
 #include <stdlib.h>
 
 #include "data/any-reader.h"
-#include "data/procedure.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 +58,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"
 
 
 
-static void psppire_data_window_base_finalize (PsppireDataWindowClass *, gpointer);
-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)
@@ -88,8 +86,8 @@ psppire_data_window_get_type (void)
       static const GTypeInfo psppire_data_window_info =
        {
          sizeof (PsppireDataWindowClass),
-         (GBaseInitFunc) psppire_data_window_base_init,
-         (GBaseFinalizeFunc) psppire_data_window_base_finalize,
+         NULL,
+         NULL,
          (GClassInitFunc)psppire_data_window_class_init,
          (GClassFinalizeFunc) NULL,
          NULL,
@@ -120,42 +118,15 @@ 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);
 
-static void
-psppire_data_window_base_finalize (PsppireDataWindowClass *class,
-                                  gpointer class_data)
-{
+  object_class->dispose = psppire_data_window_dispose;
 }
-
-
 \f
 
 
@@ -351,19 +322,18 @@ dump_rm (GtkRecentManager *rm)
 static gboolean
 load_file (PsppireWindow *de, const gchar *file_name)
 {
-  gchar *native_file_name;
+  gchar *utf8_file_name;
   struct string filename;
   gchar *syntax;
   bool ok;
 
   ds_init_empty (&filename);
 
-  native_file_name =
-    convert_glib_filename_to_system_filename (file_name, NULL);
+  utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
 
-  syntax_gen_string (&filename, ss_cstr (native_file_name));
+  syntax_gen_string (&filename, ss_cstr (utf8_file_name));
 
-  g_free (native_file_name);
+  g_free (utf8_file_name);
 
   syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
   ds_destroy (&filename);
@@ -496,7 +466,7 @@ name_has_suffix (const gchar *name)
 static void
 save_file (PsppireWindow *w)
 {
-  gchar *native_file_name = NULL;
+  gchar *utf8_file_name = NULL;
   gchar *file_name = NULL;
   GString *fnx;
   struct string filename ;
@@ -517,13 +487,12 @@ save_file (PsppireWindow *w)
 
   ds_init_empty (&filename);
 
-  native_file_name =
-    convert_glib_filename_to_system_filename (fnx->str, NULL);
+  utf8_file_name = g_filename_to_utf8 (fnx->str, -1, NULL, NULL, NULL);
 
   g_string_free (fnx, TRUE);
 
-  syntax_gen_string (&filename, ss_cstr (native_file_name));
-  g_free (native_file_name);
+  syntax_gen_string (&filename, ss_cstr (utf8_file_name));
+  g_free (utf8_file_name);
 
   syntax = g_strdup_printf ("%s OUTFILE=%s.",
                             de->save_as_portable ? "EXPORT" : "SAVE",
@@ -565,16 +534,16 @@ sysfile_info (PsppireDataWindow *de)
       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 *utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL,
+                                                  NULL);
 
       gchar *syntax;
 
       ds_init_empty (&filename);
 
-      syntax_gen_string (&filename, ss_cstr (native_file_name));
+      syntax_gen_string (&filename, ss_cstr (utf8_file_name));
 
-      g_free (native_file_name);
+      g_free (utf8_file_name);
 
       syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename));
       g_free (execute_syntax_string (syntax));
@@ -940,6 +909,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;
 
@@ -966,7 +941,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);
 
@@ -988,11 +963,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 */
@@ -1246,6 +1216,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)