Remove some unused variables
[pspp-builds.git] / src / ui / gui / psppire-window.c
index 5de6afd84a8e416ea23275d7c04a5cc151917670..576d3159deceb63bcc5be797607eb2ed8f0b6412 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <config.h>
 
+
 #include <gtk/gtkstock.h>
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtksignal.h>
@@ -39,7 +40,6 @@ static void psppire_window_class_init    (PsppireWindowClass *class);
 static void psppire_window_init          (PsppireWindow      *window);
 
 
-static PsppireWindowClass *the_class;
 static GObjectClass *parent_class;
 
 GType
@@ -194,42 +194,22 @@ psppire_window_get_property (GObject         *object,
 static void
 on_realize (GtkWindow *window, gpointer data)
 {
-  gint height, width;
-  gint x, y;
-
   PsppireConf *conf = psppire_conf_new ();
 
   const gchar *base = G_OBJECT_TYPE_NAME (window);
 
-  if (psppire_conf_get_int (conf, base, "height", &height)
-      &&
-      psppire_conf_get_int (conf, base, "width", &width) )
-    {
-      gtk_window_set_default_size (window, width, height);
-    }
-
-
-  if ( psppire_conf_get_int (conf, base, "x", &x)
-       &&
-       psppire_conf_get_int (conf, base, "x", &y) )
-    {
-      gtk_window_move (window, x, y);
-    }
-
+  psppire_conf_set_window_geometry (conf, base, window);
 }
 
 
 static gboolean
-on_configure (GtkWidget *w, GdkEventConfigure *event, gpointer data)
+on_configure (GtkWidget *window, GdkEventConfigure *event, gpointer data)
 {
-  const gchar *base = G_OBJECT_TYPE_NAME (w);
+  const gchar *base = G_OBJECT_TYPE_NAME (window);
 
   PsppireConf *conf = psppire_conf_new ();
 
-  psppire_conf_set_int (conf, base, "height", event->height);
-  psppire_conf_set_int (conf, base, "width", event->width);
-  psppire_conf_set_int (conf, base, "x", event->x);
-  psppire_conf_set_int (conf, base, "y", event->y);
+  psppire_conf_save_window_geometry (conf, base, event);
 
   return FALSE;
 }
@@ -291,7 +271,6 @@ psppire_window_class_init (PsppireWindowClass *class)
                                    PROP_FILENAME,
                                    filename_spec);
 
-  the_class = class;
   parent_class = g_type_class_peek_parent (class);
 }
 
@@ -597,11 +576,40 @@ psppire_window_save (PsppireWindow *w)
   i->save (w);
 }
 
+extern GtkRecentManager *the_recent_mgr;
+
+static void add_most_recent (const char *file_name, GtkRecentManager *rm);
+static void delete_recent (const char *file_name, GtkRecentManager *rm);
+
+gboolean
+psppire_window_load (PsppireWindow *w, const gchar *file)
+{
+  gboolean ok;
+  PsppireWindowIface *i = PSPPIRE_WINDOW_MODEL_GET_IFACE (w);
+
+  g_assert (PSPPIRE_IS_WINDOW_MODEL (w));
+
+  g_assert (i);
+
+  g_return_val_if_fail (i->load, FALSE);
+
+  ok =  i->load (w, file);
+
+  if ( ok )
+    add_most_recent (file, the_recent_mgr);
+  else
+    delete_recent (file, the_recent_mgr);
+
+  psppire_window_set_unsaved (w, FALSE);
+
+  return ok;
+}
+
 
 /* Puts FILE_NAME into the recent list.
    If it's already in the list, it moves it to the top
 */
-void
+static void
 add_most_recent (const char *file_name, GtkRecentManager *rm)
 {
   gchar *uri = g_filename_to_uri  (file_name, NULL, NULL);
@@ -612,3 +620,20 @@ add_most_recent (const char *file_name, GtkRecentManager *rm)
   g_free (uri);
 }
 
+
+
+/* 
+   If FILE_NAME exists in the recent list, then  delete it.
+ */
+static void
+delete_recent (const char *file_name, GtkRecentManager *rm)
+{
+  gchar *uri = g_filename_to_uri  (file_name, NULL, NULL);
+
+  if ( uri )
+    gtk_recent_manager_remove_item (rm, uri, NULL);
+
+  g_free (uri);
+  
+}
+