Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / lib / gtksheet / gsheet-hetero-column.c
1 /* gsheet-hetero-column.c
2  * PSPPIRE --- A Graphical User Interface for PSPP
3  * Copyright (C) 2006  Free Software Foundation
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 #include <config.h>
20
21 #include "gsheet-column-iface.h"
22 #include "gsheet-hetero-column.h"
23 #include <string.h>
24
25
26 static void  g_sheet_hetero_column_init       (GSheetHeteroColumn      *hg);
27 static void  g_sheet_hetero_column_class_init (GSheetHeteroColumnClass *class);
28 static void  g_sheet_hetero_column_finalize   (GObject           *object);
29
30 static void g_sheet_column_init (GSheetColumnIface *iface);
31
32
33 static GObjectClass *parent_class = NULL;
34
35 GType
36 g_sheet_hetero_column_get_type (void)
37 {
38   static GType hetero_column_type = 0;
39
40   if (!hetero_column_type)
41     {
42       static const GTypeInfo hetero_column_info =
43       {
44         sizeof (GSheetHeteroColumnClass),
45         NULL,           /* base_init */
46         NULL,           /* base_finalize */
47         (GClassInitFunc) g_sheet_hetero_column_class_init,
48         NULL,           /* class_finalize */
49         NULL,           /* class_data */
50         sizeof (GSheetHeteroColumn),
51         0,
52         (GInstanceInitFunc) g_sheet_hetero_column_init,
53       };
54
55       static const GInterfaceInfo column_info =
56       {
57         (GInterfaceInitFunc) g_sheet_column_init,
58         NULL,
59         NULL
60       };
61
62       hetero_column_type =
63         g_type_register_static (G_TYPE_OBJECT, "g_sheet_hetero_column",
64                                 &hetero_column_info, 0);
65
66       g_type_add_interface_static (hetero_column_type,
67                                    G_TYPE_SHEET_COLUMN,
68                                    &column_info);
69     }
70
71   return hetero_column_type;
72 }
73
74
75 static GtkSheetButton default_button;
76
77
78
79 /**
80  * g_sheet_hetero_column_new:
81  * @width: The size of columns in this hetero column
82  *
83  * Return value: a new #g_sheet_hetero_column
84  **/
85 GObject *
86 g_sheet_hetero_column_new (gint default_width, gint n_columns)
87 {
88   gint i;
89   GSheetHeteroColumn *hg;
90   GObject *retval;
91
92   retval = g_object_new (G_TYPE_SHEET_HETERO_COLUMN, NULL);
93
94   hg = G_SHEET_HETERO_COLUMN (retval);
95   hg->n_columns = n_columns;
96   hg->default_width = default_width;
97   hg->col = g_new0 (struct GSheetHeteroColumnUnit, n_columns);
98
99   for (i = 0 ; i < hg->n_columns; ++i )
100     {
101       hg->col[i].button = default_button;
102     }
103
104   return retval;
105 }
106
107 static gint
108 g_sheet_hetero_column_get_width (const GSheetColumn *geom, glong i)
109 {
110   GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geom);
111
112   g_return_val_if_fail (i < hg->n_columns, -1);
113
114   return hg->col[i].width;
115 }
116
117 static gboolean
118 g_sheet_hetero_column_get_sensitivity (const GSheetColumn *geom, glong u)
119 {
120   return TRUE;
121 }
122
123
124 static gboolean
125 g_sheet_hetero_column_get_visibility (const GSheetColumn *geom, glong u)
126 {
127   return TRUE;
128 }
129
130
131
132 static gchar *
133 g_sheet_hetero_column_get_button_label (const GSheetColumn *geom, glong u)
134 {
135   GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geom);
136
137   return g_locale_to_utf8 (hg->col[u].button.label, -1, 0, 0, 0);
138 }
139
140
141 static GtkJustification
142 g_sheet_hetero_column_get_justification (const GSheetColumn *geom, glong u)
143 {
144   return GTK_JUSTIFY_FILL;
145 }
146
147
148
149 static glong
150 g_sheet_hetero_column_get_column_count (const GSheetColumn *geom)
151 {
152   GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geom);
153
154   return hg->n_columns;
155 }
156
157 static void
158 g_sheet_hetero_column_class_init (GSheetHeteroColumnClass *class)
159 {
160   GObjectClass *object_class;
161
162   parent_class = g_type_class_peek_parent (class);
163   object_class = (GObjectClass*) class;
164
165   object_class->finalize = g_sheet_hetero_column_finalize;
166
167   default_button.label=NULL;
168   default_button.child=NULL;
169   default_button.state=GTK_STATE_NORMAL;
170   default_button.justification=GTK_JUSTIFY_CENTER;
171   default_button.label_visible = TRUE;
172 }
173
174
175 static void
176 g_sheet_hetero_column_init (GSheetHeteroColumn *o)
177 {
178 }
179
180 static void
181 g_sheet_hetero_column_finalize (GObject           *object)
182 {
183   GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (object);
184
185   g_free (hg->col);
186 }
187
188 static void
189 hetero_column_set_width (GSheetColumn *geo, glong i, gint size)
190 {
191   GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geo);
192
193   g_return_if_fail (i < hg->n_columns);
194
195   hg->col[i].width = size;
196 }
197
198
199
200 static void
201 g_sheet_column_init (GSheetColumnIface *iface)
202 {
203   iface->get_width = g_sheet_hetero_column_get_width ;
204   iface->set_width = hetero_column_set_width ;
205   iface->get_sensitivity = g_sheet_hetero_column_get_sensitivity ;
206   iface->get_visibility = g_sheet_hetero_column_get_visibility ;
207   iface->get_justification = g_sheet_hetero_column_get_justification;
208   iface->get_column_count = g_sheet_hetero_column_get_column_count;
209
210   iface->get_button_label = g_sheet_hetero_column_get_button_label;
211 }
212
213
214 void
215 g_sheet_hetero_column_set_button_label (GSheetHeteroColumn *geo,
216                                               glong i, const gchar *label)
217 {
218   g_return_if_fail (i < geo->n_columns);
219
220   g_free (geo->col[i].button.label);
221   geo->col[i].button.label = g_malloc (strlen (label) + 1);
222
223   g_stpcpy (geo->col[i].button.label, label);
224 }
225
226
227
228
229 void
230 g_sheet_hetero_column_set_width (GSheetHeteroColumn *geo, glong i, gint size)
231 {
232   GSheetColumn *iface = G_SHEET_COLUMN (geo);
233
234   hetero_column_set_width (iface, i, size);
235 }
236
237
238