1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.BuildableT;
26 
27 public  import glib.Str;
28 public  import gobject.ObjectG;
29 public  import gobject.Value;
30 public  import gtk.Builder;
31 public  import gtk.c.functions;
32 public  import gtk.c.types;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * GtkBuildable allows objects to extend and customize their deserialization
38  * from [GtkBuilder UI descriptions][BUILDER-UI].
39  * The interface includes methods for setting names and properties of objects,
40  * parsing custom tags and constructing child objects.
41  * 
42  * The GtkBuildable interface is implemented by all widgets and
43  * many of the non-widget objects that are provided by GTK+. The
44  * main user of this interface is #GtkBuilder. There should be
45  * very little need for applications to call any of these functions directly.
46  * 
47  * An object only needs to implement this interface if it needs to extend the
48  * #GtkBuilder format or run any extra routines at deserialization time.
49  */
50 public template BuildableT(TStruct)
51 {
52 	/** Get the main Gtk struct */
53 	public GtkBuildable* getBuildableStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return cast(GtkBuildable*)getStruct();
58 	}
59 
60 
61 	/**
62 	 * Adds a child to @buildable. @type is an optional string
63 	 * describing how the child should be added.
64 	 *
65 	 * Params:
66 	 *     builder = a #GtkBuilder
67 	 *     child = child to add
68 	 *     type = kind of child or %NULL
69 	 *
70 	 * Since: 2.12
71 	 */
72 	public void addChild(Builder builder, ObjectG child, string type)
73 	{
74 		gtk_buildable_add_child(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct(), (child is null) ? null : child.getObjectGStruct(), Str.toStringz(type));
75 	}
76 
77 	/**
78 	 * Constructs a child of @buildable with the name @name.
79 	 *
80 	 * #GtkBuilder calls this function if a “constructor” has been
81 	 * specified in the UI definition.
82 	 *
83 	 * Params:
84 	 *     builder = #GtkBuilder used to construct this object
85 	 *     name = name of child to construct
86 	 *
87 	 * Returns: the constructed child
88 	 *
89 	 * Since: 2.12
90 	 */
91 	public ObjectG constructChild(Builder builder, string name)
92 	{
93 		auto p = gtk_buildable_construct_child(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct(), Str.toStringz(name));
94 
95 		if(p is null)
96 		{
97 			return null;
98 		}
99 
100 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p, true);
101 	}
102 
103 	/**
104 	 * This is similar to gtk_buildable_parser_finished() but is
105 	 * called once for each custom tag handled by the @buildable.
106 	 *
107 	 * Params:
108 	 *     builder = a #GtkBuilder
109 	 *     child = child object or %NULL for non-child tags
110 	 *     tagname = the name of the tag
111 	 *     data = user data created in custom_tag_start
112 	 *
113 	 * Since: 2.12
114 	 */
115 	public void customFinished(Builder builder, ObjectG child, string tagname, void* data)
116 	{
117 		gtk_buildable_custom_finished(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct(), (child is null) ? null : child.getObjectGStruct(), Str.toStringz(tagname), data);
118 	}
119 
120 	/**
121 	 * This is called at the end of each custom element handled by
122 	 * the buildable.
123 	 *
124 	 * Params:
125 	 *     builder = #GtkBuilder used to construct this object
126 	 *     child = child object or %NULL for non-child tags
127 	 *     tagname = name of tag
128 	 *     data = user data that will be passed in to parser functions
129 	 *
130 	 * Since: 2.12
131 	 */
132 	public void customTagEnd(Builder builder, ObjectG child, string tagname, void** data)
133 	{
134 		gtk_buildable_custom_tag_end(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct(), (child is null) ? null : child.getObjectGStruct(), Str.toStringz(tagname), data);
135 	}
136 
137 	/**
138 	 * This is called for each unknown element under <child>.
139 	 *
140 	 * Params:
141 	 *     builder = a #GtkBuilder used to construct this object
142 	 *     child = child object or %NULL for non-child tags
143 	 *     tagname = name of tag
144 	 *     parser = a #GMarkupParser to fill in
145 	 *     data = return location for user data that will be passed in
146 	 *         to parser functions
147 	 *
148 	 * Returns: %TRUE if a object has a custom implementation, %FALSE
149 	 *     if it doesn't.
150 	 *
151 	 * Since: 2.12
152 	 */
153 	public bool customTagStart(Builder builder, ObjectG child, string tagname, out GMarkupParser parser, out void* data)
154 	{
155 		return gtk_buildable_custom_tag_start(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct(), (child is null) ? null : child.getObjectGStruct(), Str.toStringz(tagname), &parser, &data) != 0;
156 	}
157 
158 	/**
159 	 * Get the internal child called @childname of the @buildable object.
160 	 *
161 	 * Params:
162 	 *     builder = a #GtkBuilder
163 	 *     childname = name of child
164 	 *
165 	 * Returns: the internal child of the buildable object
166 	 *
167 	 * Since: 2.12
168 	 */
169 	public ObjectG getInternalChild(Builder builder, string childname)
170 	{
171 		auto p = gtk_buildable_get_internal_child(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct(), Str.toStringz(childname));
172 
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 
178 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
179 	}
180 
181 	/**
182 	 * Gets the name of the @buildable object.
183 	 *
184 	 * #GtkBuilder sets the name based on the
185 	 * [GtkBuilder UI definition][BUILDER-UI]
186 	 * used to construct the @buildable.
187 	 *
188 	 * Returns: the name set with gtk_buildable_set_name()
189 	 *
190 	 * Since: 2.12
191 	 */
192 	public string buildableGetName()
193 	{
194 		return Str.toString(gtk_buildable_get_name(getBuildableStruct()));
195 	}
196 
197 	/**
198 	 * Called when the builder finishes the parsing of a
199 	 * [GtkBuilder UI definition][BUILDER-UI].
200 	 * Note that this will be called once for each time
201 	 * gtk_builder_add_from_file() or gtk_builder_add_from_string()
202 	 * is called on a builder.
203 	 *
204 	 * Params:
205 	 *     builder = a #GtkBuilder
206 	 *
207 	 * Since: 2.12
208 	 */
209 	public void parserFinished(Builder builder)
210 	{
211 		gtk_buildable_parser_finished(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct());
212 	}
213 
214 	/**
215 	 * Sets the property name @name to @value on the @buildable object.
216 	 *
217 	 * Params:
218 	 *     builder = a #GtkBuilder
219 	 *     name = name of property
220 	 *     value = value of property
221 	 *
222 	 * Since: 2.12
223 	 */
224 	public void setBuildableProperty(Builder builder, string name, Value value)
225 	{
226 		gtk_buildable_set_buildable_property(getBuildableStruct(), (builder is null) ? null : builder.getBuilderStruct(), Str.toStringz(name), (value is null) ? null : value.getValueStruct());
227 	}
228 
229 	/**
230 	 * Sets the name of the @buildable object.
231 	 *
232 	 * Params:
233 	 *     name = name to set
234 	 *
235 	 * Since: 2.12
236 	 */
237 	public void buildableSetName(string name)
238 	{
239 		gtk_buildable_set_name(getBuildableStruct(), Str.toStringz(name));
240 	}
241 }