gui: Recode syntax files on load and save.
[pspp] / src / ui / gui / psppire-data-window.c
index 3698a7af3f1b5fe1efd6bb59b32f9947a931c997..604bd566a5ff2f1bcd7c8707082cc56567f81083 100644 (file)
@@ -63,6 +63,7 @@
 #include "ui/gui/weight-cases-dialog.h"
 #include "ui/syntax-gen.h"
 
+#include "gl/c-strcase.h"
 #include "gl/xvasprintf.h"
 
 #include <gettext.h>
@@ -152,9 +153,6 @@ psppire_data_window_class_init (PsppireDataWindowClass *class)
                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 }
 \f
-
-extern GtkRecentManager *the_recent_mgr;
-
 static void
 set_paste_menuitem_sensitivity (PsppireDataWindow *de, gboolean x)
 {
@@ -337,6 +335,26 @@ dump_rm (GtkRecentManager *rm)
 }
 #endif
 
+static gboolean
+name_has_por_suffix (const gchar *name)
+{
+  size_t length = strlen (name);
+  return length > 4 && !c_strcasecmp (&name[length - 4], ".por");
+}
+
+static gboolean
+name_has_sav_suffix (const gchar *name)
+{
+  size_t length = strlen (name);
+  return length > 4 && !c_strcasecmp (&name[length - 4], ".sav");
+}
+
+/* Returns true if NAME has a suffix which might denote a PSPP file */
+static gboolean
+name_has_suffix (const gchar *name)
+{
+  return name_has_por_suffix (name) || name_has_sav_suffix (name);
+}
 
 static gboolean
 load_file (PsppireWindow *de, const gchar *file_name)
@@ -363,21 +381,6 @@ load_file (PsppireWindow *de, const gchar *file_name)
   return ok;
 }
 
-/* Returns true if NAME has a suffix which might denote a PSPP file */
-static gboolean
-name_has_suffix (const gchar *name)
-{
-  if ( g_str_has_suffix (name, ".sav"))
-    return TRUE;
-  if ( g_str_has_suffix (name, ".SAV"))
-    return TRUE;
-  if ( g_str_has_suffix (name, ".por"))
-    return TRUE;
-  if ( g_str_has_suffix (name, ".POR"))
-    return TRUE;
-
-  return FALSE;
-}
 
 
 /* Save DE to file */
@@ -767,7 +770,7 @@ on_recent_files_select (GtkMenuShell *menushell,   gpointer user_data)
 
   g_free (uri);
 
-  se = psppire_syntax_window_new ();
+  se = psppire_syntax_window_new (NULL);
 
   if ( psppire_window_load (PSPPIRE_WINDOW (se), file) ) 
     gtk_widget_show (se);
@@ -1073,11 +1076,11 @@ psppire_data_window_finish_init (PsppireDataWindow *de,
       gtk_ui_manager_get_widget (uim,"/ui/menubar/file/file_recent-files");
 
 
-    GtkWidget *menu_data =
-      gtk_recent_chooser_menu_new_for_manager (the_recent_mgr);
+    GtkWidget *menu_data = gtk_recent_chooser_menu_new_for_manager (
+      gtk_recent_manager_get_default ());
 
-    GtkWidget *menu_files =
-      gtk_recent_chooser_menu_new_for_manager (the_recent_mgr);
+    GtkWidget *menu_files = gtk_recent_chooser_menu_new_for_manager (
+      gtk_recent_manager_get_default ());
 
     {
       GtkRecentFilter *filter = gtk_recent_filter_new ();