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.
21 #include "gtkcelllayout.h"
25 gtk_cell_layout_get_type (void)
27 static GType cell_layout_type = 0;
29 if (! cell_layout_type)
31 static const GTypeInfo cell_layout_info =
33 sizeof (GtkCellLayoutIface),
45 g_type_register_static (G_TYPE_INTERFACE, "GtkCellLayout",
46 &cell_layout_info, 0);
48 g_type_interface_add_prerequisite (cell_layout_type, G_TYPE_OBJECT);
51 return cell_layout_type;
55 * gtk_cell_layout_pack_start:
56 * @cell_layout: A #GtkCellLayout.
57 * @cell: A #GtkCellRenderer.
58 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout.
60 * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE,
61 * then the @cell is allocated no more space than it needs. Any unused space
62 * is divided evenly between cells for which @expand is %TRUE.
64 * Note that reusing the same cell renderer is not supported.
69 gtk_cell_layout_pack_start (GtkCellLayout *cell_layout,
70 GtkCellRenderer *cell,
73 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
74 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
76 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout,
82 * gtk_cell_layout_pack_end:
83 * @cell_layout: A #GtkCellLayout.
84 * @cell: A #GtkCellRenderer.
85 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout.
87 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the
88 * @cell is allocated no more space than it needs. Any unused space is
89 * divided evenly between cells for which @expand is %TRUE.
91 * Note that reusing the same cell renderer is not supported.
96 gtk_cell_layout_pack_end (GtkCellLayout *cell_layout,
97 GtkCellRenderer *cell,
100 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
101 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
103 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout,
109 * gtk_cell_layout_clear:
110 * @cell_layout: A #GtkCellLayout.
112 * Unsets all the mappings on all renderers on @cell_layout and
113 * removes all renderers from @cell_layout.
118 gtk_cell_layout_clear (GtkCellLayout *cell_layout)
120 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
122 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear) (cell_layout);
126 gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
127 GtkCellRenderer *cell,
132 GtkCellLayoutIface *iface;
134 attribute = va_arg (args, gchar *);
136 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
138 (* iface->clear_attributes) (cell_layout, cell);
140 while (attribute != NULL)
142 column = va_arg (args, gint);
143 (* iface->add_attribute) (cell_layout, cell, attribute, column);
144 attribute = va_arg (args, gchar *);
149 * gtk_cell_layout_set_attributes:
150 * @cell_layout: A #GtkCellLayout.
151 * @cell: A #GtkCellRenderer.
152 * @Varargs: A %NULL-terminated list of attributes.
154 * Sets the attributes in list as the attributes of @cell_layout. The
155 * attributes should be in attribute/column order, as in
156 * gtk_cell_layout_add_attribute(). All existing attributes are removed, and
157 * replaced with the new attributes.
162 gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout,
163 GtkCellRenderer *cell,
168 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
169 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
171 va_start (args, cell);
172 gtk_cell_layout_set_attributesv (cell_layout, cell, args);
177 * gtk_cell_layout_add_attribute:
178 * @cell_layout: A #GtkCellLayout.
179 * @cell: A #GtkCellRenderer.
180 * @attribute: An attribute on the renderer.
181 * @column: The column position on the model to get the attribute from.
183 * Adds an attribute mapping to the list in @cell_layout. The @column is the
184 * column of the model to get a value from, and the @attribute is the
185 * parameter on @cell to be set from the value. So for example if column 2
186 * of the model contains strings, you could have the "text" attribute of a
187 * #GtkCellRendererText get its values from column 2.
192 gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
193 GtkCellRenderer *cell,
194 const gchar *attribute,
197 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
198 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
199 g_return_if_fail (attribute != NULL);
200 g_return_if_fail (column >= 0);
202 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout,
209 * gtk_cell_layout_set_cell_data_func:
210 * @cell_layout: A #GtkCellLayout.
211 * @cell: A #GtkCellRenderer.
212 * @func: The #GtkCellLayoutDataFunc to use.
213 * @func_data: The user data for @func.
214 * @destroy: The destroy notification for @func_data.
216 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout. This function
217 * is used instead of the standard attributes mapping for setting the
218 * column value, and should set the value of @cell_layout's cell renderer(s)
219 * as appropriate. @func may be %NULL to remove and older one.
224 gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
225 GtkCellRenderer *cell,
226 GtkCellLayoutDataFunc func,
228 GDestroyNotify destroy)
230 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
231 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
233 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout,
241 * gtk_cell_layout_clear_attributes:
242 * @cell_layout: A #GtkCellLayout.
243 * @cell: A #GtkCellRenderer to clear the attribute mapping on.
245 * Clears all existing attributes previously set with
246 * gtk_cell_layout_set_attributes().
251 gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
252 GtkCellRenderer *cell)
254 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
255 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
257 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout,
262 * gtk_cell_layout_reorder:
263 * @cell_layout: A #GtkCellLayout.
264 * @cell: A #GtkCellRenderer to reorder.
265 * @position: New position to insert @cell at.
267 * Re-inserts @cell at @position. Note that @cell has already to be packed
268 * into @cell_layout for this to function properly.
273 gtk_cell_layout_reorder (GtkCellLayout *cell_layout,
274 GtkCellRenderer *cell,
277 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
278 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
280 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder) (cell_layout,
285 #define __GTK_CELL_LAYOUT_C__
286 #include "gtkaliasdef.c"