gui: Move null_if_empty_param() from psppire-window to helper.
[pspp-builds.git] / src / ui / gui / psppire-window.c
index 8a33c006162b01fee477a777ff547d112f586ddb..fbb91a78cc0f4edd45cacb5c83a56f3fe2de2343 100644 (file)
@@ -271,18 +271,6 @@ psppire_window_finalize (GObject *object)
     G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
-static GParamSpec *
-null_if_empty_param (const gchar *name, const gchar *nick,
-                     const gchar *blurb, const gchar *default_value,
-                     GParamFlags flags)
-{
-  GParamSpec *param;
-
-  param = g_param_spec_string (name, nick, blurb, default_value, flags);
-  ((GParamSpecString *) param)->null_fold_if_empty = TRUE;
-  return param;
-}
-
 static void
 psppire_window_class_init (PsppireWindowClass *class)
 {
@@ -703,10 +691,9 @@ psppire_window_save_as (PsppireWindow *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);
+static void add_most_recent (const char *file_name);
+static void delete_recent (const char *file_name);
 
 gboolean
 psppire_window_load (PsppireWindow *w, const gchar *file)
@@ -725,13 +712,11 @@ psppire_window_load (PsppireWindow *w, const gchar *file)
   if ( ok )
     {
       psppire_window_set_filename (w, file);
-      add_most_recent (file, the_recent_mgr);
+      add_most_recent (file);
       w->dirty = FALSE;
     }
   else
-    delete_recent (file, the_recent_mgr);
-
-  psppire_window_set_title (w);
+    delete_recent (file);
 
   return ok;
 }
@@ -823,18 +808,7 @@ psppire_window_open (PsppireWindow *de)
        gchar *sysname = convert_glib_filename_to_system_filename (name, NULL);
 
        if (any_reader_may_open (sysname))
-          {
-            PsppireWindow *window;
-
-            if (PSPPIRE_IS_DATA_WINDOW (de)
-                && psppire_data_window_is_empty (PSPPIRE_DATA_WINDOW (de)))
-              window = de;
-            else
-              window = PSPPIRE_WINDOW (psppire_data_window_new (NULL));
-
-            psppire_window_load (window, name);
-            gtk_widget_show (GTK_WIDGET (window));
-          }
+          open_data_window (de, name);
        else
          open_syntax_window (name);
 
@@ -854,12 +828,12 @@ psppire_window_open (PsppireWindow *de)
    If it's already in the list, it moves it to the top
 */
 static void
-add_most_recent (const char *file_name, GtkRecentManager *rm)
+add_most_recent (const char *file_name)
 {
   gchar *uri = g_filename_to_uri  (file_name, NULL, NULL);
 
   if ( uri )
-    gtk_recent_manager_add_item (rm, uri);
+    gtk_recent_manager_add_item (gtk_recent_manager_get_default (), uri);
 
   g_free (uri);
 }
@@ -870,12 +844,12 @@ add_most_recent (const char *file_name, GtkRecentManager *rm)
    If FILE_NAME exists in the recent list, then  delete it.
  */
 static void
-delete_recent (const char *file_name, GtkRecentManager *rm)
+delete_recent (const char *file_name)
 {
   gchar *uri = g_filename_to_uri  (file_name, NULL, NULL);
 
   if ( uri )
-    gtk_recent_manager_remove_item (rm, uri, NULL);
+    gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, NULL);
 
   g_free (uri);
 }