2 * Copyright (C) 2006-2007 Async Open Source,
3 * Johan Dahlin <jdahlin@async.com.br>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
23 #include "gtkbuildable.h"
24 #include "gtktypeutils.h"
29 gtk_buildable_get_type (void)
31 static GType buildable_type = 0;
35 g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkBuildable"),
36 sizeof (GtkBuildableIface),
39 return buildable_type;
43 * gtk_buildable_set_name:
44 * @buildable: a #GtkBuildable
47 * Sets the name of the @buildable object.
52 gtk_buildable_set_name (GtkBuildable *buildable,
55 GtkBuildableIface *iface;
57 g_return_if_fail (GTK_IS_BUILDABLE (buildable));
58 g_return_if_fail (name != NULL);
60 iface = GTK_BUILDABLE_GET_IFACE (buildable);
63 (* iface->set_name) (buildable, name);
65 g_object_set_data_full (G_OBJECT (buildable),
72 * gtk_buildable_get_name:
73 * @buildable: a #GtkBuildable
75 * Gets the name of the @buildable object.
77 * #GtkBuilder sets the name based on the the
78 * <link linkend="BUILDER-UI">GtkBuilder UI definition</link>
79 * used to construct the @buildable.
81 * Returns: the name set with gtk_buildable_set_name()
86 gtk_buildable_get_name (GtkBuildable *buildable)
88 GtkBuildableIface *iface;
90 g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), NULL);
92 iface = GTK_BUILDABLE_GET_IFACE (buildable);
95 return (* iface->get_name) (buildable);
97 return (const gchar*)g_object_get_data (G_OBJECT (buildable),
102 * gtk_buildable_add_child:
103 * @buildable: a #GtkBuildable
104 * @builder: a #GtkBuilder
105 * @child: child to add
106 * @type: kind of child or %NULL
108 * Adds a child to @buildable. @type is an optional string
109 * describing how the child should be added.
114 gtk_buildable_add_child (GtkBuildable *buildable,
119 GtkBuildableIface *iface;
121 g_return_if_fail (GTK_IS_BUILDABLE (buildable));
122 g_return_if_fail (GTK_IS_BUILDER (builder));
124 iface = GTK_BUILDABLE_GET_IFACE (buildable);
125 g_return_if_fail (iface->add_child != NULL);
127 (* iface->add_child) (buildable, builder, child, type);
131 * gtk_buildable_set_buildable_property:
132 * @buildable: a #GtkBuildable
133 * @builder: a #GtkBuilder
134 * @name: name of property
135 * @value: value of property
137 * Sets the property name @name to @value on the @buildable object.
142 gtk_buildable_set_buildable_property (GtkBuildable *buildable,
147 GtkBuildableIface *iface;
149 g_return_if_fail (GTK_IS_BUILDABLE (buildable));
150 g_return_if_fail (GTK_IS_BUILDER (builder));
151 g_return_if_fail (name != NULL);
152 g_return_if_fail (value != NULL);
154 iface = GTK_BUILDABLE_GET_IFACE (buildable);
155 if (iface->set_buildable_property)
156 (* iface->set_buildable_property) (buildable, builder, name, value);
158 g_object_set_property (G_OBJECT (buildable), name, value);
162 * gtk_buildable_parser_finished:
163 * @buildable: a #GtkBuildable
164 * @builder: a #GtkBuilder
166 * Called when the builder finishes the parsing of a
167 * <link linkend="BUILDER-UI">GtkBuilder UI definition</link>.
168 * Note that this will be called once for each time
169 * gtk_builder_add_from_file() or gtk_builder_add_from_string()
170 * is called on a builder.
175 gtk_buildable_parser_finished (GtkBuildable *buildable,
178 GtkBuildableIface *iface;
180 g_return_if_fail (GTK_IS_BUILDABLE (buildable));
181 g_return_if_fail (GTK_IS_BUILDER (builder));
183 iface = GTK_BUILDABLE_GET_IFACE (buildable);
184 if (iface->parser_finished)
185 (* iface->parser_finished) (buildable, builder);
189 * gtk_buildable_construct_child:
190 * @buildable: A #GtkBuildable
191 * @builder: #GtkBuilder used to construct this object
192 * @name: name of child to construct
194 * Constructs a child of @buildable with the name @name.
196 * #GtkBuilder calls this function if a "constructor" has been
197 * specified in the UI definition.
199 * Returns: the constructed child
204 gtk_buildable_construct_child (GtkBuildable *buildable,
208 GtkBuildableIface *iface;
210 g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), NULL);
211 g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
212 g_return_val_if_fail (name != NULL, NULL);
214 iface = GTK_BUILDABLE_GET_IFACE (buildable);
215 g_return_val_if_fail (iface->construct_child != NULL, NULL);
217 return (* iface->construct_child) (buildable, builder, name);
221 * gtk_buildable_custom_tag_start:
222 * @buildable: a #GtkBuildable
223 * @builder: a #GtkBuilder used to construct this object
224 * @child: child object or %NULL for non-child tags
225 * @tagname: name of tag
226 * @parser: a #GMarkupParser structure to fill in
227 * @data: return location for user data that will be passed in
228 * to parser functions
230 * This is called for each unknown element under <child>.
232 * Returns: %TRUE if a object has a custom implementation, %FALSE
238 gtk_buildable_custom_tag_start (GtkBuildable *buildable,
241 const gchar *tagname,
242 GMarkupParser *parser,
245 GtkBuildableIface *iface;
247 g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), FALSE);
248 g_return_val_if_fail (GTK_IS_BUILDER (builder), FALSE);
249 g_return_val_if_fail (tagname != NULL, FALSE);
251 iface = GTK_BUILDABLE_GET_IFACE (buildable);
252 g_return_val_if_fail (iface->custom_tag_start != NULL, FALSE);
254 return (* iface->custom_tag_start) (buildable, builder, child,
255 tagname, parser, data);
259 * gtk_buildable_custom_tag_end:
260 * @buildable: A #GtkBuildable
261 * @builder: #GtkBuilder used to construct this object
262 * @child: child object or %NULL for non-child tags
263 * @tagname: name of tag
264 * @data: user data that will be passed in to parser functions
266 * This is called at the end of each custom element handled by
272 gtk_buildable_custom_tag_end (GtkBuildable *buildable,
275 const gchar *tagname,
278 GtkBuildableIface *iface;
280 g_return_if_fail (GTK_IS_BUILDABLE (buildable));
281 g_return_if_fail (GTK_IS_BUILDER (builder));
282 g_return_if_fail (tagname != NULL);
284 iface = GTK_BUILDABLE_GET_IFACE (buildable);
285 if (iface->custom_tag_end)
286 (* iface->custom_tag_end) (buildable, builder, child, tagname, data);
290 * gtk_buildable_custom_finished:
291 * @buildable: a #GtkBuildable
292 * @builder: a #GtkBuilder
293 * @child: child object or %NULL for non-child tags
294 * @tagname: the name of the tag
295 * @data: user data created in custom_tag_start
297 * This is similar to gtk_buildable_parser_finished() but is
298 * called once for each custom tag handled by the @buildable.
303 gtk_buildable_custom_finished (GtkBuildable *buildable,
306 const gchar *tagname,
309 GtkBuildableIface *iface;
311 g_return_if_fail (GTK_IS_BUILDABLE (buildable));
312 g_return_if_fail (GTK_IS_BUILDER (builder));
314 iface = GTK_BUILDABLE_GET_IFACE (buildable);
315 if (iface->custom_finished)
316 (* iface->custom_finished) (buildable, builder, child, tagname, data);
320 * gtk_buildable_get_internal_child:
321 * @buildable: a #GtkBuildable
322 * @builder: a #GtkBuilder
323 * @childname: name of child
325 * Get the internal child called @childname of the @buildable object.
327 * Returns: the internal child of the buildable object
332 gtk_buildable_get_internal_child (GtkBuildable *buildable,
334 const gchar *childname)
336 GtkBuildableIface *iface;
338 g_return_val_if_fail (GTK_IS_BUILDABLE (buildable), NULL);
339 g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
340 g_return_val_if_fail (childname != NULL, NULL);
342 iface = GTK_BUILDABLE_GET_IFACE (buildable);
343 if (!iface->get_internal_child)
346 return (* iface->get_internal_child) (buildable, builder, childname);
349 #define __GTK_BUILDABLE_C__
350 #include "gtkaliasdef.c"