2 * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "gtkcelllayout.h"
23 gtk_cell_layout_get_type (void)
25 static GType cell_layout_type = 0;
27 if (! cell_layout_type)
29 static const GTypeInfo cell_layout_info =
31 sizeof (GtkCellLayoutIface),
43 g_type_register_static (G_TYPE_INTERFACE, "GtkCellLayout",
44 &cell_layout_info, 0);
46 g_type_interface_add_prerequisite (cell_layout_type, G_TYPE_OBJECT);
49 return cell_layout_type;
53 * gtk_cell_layout_pack_start:
54 * @cell_layout: A #GtkCellLayout.
55 * @cell: A #GtkCellRenderer.
56 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout.
58 * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE,
59 * then the @cell is allocated no more space than it needs. Any unused space
60 * is divided evenly between cells for which @expand is %TRUE.
65 gtk_cell_layout_pack_start (GtkCellLayout *cell_layout,
66 GtkCellRenderer *cell,
69 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
70 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
72 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout,
78 * gtk_cell_layout_pack_end:
79 * @cell_layout: A #GtkCellLayout.
80 * @cell: A #GtkCellRenderer.
81 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout.
83 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the
84 * @cell is allocated no more space than it needs. Any unused space is
85 * divided evenly between cells for which @expand is %TRUE.
90 gtk_cell_layout_pack_end (GtkCellLayout *cell_layout,
91 GtkCellRenderer *cell,
94 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
95 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
97 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout,
103 * gtk_cell_layout_clear:
104 * @cell_layout: A #GtkCellLayout.
106 * Unsets all the mappings on all renderers on @cell_layout.
111 gtk_cell_layout_clear (GtkCellLayout *cell_layout)
113 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
115 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear) (cell_layout);
119 gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
120 GtkCellRenderer *cell,
125 GtkCellLayoutIface *iface;
127 attribute = va_arg (args, gchar *);
129 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
131 (* iface->clear_attributes) (cell_layout, cell);
133 while (attribute != NULL)
135 column = va_arg (args, gint);
136 (* iface->add_attribute) (cell_layout, cell, attribute, column);
137 attribute = va_arg (args, gchar *);
142 * gtk_cell_layout_set_attributes:
143 * @cell_layout: A #GtkCellLayout.
144 * @cell: A #GtkCellRenderer.
145 * @Varargs: A %NULL-terminated list of attributes.
147 * Sets the attributes in list as the attributes of @cell_layout. The
148 * attributes should be in attribute/column order, as in
149 * gtk_cell_layout_add_attribute(). All existing attributes are removed, and
150 * replaced with the new attributes.
155 gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout,
156 GtkCellRenderer *cell,
161 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
162 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
164 va_start (args, cell);
165 gtk_cell_layout_set_attributesv (cell_layout, cell, args);
170 * gtk_cell_layout_add_attribute:
171 * @cell_layout: A #GtkCellLayout.
172 * @cell: A #GtkCellRenderer.
173 * @attribute: An attribute on the renderer.
174 * @column: The column position on the model to get the attribute from.
176 * Adds an attribute mapping to the list in @cell_layout. The @column is the
177 * column of the model to get a value from, and the @attribute is the
178 * parameter on @cell to be set from the value. So for example if column 2
179 * of the model contains strings, you could have the "text" attribute of a
180 * #GtkCellRendererText get its values from column 2.
185 gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
186 GtkCellRenderer *cell,
187 const gchar *attribute,
190 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
191 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
192 g_return_if_fail (attribute != NULL);
193 g_return_if_fail (column >= 0);
195 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout,
202 * gtk_cell_layout_set_cell_data_func:
203 * @cell_layout: A #GtkCellLayout.
204 * @cell: A #GtkCellRenderer.
205 * @func: The #GtkCellLayoutDataFunc to use.
206 * @func_data: The user data for @func.
207 * @destroy: The destroy notification for @func_data.
209 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout. This function
210 * is used instead of the standard attributes mapping for setting the
211 * column value, and should set the value of @cell_layout's cell renderer(s)
212 * as appropriate. @func may be %NULL to remove and older one.
217 gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
218 GtkCellRenderer *cell,
219 GtkCellLayoutDataFunc func,
221 GDestroyNotify destroy)
223 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
224 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
226 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout,
234 * gtk_cell_layout_clear_attributes:
235 * @cell_layout: A #GtkCellLayout.
236 * @cell: A #GtkCellRenderer to clear the attribute mapping on.
238 * Clears all existing attributes previously set with
239 * gtk_cell_layout_set_attributes().
244 gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
245 GtkCellRenderer *cell)
247 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
248 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
250 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout,