Replace checkbox-treeview functions with a object PsppireCheckboxTreeview
[pspp] / src / ui / gui / psppire-window.c
index 4eb274b5284805b3cfc8742499d11c1409cd7a26..0a4021f71841585bd02544a07d5103ad32c0a9ee 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2009, 2010, 2011  Free Software Foundation
+   Copyright (C) 2009, 2010, 2011, 2013  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
@@ -17,6 +17,7 @@
 #include <config.h>
 
 #include "psppire-window.h"
+#include "psppire-window-base.h"
 
 #include <gtk/gtk.h>
 
@@ -32,7 +33,6 @@
 #include "data/dataset.h"
 
 #include "helper.h"
-#include "psppire-conf.h"
 #include "psppire-data-window.h"
 #include "psppire-encoding-selector.h"
 #include "psppire-syntax-window.h"
@@ -67,7 +67,7 @@ psppire_window_get_type (void)
       };
 
       psppire_window_type =
-       g_type_register_static (GTK_TYPE_WINDOW, "PsppireWindow",
+       g_type_register_static (PSPPIRE_TYPE_WINDOW_BASE, "PsppireWindow",
                                &psppire_window_info, G_TYPE_FLAG_ABSTRACT);
     }
 
@@ -229,17 +229,6 @@ psppire_window_get_property (GObject         *object,
 }
 
 
-static void
-on_realize (GtkWindow *window, gpointer data)
-{
-  PsppireConf *conf = psppire_conf_new ();
-
-  const gchar *base = G_OBJECT_TYPE_NAME (window);
-
-  psppire_conf_set_window_geometry (conf, base, window);
-}
-
-
 static void
 psppire_window_finalize (GObject *object)
 {
@@ -247,6 +236,8 @@ psppire_window_finalize (GObject *object)
 
   PsppireWindowRegister *reg = psppire_window_register_new ();
 
+  g_signal_handler_disconnect (reg, window->remove_handler);
+  g_signal_handler_disconnect (reg, window->insert_handler);
   psppire_window_register_remove (reg, window->list_name);
   g_free (window->filename);
   g_free (window->basename);
@@ -254,12 +245,6 @@ psppire_window_finalize (GObject *object)
   g_free (window->description);
   g_free (window->list_name);
 
-  g_signal_handler_disconnect (psppire_window_register_new (),
-                              window->remove_handler);
-
-  g_signal_handler_disconnect (psppire_window_register_new (),
-                              window->insert_handler);
-
   g_hash_table_destroy (window->menuitem_table);
 
   if (G_OBJECT_CLASS (parent_class)->finalize)
@@ -351,11 +336,12 @@ insert_menuitem_into_menu (PsppireWindow *window, gpointer key)
 
   /* Add a separator before adding the first real item.  If we add a separator
      at any other time, sometimes GtkUIManager removes it. */
-  if (g_hash_table_size (window->menuitem_table) == 0)
+  if (!window->added_separator)
     {
       GtkWidget *separator = gtk_separator_menu_item_new ();
       gtk_widget_show (separator);
       gtk_menu_shell_append (window->menu, separator);
+      window->added_separator = TRUE;
     }
 
   filename = g_filename_display_name (key);
@@ -423,13 +409,6 @@ on_delete (PsppireWindow *w, GdkEvent *event, gpointer user_data)
 {
   PsppireWindowRegister *reg = psppire_window_register_new ();
 
-  const gchar *base = G_OBJECT_TYPE_NAME (w);
-
-  PsppireConf *conf = psppire_conf_new ();
-
-  psppire_conf_save_window_geometry (conf, base, GTK_WINDOW (w));
-
-
   if ( w->dirty )
     {
       gint response = psppire_window_query_save (w);
@@ -485,14 +464,12 @@ psppire_window_init (PsppireWindow *window)
                                             G_CALLBACK (remove_menuitem),
                                             window);
 
+  window->added_separator = FALSE;
   window->dirty = FALSE;
 
   g_signal_connect_swapped (window, "delete-event", G_CALLBACK (on_delete), window);
 
   g_object_set (window, "icon-name", "pspp", NULL);
-
-  g_signal_connect (window, "realize",
-                   G_CALLBACK (on_realize), window);
 }
 
 /*
@@ -683,7 +660,7 @@ psppire_window_save_as (PsppireWindow *w)
 static void delete_recent (const char *file_name);
 
 gboolean
-psppire_window_load (PsppireWindow *w, const gchar *file)
+psppire_window_load (PsppireWindow *w, const gchar *file, gpointer hint)
 {
   gboolean ok;
   PsppireWindowIface *i = PSPPIRE_WINDOW_MODEL_GET_IFACE (w);
@@ -694,7 +671,7 @@ psppire_window_load (PsppireWindow *w, const gchar *file)
 
   g_return_val_if_fail (i->load, FALSE);
 
-  ok = i->load (w, file);
+  ok = i->load (w, file, hint);
 
   if ( ok )
     {
@@ -827,7 +804,7 @@ psppire_window_open (PsppireWindow *de)
           gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog)));
 
        if (any_reader_may_open (sysname))
-          open_data_window (de, name);
+          open_data_window (de, name, NULL);
        else
          open_syntax_window (name, encoding);