1 /* gsheet-uniform-column.c
3 * PSPPIRE --- A Graphical User Interface for PSPP
4 * Copyright (C) 2006 Free Software Foundation
5 * Written by John Darrington
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "gsheet-column-iface.h"
23 #include "gsheet-uniform-column.h"
26 static void g_sheet_uniform_column_init (GSheetUniformColumn *ug);
27 static void g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class);
28 static void g_sheet_uniform_column_finalize (GObject *object);
30 static void g_sheet_column_init (GSheetColumnIface *iface);
33 static GObjectClass *parent_class = NULL;
36 g_sheet_uniform_column_get_type (void)
38 static GType uniform_column_type = 0;
40 if (!uniform_column_type)
42 static const GTypeInfo uniform_column_info =
44 sizeof (GSheetUniformColumnClass),
46 NULL, /* base_finalize */
47 (GClassInitFunc) g_sheet_uniform_column_class_init,
48 NULL, /* class_finalize */
49 NULL, /* class_data */
50 sizeof (GSheetUniformColumn),
52 (GInstanceInitFunc) g_sheet_uniform_column_init,
55 static const GInterfaceInfo column_info =
57 (GInterfaceInitFunc) g_sheet_column_init,
63 g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_column",
64 &uniform_column_info, 0);
66 g_type_add_interface_static (uniform_column_type,
71 return uniform_column_type;
76 * g_sheet_uniform_column_new:
77 * @width: The size of columns in this uniform column
79 * Return value: a new #g_sheet_uniform_column
82 g_sheet_uniform_column_new (gint width, gint n_columns)
84 GSheetUniformColumn *ug;
87 retval = g_object_new (G_TYPE_SHEET_UNIFORM_COLUMN, NULL);
89 ug = G_SHEET_UNIFORM_COLUMN(retval);
90 ug->n_columns = n_columns;
92 ug->is_visible = TRUE;
93 ug->is_sensitive = FALSE;
99 g_sheet_uniform_column_get_width(const GSheetColumn *geom, gint u)
101 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
107 g_sheet_uniform_column_get_sensitivity(const GSheetColumn *geom, gint u)
109 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
111 return ug->is_sensitive;
116 g_sheet_uniform_column_get_visibility(const GSheetColumn *geom, gint u)
118 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
120 return ug->is_visible;
125 g_sheet_uniform_column_get_button_label(const GSheetColumn *geom, gint u)
130 label = g_strdup_printf("%d", u);
136 static GtkJustification
137 g_sheet_uniform_column_get_justification(const GSheetColumn *geom, gint u)
140 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
143 return GTK_JUSTIFY_FILL;
149 g_sheet_uniform_column_get_column_count(const GSheetColumn *geom)
151 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
153 return ug->n_columns;
157 g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class)
159 GObjectClass *object_class;
161 parent_class = g_type_class_peek_parent (class);
162 object_class = (GObjectClass*) class;
164 object_class->finalize = g_sheet_uniform_column_finalize;
170 g_sheet_uniform_column_init (GSheetUniformColumn *o)
175 g_sheet_uniform_column_finalize (GObject *object)
181 g_sheet_column_init (GSheetColumnIface *iface)
183 iface->get_width = g_sheet_uniform_column_get_width ;
184 iface->get_sensitivity = g_sheet_uniform_column_get_sensitivity ;
185 iface->get_visibility = g_sheet_uniform_column_get_visibility ;
186 iface->get_justification = g_sheet_uniform_column_get_justification;
187 iface->get_column_count = g_sheet_uniform_column_get_column_count;
188 iface->get_button_label = g_sheet_uniform_column_get_button_label;