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