gui: Make File|Recently Used Data behave like File|Open.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 9 May 2011 04:52:08 +0000 (21:52 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 10 May 2011 04:34:22 +0000 (21:34 -0700)
File|Open opens a new dataset if the current one is non-empty.  Due
to an oversight, File|Recently Used Data always replaced the current
dataset.  This commit makes File|Recently Used Data work just like
File|Open.

src/ui/gui/psppire-data-window.c
src/ui/gui/psppire-data-window.h
src/ui/gui/psppire-window.c

index c3886e1dfcf7855336becfe4a7236b477aed4192..3698a7af3f1b5fe1efd6bb59b32f9947a931c997 100644 (file)
@@ -748,7 +748,7 @@ on_recent_data_select (GtkMenuShell *menushell,
 
   g_free (uri);
 
-  psppire_window_load (window, file);
+  open_data_window (window, file);
 
   g_free (file);
 }
@@ -1347,3 +1347,18 @@ create_data_window (void)
 {
   gtk_widget_show (psppire_data_window_new (NULL));
 }
+
+void
+open_data_window (PsppireWindow *victim, const char *file_name)
+{
+  GtkWidget *window;
+
+  if (PSPPIRE_IS_DATA_WINDOW (victim)
+      && psppire_data_window_is_empty (PSPPIRE_DATA_WINDOW (victim)))
+    window = GTK_WIDGET (victim);
+  else
+    window = psppire_data_window_new (NULL);
+
+  psppire_window_load (PSPPIRE_WINDOW (window), file_name);
+  gtk_widget_show (window);
+}
index 64fe076dc7417a8a1dc78dda66085e7ffff3fd32..93b51b0cee9aa7e5f7e973672869de8dd923e620 100644 (file)
@@ -89,6 +89,7 @@ PsppireDataWindow *psppire_data_window_for_dataset (struct dataset *);
 
 bool psppire_data_window_is_empty (PsppireDataWindow *);
 void create_data_window (void);
+void open_data_window (PsppireWindow *victim, const char *file_name);
 
 G_END_DECLS
 
index f294364502aeccfe47409bb6c9b9ae390be077d9..a2bf672e0d3704d9ad630fcba69dbb08a22632f8 100644 (file)
@@ -821,18 +821,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);