Removed my authorship lines.
[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 "gsheet-column-iface.h"
22 #include "gsheet-uniform-column.h"
23
24
25 static void  g_sheet_uniform_column_init       (GSheetUniformColumn      *ug);
26 static void  g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class);
27 static void  g_sheet_uniform_column_finalize   (GObject           *object);
28
29 static void g_sheet_column_init (GSheetColumnIface *iface);
30
31
32 static GObjectClass *parent_class = NULL;
33
34 GType
35 g_sheet_uniform_column_get_type (void)
36 {
37   static GType uniform_column_type = 0;
38
39   if (!uniform_column_type)
40     {
41       static const GTypeInfo uniform_column_info =
42       {
43         sizeof (GSheetUniformColumnClass),
44         NULL,           /* base_init */
45         NULL,           /* base_finalize */
46         (GClassInitFunc) g_sheet_uniform_column_class_init,
47         NULL,           /* class_finalize */
48         NULL,           /* class_data */
49         sizeof (GSheetUniformColumn),
50         0,
51         (GInstanceInitFunc) g_sheet_uniform_column_init,
52       };
53
54       static const GInterfaceInfo column_info =
55       {
56         (GInterfaceInitFunc) g_sheet_column_init,
57         NULL,
58         NULL
59       };
60
61       uniform_column_type = 
62         g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_column",
63                                 &uniform_column_info, 0);
64
65       g_type_add_interface_static (uniform_column_type,
66                                    G_TYPE_SHEET_COLUMN,
67                                    &column_info);
68     }
69
70   return uniform_column_type;
71 }
72
73
74 /**
75  * g_sheet_uniform_column_new:
76  * @width: The size of columns in this uniform column
77  *
78  * Return value: a new #g_sheet_uniform_column
79  **/
80 GObject *
81 g_sheet_uniform_column_new (gint width, gint n_columns)
82 {
83   GSheetUniformColumn *ug;
84   GObject *retval;
85
86   retval = g_object_new (G_TYPE_SHEET_UNIFORM_COLUMN, NULL);
87
88   ug = G_SHEET_UNIFORM_COLUMN(retval);
89   ug->n_columns = n_columns;
90   ug->width = width;
91   ug->is_visible = TRUE;
92   ug->is_sensitive = FALSE;
93
94   return retval;
95 }
96
97 static gint 
98 g_sheet_uniform_column_get_width(const GSheetColumn *geom, gint u)
99 {
100   GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
101   
102   return ug->width;
103 }
104
105 static gint 
106 g_sheet_uniform_column_get_sensitivity(const GSheetColumn *geom, gint u)
107 {
108   GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
109   
110   return ug->is_sensitive;
111 }
112
113
114 static gint 
115 g_sheet_uniform_column_get_visibility(const GSheetColumn *geom, gint u)
116 {
117   GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
118   
119   return ug->is_visible;
120 }
121
122
123 static gchar *
124 g_sheet_uniform_column_get_button_label(const GSheetColumn *geom, gint u)
125 {
126   gchar *label = g_strdup_printf("%d", u);
127
128   return label;
129 }
130
131
132 static GtkJustification
133 g_sheet_uniform_column_get_justification(const GSheetColumn *geom, gint u)
134 {
135   return GTK_JUSTIFY_FILL;
136 }
137
138
139
140 static gint 
141 g_sheet_uniform_column_get_column_count(const GSheetColumn *geom)
142 {
143   GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
144
145   return ug->n_columns;
146 }
147
148 static void
149 g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class)
150 {
151   GObjectClass *object_class;
152
153   parent_class = g_type_class_peek_parent (class);
154   object_class = (GObjectClass*) class;
155
156   object_class->finalize = g_sheet_uniform_column_finalize;
157
158 }
159
160
161 static void
162 g_sheet_uniform_column_init (GSheetUniformColumn *o)
163 {
164 }
165
166 static void         
167 g_sheet_uniform_column_finalize (GObject           *object)
168 {
169 }
170
171
172 static void
173 g_sheet_column_init (GSheetColumnIface *iface)
174 {
175   iface->get_width = g_sheet_uniform_column_get_width ;
176   iface->get_sensitivity = g_sheet_uniform_column_get_sensitivity ;
177   iface->get_visibility = g_sheet_uniform_column_get_visibility ;
178   iface->get_justification = g_sheet_uniform_column_get_justification;
179   iface->get_column_count = g_sheet_uniform_column_get_column_count;
180   iface->get_button_label = g_sheet_uniform_column_get_button_label;
181 }
182