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, see <http://www.gnu.org/licenses/>.
19 * SECTION:gtkcelllayout
20 * @Short_Description: An interface for packing cells
21 * @Title: GtkCellLayout
23 * #GtkCellLayout is an interface to be implemented by all objects which
24 * want to provide a #GtkTreeViewColumn<!-- -->-like API for packing cells, setting
25 * attributes and data funcs.
27 * One of the notable features provided by implementations of GtkCellLayout
28 * are <emphasis>attributes</emphasis>. Attributes let you set the properties
29 * in flexible ways. They can just be set to constant values like regular
30 * properties. But they can also be mapped to a column of the underlying
31 * tree model with gtk_cell_layout_set_attributes(), which means that the value
32 * of the attribute can change from cell to cell as they are rendered by the
33 * cell renderer. Finally, it is possible to specify a function with
34 * gtk_cell_layout_set_cell_data_func() that is called to determine the value
35 * of the attribute for each cell that is rendered.
37 * <refsect2 id="GtkCellLayout-BUILDER-UI">
38 * <title>GtkCellLayouts as GtkBuildable</title>
40 * Implementations of GtkCellLayout which also implement the GtkBuildable
41 * interface (#GtkCellView, #GtkIconView, #GtkComboBox,
42 * #GtkEntryCompletion, #GtkTreeViewColumn) accept GtkCellRenderer objects
43 * as <child> elements in UI definitions. They support a custom
44 * <attributes> element for their children, which can contain
45 * multiple <attribute> elements. Each <attribute> element has
46 * a name attribute which specifies a property of the cell renderer; the
47 * content of the element is the attribute value.
50 * <title>A UI definition fragment specifying attributes</title>
51 * <programlisting><![CDATA[
52 * <object class="GtkCellView">
54 * <object class="GtkCellRendererText"/>
56 * <attribute name="text">0</attribute>
60 * ]]></programlisting>
63 * Furthermore for implementations of GtkCellLayout that use a #GtkCellArea
64 * to lay out cells (all GtkCellLayouts in GTK+ use a GtkCellArea)
65 * <link linkend="cell-properties">cell properties</link> can also be defined
66 * in the format by specifying the custom <cell-packing> attribute which
67 * can contain multiple <property> elements defined in the normal way.
69 * <title>A UI definition fragment specifying cell properties</title>
70 * <programlisting><![CDATA[
71 * <object class="GtkTreeViewColumn">
73 * <object class="GtkCellRendererText"/>
75 * <property name="align">True</property>
76 * <property name="expand">False</property>
80 * ]]></programlisting>
86 * <title>Subclassing GtkCellLayout implementations</title>
88 * When subclassing a widget that implements #GtkCellLayout like
89 * #GtkIconView or #GtkComboBox, there are some considerations related
90 * to the fact that these widgets internally use a #GtkCellArea.
91 * The cell area is exposed as a construct-only property by these
92 * widgets. This means that it is possible to e.g. do
93 * <informalexample><programlisting>
94 * combo = g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL);
95 * </programlisting></informalexample>
96 * to use a custom cell area with a combo box. But construct properties
97 * are only initialized <emphasis>after</emphasis> instance init()
98 * functions have run, which means that using functions which rely on
99 * the existence of the cell area in your subclass' init() function will
100 * cause the default cell area to be instantiated. In this case, a provided
101 * construct property value will be ignored (with a warning, to alert
102 * you to the problem).
103 * <informalexample><programlisting>
105 * my_combo_box_init (MyComboBox *b)
107 * GtkCellRenderer *cell;
109 * cell = gtk_cell_renderer_pixbuf_new ();
110 * /* The following call causes the default cell area for combo boxes,
111 * * a GtkCellAreaBox, to be instantiated
113 * gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (b), cell, FALSE);
118 * my_combo_box_new (GtkCellArea *area)
120 * /* This call is going to cause a warning
121 * * about area being ignored
123 * return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL);
125 * </programlisting></informalexample>
126 * If supporting alternative cell areas with your derived widget is
127 * not important, then this does not have to concern you. If you want
128 * to support alternative cell areas, you can do so by moving the
129 * problematic calls out of init() and into a constructor()
139 #include "gtkcelllayout.h"
140 #include "gtkbuilderprivate.h"
143 #define warn_no_cell_area(func) \
144 g_critical ("%s: Called but no GtkCellArea is available yet", func)
146 typedef GtkCellLayoutIface GtkCellLayoutInterface;
147 G_DEFINE_INTERFACE (GtkCellLayout, gtk_cell_layout, G_TYPE_OBJECT);
149 static void gtk_cell_layout_default_pack_start (GtkCellLayout *cell_layout,
150 GtkCellRenderer *cell,
152 static void gtk_cell_layout_default_pack_end (GtkCellLayout *cell_layout,
153 GtkCellRenderer *cell,
155 static void gtk_cell_layout_default_clear (GtkCellLayout *cell_layout);
156 static void gtk_cell_layout_default_add_attribute (GtkCellLayout *cell_layout,
157 GtkCellRenderer *cell,
158 const gchar *attribute,
160 static void gtk_cell_layout_default_set_cell_data_func (GtkCellLayout *cell_layout,
161 GtkCellRenderer *cell,
162 GtkCellLayoutDataFunc func,
164 GDestroyNotify destroy);
165 static void gtk_cell_layout_default_clear_attributes (GtkCellLayout *cell_layout,
166 GtkCellRenderer *cell);
167 static void gtk_cell_layout_default_reorder (GtkCellLayout *cell_layout,
168 GtkCellRenderer *cell,
170 static GList *gtk_cell_layout_default_get_cells (GtkCellLayout *cell_layout);
174 gtk_cell_layout_default_init (GtkCellLayoutIface *iface)
176 iface->pack_start = gtk_cell_layout_default_pack_start;
177 iface->pack_end = gtk_cell_layout_default_pack_end;
178 iface->clear = gtk_cell_layout_default_clear;
179 iface->add_attribute = gtk_cell_layout_default_add_attribute;
180 iface->set_cell_data_func = gtk_cell_layout_default_set_cell_data_func;
181 iface->clear_attributes = gtk_cell_layout_default_clear_attributes;
182 iface->reorder = gtk_cell_layout_default_reorder;
183 iface->get_cells = gtk_cell_layout_default_get_cells;
186 /* Default implementation is to fall back on an underlying cell area */
188 gtk_cell_layout_default_pack_start (GtkCellLayout *cell_layout,
189 GtkCellRenderer *cell,
192 GtkCellLayoutIface *iface;
195 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
199 area = iface->get_area (cell_layout);
202 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (area), cell, expand);
204 warn_no_cell_area ("GtkCellLayoutIface->pack_start()");
209 gtk_cell_layout_default_pack_end (GtkCellLayout *cell_layout,
210 GtkCellRenderer *cell,
213 GtkCellLayoutIface *iface;
216 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
220 area = iface->get_area (cell_layout);
223 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (area), cell, expand);
225 warn_no_cell_area ("GtkCellLayoutIface->pack_end()");
230 gtk_cell_layout_default_clear (GtkCellLayout *cell_layout)
232 GtkCellLayoutIface *iface;
235 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
239 area = iface->get_area (cell_layout);
242 gtk_cell_layout_clear (GTK_CELL_LAYOUT (area));
244 warn_no_cell_area ("GtkCellLayoutIface->clear()");
249 gtk_cell_layout_default_add_attribute (GtkCellLayout *cell_layout,
250 GtkCellRenderer *cell,
251 const gchar *attribute,
254 GtkCellLayoutIface *iface;
257 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
261 area = iface->get_area (cell_layout);
264 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (area), cell, attribute, column);
266 warn_no_cell_area ("GtkCellLayoutIface->add_attribute()");
271 gtk_cell_layout_default_set_cell_data_func (GtkCellLayout *cell_layout,
272 GtkCellRenderer *cell,
273 GtkCellLayoutDataFunc func,
275 GDestroyNotify destroy)
277 GtkCellLayoutIface *iface;
280 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
284 area = iface->get_area (cell_layout);
287 _gtk_cell_area_set_cell_data_func_with_proxy (area, cell,
288 (GFunc)func, func_data, destroy,
291 warn_no_cell_area ("GtkCellLayoutIface->set_cell_data_func()");
296 gtk_cell_layout_default_clear_attributes (GtkCellLayout *cell_layout,
297 GtkCellRenderer *cell)
299 GtkCellLayoutIface *iface;
302 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
306 area = iface->get_area (cell_layout);
309 gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (area), cell);
311 warn_no_cell_area ("GtkCellLayoutIface->clear_attributes()");
316 gtk_cell_layout_default_reorder (GtkCellLayout *cell_layout,
317 GtkCellRenderer *cell,
320 GtkCellLayoutIface *iface;
323 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
327 area = iface->get_area (cell_layout);
330 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (area), cell, position);
332 warn_no_cell_area ("GtkCellLayoutIface->reorder()");
337 gtk_cell_layout_default_get_cells (GtkCellLayout *cell_layout)
339 GtkCellLayoutIface *iface;
342 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
346 area = iface->get_area (cell_layout);
349 return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (area));
351 warn_no_cell_area ("GtkCellLayoutIface->get_cells()");
358 * gtk_cell_layout_pack_start:
359 * @cell_layout: a #GtkCellLayout
360 * @cell: a #GtkCellRenderer
361 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout
363 * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE,
364 * then the @cell is allocated no more space than it needs. Any unused space
365 * is divided evenly between cells for which @expand is %TRUE.
367 * Note that reusing the same cell renderer is not supported.
372 gtk_cell_layout_pack_start (GtkCellLayout *cell_layout,
373 GtkCellRenderer *cell,
376 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
377 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
379 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start (cell_layout, cell, expand);
383 * gtk_cell_layout_pack_end:
384 * @cell_layout: a #GtkCellLayout
385 * @cell: a #GtkCellRenderer
386 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout
388 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the
389 * @cell is allocated no more space than it needs. Any unused space is
390 * divided evenly between cells for which @expand is %TRUE.
392 * Note that reusing the same cell renderer is not supported.
397 gtk_cell_layout_pack_end (GtkCellLayout *cell_layout,
398 GtkCellRenderer *cell,
401 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
402 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
404 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end (cell_layout, cell, expand);
408 * gtk_cell_layout_clear:
409 * @cell_layout: a #GtkCellLayout
411 * Unsets all the mappings on all renderers on @cell_layout and
412 * removes all renderers from @cell_layout.
417 gtk_cell_layout_clear (GtkCellLayout *cell_layout)
419 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
421 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear (cell_layout);
425 gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
426 GtkCellRenderer *cell,
432 attribute = va_arg (args, gchar *);
434 gtk_cell_layout_clear_attributes (cell_layout, cell);
436 while (attribute != NULL)
438 column = va_arg (args, gint);
440 gtk_cell_layout_add_attribute (cell_layout, cell, attribute, column);
442 attribute = va_arg (args, gchar *);
447 * gtk_cell_layout_set_attributes:
448 * @cell_layout: a #GtkCellLayout
449 * @cell: a #GtkCellRenderer
450 * @...: a %NULL-terminated list of attributes
452 * Sets the attributes in list as the attributes of @cell_layout.
454 * The attributes should be in attribute/column order, as in
455 * gtk_cell_layout_add_attribute(). All existing attributes are
456 * removed, and replaced with the new attributes.
461 gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout,
462 GtkCellRenderer *cell,
467 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
468 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
470 va_start (args, cell);
471 gtk_cell_layout_set_attributesv (cell_layout, cell, args);
476 * gtk_cell_layout_add_attribute:
477 * @cell_layout: a #GtkCellLayout
478 * @cell: a #GtkCellRenderer
479 * @attribute: an attribute on the renderer
480 * @column: the column position on the model to get the attribute from
482 * Adds an attribute mapping to the list in @cell_layout.
484 * The @column is the column of the model to get a value from, and the
485 * @attribute is the parameter on @cell to be set from the value. So for
486 * example if column 2 of the model contains strings, you could have the
487 * "text" attribute of a #GtkCellRendererText get its values from column 2.
492 gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
493 GtkCellRenderer *cell,
494 const gchar *attribute,
497 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
498 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
499 g_return_if_fail (attribute != NULL);
500 g_return_if_fail (column >= 0);
502 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute (cell_layout, cell, attribute, column);
506 * gtk_cell_layout_set_cell_data_func:
507 * @cell_layout: a #GtkCellLayout
508 * @cell: a #GtkCellRenderer
509 * @func: (allow-none): the #GtkCellLayoutDataFunc to use, or %NULL
510 * @func_data: user data for @func
511 * @destroy: destroy notify for @func_data
513 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout.
515 * This function is used instead of the standard attributes mapping
516 * for setting the column value, and should set the value of @cell_layout's
517 * cell renderer(s) as appropriate.
519 * @func may be %NULL to remove a previously set function.
524 gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
525 GtkCellRenderer *cell,
526 GtkCellLayoutDataFunc func,
528 GDestroyNotify destroy)
530 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
531 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
533 GTK_CELL_LAYOUT_GET_IFACE
534 (cell_layout)->set_cell_data_func (cell_layout, cell, func, func_data, destroy);
538 * gtk_cell_layout_clear_attributes:
539 * @cell_layout: a #GtkCellLayout
540 * @cell: a #GtkCellRenderer to clear the attribute mapping on
542 * Clears all existing attributes previously set with
543 * gtk_cell_layout_set_attributes().
548 gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
549 GtkCellRenderer *cell)
551 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
552 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
554 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes (cell_layout, cell);
558 * gtk_cell_layout_reorder:
559 * @cell_layout: a #GtkCellLayout
560 * @cell: a #GtkCellRenderer to reorder
561 * @position: new position to insert @cell at
563 * Re-inserts @cell at @position.
565 * Note that @cell has already to be packed into @cell_layout
566 * for this to function properly.
571 gtk_cell_layout_reorder (GtkCellLayout *cell_layout,
572 GtkCellRenderer *cell,
575 g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
576 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
578 GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder (cell_layout, cell, position);
582 * gtk_cell_layout_get_cells:
583 * @cell_layout: a #GtkCellLayout
585 * Returns the cell renderers which have been added to @cell_layout.
587 * Return value: (element-type GtkCellRenderer) (transfer container):
588 * a list of cell renderers. The list, but not the renderers has
589 * been newly allocated and should be freed with g_list_free()
590 * when no longer needed.
595 gtk_cell_layout_get_cells (GtkCellLayout *cell_layout)
597 g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
599 return GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->get_cells (cell_layout);
603 * gtk_cell_layout_get_area:
604 * @cell_layout: a #GtkCellLayout
606 * Returns the underlying #GtkCellArea which might be @cell_layout
607 * if called on a #GtkCellArea or might be %NULL if no #GtkCellArea
608 * is used by @cell_layout.
610 * Return value: (transfer none): the cell area used by @cell_layout.
615 gtk_cell_layout_get_area (GtkCellLayout *cell_layout)
617 GtkCellLayoutIface *iface;
619 g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
621 iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
623 return iface->get_area (cell_layout);
628 /* Attribute parsing */
630 GtkCellLayout *cell_layout;
631 GtkCellRenderer *renderer;
633 } AttributesSubParserData;
636 attributes_start_element (GMarkupParseContext *context,
637 const gchar *element_name,
639 const gchar **values,
643 AttributesSubParserData *parser_data = (AttributesSubParserData*)user_data;
646 if (strcmp (element_name, "attribute") == 0)
648 for (i = 0; names[i]; i++)
649 if (strcmp (names[i], "name") == 0)
650 parser_data->attr_name = g_strdup (values[i]);
652 else if (strcmp (element_name, "attributes") == 0)
655 g_warning ("Unsupported tag for GtkCellLayout: %s\n", element_name);
659 attributes_text_element (GMarkupParseContext *context,
665 AttributesSubParserData *parser_data = (AttributesSubParserData*)user_data;
670 if (!parser_data->attr_name)
673 string = g_strndup (text, text_len);
675 l = g_ascii_strtoll (string, &endptr, 0);
676 if (errno || endptr == string)
680 GTK_BUILDER_ERROR_INVALID_VALUE,
681 "Could not parse integer `%s'",
688 gtk_cell_layout_add_attribute (parser_data->cell_layout,
689 parser_data->renderer,
690 parser_data->attr_name, l);
691 g_free (parser_data->attr_name);
692 parser_data->attr_name = NULL;
695 static const GMarkupParser attributes_parser =
697 attributes_start_element,
699 attributes_text_element,
703 /* Cell packing parsing */
705 gtk_cell_layout_buildable_set_cell_property (GtkCellArea *area,
707 GtkCellRenderer *cell,
712 GValue gvalue = G_VALUE_INIT;
713 GError *error = NULL;
715 pspec = gtk_cell_area_class_find_cell_property (GTK_CELL_AREA_GET_CLASS (area), name);
718 g_warning ("%s does not have a property called %s",
719 g_type_name (G_OBJECT_TYPE (area)), name);
723 if (!gtk_builder_value_from_string (builder, pspec, value, &gvalue, &error))
725 g_warning ("Could not read property %s:%s with value %s of type %s: %s",
726 g_type_name (G_OBJECT_TYPE (area)),
729 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
731 g_error_free (error);
735 gtk_cell_area_cell_set_property (area, cell, name, &gvalue);
736 g_value_unset (&gvalue);
741 GtkCellLayout *cell_layout;
742 GtkCellRenderer *renderer;
744 gchar *cell_prop_name;
746 gboolean translatable;
747 } CellPackingSubParserData;
750 cell_packing_start_element (GMarkupParseContext *context,
751 const gchar *element_name,
753 const gchar **values,
757 CellPackingSubParserData *parser_data = (CellPackingSubParserData*)user_data;
760 if (strcmp (element_name, "property") == 0)
762 for (i = 0; names[i]; i++)
763 if (strcmp (names[i], "name") == 0)
764 parser_data->cell_prop_name = g_strdup (values[i]);
765 else if (strcmp (names[i], "translatable") == 0)
767 if (!_gtk_builder_boolean_from_string (values[i],
768 &parser_data->translatable,
772 else if (strcmp (names[i], "comments") == 0)
773 ; /* for translators */
774 else if (strcmp (names[i], "context") == 0)
775 parser_data->context = g_strdup (values[i]);
777 g_warning ("Unsupported attribute for GtkCellLayout Cell "
778 "property: %s\n", names[i]);
780 else if (strcmp (element_name, "cell-packing") == 0)
783 g_warning ("Unsupported tag for GtkCellLayout: %s\n", element_name);
787 cell_packing_text_element (GMarkupParseContext *context,
793 CellPackingSubParserData *parser_data = (CellPackingSubParserData*)user_data;
795 if (parser_data->cell_prop_name)
796 g_string_append_len (parser_data->string, text, text_len);
800 cell_packing_end_element (GMarkupParseContext *context,
801 const gchar *element_name,
805 CellPackingSubParserData *parser_data = (CellPackingSubParserData*)user_data;
808 area = gtk_cell_layout_get_area (parser_data->cell_layout);
812 /* translate the string */
813 if (parser_data->string->len && parser_data->translatable)
818 domain = gtk_builder_get_translation_domain (parser_data->builder);
820 translated = _gtk_builder_parser_translate (domain,
821 parser_data->context,
822 parser_data->string->str);
823 g_string_set_size (parser_data->string, 0);
824 g_string_append (parser_data->string, translated);
827 if (parser_data->cell_prop_name)
828 gtk_cell_layout_buildable_set_cell_property (area,
829 parser_data->builder,
830 parser_data->renderer,
831 parser_data->cell_prop_name,
832 parser_data->string->str);
835 g_warning ("%s does not have an internal GtkCellArea class and cannot apply child cell properties",
836 g_type_name (G_OBJECT_TYPE (parser_data->cell_layout)));
838 g_string_set_size (parser_data->string, 0);
839 g_free (parser_data->cell_prop_name);
840 g_free (parser_data->context);
841 parser_data->cell_prop_name = NULL;
842 parser_data->context = NULL;
843 parser_data->translatable = FALSE;
847 static const GMarkupParser cell_packing_parser =
849 cell_packing_start_element,
850 cell_packing_end_element,
851 cell_packing_text_element,
855 _gtk_cell_layout_buildable_custom_tag_start (GtkBuildable *buildable,
858 const gchar *tagname,
859 GMarkupParser *parser,
862 AttributesSubParserData *attr_data;
863 CellPackingSubParserData *packing_data;
868 if (strcmp (tagname, "attributes") == 0)
870 attr_data = g_slice_new0 (AttributesSubParserData);
871 attr_data->cell_layout = GTK_CELL_LAYOUT (buildable);
872 attr_data->renderer = GTK_CELL_RENDERER (child);
873 attr_data->attr_name = NULL;
875 *parser = attributes_parser;
879 else if (strcmp (tagname, "cell-packing") == 0)
881 packing_data = g_slice_new0 (CellPackingSubParserData);
882 packing_data->string = g_string_new ("");
883 packing_data->builder = builder;
884 packing_data->cell_layout = GTK_CELL_LAYOUT (buildable);
885 packing_data->renderer = GTK_CELL_RENDERER (child);
887 *parser = cell_packing_parser;
888 *data = packing_data;
896 _gtk_cell_layout_buildable_custom_tag_end (GtkBuildable *buildable,
899 const gchar *tagname,
902 AttributesSubParserData *attr_data;
903 CellPackingSubParserData *packing_data;
905 if (strcmp (tagname, "attributes") == 0)
907 attr_data = (AttributesSubParserData*)data;
908 g_assert (!attr_data->attr_name);
909 g_slice_free (AttributesSubParserData, attr_data);
912 else if (strcmp (tagname, "cell-packing") == 0)
914 packing_data = (CellPackingSubParserData *)data;
915 g_string_free (packing_data->string, TRUE);
916 g_slice_free (CellPackingSubParserData, packing_data);
923 _gtk_cell_layout_buildable_add_child (GtkBuildable *buildable,
928 g_return_if_fail (GTK_IS_CELL_LAYOUT (buildable));
929 g_return_if_fail (GTK_IS_CELL_RENDERER (child));
931 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (buildable), GTK_CELL_RENDERER (child), FALSE);