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