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"
26 gtk_cell_layout_get_type (void)
28 static GType cell_layout_type = 0;
30 if (! cell_layout_type)
32 const GTypeInfo cell_layout_info =
34 sizeof (GtkCellLayoutIface),
46 g_type_register_static (G_TYPE_INTERFACE, I_("GtkCellLayout"),
47 &cell_layout_info, 0);
49 g_type_interface_add_prerequisite (cell_layout_type, G_TYPE_OBJECT);
52 return cell_layout_type;
56 * gtk_cell_layout_pack_start:
57 * @cell_layout: A #GtkCellLayout.
58 * @cell: A #GtkCellRenderer.
59 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout.
61 * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE,
62 * then the @cell is allocated no more space than it needs. Any unused space
63 * is divided evenly between cells for which @expand is %TRUE.
65 * Note that reusing the same cell renderer is not supported.
70 gtk_cell_layout_pack_start (GtkCellLayout *cell_layout,
71 GtkCellRenderer *cell,
74 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
75 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
77 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout,
83 * gtk_cell_layout_pack_end:
84 * @cell_layout: A #GtkCellLayout.
85 * @cell: A #GtkCellRenderer.
86 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout.
88 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the
89 * @cell is allocated no more space than it needs. Any unused space is
90 * divided evenly between cells for which @expand is %TRUE.
92 * Note that reusing the same cell renderer is not supported.
97 gtk_cell_layout_pack_end (GtkCellLayout *cell_layout,
98 GtkCellRenderer *cell,
101 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
102 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
104 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout,
110 * gtk_cell_layout_clear:
111 * @cell_layout: A #GtkCellLayout.
113 * Unsets all the mappings on all renderers on @cell_layout and
114 * removes all renderers from @cell_layout.
119 gtk_cell_layout_clear (GtkCellLayout *cell_layout)
121 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
123 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear) (cell_layout);
127 gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
128 GtkCellRenderer *cell,
133 GtkCellLayoutIface *iface;
135 attribute = va_arg (args, gchar *);
137 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
139 (* iface->clear_attributes) (cell_layout, cell);
141 while (attribute != NULL)
143 column = va_arg (args, gint);
144 (* iface->add_attribute) (cell_layout, cell, attribute, column);
145 attribute = va_arg (args, gchar *);
150 * gtk_cell_layout_set_attributes:
151 * @cell_layout: A #GtkCellLayout.
152 * @cell: A #GtkCellRenderer.
153 * @Varargs: A %NULL-terminated list of attributes.
155 * Sets the attributes in list as the attributes of @cell_layout. The
156 * attributes should be in attribute/column order, as in
157 * gtk_cell_layout_add_attribute(). All existing attributes are removed, and
158 * replaced with the new attributes.
163 gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout,
164 GtkCellRenderer *cell,
169 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
170 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
172 va_start (args, cell);
173 gtk_cell_layout_set_attributesv (cell_layout, cell, args);
178 * gtk_cell_layout_add_attribute:
179 * @cell_layout: A #GtkCellLayout.
180 * @cell: A #GtkCellRenderer.
181 * @attribute: An attribute on the renderer.
182 * @column: The column position on the model to get the attribute from.
184 * Adds an attribute mapping to the list in @cell_layout. The @column is the
185 * column of the model to get a value from, and the @attribute is the
186 * parameter on @cell to be set from the value. So for example if column 2
187 * of the model contains strings, you could have the "text" attribute of a
188 * #GtkCellRendererText get its values from column 2.
193 gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
194 GtkCellRenderer *cell,
195 const gchar *attribute,
198 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
199 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
200 g_return_if_fail (attribute != NULL);
201 g_return_if_fail (column >= 0);
203 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout,
210 * gtk_cell_layout_set_cell_data_func:
211 * @cell_layout: A #GtkCellLayout.
212 * @cell: A #GtkCellRenderer.
213 * @func: The #GtkCellLayoutDataFunc to use.
214 * @func_data: The user data for @func.
215 * @destroy: The destroy notification for @func_data.
217 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout. This function
218 * is used instead of the standard attributes mapping for setting the
219 * column value, and should set the value of @cell_layout's cell renderer(s)
220 * as appropriate. @func may be %NULL to remove and older one.
225 gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
226 GtkCellRenderer *cell,
227 GtkCellLayoutDataFunc func,
229 GDestroyNotify destroy)
231 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
232 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
234 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout,
242 * gtk_cell_layout_clear_attributes:
243 * @cell_layout: A #GtkCellLayout.
244 * @cell: A #GtkCellRenderer to clear the attribute mapping on.
246 * Clears all existing attributes previously set with
247 * gtk_cell_layout_set_attributes().
252 gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
253 GtkCellRenderer *cell)
255 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
256 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
258 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout,
263 * gtk_cell_layout_reorder:
264 * @cell_layout: A #GtkCellLayout.
265 * @cell: A #GtkCellRenderer to reorder.
266 * @position: New position to insert @cell at.
268 * Re-inserts @cell at @position. Note that @cell has already to be packed
269 * into @cell_layout for this to function properly.
274 gtk_cell_layout_reorder (GtkCellLayout *cell_layout,
275 GtkCellRenderer *cell,
278 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
279 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
281 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder) (cell_layout,
287 * gtk_cell_layout_get_cells:
288 * @cell_layout: a #GtkCellLayout
290 * Returns the cell renderers which have been added to @cell_layout.
292 * Return value: a list of cell renderers. The list, but not the
293 * renderers has been newly allocated and should be freed with
294 * g_list_free() when no longer needed.
299 gtk_cell_layout_get_cells (GtkCellLayout *cell_layout)
301 GtkCellLayoutIface *iface;
303 g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
305 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
306 if (iface->get_cells)
307 return iface->get_cells (cell_layout);
312 #define __GTK_CELL_LAYOUT_C__
313 #include "gtkaliasdef.c"