gui: Use dispose instead of finalize method in PsppireDataWindow.
[pspp-builds.git] / src / ui / gui / psppire-data-window.c
index 9a3470ae4df8e90fea20069019d638ae3d95b39c..9edc9208ac86a9c3db353e45753d38095da6d08a 100644 (file)
 
 
 
-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 +87,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 +119,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 +323,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 +467,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 +488,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 +535,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));
@@ -1247,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)