cairo-fsm: Remove dead code in xr_fsm_create().
[pspp] / src / output / group-item.c
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2018 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 #include <config.h>
18
19 #include "output/group-item.h"
20
21 #include <stdlib.h>
22
23 #include "libpspp/compiler.h"
24 #include "libpspp/str.h"
25 #include "output/driver.h"
26 #include "output/output-item-provider.h"
27
28 #include "gl/xalloc.h"
29
30 #include "gettext.h"
31 #define _(msgid) gettext (msgid)
32
33 struct group_open_item *
34 group_open_item_create (const char *command_name, const char *label)
35 {
36   return group_open_item_create_nocopy (
37     xstrdup_if_nonnull (command_name),
38     xstrdup_if_nonnull (label));
39 }
40
41 struct group_open_item *
42 group_open_item_create_nocopy (char *command_name, char *label)
43 {
44   struct group_open_item *item = xmalloc (sizeof *item);
45   *item = (struct group_open_item) {
46     .output_item = OUTPUT_ITEM_INITIALIZER (&group_open_item_class),
47     .output_item.label = label,
48     .command_name = command_name,
49   };
50   return item;
51 }
52
53 /* Submits ITEM to the configured output drivers, and transfers ownership to
54    the output subsystem. */
55 void
56 group_open_item_submit (struct group_open_item *item)
57 {
58   output_submit (&item->output_item);
59 }
60
61 static const char *
62 group_open_item_get_label (const struct output_item *output_item)
63 {
64   struct group_open_item *item = to_group_open_item (output_item);
65
66   return item->command_name ? item->command_name : _("Group");
67 }
68
69 static void
70 group_open_item_destroy (struct output_item *output_item)
71 {
72   struct group_open_item *item = to_group_open_item (output_item);
73
74   free (item->command_name);
75   free (item);
76 }
77
78 const struct output_item_class group_open_item_class =
79   {
80     group_open_item_get_label,
81     group_open_item_destroy,
82   };
83 \f
84 struct group_close_item *
85 group_close_item_create (void)
86 {
87   struct group_close_item *item = xmalloc (sizeof *item);
88   *item = (struct group_close_item) {
89     .output_item = OUTPUT_ITEM_INITIALIZER (&group_close_item_class),
90   };
91   return item;
92 }
93
94 /* Submits ITEM to the configured output drivers, and transfers ownership to
95    the output subsystem. */
96 void
97 group_close_item_submit (struct group_close_item *item)
98 {
99   output_submit (&item->output_item);
100 }
101
102 static const char *
103 group_close_item_get_label (const struct output_item *output_item UNUSED)
104 {
105   /* Not marked for translation: user should never see it. */
106   return "Group Close";
107 }
108
109 static void
110 group_close_item_destroy (struct output_item *output_item)
111 {
112   struct group_close_item *item = to_group_close_item (output_item);
113
114   free (item);
115 }
116
117 const struct output_item_class group_close_item_class =
118   {
119     group_close_item_get_label,
120     group_close_item_destroy,
121   };