X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-output-window.c;h=cf65a2f9e6c518c7dbd7b6581a0808b10ea06c92;hb=27e94a1fb74828d4289110ad8b66e8b3eb8bc55e;hp=b2ea1103ea4c5eecfe77449560933e0c9182e4bd;hpb=933040005343d87414f14c48c90dfaa92110dc0a;p=pspp-builds.git diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index b2ea1103..cf65a2f9 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008, 2009, 2010 Free Software Foundation + Copyright (C) 2008, 2009, 2010, 2011 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 @@ -16,33 +16,32 @@ #include -#include -#include -#include "helper.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include - -#include "help-menu.h" - -#include "psppire-output-window.h" - - -#include "xalloc.h" - -#include #include +#include #include +#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/message-item.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 #define _(msgid) gettext (msgid) #define N_(msgid) msgid @@ -111,7 +110,8 @@ psppire_output_window_dispose (GObject *obj) viewer->items = NULL; viewer->n_items = viewer->allocated_items = 0; - g_object_unref (viewer->print_settings); + if (viewer->print_settings != NULL) + g_object_unref (viewer->print_settings); /* Chain up to the parent class */ G_OBJECT_CLASS (parent_class)->dispose (obj); @@ -150,6 +150,7 @@ struct psppire_output_driver struct output_driver driver; PsppireOutputWindow *viewer; struct xr_driver *xr; + int font_height; }; static struct output_driver_class psppire_output_class; @@ -223,8 +224,10 @@ psppire_output_submit (struct output_driver *this, { const GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (viewer)); struct string_map options = STRING_MAP_INITIALIZER (options); + struct text_item *text_item; PangoFontDescription *font_desc; char *font_name; + int font_width; /* Use GTK+ default font as proportional font. */ font_name = pango_font_description_to_string (style->font_desc); @@ -245,7 +248,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"); @@ -254,7 +256,15 @@ psppire_output_submit (struct output_driver *this, pod->xr = xr_driver_create (cr, &options); string_map_destroy (&options); + + text_item = text_item_create (TEXT_ITEM_PARAGRAPH, "X"); + r = xr_rendering_create (pod->xr, text_item_super (text_item), cr); + xr_rendering_measure (r, &font_width, &pod->font_height); + /* xr_rendering_destroy (r); */ + text_item_unref (text_item); } + else + pod->viewer->y += pod->font_height / 2; r = xr_rendering_create (pod->xr, item, cr); if (r == NULL) @@ -296,6 +306,13 @@ psppire_output_submit (struct output_driver *this, ds_clear (&title); if (is_text_item (item)) ds_put_cstr (&title, text_item_get_text (to_text_item (item))); + else if (is_message_item (item)) + { + const struct message_item *msg_item = to_message_item (item); + const struct msg *msg = message_item_get_msg (msg_item); + ds_put_format (&title, "%s: %s", _("Message"), + msg_severity_to_string (msg->severity)); + } else if (is_table_item (item)) { const char *caption = table_item_get_caption (to_table_item (item)); @@ -455,7 +472,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"}, @@ -474,7 +491,7 @@ on_combo_change (GtkFileChooser *chooser) int x = 0; gchar *fn = gtk_file_chooser_get_filename (chooser); - if (combo && GTK_WIDGET_REALIZED (combo)) + if (combo && gtk_widget_get_realized (combo)) x = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); if (fn == NULL) @@ -510,7 +527,7 @@ on_file_chooser_change (GObject *w, GParamSpec *pspec, gpointer data) GtkFileChooser *chooser = data; const gchar *name = g_param_spec_get_name (pspec); - if ( ! GTK_WIDGET_REALIZED (chooser)) + if ( ! gtk_widget_get_realized (GTK_WIDGET (chooser))) return; /* Ignore this one. It causes recursion. */ @@ -801,7 +818,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 +830,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 +908,7 @@ clipboard_get_cb (GtkClipboard *clipboard, unlink (filename); free (filename); + rmdir (dirname); g_list_free (rows); } @@ -1038,7 +1063,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)); }