Merge 'master' into 'psppsheet'.
[pspp] / src / ui / gui / psppire-output-window.c
index 99a11ed52d9fe84e8c84e27e43183f25535c7f8e..d1d7e89166154b849352028d9858ab1a5ab4267b 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2008, 2009, 2010, 2011  Free Software Foundation
+   Copyright (C) 2008, 2009, 2010, 2011, 2012  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include "output/table-item.h"
 #include "output/text-item.h"
 #include "ui/gui/help-menu.h"
-#include "ui/gui/helper.h"
+#include "ui/gui/builder-wrapper.h"
 #include "ui/gui/psppire-output-window.h"
 
 #include "gl/error.h"
 #include "gl/tmpdir.h"
 #include "gl/xalloc.h"
+#include "gl/c-xvasprintf.h"
+
+#include "helper.h"
 
 #include <gettext.h>
 #define _(msgid) gettext (msgid)
@@ -180,10 +183,8 @@ expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
 
   const GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (viewer));
 
-  struct text_item *text_item;
   PangoFontDescription *font_desc;
   char *font_name;
-  int font_width;
   
   gchar *fgc =
     gdk_color_to_string (&style->text[gtk_widget_get_state (GTK_WIDGET (widget))]);
@@ -736,6 +737,12 @@ enum {
   SELECT_FMT_ODT
 };
 
+/* GNU Hurd doesn't have PATH_MAX.  Use a fallback.
+   Temporary directory names are usually not that long.  */
+#ifndef PATH_MAX
+# define PATH_MAX 1024
+#endif
+
 static void
 clipboard_get_cb (GtkClipboard     *clipboard,
                  GtkSelectionData *selection_data,
@@ -949,6 +956,7 @@ psppire_output_window_init (PsppireOutputWindow *window)
   GtkAction *copy_action;
   GtkAction *select_all_action;
   GtkTreeSelection *sel;
+  GtkTreeModel *model;
 
   string_map_init (&window->render_opts);
 
@@ -976,12 +984,13 @@ psppire_output_window_init (PsppireOutputWindow *window)
 
   g_signal_connect (sel, "changed", G_CALLBACK (on_selection_change), copy_action);
 
-  gtk_tree_view_set_model (window->overview,
-                           GTK_TREE_MODEL (gtk_tree_store_new (
+  model = GTK_TREE_MODEL (gtk_tree_store_new (
                                              N_COLS,
                                              G_TYPE_STRING,  /* COL_TITLE */
                                             G_TYPE_POINTER, /* COL_ADDR */
-                                             G_TYPE_LONG))); /* COL_Y */
+                                             G_TYPE_LONG));  /* COL_Y */
+  gtk_tree_view_set_model (window->overview, model);
+  g_object_unref (model);
 
   window->in_command = false;
 
@@ -1041,7 +1050,6 @@ psppire_output_window_new (void)
                                   NULL));
 }
 
-
 \f
 static void
 create_xr_print_driver (GtkPrintContext *context, PsppireOutputWindow *window)
@@ -1064,15 +1072,15 @@ create_xr_print_driver (GtkPrintContext *context, PsppireOutputWindow *window)
 
   string_map_init (&options);
   string_map_insert_nocopy (&options, xstrdup ("paper-size"),
-                            xasprintf("%.2fx%.2fmm", width, height));
+                            c_xasprintf("%.2fx%.2fmm", width, height));
   string_map_insert_nocopy (&options, xstrdup ("left-margin"),
-                            xasprintf ("%.2fmm", left_margin));
+                            c_xasprintf ("%.2fmm", left_margin));
   string_map_insert_nocopy (&options, xstrdup ("right-margin"),
-                            xasprintf ("%.2fmm", right_margin));
+                            c_xasprintf ("%.2fmm", right_margin));
   string_map_insert_nocopy (&options, xstrdup ("top-margin"),
-                            xasprintf ("%.2fmm", top_margin));
+                            c_xasprintf ("%.2fmm", top_margin));
   string_map_insert_nocopy (&options, xstrdup ("bottom-margin"),
-                            xasprintf ("%.2fmm", bottom_margin));
+                            c_xasprintf ("%.2fmm", bottom_margin));
 
   window->print_xrd =
     xr_driver_create (gtk_print_context_get_cairo_context (context), &options);