Allow translation of default filenames in GUI
[pspp] / src / ui / gui / psppire-output-window.c
index b2ea1103ea4c5eecfe77449560933e0c9182e4bd..9886810f1134f109d7cc5496ad36f5876e587090 100644 (file)
 
 #include <config.h>
 
-#include <gtk/gtksignal.h>
-#include <gtk/gtkbox.h>
-#include "helper.h"
-
-#include <libpspp/cast.h>
-#include <libpspp/message.h>
-#include <libpspp/string-map.h>
-#include <output/cairo.h>
-#include <output/chart-item.h>
-#include <output/driver-provider.h>
-#include <output/output-item.h>
-#include <output/table-item.h>
-#include <output/text-item.h>
-#include <output/tab.h>
+#include <errno.h>
+#include <gtk/gtk.h>
 #include <stdlib.h>
-
-#include "help-menu.h"
-
-#include "psppire-output-window.h"
-
-
-#include "xalloc.h"
-
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
 
+#include "libpspp/cast.h"
+#include "libpspp/message.h"
+#include "libpspp/string-map.h"
+#include "output/cairo.h"
+#include "output/chart-item.h"
+#include "output/driver-provider.h"
+#include "output/output-item.h"
+#include "output/tab.h"
+#include "output/table-item.h"
+#include "output/text-item.h"
+#include "ui/gui/help-menu.h"
+#include "ui/gui/helper.h"
+#include "ui/gui/psppire-output-window.h"
+
+#include "gl/error.h"
+#include "gl/tmpdir.h"
+#include "gl/xalloc.h"
+
 #include <gettext.h>
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
@@ -245,7 +243,6 @@ psppire_output_submit (struct output_driver *this,
          it is already close enough to INT_MAX when expressed as thousands of a
          point.) */
       string_map_insert (&options, "paper-size", "300x200000mm");
-      string_map_insert (&options, "headers", "off");
       string_map_insert (&options, "left-margin", "0");
       string_map_insert (&options, "right-margin", "0");
       string_map_insert (&options, "top-margin", "0");
@@ -455,7 +452,7 @@ enum
 #define N_EXTENTIONS (n_FT - 1)
 
 struct file_types ft[n_FT] = {
-  {N_("Infer file type from extention"),  NULL},
+  {N_("Infer file type from extension"),  NULL},
   {N_("PDF (*.pdf)"),                     ".pdf"},
   {N_("HTML (*.html)"),                   ".html"},
   {N_("OpenDocument (*.odt)"),            ".odt"},
@@ -801,7 +798,7 @@ clipboard_get_cb (GtkClipboard     *clipboard,
   gsize length;
   gchar *text = NULL;
   struct output_driver *driver = NULL;
-  char *filename = NULL;
+  char dirname[PATH_MAX], *filename;
   struct string_map options;
 
   GtkTreeSelection *sel = gtk_tree_view_get_selection (window->overview);
@@ -813,8 +810,15 @@ clipboard_get_cb (GtkClipboard     *clipboard,
   if ( n == NULL)
     return;
 
+  if (path_search (dirname, sizeof dirname, NULL, NULL, true)
+      || mkdtemp (dirname) == NULL)
+    {
+      error (0, errno, _("failed to create temporary directory"));
+      return;
+    }
+  filename = xasprintf ("%s/clip.tmp", dirname);
+
   string_map_init (&options);
-  filename = tempnam (NULL, NULL);
   string_map_insert (&options, "output-file", filename);
 
   switch (info)
@@ -884,6 +888,7 @@ clipboard_get_cb (GtkClipboard     *clipboard,
 
   unlink (filename);
   free (filename);
+  rmdir (dirname);
 
   g_list_free (rows);
 }
@@ -1038,7 +1043,8 @@ GtkWidget*
 psppire_output_window_new (void)
 {
   return GTK_WIDGET (g_object_new (psppire_output_window_get_type (),
-                                  "filename", "Output",
+                                  /* TRANSLATORS: This will form a filename.  Please avoid whitespace. */
+                                  "filename", _("Output"),
                                   "description", _("Output Viewer"),
                                   NULL));
 }