1 /* gsheet-uniform-column.c
3 * PSPPIRE --- A Graphical User Interface for PSPP
4 * Copyright (C) 2006 Free Software Foundation
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.
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.
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
21 #include "gsheet-column-iface.h"
22 #include "gsheet-uniform-column.h"
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);
29 static void g_sheet_column_init (GSheetColumnIface *iface);
32 static GObjectClass *parent_class = NULL;
35 g_sheet_uniform_column_get_type (void)
37 static GType uniform_column_type = 0;
39 if (!uniform_column_type)
41 static const GTypeInfo uniform_column_info =
43 sizeof (GSheetUniformColumnClass),
45 NULL, /* base_finalize */
46 (GClassInitFunc) g_sheet_uniform_column_class_init,
47 NULL, /* class_finalize */
48 NULL, /* class_data */
49 sizeof (GSheetUniformColumn),
51 (GInstanceInitFunc) g_sheet_uniform_column_init,
54 static const GInterfaceInfo column_info =
56 (GInterfaceInitFunc) g_sheet_column_init,
62 g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_column",
63 &uniform_column_info, 0);
65 g_type_add_interface_static (uniform_column_type,
70 return uniform_column_type;
75 * g_sheet_uniform_column_new:
76 * @width: The size of columns in this uniform column
78 * Return value: a new #g_sheet_uniform_column
81 g_sheet_uniform_column_new (gint width, gint n_columns)
83 GSheetUniformColumn *ug;
86 retval = g_object_new (G_TYPE_SHEET_UNIFORM_COLUMN, NULL);
88 ug = G_SHEET_UNIFORM_COLUMN(retval);
89 ug->n_columns = n_columns;
91 ug->is_visible = TRUE;
92 ug->is_sensitive = FALSE;
98 g_sheet_uniform_column_get_width(const GSheetColumn *geom, gint u)
100 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
106 g_sheet_uniform_column_get_sensitivity(const GSheetColumn *geom, gint u)
108 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
110 return ug->is_sensitive;
115 g_sheet_uniform_column_get_visibility(const GSheetColumn *geom, gint u)
117 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
119 return ug->is_visible;
124 g_sheet_uniform_column_get_button_label(const GSheetColumn *geom, gint u)
126 gchar *label = g_strdup_printf("%d", u);
132 static GtkJustification
133 g_sheet_uniform_column_get_justification(const GSheetColumn *geom, gint u)
135 return GTK_JUSTIFY_FILL;
141 g_sheet_uniform_column_get_column_count(const GSheetColumn *geom)
143 GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
145 return ug->n_columns;
149 g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class)
151 GObjectClass *object_class;
153 parent_class = g_type_class_peek_parent (class);
154 object_class = (GObjectClass*) class;
156 object_class->finalize = g_sheet_uniform_column_finalize;
162 g_sheet_uniform_column_init (GSheetUniformColumn *o)
167 g_sheet_uniform_column_finalize (GObject *object)
173 g_sheet_column_init (GSheetColumnIface *iface)
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;