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.
67 gtk_cell_layout_pack_start (GtkCellLayout *cell_layout,
68 GtkCellRenderer *cell,
71 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
72 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
74 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout,
80 * gtk_cell_layout_pack_end:
81 * @cell_layout: A #GtkCellLayout.
82 * @cell: A #GtkCellRenderer.
83 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout.
85 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the
86 * @cell is allocated no more space than it needs. Any unused space is
87 * divided evenly between cells for which @expand is %TRUE.
92 gtk_cell_layout_pack_end (GtkCellLayout *cell_layout,
93 GtkCellRenderer *cell,
96 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
97 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
99 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout,
105 * gtk_cell_layout_clear:
106 * @cell_layout: A #GtkCellLayout.
108 * Unsets all the mappings on all renderers on @cell_layout and
109 * removes all renderers from @cell_layout.
114 gtk_cell_layout_clear (GtkCellLayout *cell_layout)
116 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
118 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear) (cell_layout);
122 gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
123 GtkCellRenderer *cell,
128 GtkCellLayoutIface *iface;
130 attribute = va_arg (args, gchar *);
132 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
134 (* iface->clear_attributes) (cell_layout, cell);
136 while (attribute != NULL)
138 column = va_arg (args, gint);
139 (* iface->add_attribute) (cell_layout, cell, attribute, column);
140 attribute = va_arg (args, gchar *);
145 * gtk_cell_layout_set_attributes:
146 * @cell_layout: A #GtkCellLayout.
147 * @cell: A #GtkCellRenderer.
148 * @Varargs: A %NULL-terminated list of attributes.
150 * Sets the attributes in list as the attributes of @cell_layout. The
151 * attributes should be in attribute/column order, as in
152 * gtk_cell_layout_add_attribute(). All existing attributes are removed, and
153 * replaced with the new attributes.
158 gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout,
159 GtkCellRenderer *cell,
164 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
165 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
167 va_start (args, cell);
168 gtk_cell_layout_set_attributesv (cell_layout, cell, args);
173 * gtk_cell_layout_add_attribute:
174 * @cell_layout: A #GtkCellLayout.
175 * @cell: A #GtkCellRenderer.
176 * @attribute: An attribute on the renderer.
177 * @column: The column position on the model to get the attribute from.
179 * Adds an attribute mapping to the list in @cell_layout. The @column is the
180 * column of the model to get a value from, and the @attribute is the
181 * parameter on @cell to be set from the value. So for example if column 2
182 * of the model contains strings, you could have the "text" attribute of a
183 * #GtkCellRendererText get its values from column 2.
188 gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
189 GtkCellRenderer *cell,
190 const gchar *attribute,
193 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
194 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
195 g_return_if_fail (attribute != NULL);
196 g_return_if_fail (column >= 0);
198 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout,
205 * gtk_cell_layout_set_cell_data_func:
206 * @cell_layout: A #GtkCellLayout.
207 * @cell: A #GtkCellRenderer.
208 * @func: The #GtkCellLayoutDataFunc to use.
209 * @func_data: The user data for @func.
210 * @destroy: The destroy notification for @func_data.
212 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout. This function
213 * is used instead of the standard attributes mapping for setting the
214 * column value, and should set the value of @cell_layout's cell renderer(s)
215 * as appropriate. @func may be %NULL to remove and older one.
220 gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
221 GtkCellRenderer *cell,
222 GtkCellLayoutDataFunc func,
224 GDestroyNotify destroy)
226 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
227 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
229 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout,
237 * gtk_cell_layout_clear_attributes:
238 * @cell_layout: A #GtkCellLayout.
239 * @cell: A #GtkCellRenderer to clear the attribute mapping on.
241 * Clears all existing attributes previously set with
242 * gtk_cell_layout_set_attributes().
247 gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
248 GtkCellRenderer *cell)
250 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
251 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
253 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout,
258 * gtk_cell_layout_reorder:
259 * @cell_layout: A #GtkCellLayout.
260 * @cell: A #GtkCellRenderer to reorder.
261 * @position: New position to insert @cell at.
263 * Re-inserts @cell at @position. Note that @cell has already to be packed
264 * into @cell_layout for this to function properly.
269 gtk_cell_layout_reorder (GtkCellLayout *cell_layout,
270 GtkCellRenderer *cell,
273 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
274 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
276 (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder) (cell_layout,
281 #define __GTK_CELL_LAYOUT_C__
282 #include "gtkaliasdef.c"