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 * SECTION:gtkcelllayout
22 * @Short_Description: An interface for packing cells
23 * @Title: GtkCellLayout
25 * #GtkCellLayout is an interface to be implemented by all objects which
26 * want to provide a #GtkTreeViewColumn-like API for packing cells, setting
27 * attributes and data funcs.
29 * One of the notable features provided by implementations of GtkCellLayout
30 * are <emphasis>attributes</emphasis>. Attributes let you set the properties
31 * in flexible ways. They can just be set to constant values like regular
32 * properties. But they can also be mapped to a column of the underlying
33 * tree model with gtk_cell_layout_set_attributes(), which means that the value
34 * of the attribute can change from cell to cell as they are rendered by the
35 * cell renderer. Finally, it is possible to specify a function with
36 * gtk_cell_layout_set_cell_data_func() that is called to determine the value
37 * of the attribute for each cell that is rendered.
39 * <refsect2 id="GtkCellLayout-BUILDER-UI">
40 * <title>GtkCellLayouts as GtkBuildable</title>
42 * Implementations of GtkCellLayout which also implement the GtkBuildable
43 * interface (#GtkCellView, #GtkIconView, #GtkComboBox, #GtkComboBoxEntry,
44 * #GtkEntryCompletion, #GtkTreeViewColumn) accept GtkCellRenderer objects
45 * as <child> elements in UI definitions. They support a custom
46 * <attributes> element for their children, which can contain
47 * multiple <attribute> elements. Each <attribute> element has
48 * a name attribute which specifies a property of the cell renderer; the
49 * content of the element is the attribute value.
52 * <title>A UI definition fragment specifying attributes</title>
53 * <programlisting><![CDATA[
54 * <object class="GtkCellView">
56 * <object class="GtkCellRendererText"/>
58 * <attribute name="text">0</attribute>
62 * ]]></programlisting>
65 * Furthermore for implementations of GtkCellLayout that use a #GtkCellArea
66 * to lay out cells (all GtkCellLayouts in GTK+ use a GtkCellArea)
67 * <link linkend="cell-properties">cell properties</link> can also be defined
68 * in the format by specifying the custom <cell-packing> attribute which
69 * can contain multiple <property> elements defined in the normal way.
71 * <title>A UI definition fragment specifying cell properties</title>
72 * <programlisting><![CDATA[
73 * <object class="GtkTreeViewColumn">
75 * <object class="GtkCellRendererText"/>
77 * <property name="align">True</property>
78 * <property name="expand">False</property>
82 * ]]></programlisting>
88 * <title>Subclassing GtkCellLayout implementations</title>
90 * When subclassing a widget that implements #GtkCellLayout like
91 * #GtkIconView or #GtkComboBox, there are some considerations related
92 * to the fact that these widgets internally use a #GtkCellArea.
93 * The cell area is exposed as a construct-only property by these
94 * widgets. This means that it is possible to e.g. do
95 * <informalexample><programlisting>
96 * combo = g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL);
97 * </programlisting></informalexample>
98 * to use a custom cell area with a combo box. But construct properties
99 * are only initialized <emphasis>after</emphasis> instance init()
100 * functions have run, which means that using functions which rely on
101 * the existence of the cell area in your subclass' init() function will
102 * cause the default cell area to be instantiated. In this case, a provided
103 * construct property value will be ignored (with a warning, to alert
104 * you to the problem).
105 * <informalexample><programlisting>
107 * my_combo_box_init (MyComboBox *b)
109 * GtkCellRenderer *cell;
111 * cell = gtk_cell_renderer_pixbuf_new ();
112 * /* The following call causes the default cell area for combo boxes,
113 * * a GtkCellAreaBox, to be instantiated
115 * gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (b), cell, FALSE);
120 * my_combo_box_new (GtkCellArea *area)
122 * /* This call is going to cause a warning
123 * * about area being ignored
125 * return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL);
127 * </programlisting></informalexample>
128 * If supporting alternative cell areas with your derived widget is
129 * not important, then this does not have to concern you. If you want
130 * to support alternative cell areas, you can do so by moving the
131 * problematic calls out of init() and into a constructor()
141 #include "gtkcelllayout.h"
142 #include "gtkbuilderprivate.h"
145 #define warn_no_cell_area(func) \
146 g_critical ("%s: Called but no GtkCellArea is available yet", func)
148 typedef GtkCellLayoutIface GtkCellLayoutInterface;
149 G_DEFINE_INTERFACE (GtkCellLayout, gtk_cell_layout, G_TYPE_OBJECT);
151 static void gtk_cell_layout_default_pack_start (GtkCellLayout *cell_layout,
152 GtkCellRenderer *cell,
154 static void gtk_cell_layout_default_pack_end (GtkCellLayout *cell_layout,
155 GtkCellRenderer *cell,
157 static void gtk_cell_layout_default_clear (GtkCellLayout *cell_layout);
158 static void gtk_cell_layout_default_add_attribute (GtkCellLayout *cell_layout,
159 GtkCellRenderer *cell,
160 const gchar *attribute,
162 static void gtk_cell_layout_default_set_cell_data_func (GtkCellLayout *cell_layout,
163 GtkCellRenderer *cell,
164 GtkCellLayoutDataFunc func,
166 GDestroyNotify destroy);
167 static void gtk_cell_layout_default_clear_attributes (GtkCellLayout *cell_layout,
168 GtkCellRenderer *cell);
169 static void gtk_cell_layout_default_reorder (GtkCellLayout *cell_layout,
170 GtkCellRenderer *cell,
172 static GList *gtk_cell_layout_default_get_cells (GtkCellLayout *cell_layout);
176 gtk_cell_layout_default_init (GtkCellLayoutIface *iface)
178 iface->pack_start = gtk_cell_layout_default_pack_start;
179 iface->pack_end = gtk_cell_layout_default_pack_end;
180 iface->clear = gtk_cell_layout_default_clear;
181 iface->add_attribute = gtk_cell_layout_default_add_attribute;
182 iface->set_cell_data_func = gtk_cell_layout_default_set_cell_data_func;
183 iface->clear_attributes = gtk_cell_layout_default_clear_attributes;
184 iface->reorder = gtk_cell_layout_default_reorder;
185 iface->get_cells = gtk_cell_layout_default_get_cells;
188 /* Default implementation is to fall back on an underlying cell area */
190 gtk_cell_layout_default_pack_start (GtkCellLayout *cell_layout,
191 GtkCellRenderer *cell,
194 GtkCellLayoutIface *iface;
197 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
201 area = iface->get_area (cell_layout);
204 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (area), cell, expand);
206 warn_no_cell_area ("GtkCellLayoutIface->pack_start()");
211 gtk_cell_layout_default_pack_end (GtkCellLayout *cell_layout,
212 GtkCellRenderer *cell,
215 GtkCellLayoutIface *iface;
218 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
222 area = iface->get_area (cell_layout);
225 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (area), cell, expand);
227 warn_no_cell_area ("GtkCellLayoutIface->pack_end()");
232 gtk_cell_layout_default_clear (GtkCellLayout *cell_layout)
234 GtkCellLayoutIface *iface;
237 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
241 area = iface->get_area (cell_layout);
244 gtk_cell_layout_clear (GTK_CELL_LAYOUT (area));
246 warn_no_cell_area ("GtkCellLayoutIface->clear()");
251 gtk_cell_layout_default_add_attribute (GtkCellLayout *cell_layout,
252 GtkCellRenderer *cell,
253 const gchar *attribute,
256 GtkCellLayoutIface *iface;
259 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
263 area = iface->get_area (cell_layout);
266 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (area), cell, attribute, column);
268 warn_no_cell_area ("GtkCellLayoutIface->add_attribute()");
273 gtk_cell_layout_default_set_cell_data_func (GtkCellLayout *cell_layout,
274 GtkCellRenderer *cell,
275 GtkCellLayoutDataFunc func,
277 GDestroyNotify destroy)
279 GtkCellLayoutIface *iface;
282 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
286 area = iface->get_area (cell_layout);
289 _gtk_cell_area_set_cell_data_func_with_proxy (area, cell,
290 (GFunc)func, func_data, destroy,
293 warn_no_cell_area ("GtkCellLayoutIface->set_cell_data_func()");
298 gtk_cell_layout_default_clear_attributes (GtkCellLayout *cell_layout,
299 GtkCellRenderer *cell)
301 GtkCellLayoutIface *iface;
304 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
308 area = iface->get_area (cell_layout);
311 gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (area), cell);
313 warn_no_cell_area ("GtkCellLayoutIface->clear_attributes()");
318 gtk_cell_layout_default_reorder (GtkCellLayout *cell_layout,
319 GtkCellRenderer *cell,
322 GtkCellLayoutIface *iface;
325 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
329 area = iface->get_area (cell_layout);
332 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (area), cell, position);
334 warn_no_cell_area ("GtkCellLayoutIface->reorder()");
339 gtk_cell_layout_default_get_cells (GtkCellLayout *cell_layout)
341 GtkCellLayoutIface *iface;
344 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
348 area = iface->get_area (cell_layout);
351 return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (area));
353 warn_no_cell_area ("GtkCellLayoutIface->get_cells()");
360 * gtk_cell_layout_pack_start:
361 * @cell_layout: a #GtkCellLayout
362 * @cell: a #GtkCellRenderer
363 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout
365 * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE,
366 * then the @cell is allocated no more space than it needs. Any unused space
367 * is divided evenly between cells for which @expand is %TRUE.
369 * Note that reusing the same cell renderer is not supported.
374 gtk_cell_layout_pack_start (GtkCellLayout *cell_layout,
375 GtkCellRenderer *cell,
378 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
379 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
381 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start (cell_layout, cell, expand);
385 * gtk_cell_layout_pack_end:
386 * @cell_layout: a #GtkCellLayout
387 * @cell: a #GtkCellRenderer
388 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout
390 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the
391 * @cell is allocated no more space than it needs. Any unused space is
392 * divided evenly between cells for which @expand is %TRUE.
394 * Note that reusing the same cell renderer is not supported.
399 gtk_cell_layout_pack_end (GtkCellLayout *cell_layout,
400 GtkCellRenderer *cell,
403 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
404 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
406 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end (cell_layout, cell, expand);
410 * gtk_cell_layout_clear:
411 * @cell_layout: a #GtkCellLayout
413 * Unsets all the mappings on all renderers on @cell_layout and
414 * removes all renderers from @cell_layout.
419 gtk_cell_layout_clear (GtkCellLayout *cell_layout)
421 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
423 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear (cell_layout);
427 gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
428 GtkCellRenderer *cell,
434 attribute = va_arg (args, gchar *);
436 gtk_cell_layout_clear_attributes (cell_layout, cell);
438 while (attribute != NULL)
440 column = va_arg (args, gint);
442 gtk_cell_layout_add_attribute (cell_layout, cell, attribute, column);
444 attribute = va_arg (args, gchar *);
449 * gtk_cell_layout_set_attributes:
450 * @cell_layout: a #GtkCellLayout
451 * @cell: a #GtkCellRenderer
452 * @...: a %NULL-terminated list of attributes
454 * Sets the attributes in list as the attributes of @cell_layout.
456 * The attributes should be in attribute/column order, as in
457 * gtk_cell_layout_add_attribute(). All existing attributes are
458 * removed, and replaced with the new attributes.
463 gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout,
464 GtkCellRenderer *cell,
469 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
470 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
472 va_start (args, cell);
473 gtk_cell_layout_set_attributesv (cell_layout, cell, args);
478 * gtk_cell_layout_add_attribute:
479 * @cell_layout: a #GtkCellLayout
480 * @cell: a #GtkCellRenderer
481 * @attribute: an attribute on the renderer
482 * @column: the column position on the model to get the attribute from
484 * Adds an attribute mapping to the list in @cell_layout.
486 * The @column is the column of the model to get a value from, and the
487 * @attribute is the parameter on @cell to be set from the value. So for
488 * example if column 2 of the model contains strings, you could have the
489 * "text" attribute of a #GtkCellRendererText get its values from column 2.
494 gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
495 GtkCellRenderer *cell,
496 const gchar *attribute,
499 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
500 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
501 g_return_if_fail (attribute != NULL);
502 g_return_if_fail (column >= 0);
504 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute (cell_layout, cell, attribute, column);
508 * gtk_cell_layout_set_cell_data_func:
509 * @cell_layout: a #GtkCellLayout
510 * @cell: a #GtkCellRenderer
511 * @func: (allow-none): the #GtkCellLayoutDataFunc to use, or %NULL
512 * @func_data: user data for @func
513 * @destroy: destroy notify for @func_data
515 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout.
517 * This function is used instead of the standard attributes mapping
518 * for setting the column value, and should set the value of @cell_layout's
519 * cell renderer(s) as appropriate.
521 * @func may be %NULL to remove a previously set function.
526 gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
527 GtkCellRenderer *cell,
528 GtkCellLayoutDataFunc func,
530 GDestroyNotify destroy)
532 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
533 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
535 GTK_CELL_LAYOUT_GET_IFACE
536 (cell_layout)->set_cell_data_func (cell_layout, cell, func, func_data, destroy);
540 * gtk_cell_layout_clear_attributes:
541 * @cell_layout: a #GtkCellLayout
542 * @cell: a #GtkCellRenderer to clear the attribute mapping on
544 * Clears all existing attributes previously set with
545 * gtk_cell_layout_set_attributes().
550 gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
551 GtkCellRenderer *cell)
553 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
554 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
556 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes (cell_layout, cell);
560 * gtk_cell_layout_reorder:
561 * @cell_layout: a #GtkCellLayout
562 * @cell: a #GtkCellRenderer to reorder
563 * @position: new position to insert @cell at
565 * Re-inserts @cell at @position.
567 * Note that @cell has already to be packed into @cell_layout
568 * for this to function properly.
573 gtk_cell_layout_reorder (GtkCellLayout *cell_layout,
574 GtkCellRenderer *cell,
577 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
578 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
580 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder (cell_layout, cell, position);
584 * gtk_cell_layout_get_cells:
585 * @cell_layout: a #GtkCellLayout
587 * Returns the cell renderers which have been added to @cell_layout.
589 * Return value: (element-type GtkCellRenderer) (transfer container):
590 * a list of cell renderers. The list, but not the renderers has
591 * been newly allocated and should be freed with g_list_free()
592 * when no longer needed.
597 gtk_cell_layout_get_cells (GtkCellLayout *cell_layout)
599 g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
601 return GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->get_cells (cell_layout);
605 * gtk_cell_layout_get_area:
606 * @cell_layout: a #GtkCellLayout
608 * Returns the underlying #GtkCellArea which might be @cell_layout
609 * if called on a #GtkCellArea or might be %NULL if no #GtkCellArea
610 * is used by @cell_layout.
612 * Return value: (transfer none): the cell area used by @cell_layout.
617 gtk_cell_layout_get_area (GtkCellLayout *cell_layout)
619 GtkCellLayoutIface *iface;
621 g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
623 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
625 return iface->get_area (cell_layout);
630 /* Attribute parsing */
632 GtkCellLayout *cell_layout;
633 GtkCellRenderer *renderer;
635 } AttributesSubParserData;
638 attributes_start_element (GMarkupParseContext *context,
639 const gchar *element_name,
641 const gchar **values,
645 AttributesSubParserData *parser_data = (AttributesSubParserData*)user_data;
648 if (strcmp (element_name, "attribute") == 0)
650 for (i = 0; names[i]; i++)
651 if (strcmp (names[i], "name") == 0)
652 parser_data->attr_name = g_strdup (values[i]);
654 else if (strcmp (element_name, "attributes") == 0)
657 g_warning ("Unsupported tag for GtkCellLayout: %s\n", element_name);
661 attributes_text_element (GMarkupParseContext *context,
667 AttributesSubParserData *parser_data = (AttributesSubParserData*)user_data;
672 if (!parser_data->attr_name)
675 string = g_strndup (text, text_len);
677 l = g_ascii_strtoll (string, &endptr, 0);
678 if (errno || endptr == string)
682 GTK_BUILDER_ERROR_INVALID_VALUE,
683 "Could not parse integer `%s'",
690 gtk_cell_layout_add_attribute (parser_data->cell_layout,
691 parser_data->renderer,
692 parser_data->attr_name, l);
693 g_free (parser_data->attr_name);
694 parser_data->attr_name = NULL;
697 static const GMarkupParser attributes_parser =
699 attributes_start_element,
701 attributes_text_element,
705 /* Cell packing parsing */
707 gtk_cell_layout_buildable_set_cell_property (GtkCellArea *area,
709 GtkCellRenderer *cell,
714 GValue gvalue = G_VALUE_INIT;
715 GError *error = NULL;
717 pspec = gtk_cell_area_class_find_cell_property (GTK_CELL_AREA_GET_CLASS (area), name);
720 g_warning ("%s does not have a property called %s",
721 g_type_name (G_OBJECT_TYPE (area)), name);
725 if (!gtk_builder_value_from_string (builder, pspec, value, &gvalue, &error))
727 g_warning ("Could not read property %s:%s with value %s of type %s: %s",
728 g_type_name (G_OBJECT_TYPE (area)),
731 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
733 g_error_free (error);
737 gtk_cell_area_cell_set_property (area, cell, name, &gvalue);
738 g_value_unset (&gvalue);
743 GtkCellLayout *cell_layout;
744 GtkCellRenderer *renderer;
746 gchar *cell_prop_name;
748 gboolean translatable;
749 } CellPackingSubParserData;
752 cell_packing_start_element (GMarkupParseContext *context,
753 const gchar *element_name,
755 const gchar **values,
759 CellPackingSubParserData *parser_data = (CellPackingSubParserData*)user_data;
762 if (strcmp (element_name, "property") == 0)
764 for (i = 0; names[i]; i++)
765 if (strcmp (names[i], "name") == 0)
766 parser_data->cell_prop_name = g_strdup (values[i]);
767 else if (strcmp (names[i], "translatable") == 0)
769 if (!_gtk_builder_boolean_from_string (values[i],
770 &parser_data->translatable,
774 else if (strcmp (names[i], "comments") == 0)
775 ; /* for translators */
776 else if (strcmp (names[i], "context") == 0)
777 parser_data->context = g_strdup (values[i]);
779 g_warning ("Unsupported attribute for GtkCellLayout Cell "
780 "property: %s\n", names[i]);
782 else if (strcmp (element_name, "cell-packing") == 0)
785 g_warning ("Unsupported tag for GtkCellLayout: %s\n", element_name);
789 cell_packing_text_element (GMarkupParseContext *context,
795 CellPackingSubParserData *parser_data = (CellPackingSubParserData*)user_data;
797 if (parser_data->cell_prop_name)
798 g_string_append_len (parser_data->string, text, text_len);
802 cell_packing_end_element (GMarkupParseContext *context,
803 const gchar *element_name,
807 CellPackingSubParserData *parser_data = (CellPackingSubParserData*)user_data;
810 area = gtk_cell_layout_get_area (parser_data->cell_layout);
814 /* translate the string */
815 if (parser_data->string->len && parser_data->translatable)
820 domain = gtk_builder_get_translation_domain (parser_data->builder);
822 translated = _gtk_builder_parser_translate (domain,
823 parser_data->context,
824 parser_data->string->str);
825 g_string_set_size (parser_data->string, 0);
826 g_string_append (parser_data->string, translated);
829 if (parser_data->cell_prop_name)
830 gtk_cell_layout_buildable_set_cell_property (area,
831 parser_data->builder,
832 parser_data->renderer,
833 parser_data->cell_prop_name,
834 parser_data->string->str);
837 g_warning ("%s does not have an internal GtkCellArea class and cannot apply child cell properties",
838 g_type_name (G_OBJECT_TYPE (parser_data->cell_layout)));
840 g_string_set_size (parser_data->string, 0);
841 g_free (parser_data->cell_prop_name);
842 g_free (parser_data->context);
843 parser_data->cell_prop_name = NULL;
844 parser_data->context = NULL;
845 parser_data->translatable = FALSE;
849 static const GMarkupParser cell_packing_parser =
851 cell_packing_start_element,
852 cell_packing_end_element,
853 cell_packing_text_element,
857 _gtk_cell_layout_buildable_custom_tag_start (GtkBuildable *buildable,
860 const gchar *tagname,
861 GMarkupParser *parser,
864 AttributesSubParserData *attr_data;
865 CellPackingSubParserData *packing_data;
870 if (strcmp (tagname, "attributes") == 0)
872 attr_data = g_slice_new0 (AttributesSubParserData);
873 attr_data->cell_layout = GTK_CELL_LAYOUT (buildable);
874 attr_data->renderer = GTK_CELL_RENDERER (child);
875 attr_data->attr_name = NULL;
877 *parser = attributes_parser;
881 else if (strcmp (tagname, "cell-packing") == 0)
883 packing_data = g_slice_new0 (CellPackingSubParserData);
884 packing_data->string = g_string_new ("");
885 packing_data->builder = builder;
886 packing_data->cell_layout = GTK_CELL_LAYOUT (buildable);
887 packing_data->renderer = GTK_CELL_RENDERER (child);
889 *parser = cell_packing_parser;
890 *data = packing_data;
898 _gtk_cell_layout_buildable_custom_tag_end (GtkBuildable *buildable,
901 const gchar *tagname,
904 AttributesSubParserData *attr_data;
905 CellPackingSubParserData *packing_data;
907 if (strcmp (tagname, "attributes") == 0)
909 attr_data = (AttributesSubParserData*)data;
910 g_assert (!attr_data->attr_name);
911 g_slice_free (AttributesSubParserData, attr_data);
914 else if (strcmp (tagname, "cell-packing") == 0)
916 packing_data = (CellPackingSubParserData *)data;
917 g_string_free (packing_data->string, TRUE);
918 g_slice_free (CellPackingSubParserData, packing_data);
925 _gtk_cell_layout_buildable_add_child (GtkBuildable *buildable,
930 g_return_if_fail (GTK_IS_CELL_LAYOUT (buildable));
931 g_return_if_fail (GTK_IS_CELL_RENDERER (child));
933 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (buildable), GTK_CELL_RENDERER (child), FALSE);