From: Ben Pfaff Date: Sat, 13 Sep 2014 23:55:19 +0000 (-0700) Subject: output: Rename caption to title. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=5b5099296b3c7212623991de8920e1459e234922 output: Rename caption to title. This brings PSPP a small step closer to the table model that SPSS uses, which allows for a brief title above the table and a more verbose caption below it. --- diff --git a/src/output/csv.c b/src/output/csv.c index d2f2ac3b63..2784b24998 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -46,7 +46,7 @@ struct csv_driver char *separator; /* Field separator (usually comma or tab). */ int quote; /* Quote character (usually ' or ") or 0. */ char *quote_set; /* Characters that force quoting. */ - bool captions; /* Print table captions? */ + bool titles; /* Print table titles? */ char *file_name; /* Output file name. */ char *command_name; /* Current command. */ @@ -87,7 +87,7 @@ csv_create (const char *file_name, enum settings_output_devices device_type, csv->quote = quote[0]; free (quote); csv->quote_set = xasprintf ("\n\r\t%s%c", csv->separator, csv->quote); - csv->captions = parse_boolean (opt (d, o, "captions", "true")); + csv->titles = parse_boolean (opt (d, o, "titles", "true")); csv->file_name = xstrdup (file_name); csv->file = fn_open (csv->file_name, "w"); csv->n_items = 0; @@ -189,12 +189,12 @@ csv_output_subtable (struct csv_driver *csv, struct string *s, const struct table_item *item) { const struct table *t = table_item_get_table (item); - const char *caption = table_item_get_caption (item); + const char *title = table_item_get_title (item); int y, x; - if (csv->captions && caption != NULL) + if (csv->titles && title != NULL) { - csv_output_field_format (csv, "Table: %s", caption); + csv_output_field_format (csv, "Table: %s", title); putc ('\n', csv->file); } @@ -259,16 +259,16 @@ csv_submit (struct output_driver *driver, if (is_table_item (output_item)) { struct table_item *table_item = to_table_item (output_item); - const char *caption = table_item_get_caption (table_item); + const char *title = table_item_get_title (table_item); const struct table *t = table_item_get_table (table_item); int footnote_idx; int x, y; csv_put_separator (csv); - if (csv->captions && caption != NULL) + if (csv->titles && title != NULL) { - csv_output_field_format (csv, "Table: %s", caption); + csv_output_field_format (csv, "Table: %s", title); putc ('\n', csv->file); } diff --git a/src/output/html.c b/src/output/html.c index 19d1085e41..715682a9ea 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -377,7 +377,7 @@ static void html_output_table (struct html_driver *html, const struct table_item *item) { const struct table *t = table_item_get_table (item); - const char *caption = table_item_get_caption (item); + const char *title = table_item_get_title (item); int footnote_idx = 0; int y; @@ -428,10 +428,10 @@ html_output_table (struct html_driver *html, const struct table_item *item) fputs ("\n", html->file); - if (caption != NULL) + if (title != NULL) { fputs (" ", html->file); - escape_string (html->file, caption, strlen (caption), " ", "
"); + escape_string (html->file, title, strlen (title), " ", "
"); fputs ("\n", html->file); } diff --git a/src/output/odt.c b/src/output/odt.c index d0860585cd..21aaeb6c1a 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -454,17 +454,17 @@ static void write_table (struct odt_driver *odt, const struct table_item *item) { const struct table *tab = table_item_get_table (item); - const char *caption = table_item_get_caption (item); + const char *title = table_item_get_title (item); int r, c; /* Write a heading for the table */ - if (caption != NULL) + if (title != NULL) { xmlTextWriterStartElement (odt->content_wtr, _xml("text:h")); xmlTextWriterWriteFormatAttribute (odt->content_wtr, _xml("text:outline-level"), "%d", 2); xmlTextWriterWriteString (odt->content_wtr, - _xml (table_item_get_caption (item)) ); + _xml (table_item_get_title (item)) ); xmlTextWriterEndElement (odt->content_wtr); } diff --git a/src/output/render.c b/src/output/render.c index f41f504df0..84eef66795 100644 --- a/src/output/render.c +++ b/src/output/render.c @@ -1484,14 +1484,14 @@ render_pager_create (const struct render_params *params, const struct table_item *table_item) { struct render_pager *p; - const char *caption; + const char *title; p = xzalloc (sizeof *p); p->params = params; - caption = table_item_get_caption (table_item); - if (caption) - render_pager_add_table (p, table_from_string (TAB_LEFT, caption)); + title = table_item_get_title (table_item); + if (title) + render_pager_add_table (p, table_from_string (TAB_LEFT, title)); render_pager_add_table (p, table_ref (table_item_get_table (table_item))); add_footnote_page (p, p->pages[p->n_pages - 1]); diff --git a/src/output/tab.h b/src/output/tab.h index 76be9d4f65..bb932fddcb 100644 --- a/src/output/tab.h +++ b/src/output/tab.h @@ -25,9 +25,9 @@ Some of the features of this type of table are obsolete but have not yet been removed, because some code still uses them. These features are: - - The title. The title (or caption, actually) is a property of the - table_item (see output/table-item.h) in which a table is embedded, - not a property of the table itself. + - The title. The title is a property of the table_item (see + output/table-item.h) in which a table is embedded, not a property of + the table itself. - Row and columns offsets (via tab_offset(), tab_next_row()). This feature simply isn't used enough to justify keeping it. diff --git a/src/output/table-item.c b/src/output/table-item.c index 664f093abf..45add25f34 100644 --- a/src/output/table-item.c +++ b/src/output/table-item.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009, 2011 Free Software Foundation, Inc. + Copyright (C) 2009, 2011, 2014 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 @@ -29,15 +29,15 @@ #include "gl/xalloc.h" /* Initializes ITEM as a table item for rendering TABLE. The new table item - initially has the specified CAPTION, which may be NULL if no caption is yet - available. The caller retains ownership of CAPTION. */ + initially has the specified TITLE, which may be NULL if no title is yet + available. The caller retains ownership of TITLE. */ struct table_item * -table_item_create (struct table *table, const char *caption) +table_item_create (struct table *table, const char *title) { struct table_item *item = xmalloc (sizeof *item); output_item_init (&item->output_item, &table_item_class); item->table = table; - item->caption = caption != NULL ? xstrdup (caption) : NULL; + item->title = title != NULL ? xstrdup (title) : NULL; return item; } @@ -49,25 +49,24 @@ table_item_get_table (const struct table_item *table_item) return table_item->table; } -/* Returns ITEM's caption, which is a null pointer if no caption has been +/* Returns ITEM's title, which is a null pointer if no title has been set. */ const char * -table_item_get_caption (const struct table_item *item) +table_item_get_title (const struct table_item *item) { - return item->caption; + return item->title; } -/* Sets ITEM's caption to CAPTION, replacing any previous caption. Specify - NULL for CAPTION to clear any caption from ITEM. The caller retains - ownership of CAPTION. +/* Sets ITEM's title to TITLE, replacing any previous title. Specify NULL for + TITLE to clear any title from ITEM. The caller retains ownership of TITLE. This function may only be used on a table_item that is unshared. */ void -table_item_set_caption (struct table_item *item, const char *caption) +table_item_set_title (struct table_item *item, const char *title) { assert (!table_item_is_shared (item)); - free (item->caption); - item->caption = caption != NULL ? xstrdup (caption) : NULL; + free (item->title); + item->title = title != NULL ? xstrdup (title) : NULL; } /* Submits TABLE_ITEM to the configured output drivers, and transfers ownership @@ -82,7 +81,7 @@ static void table_item_destroy (struct output_item *output_item) { struct table_item *item = to_table_item (output_item); - free (item->caption); + free (item->title); table_unref (item->table); free (item); } diff --git a/src/output/table-item.h b/src/output/table-item.h index dddf846ca9..15f5c568f3 100644 --- a/src/output/table-item.h +++ b/src/output/table-item.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009, 2011 Free Software Foundation, Inc. + Copyright (C) 2009, 2011, 2014 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 @@ -21,7 +21,7 @@ A table item is a subclass of an output item (see output-item.h) that contains a table (see table.h) and some formatting properties (currently - just a caption). */ + just a title). */ #include "libpspp/compiler.h" #include "output/output-item.h" @@ -34,15 +34,15 @@ struct table_item { struct output_item output_item; /* Superclass. */ struct table *table; /* The table to be rendered. */ - char *caption; /* May be null if there is no caption. */ + char *title; /* May be null if there is no title. */ }; -struct table_item *table_item_create (struct table *, const char *caption); +struct table_item *table_item_create (struct table *, const char *title); const struct table *table_item_get_table (const struct table_item *); -const char *table_item_get_caption (const struct table_item *); -void table_item_set_caption (struct table_item *, const char *); +const char *table_item_get_title (const struct table_item *); +void table_item_set_title (struct table_item *, const char *); /* This boilerplate for table_item, a subclass of output_item, was autogenerated by mk-class-boilerplate. */ diff --git a/src/ui/gui/psppire-output-view.c b/src/ui/gui/psppire-output-view.c index b820207463..6b9445b404 100644 --- a/src/ui/gui/psppire-output-view.c +++ b/src/ui/gui/psppire-output-view.c @@ -76,9 +76,9 @@ struct psppire_output_view enum { - COL_TITLE, /* Table title. */ + COL_NAME, /* Table name. */ COL_ADDR, /* Pointer to the table */ - COL_Y, /* Y position of top of title. */ + COL_Y, /* Y position of top of name. */ N_COLS }; @@ -241,7 +241,7 @@ psppire_output_view_put (struct psppire_output_view *view, { GtkWidget *drawing_area; struct xr_rendering *r; - struct string title; + struct string name; GtkTreeStore *store; GtkTreePath *path; GtkTreeIter iter; @@ -301,7 +301,7 @@ psppire_output_view_put (struct psppire_output_view *view, { store = GTK_TREE_STORE (gtk_tree_view_get_model (view->overview)); - ds_init_empty (&title); + ds_init_empty (&name); if (is_text_item (item) && text_item_get_type (to_text_item (item)) == TEXT_ITEM_COMMAND_OPEN) { @@ -315,38 +315,38 @@ psppire_output_view_put (struct psppire_output_view *view, gtk_tree_store_append (store, &iter, p); } - ds_clear (&title); + ds_clear (&name); if (is_text_item (item)) - ds_put_cstr (&title, text_item_get_text (to_text_item (item))); + ds_put_cstr (&name, 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"), + ds_put_format (&name, "%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)); - if (caption != NULL) - ds_put_format (&title, "Table: %s", caption); + const char *title = table_item_get_title (to_table_item (item)); + if (title != NULL) + ds_put_format (&name, "Table: %s", title); else - ds_put_cstr (&title, "Table"); + ds_put_cstr (&name, "Table"); } else if (is_chart_item (item)) { const char *s = chart_item_get_title (to_chart_item (item)); if (s != NULL) - ds_put_format (&title, "Chart: %s", s); + ds_put_format (&name, "Chart: %s", s); else - ds_put_cstr (&title, "Chart"); + ds_put_cstr (&name, "Chart"); } gtk_tree_store_set (store, &iter, - COL_TITLE, ds_cstr (&title), + COL_NAME, ds_cstr (&name), COL_ADDR, item, COL_Y, view->y, -1); - ds_destroy (&title); + ds_destroy (&name); path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter); gtk_tree_view_expand_row (view->overview, path, TRUE); @@ -643,7 +643,7 @@ psppire_output_view_new (GtkLayout *output, GtkTreeView *overview, { model = GTK_TREE_MODEL (gtk_tree_store_new ( N_COLS, - G_TYPE_STRING, /* COL_TITLE */ + G_TYPE_STRING, /* COL_NAME */ G_TYPE_POINTER, /* COL_ADDR */ G_TYPE_LONG)); /* COL_Y */ gtk_tree_view_set_model (overview, model); @@ -658,7 +658,7 @@ psppire_output_view_new (GtkLayout *output, GtkTreeView *overview, gtk_tree_view_append_column (GTK_TREE_VIEW (overview), column); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, TRUE); - gtk_tree_view_column_add_attribute (column, renderer, "text", COL_TITLE); + gtk_tree_view_column_add_attribute (column, renderer, "text", COL_NAME); g_signal_connect (GTK_TREE_VIEW (overview), "row-activated", G_CALLBACK (on_row_activate), view);