1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2018 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "output/group-item.h"
23 #include "libpspp/compiler.h"
24 #include "output/driver.h"
25 #include "output/output-item-provider.h"
27 #include "gl/xalloc.h"
30 #define _(msgid) gettext (msgid)
32 struct group_open_item *
33 group_open_item_create (const char *command_name, const char *label)
35 return group_open_item_create_nocopy (
36 command_name ? xstrdup (command_name) : NULL,
37 label ? xstrdup (label) : NULL);
40 struct group_open_item *
41 group_open_item_create_nocopy (char *command_name, char *label)
43 struct group_open_item *item = xmalloc (sizeof *item);
44 *item = (struct group_open_item) {
45 .output_item = OUTPUT_ITEM_INITIALIZER (&group_open_item_class),
46 .output_item.label = label,
47 .command_name = command_name,
52 /* Submits ITEM to the configured output drivers, and transfers ownership to
53 the output subsystem. */
55 group_open_item_submit (struct group_open_item *item)
57 output_submit (&item->output_item);
61 group_open_item_get_label (const struct output_item *output_item)
63 struct group_open_item *item = to_group_open_item (output_item);
65 return item->command_name ? item->command_name : _("Group");
69 group_open_item_destroy (struct output_item *output_item)
71 struct group_open_item *item = to_group_open_item (output_item);
73 free (item->command_name);
77 const struct output_item_class group_open_item_class =
79 group_open_item_get_label,
80 group_open_item_destroy,
83 struct group_close_item *
84 group_close_item_create (void)
86 struct group_close_item *item = xmalloc (sizeof *item);
87 *item = (struct group_close_item) {
88 .output_item = OUTPUT_ITEM_INITIALIZER (&group_close_item_class),
93 /* Submits ITEM to the configured output drivers, and transfers ownership to
94 the output subsystem. */
96 group_close_item_submit (struct group_close_item *item)
98 output_submit (&item->output_item);
102 group_close_item_get_label (const struct output_item *output_item UNUSED)
104 /* Not marked for translation: user should never see it. */
105 return "Group Close";
109 group_close_item_destroy (struct output_item *output_item)
111 struct group_close_item *item = to_group_close_item (output_item);
116 const struct output_item_class group_close_item_class =
118 group_close_item_get_label,
119 group_close_item_destroy,