c0f6732a5e51c2a38965d6c8347ae82abca560cb
[pspp-builds.git] / lib / gtksheet / gsheet-uniform-column.c
1 /* gsheet-uniform-column.c
2  *
3  * PSPPIRE --- A Graphical User Interface for PSPP
4  * Copyright (C) 2006  Free Software Foundation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #include <config.h>
22
23 #include "gsheet-column-iface.h"
24 #include "gsheet-uniform-column.h"
25
26
27 static void  g_sheet_uniform_column_init       (GSheetUniformColumn      *ug);
28 static void  g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class);
29 static void  g_sheet_uniform_column_finalize   (GObject           *object);
30
31 static void g_sheet_column_init (GSheetColumnIface *iface);
32
33
34 static GObjectClass *parent_class = NULL;
35
36 GType
37 g_sheet_uniform_column_get_type (void)
38 {
39   static GType uniform_column_type = 0;
40
41   if (!uniform_column_type)
42     {
43       static const GTypeInfo uniform_column_info =
44       {
45         sizeof (GSheetUniformColumnClass),
46         NULL,           /* base_init */
47         NULL,           /* base_finalize */
48         (GClassInitFunc) g_sheet_uniform_column_class_init,
49         NULL,           /* class_finalize */
50         NULL,           /* class_data */
51         sizeof (GSheetUniformColumn),
52         0,
53         (GInstanceInitFunc) g_sheet_uniform_column_init,
54       };
55
56       static const GInterfaceInfo column_info =
57       {
58         (GInterfaceInitFunc) g_sheet_column_init,
59         NULL,
60         NULL
61       };
62
63       uniform_column_type =
64         g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_column",
65                                 &uniform_column_info, 0);
66
67       g_type_add_interface_static (uniform_column_type,
68                                    G_TYPE_SHEET_COLUMN,
69                                    &column_info);
70     }
71
72   return uniform_column_type;
73 }
74
75
76 /**
77  * g_sheet_uniform_column_new:
78  * @width: The size of columns in this uniform column
79  *
80  * Return value: a new #g_sheet_uniform_column
81  **/
82 GObject *
83 g_sheet_uniform_column_new (gint width, gint n_columns)
84 {
85   GSheetUniformColumn *ug;
86   GObject *retval;
87
88   retval = g_object_new (G_TYPE_SHEET_UNIFORM_COLUMN, NULL);
89
90   ug = G_SHEET_UNIFORM_COLUMN(retval);
91   ug->n_columns = n_columns;
92   ug->width = width;
93   ug->is_sensitive = FALSE;
94
95   return retval;
96 }
97
98 static gint
99 g_sheet_uniform_column_get_width (const GSheetColumn *geom, glong u)
100 {
101   GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN (geom);
102
103   return ug->width;
104 }
105
106 static gboolean
107 g_sheet_uniform_column_get_sensitivity (const GSheetColumn *geom, glong u)
108 {
109   GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN (geom);
110
111   return ug->is_sensitive;
112 }
113
114
115 static gchar *
116 g_sheet_uniform_column_get_button_label (const GSheetColumn *geom, glong u)
117 {
118   gchar *label = g_strdup_printf ("%ld", u);
119
120   return label;
121 }
122
123
124 static GtkJustification
125 g_sheet_uniform_column_get_justification (const GSheetColumn *geom, glong u)
126 {
127   return GTK_JUSTIFY_FILL;
128 }
129
130
131
132 static glong
133 g_sheet_uniform_column_get_column_count (const GSheetColumn *geom)
134 {
135   GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN (geom);
136
137   return ug->n_columns;
138 }
139
140 static void
141 g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class)
142 {
143   GObjectClass *object_class;
144
145   parent_class = g_type_class_peek_parent (class);
146   object_class = (GObjectClass*) class;
147
148   object_class->finalize = g_sheet_uniform_column_finalize;
149
150 }
151
152
153 static void
154 g_sheet_uniform_column_init (GSheetUniformColumn *o)
155 {
156 }
157
158 static void
159 g_sheet_uniform_column_finalize (GObject *object)
160 {
161 }
162
163
164 static void
165 g_sheet_column_init (GSheetColumnIface *iface)
166 {
167   iface->get_width = g_sheet_uniform_column_get_width ;
168   iface->get_sensitivity = g_sheet_uniform_column_get_sensitivity ;
169   iface->get_justification = g_sheet_uniform_column_get_justification;
170   iface->get_column_count = g_sheet_uniform_column_get_column_count;
171   iface->get_button_label = g_sheet_uniform_column_get_button_label;
172 }
173