From: Ben Pfaff Date: Wed, 17 Jun 2009 05:38:52 +0000 (-0700) Subject: output: Implement very rudimentary graphical GUI output for PSPPIRE. X-Git-Tag: v0.7.3~31 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f633dff560960ab2c7d25108ec591d4db7a612a3;p=pspp-builds.git output: Implement very rudimentary graphical GUI output for PSPPIRE. It's quick and dirty and lacks many important features (such as scrolling, and not leaking memory), but it does look a lot better than a text editor window. --- diff --git a/src/output/cairo.c b/src/output/cairo.c index 8da63817..f99f7f1d 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -16,6 +16,8 @@ #include +#include + #include #include #include @@ -102,29 +104,36 @@ struct xr_font /* Cairo output driver extension record. */ struct xr_driver_ext { - char *file_name; /* Output file name. */ - enum xr_output_type file_type; /* Type of output file. */ cairo_t *cairo; + struct xr_font fonts[OUTP_FONT_CNT]; bool draw_headers; /* Draw headers at top of page? */ int page_number; /* Current page number. */ + int line_gutter; /* Space around lines. */ + int line_space; /* Space between lines. */ + int line_width; /* Width of lines. */ + }; + +struct xr_driver_options + { + struct outp_driver *driver; + + char *file_name; /* Output file name. */ + enum xr_output_type file_type; /* Type of output file. */ + + bool portrait; /* Portrait mode? */ + int paper_width; /* Width of paper before dropping margins. */ int paper_length; /* Length of paper before dropping margins. */ int left_margin; /* Left margin in XR units. */ int right_margin; /* Right margin in XR units. */ int top_margin; /* Top margin in XR units. */ int bottom_margin; /* Bottom margin in XR units. */ - - int line_gutter; /* Space around lines. */ - int line_space; /* Space between lines. */ - int line_width; /* Width of lines. */ - - struct xr_font fonts[OUTP_FONT_CNT]; }; -static bool handle_option (void *this, const char *key, +static bool handle_option (void *options, const char *key, const struct string *val); static void draw_headers (struct outp_driver *this); @@ -134,34 +143,18 @@ static int text_width (struct outp_driver *, const char *, enum outp_font); /* Driver initialization. */ -static bool -xr_open_driver (const char *name, int types, struct substring options) +static struct outp_driver * +xr_allocate (const char *name, int types) { - cairo_surface_t *surface; - cairo_status_t status; struct outp_driver *this; struct xr_driver_ext *x; - double width_pt, length_pt; size_t i; this = outp_allocate_driver (&cairo_class, name, types); this->width = this->length = 0; this->font_height = XR_POINT * 10; - - this->ext = x = xmalloc (sizeof *x); - x->file_name = xstrdup ("pspp.pdf"); - x->file_type = XR_PDF; - x->draw_headers = true; - x->page_number = 0; - x->portrait = true; - outp_get_paper_size ("", &x->paper_width, &x->paper_length); - x->left_margin = XR_INCH / 2; - x->right_margin = XR_INCH / 2; - x->top_margin = XR_INCH / 2; - x->bottom_margin = XR_INCH / 2; - x->line_gutter = XR_POINT; - x->line_space = XR_POINT; - x->line_width = XR_POINT / 2; + this->ext = x = xzalloc (sizeof *x); + x->cairo = NULL; x->fonts[OUTP_FIXED].string = xstrdup ("monospace"); x->fonts[OUTP_PROPORTIONAL].string = xstrdup ("serif"); x->fonts[OUTP_EMPHASIS].string = xstrdup ("serif italic"); @@ -172,12 +165,87 @@ xr_open_driver (const char *name, int types, struct substring options) font->metrics = NULL; font->layout = NULL; } + x->draw_headers = true; + x->page_number = 0; + x->line_gutter = XR_POINT; + x->line_space = XR_POINT; + x->line_width = XR_POINT / 2; + + return this; +} + +static bool +xr_set_cairo (struct outp_driver *this, cairo_t *cairo) +{ + struct xr_driver_ext *x = this->ext; + int i; + + x->cairo = cairo; + + cairo_set_line_width (x->cairo, xr_to_pt (x->line_width)); + + for (i = 0; i < OUTP_FONT_CNT; i++) + if (!load_font (this, &x->fonts[i])) + return false; + + this->fixed_width = text_width (this, "0", OUTP_FIXED); + this->prop_em_width = text_width (this, "0", OUTP_PROPORTIONAL); + + this->horiz_line_width[OUTP_L_NONE] = 0; + this->horiz_line_width[OUTP_L_SINGLE] = 2 * x->line_gutter + x->line_width; + this->horiz_line_width[OUTP_L_DOUBLE] = (2 * x->line_gutter + x->line_space + + 2 * x->line_width); + memcpy (this->vert_line_width, this->horiz_line_width, + sizeof this->vert_line_width); + + return true; +} + +struct outp_driver * +xr_create_driver (cairo_t *cairo) +{ + struct outp_driver *this; + + this = xr_allocate ("cairo", 0); + this->width = INT_MAX / 8; + this->length = INT_MAX / 8; + if (!xr_set_cairo (this, cairo)) + { + this->class->close_driver (this); + outp_free_driver (this); + return NULL; + } + return this; +} - outp_parse_options (name, options, handle_option, this); +static bool +xr_open_driver (const char *name, int types, struct substring option_string) +{ + struct outp_driver *this; + struct xr_driver_ext *x; + struct xr_driver_options options; + cairo_surface_t *surface; + cairo_status_t status; + double width_pt, length_pt; - width_pt = x->paper_width / 1000.0; - length_pt = x->paper_length / 1000.0; - if (x->portrait) + this = xr_allocate (name, types); + x = this->ext; + + options.driver = this; + options.file_name = xstrdup ("pspp.pdf"); + options.file_type = XR_PDF; + options.portrait = true; + outp_get_paper_size ("", &options.paper_width, &options.paper_length); + options.left_margin = XR_INCH / 2; + options.right_margin = XR_INCH / 2; + options.top_margin = XR_INCH / 2; + options.bottom_margin = XR_INCH / 2; + + outp_parse_options (this->name, option_string, handle_option, &options); + + width_pt = options.paper_width / 1000.0; + length_pt = options.paper_length / 1000.0; + if (options.portrait) { this->width = pt_to_xr (width_pt); this->length = pt_to_xr (length_pt); @@ -188,16 +256,18 @@ xr_open_driver (const char *name, int types, struct substring options) this->length = pt_to_xr (length_pt); } if (x->draw_headers) - x->top_margin += 3 * this->font_height; - this->width -= x->left_margin + x->right_margin; - this->length -= x->top_margin + x->bottom_margin; - - if (x->file_type == XR_PDF) - surface = cairo_pdf_surface_create (x->file_name, width_pt, length_pt); - else if (x->file_type == XR_PS) - surface = cairo_ps_surface_create (x->file_name, width_pt, length_pt); - else if (x->file_type == XR_SVG) - surface = cairo_svg_surface_create (x->file_name, width_pt, length_pt); + options.top_margin += 3 * this->font_height; + this->width -= options.left_margin + options.right_margin; + this->length -= options.top_margin + options.bottom_margin; + + if (options.file_type == XR_PDF) + surface = cairo_pdf_surface_create (options.file_name, + width_pt, length_pt); + else if (options.file_type == XR_PS) + surface = cairo_ps_surface_create (options.file_name, width_pt, length_pt); + else if (options.file_type == XR_SVG) + surface = cairo_svg_surface_create (options.file_name, + width_pt, length_pt); else NOT_REACHED (); @@ -205,7 +275,7 @@ xr_open_driver (const char *name, int types, struct substring options) if (status != CAIRO_STATUS_SUCCESS) { error (0, 0, _("opening output file \"%s\": %s"), - x->file_name, cairo_status_to_string (status)); + options.file_name, cairo_status_to_string (status)); cairo_surface_destroy (surface); goto error; } @@ -214,13 +284,8 @@ xr_open_driver (const char *name, int types, struct substring options) cairo_surface_destroy (surface); cairo_translate (x->cairo, - xr_to_pt (x->left_margin), - xr_to_pt (x->top_margin)); - cairo_set_line_width (x->cairo, xr_to_pt (x->line_width)); - - for (i = 0; i < OUTP_FONT_CNT; i++) - if (!load_font (this, &x->fonts[i])) - goto error; + xr_to_pt (options.left_margin), + xr_to_pt (options.top_margin)); if (this->length / this->font_height < 15) { @@ -232,22 +297,17 @@ xr_open_driver (const char *name, int types, struct substring options) goto error; } - this->fixed_width = text_width (this, "0", OUTP_FIXED); - this->prop_em_width = text_width (this, "0", OUTP_PROPORTIONAL); - - this->horiz_line_width[OUTP_L_NONE] = 0; - this->horiz_line_width[OUTP_L_SINGLE] = 2 * x->line_gutter + x->line_width; - this->horiz_line_width[OUTP_L_DOUBLE] = (2 * x->line_gutter + x->line_space - + 2 * x->line_width); - memcpy (this->vert_line_width, this->horiz_line_width, - sizeof this->vert_line_width); + if (!xr_set_cairo (this, x->cairo)) + goto error; outp_register_driver (this); + free (options.file_name); return true; error: this->class->close_driver (this); outp_free_driver (this); + free (options.file_name); return false; } @@ -265,12 +325,11 @@ xr_close_driver (struct outp_driver *this) cairo_surface_finish (cairo_get_target (x->cairo)); status = cairo_status (x->cairo); if (status != CAIRO_STATUS_SUCCESS) - error (0, 0, _("writing output file \"%s\": %s"), - x->file_name, cairo_status_to_string (status)); + error (0, 0, _("error writing output file for %s driver: %s"), + this->name, cairo_status_to_string (status)); cairo_destroy (x->cairo); } - free (x->file_name); for (i = 0; i < OUTP_FONT_CNT; i++) free_font (&x->fonts[i]); free (x); @@ -318,10 +377,10 @@ static const struct outp_option option_tab[] = }; static bool -handle_option (void *this_, const char *key, - const struct string *val) +handle_option (void *options_, const char *key, const struct string *val) { - struct outp_driver *this = this_; + struct xr_driver_options *options = options_; + struct outp_driver *this = options->driver; struct xr_driver_ext *x = this->ext; int subcat; char *value = ds_cstr (val); @@ -334,16 +393,16 @@ handle_option (void *this_, const char *key, "driver"), key); break; case output_file_arg: - free (x->file_name); - x->file_name = xstrdup (value); + free (options->file_name); + options->file_name = xstrdup (value); break; case output_type_arg: if (!strcmp (value, "pdf")) - x->file_type = XR_PDF; + options->file_type = XR_PDF; else if (!strcmp (value, "ps")) - x->file_type = XR_PS; + options->file_type = XR_PS; else if (!strcmp (value, "svg")) - x->file_type = XR_SVG; + options->file_type = XR_SVG; else { error (0, 0, _("unknown Cairo output type \"%s\""), value); @@ -351,13 +410,14 @@ handle_option (void *this_, const char *key, } break; case paper_size_arg: - outp_get_paper_size (value, &x->paper_width, &x->paper_length); + outp_get_paper_size (value, + &options->paper_width, &options->paper_length); break; case orientation_arg: if (!strcmp (value, "portrait")) - x->portrait = true; + options->portrait = true; else if (!strcmp (value, "landscape")) - x->portrait = false; + options->portrait = false; else error (0, 0, _("unknown orientation `%s' (valid orientations are " "`portrait' and `landscape')"), value); @@ -384,16 +444,16 @@ handle_option (void *this_, const char *key, switch (subcat) { case 0: - x->left_margin = dimension; + options->left_margin = dimension; break; case 1: - x->right_margin = dimension; + options->right_margin = dimension; break; case 2: - x->top_margin = dimension; + options->top_margin = dimension; break; case 3: - x->bottom_margin = dimension; + options->bottom_margin = dimension; break; case 4: this->font_height = dimension; @@ -777,7 +837,6 @@ xr_text_metrics (struct outp_driver *this, const struct outp_text *t, static void xr_text_draw (struct outp_driver *this, const struct outp_text *t) { - assert (this->page_open); text (this, t, true, NULL, NULL); } diff --git a/src/output/cairo.h b/src/output/cairo.h new file mode 100644 index 00000000..c4f8a813 --- /dev/null +++ b/src/output/cairo.h @@ -0,0 +1,24 @@ +/* PSPP - a program for statistical analysis. + Copyright (C) 2009 Free Software Foundation, Inc. + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef OUTPUT_CAIRO_H +#define OUTPUT_CAIRO_H 1 + +#include + +struct outp_driver *xr_create_driver (cairo_t *); + +#endif /* output/cairo.h */ diff --git a/src/ui/gui/executor.c b/src/ui/gui/executor.c index 9336f7ce..aa2fae51 100644 --- a/src/ui/gui/executor.c +++ b/src/ui/gui/executor.c @@ -104,7 +104,5 @@ execute_syntax (struct getl_interface *sss) som_flush (); - psppire_output_window_reload (); - return retval; } diff --git a/src/ui/gui/output-viewer.glade b/src/ui/gui/output-viewer.glade index 0b709ee4..a396a7a4 100644 --- a/src/ui/gui/output-viewer.glade +++ b/src/ui/gui/output-viewer.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -16,7 +16,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK _File @@ -49,7 +48,6 @@ - False False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK _Edit @@ -131,12 +129,9 @@ GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC - + True - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False - 5 diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index b0eff950..510d1c9e 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 Free Software Foundation + Copyright (C) 2008, 2009 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 @@ -21,6 +21,10 @@ #include "helper.h" #include +#include +#include +#include +#include #include #include "about.h" @@ -106,13 +110,104 @@ psppire_output_window_base_finalize (PsppireOutputWindowClass *class, gpointer class_data) { } - - +/* Output driver class. */ static PsppireOutputWindow *the_output_viewer = NULL; +static gboolean +expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + struct som_entity *entity = g_object_get_data (G_OBJECT (widget), "entity"); + GdkWindow *window = widget->window; + cairo_t *cairo = gdk_cairo_create (GDK_DRAWABLE (window)); + struct outp_driver *driver = xr_create_driver (cairo); /* XXX can fail */ + struct tab_table *t = entity->ext; + void *rendering; + + rendering = entity->class->render_init (entity, driver, tab_l (t), + tab_r (t), tab_t (t), tab_b (t)); + + entity->class->title (rendering, 0, 0, + entity->table_num, entity->subtable_num); + entity->class->render (rendering, tab_l (t), tab_t (t), + tab_nc (t) - tab_r (t), + tab_nr (t) - tab_b (t)); + + entity->class->render_free (rendering); + driver->class->close_driver (driver); + outp_free_driver (driver); + return TRUE; +} + +static void +psppire_output_submit (struct outp_driver *this, struct som_entity *entity) +{ + if (the_output_viewer == NULL) + { + the_output_viewer = PSPPIRE_OUTPUT_WINDOW (psppire_output_window_new ()); + gtk_widget_show_now (GTK_WIDGET (the_output_viewer)); + } + + if (entity->type == SOM_TABLE) + { + GdkWindow *window = GTK_WIDGET (the_output_viewer)->window; + cairo_t *cairo = gdk_cairo_create (GDK_DRAWABLE (window)); + struct outp_driver *driver = xr_create_driver (cairo); /* XXX can fail */ + struct tab_table *t = entity->ext; + GtkWidget *drawing_area; + void *rendering; + int tw, th; + + tab_ref (t); + rendering = entity->class->render_init (entity, driver, tab_l (t), + tab_r (t), tab_t (t), tab_b (t)); + entity->class->area (rendering, &tw, &th); + + drawing_area = gtk_drawing_area_new (); + g_object_set_data (G_OBJECT (drawing_area), + "entity", xmemdup (entity, sizeof *entity)); + gtk_widget_set_size_request (drawing_area, tw / 1024, th / 1024); + gtk_layout_put (the_output_viewer->output, drawing_area, + 0, the_output_viewer->y); + gtk_widget_show (drawing_area); + g_signal_connect (G_OBJECT (drawing_area), "expose_event", + G_CALLBACK (expose_event_callback), NULL); + + entity->class->render_free (rendering); + driver->class->close_driver (driver); + outp_free_driver (driver); + + the_output_viewer->y += th / 1024; + } + + gtk_window_set_urgency_hint (GTK_WINDOW (the_output_viewer), TRUE); +} + +static struct outp_class psppire_output_class = + { + "PSPPIRE", /* name */ + true, /* special */ + NULL, /* open_driver */ + NULL, /* close_driver */ + NULL, /* open_page */ + NULL, /* close_page */ + NULL, /* flush */ + psppire_output_submit, /* submit */ + NULL, /* line */ + NULL, /* text_metrics */ + NULL, /* text_draw */ + NULL, /* initialise_chart */ + NULL, /* finalise_chart */ + }; +void +psppire_output_window_setup (void) +{ + outp_register_driver (outp_allocate_driver (&psppire_output_class, + "PSPPIRE", 0)); +} + int viewer_length = 16; int viewer_width = 59; @@ -127,8 +222,6 @@ on_delete (GtkWidget *w, GdkEvent *event, gpointer user_data) the_output_viewer = NULL; - unlink (output_file_name()); - return FALSE; } @@ -139,43 +232,6 @@ cancel_urgency (GtkWindow *window, gpointer data) { gtk_window_set_urgency_hint (window, FALSE); } -/* Sets width and length according to the new size - of the output window */ -static void -on_textview_resize (GtkWidget *widget, - GtkAllocation *allocation, - gpointer user_data) -{ - PangoContext * context ; - PangoLayout *layout ; - PangoRectangle logical; - GtkStyle *style; - gint right_margin, left_margin; - GtkTextView *text_view = GTK_TEXT_VIEW (widget); - - context = gtk_widget_create_pango_context (widget); - layout = pango_layout_new (context); - - style = gtk_widget_get_style (widget); - - pango_layout_set_font_description (layout, style->font_desc); - - /* Find the width of one character. We can use any character, because - the textview has a monospaced font */ - pango_layout_set_text (layout, "M", 1); - - pango_layout_get_extents (layout, NULL, &logical); - - left_margin = gtk_text_view_get_left_margin (text_view); - right_margin = gtk_text_view_get_right_margin (text_view); - - viewer_length = allocation->height / PANGO_PIXELS (logical.height); - viewer_width = (allocation->width - right_margin - left_margin) - / PANGO_PIXELS (logical.width); - - g_object_unref (G_OBJECT (layout)); - g_object_unref (G_OBJECT (context)); -} static void @@ -183,55 +239,18 @@ psppire_output_window_init (PsppireOutputWindow *window) { GtkBuilder *xml = builder_new ("output-viewer.ui"); - GtkWidget *box = gtk_vbox_new (FALSE, 0); - - GtkWidget *sw = get_widget_assert (xml, "scrolledwindow1"); - - GtkWidget *menubar = get_widget_assert (xml, "menubar1"); + gtk_widget_reparent (get_widget_assert (xml, "vbox1"), GTK_WIDGET (window)); - window->textview = get_widget_assert (xml, "output-viewer-textview"); - - - gtk_container_add (GTK_CONTAINER (window), box); - - - g_object_ref (menubar); - gtk_widget_unparent (menubar); - - g_object_ref (sw); - gtk_widget_unparent (sw); - - - gtk_box_pack_start (GTK_BOX (box), menubar, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (box), sw, TRUE, TRUE, 0); - - - gtk_widget_show_all (box); + window->output = GTK_LAYOUT (get_widget_assert (xml, "output")); + window->y = 0; connect_help (xml); - window->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (window->textview)); - g_signal_connect (window, "focus-in-event", G_CALLBACK (cancel_urgency), NULL); - { - /* Output uses ascii characters for tabular material. - So we need a monospaced font otherwise it'll look silly */ - PangoFontDescription *font_desc = - pango_font_description_from_string ("monospace"); - - gtk_widget_modify_font (window->textview, font_desc); - pango_font_description_free (font_desc); - } - - g_signal_connect (window->textview, "size-allocate", - G_CALLBACK (on_textview_resize), NULL); - - window->fp = NULL; - g_signal_connect (get_action_assert (xml,"help_about"), "activate", G_CALLBACK (about_new), @@ -269,108 +288,3 @@ psppire_output_window_new (void) "description", _("Output Viewer"), NULL)); } - -static void reload_viewer (PsppireOutputWindow *ow); - -void -psppire_output_window_reload (void) -{ - struct stat buf; - - /* If there is no output, then don't do anything */ - if (0 != stat (output_file_name(), &buf)) - return ; - - if ( NULL == the_output_viewer ) - { - the_output_viewer = PSPPIRE_OUTPUT_WINDOW (psppire_output_window_new ()); - gtk_widget_show (GTK_WIDGET (the_output_viewer)); - } - - reload_viewer (the_output_viewer); - -} - - -static void -reload_viewer (PsppireOutputWindow *ow) -{ - GtkTextIter end_iter; - GtkTextMark *mark ; - - char *line = NULL; - - gboolean chars_inserted = FALSE; - - gtk_text_buffer_get_end_iter (ow->buffer, &end_iter); - - line = xrealloc (line, sizeof (char) * (viewer_width + 1)); - - mark = gtk_text_buffer_create_mark (ow->buffer, NULL, &end_iter, TRUE); - -#ifdef __CYGWIN__ - /* - Apparently Windoze is not capabale of writing to a file whilst - another (or the same) process is reading from it. Therefore, we - must close the file after reading it, and clear the entire buffer - before writing to it. - This will be slower for large buffers, but should work - (in so far as anything ever works on windows). - */ - { - GtkTextIter start_iter; - FILE *fp = fopen (output_file_name(), "r"); - if ( !fp) - { - g_critical ("Cannot open %s\n", output_file_name()); - return; - } - - /* Delete all the entire buffer */ - gtk_text_buffer_get_start_iter (ow->buffer, &start_iter); - gtk_text_buffer_delete (ow->buffer, &start_iter, &end_iter); - - - gtk_text_buffer_get_start_iter (ow->buffer, &start_iter); - /* Read in the next lot of text */ - while (fgets (line, viewer_width + 1, fp) != NULL) - { - chars_inserted = TRUE; - gtk_text_buffer_insert (ow->buffer, &start_iter, line, -1); - } - - fclose (fp); - } -#else - { - if ( ow->fp == NULL) - { - ow->fp = fopen (output_file_name(), "r"); - if ( ow->fp == NULL) - { - g_critical ("Cannot open %s\n", output_file_name()); - return; - } - } - - /* Read in the next lot of text */ - while (fgets (line, viewer_width + 1, ow->fp) != NULL) - { - chars_inserted = TRUE; - gtk_text_buffer_insert (ow->buffer, &end_iter, line, -1); - } - } -#endif - - /* Scroll to where the start of this lot of text begins */ - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (ow->textview), - mark, - 0.1, TRUE, 0.0, 0.0); - - - if ( chars_inserted ) - gtk_window_set_urgency_hint ( GTK_WINDOW (ow), TRUE); -} - - - diff --git a/src/ui/gui/psppire-output-window.h b/src/ui/gui/psppire-output-window.h index 621a9e24..7b62be20 100644 --- a/src/ui/gui/psppire-output-window.h +++ b/src/ui/gui/psppire-output-window.h @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008 Free Software Foundation + Copyright (C) 2008, 2009 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 @@ -30,10 +30,6 @@ extern int viewer_length; extern int viewer_width ; -#define OUTPUT_FILE_NAME "psppire.txt" - - - G_BEGIN_DECLS #define PSPPIRE_OUTPUT_WINDOW_TYPE (psppire_output_window_get_type ()) @@ -55,9 +51,8 @@ struct _PsppireOutputWindow PsppireWindow parent; /* */ - GtkTextBuffer *buffer; /* The buffer which contains the text */ - GtkWidget *textview ; - FILE *fp; /* The file it's viewing */ + GtkLayout *output; + int y; }; struct _PsppireOutputWindowClass @@ -69,9 +64,7 @@ struct _PsppireOutputWindowClass GType psppire_output_window_get_type (void); GtkWidget* psppire_output_window_new (void); - -void psppire_output_window_reload (void); - +void psppire_output_window_setup (void); G_END_DECLS diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 3555463f..928a1c92 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -121,25 +121,7 @@ initialize (struct command_line_processor *clp, int argc, char **argv) create_icon_factory (); - { - const char *filename = output_file_name (); - - struct string config_string; - - ds_init_empty (&config_string); - - ds_put_format (&config_string, - "gui:ascii:screen:squeeze=on headers=off top-margin=0 " - "bottom-margin=0 paginate=off length=auto width=auto " - "emphasis=none " - "output-file=\"%s\" append=yes", filename); - - outp_configure_driver_line (ds_ss (&config_string)); - - unlink (filename); - - ds_destroy (&config_string); - } + psppire_output_window_setup (); journal_enable (); textdomain (PACKAGE); @@ -339,16 +321,3 @@ parse_non_options (int key, char *arg, struct argp_state *state) const struct argp non_option_argp = {NULL, parse_non_options, 0, 0, 0, 0, 0}; - - -const char * -output_file_name (void) -{ - const char *dir = default_output_path (); - static char *filename = NULL; - - if ( NULL == filename ) - filename = xasprintf ("%s%s", dir, OUTPUT_FILE_NAME); - - return filename; -}