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.Builder;
26 
27 private import glib.ConstructionException;
28 private import glib.ErrorG;
29 private import glib.GException;
30 private import glib.Module;
31 private import glib.Str;
32 private import gobject.ObjectG;
33 private import gobject.ParamSpec;
34 private import gobject.Type;
35 private import gobject.Value;
36 private import gtk.Application;
37 private import gtkc.glib;
38 private import gtkc.gobject;
39 private import gtkc.gtk;
40 public  import gtkc.gtktypes;
41 private import gtkc.paths;
42 private import std.string;
43 
44 
45 /**
46  * A GtkBuilder is an auxiliary object that reads textual descriptions
47  * of a user interface and instantiates the described objects. To create
48  * a GtkBuilder from a user interface description, call
49  * gtk_builder_new_from_file(), gtk_builder_new_from_resource() or
50  * gtk_builder_new_from_string().
51  * 
52  * In the (unusual) case that you want to add user interface
53  * descriptions from multiple sources to the same GtkBuilder you can
54  * call gtk_builder_new() to get an empty builder and populate it by
55  * (multiple) calls to gtk_builder_add_from_file(),
56  * gtk_builder_add_from_resource() or gtk_builder_add_from_string().
57  * 
58  * A GtkBuilder holds a reference to all objects that it has constructed
59  * and drops these references when it is finalized. This finalization can
60  * cause the destruction of non-widget objects or widgets which are not
61  * contained in a toplevel window. For toplevel windows constructed by a
62  * builder, it is the responsibility of the user to call gtk_widget_destroy()
63  * to get rid of them and all the widgets they contain.
64  * 
65  * The functions gtk_builder_get_object() and gtk_builder_get_objects()
66  * can be used to access the widgets in the interface by the names assigned
67  * to them inside the UI description. Toplevel windows returned by these
68  * functions will stay around until the user explicitly destroys them
69  * with gtk_widget_destroy(). Other widgets will either be part of a
70  * larger hierarchy constructed by the builder (in which case you should
71  * not have to worry about their lifecycle), or without a parent, in which
72  * case they have to be added to some container to make use of them.
73  * Non-widget objects need to be reffed with g_object_ref() to keep them
74  * beyond the lifespan of the builder.
75  * 
76  * The function gtk_builder_connect_signals() and variants thereof can be
77  * used to connect handlers to the named signals in the description.
78  * 
79  * # GtkBuilder UI Definitions # {#BUILDER-UI}
80  * 
81  * GtkBuilder parses textual descriptions of user interfaces which are
82  * specified in an XML format which can be roughly described by the
83  * RELAX NG schema below. We refer to these descriptions as “GtkBuilder
84  * UI definitions” or just “UI definitions” if the context is clear.
85  * Do not confuse GtkBuilder UI Definitions with
86  * [GtkUIManager UI Definitions][XML-UI], which are more limited in scope.
87  * It is common to use `.ui` as the filename extension for files containing
88  * GtkBuilder UI definitions.
89  * 
90  * [RELAX NG Compact Syntax](https://git.gnome.org/browse/gtk+/tree/gtk/gtkbuilder.rnc)
91  * 
92  * The toplevel element is <interface>. It optionally takes a “domain”
93  * attribute, which will make the builder look for translated strings
94  * using dgettext() in the domain specified. This can also be done by
95  * calling gtk_builder_set_translation_domain() on the builder.
96  * Objects are described by <object> elements, which can contain
97  * <property> elements to set properties, <signal> elements which
98  * connect signals to handlers, and <child> elements, which describe
99  * child objects (most often widgets inside a container, but also e.g.
100  * actions in an action group, or columns in a tree model). A <child>
101  * element contains an <object> element which describes the child object.
102  * The target toolkit version(s) are described by <requires> elements,
103  * the “lib” attribute specifies the widget library in question (currently
104  * the only supported value is “gtk+”) and the “version” attribute specifies
105  * the target version in the form “<major>.<minor>”. The builder will error
106  * out if the version requirements are not met.
107  * 
108  * Typically, the specific kind of object represented by an <object>
109  * element is specified by the “class” attribute. If the type has not
110  * been loaded yet, GTK+ tries to find the get_type() function from the
111  * class name by applying heuristics. This works in most cases, but if
112  * necessary, it is possible to specify the name of the get_type() function
113  * explictly with the "type-func" attribute. As a special case, GtkBuilder
114  * allows to use an object that has been constructed by a #GtkUIManager in
115  * another part of the UI definition by specifying the id of the #GtkUIManager
116  * in the “constructor” attribute and the name of the object in the “id”
117  * attribute.
118  * 
119  * Objects may be given a name with the “id” attribute, which allows the
120  * application to retrieve them from the builder with gtk_builder_get_object().
121  * An id is also necessary to use the object as property value in other
122  * parts of the UI definition. GTK+ reserves ids starting and ending
123  * with ___ (3 underscores) for its own purposes.
124  * 
125  * Setting properties of objects is pretty straightforward with the
126  * <property> element: the “name” attribute specifies the name of the
127  * property, and the content of the element specifies the value.
128  * If the “translatable” attribute is set to a true value, GTK+ uses
129  * gettext() (or dgettext() if the builder has a translation domain set)
130  * to find a translation for the value. This happens before the value
131  * is parsed, so it can be used for properties of any type, but it is
132  * probably most useful for string properties. It is also possible to
133  * specify a context to disambiguate short strings, and comments which
134  * may help the translators.
135  * 
136  * GtkBuilder can parse textual representations for the most common
137  * property types: characters, strings, integers, floating-point numbers,
138  * booleans (strings like “TRUE”, “t”, “yes”, “y”, “1” are interpreted
139  * as %TRUE, strings like “FALSE”, “f”, “no”, “n”, “0” are interpreted
140  * as %FALSE), enumerations (can be specified by their name, nick or
141  * integer value), flags (can be specified by their name, nick, integer
142  * value, optionally combined with “|”, e.g. “GTK_VISIBLE|GTK_REALIZED”)
143  * and colors (in a format understood by gdk_rgba_parse()). Pixbufs can
144  * be specified as a filename of an image file to load. Objects can be
145  * referred to by their name and by default refer to objects declared
146  * in the local xml fragment and objects exposed via
147  * gtk_builder_expose_object().
148  * 
149  * In general, GtkBuilder allows forward references to objects —
150  * declared in the local xml; an object doesn’t have to be constructed
151  * before it can be referred to. The exception to this rule is that an
152  * object has to be constructed before it can be used as the value of
153  * a construct-only property.
154  * 
155  * It is also possible to bind a property value to another object's
156  * property value using the attributes
157  * "bind-source" to specify the source object of the binding,
158  * "bind-property" to specify the source property and optionally
159  * "bind-flags" to specify the binding flags
160  * Internally builder implement this using GBinding objects.
161  * For more information see g_object_bind_property()
162  * 
163  * Signal handlers are set up with the <signal> element. The “name”
164  * attribute specifies the name of the signal, and the “handler” attribute
165  * specifies the function to connect to the signal. By default, GTK+ tries
166  * to find the handler using g_module_symbol(), but this can be changed by
167  * passing a custom #GtkBuilderConnectFunc to
168  * gtk_builder_connect_signals_full(). The remaining attributes, “after”,
169  * “swapped” and “object”, have the same meaning as the corresponding
170  * parameters of the g_signal_connect_object() or
171  * g_signal_connect_data() functions. A “last_modification_time”
172  * attribute is also allowed, but it does not have a meaning to the
173  * builder.
174  * 
175  * Sometimes it is necessary to refer to widgets which have implicitly
176  * been constructed by GTK+ as part of a composite widget, to set
177  * properties on them or to add further children (e.g. the @vbox of
178  * a #GtkDialog). This can be achieved by setting the “internal-child”
179  * propery of the <child> element to a true value. Note that GtkBuilder
180  * still requires an <object> element for the internal child, even if it
181  * has already been constructed.
182  * 
183  * A number of widgets have different places where a child can be added
184  * (e.g. tabs vs. page content in notebooks). This can be reflected in
185  * a UI definition by specifying the “type” attribute on a <child>
186  * The possible values for the “type” attribute are described in the
187  * sections describing the widget-specific portions of UI definitions.
188  * 
189  * # A GtkBuilder UI Definition
190  * 
191  * |[
192  * <interface>
193  * <object class="GtkDialog" id="dialog1">
194  * <child internal-child="vbox">
195  * <object class="GtkBox" id="vbox1">
196  * <property name="border-width">10</property>
197  * <child internal-child="action_area">
198  * <object class="GtkButtonBox" id="hbuttonbox1">
199  * <property name="border-width">20</property>
200  * <child>
201  * <object class="GtkButton" id="ok_button">
202  * <property name="label">gtk-ok</property>
203  * <property name="use-stock">TRUE</property>
204  * <signal name="clicked" handler="ok_button_clicked"/>
205  * </object>
206  * </child>
207  * </object>
208  * </child>
209  * </object>
210  * </child>
211  * </object>
212  * </interface>
213  * ]|
214  * 
215  * Beyond this general structure, several object classes define their
216  * own XML DTD fragments for filling in the ANY placeholders in the DTD
217  * above. Note that a custom element in a <child> element gets parsed by
218  * the custom tag handler of the parent object, while a custom element in
219  * an <object> element gets parsed by the custom tag handler of the object.
220  * 
221  * These XML fragments are explained in the documentation of the
222  * respective objects.
223  * 
224  * Additionally, since 3.10 a special <template> tag has been added
225  * to the format allowing one to define a widget class’s components.
226  */
227 public class Builder : ObjectG
228 {
229 	/** the main Gtk struct */
230 	protected GtkBuilder* gtkBuilder;
231 
232 	/** Get the main Gtk struct */
233 	public GtkBuilder* getBuilderStruct()
234 	{
235 		return gtkBuilder;
236 	}
237 
238 	/** the main Gtk struct as a void* */
239 	protected override void* getStruct()
240 	{
241 		return cast(void*)gtkBuilder;
242 	}
243 
244 	protected override void setStruct(GObject* obj)
245 	{
246 		gtkBuilder = cast(GtkBuilder*)obj;
247 		super.setStruct(obj);
248 	}
249 
250 	/**
251 	 * Sets our main struct and passes it to the parent class.
252 	 */
253 	public this (GtkBuilder* gtkBuilder, bool ownedRef = false)
254 	{
255 		this.gtkBuilder = gtkBuilder;
256 		super(cast(GObject*)gtkBuilder, ownedRef);
257 	}
258 
259 	/**
260 	 * Creates a new builder object.
261 	 * Since 2.12
262 	 * Throws: ConstructionException GTK+ fails to create the object.
263 	 */
264 	public this ()
265 	{
266 		// GtkBuilder* gtk_builder_new (void);
267 		auto p = gtk_builder_new();
268 		if(p is null)
269 		{
270 			throw new ConstructionException("null returned by gtk_builder_new()");
271 		}
272 		this(cast(GtkBuilder*) p);
273 		
274 		GtkBuilderClass* klass = Type.getInstanceClass!(GtkBuilderClass)( this );
275 		klass.getTypeFromName = &gtk_builder_real_get_type_from_name_override;
276 	}
277 	
278 	/**
279 	 * This function is a modification of _gtk_builder_resolve_type_lazily from "gtk/gtkbuilder.c".
280 	 * It is needed because it assumes we are linking at compile time to the gtk libs.
281 	 * specifically the NULL in g_module_open( NULL, 0 );
282 	 * It replaces the default function pointer "get_type_from_name" in GtkBuilderClass.
283 	 */
284 	extern(C) private static GType gtk_builder_real_get_type_from_name_override ( GtkBuilder* builder, const(char)* name )
285 	{
286 		GType gtype;
287 		gtype = g_type_from_name( name );
288 		if (gtype != GType.INVALID)
289 		{
290 			return gtype;
291 		}
292 		
293 		/*
294 		 * Try to map a type name to a _get_type function
295 		 * and call it, eg:
296 		 *
297 		 * GtkWindow -> gtk_window_get_type
298 		 * GtkHBox -> gtk_hbox_get_type
299 		 * GtkUIManager -> gtk_ui_manager_get_type
300 		 *
301 		 */
302 		char   c;
303 		string symbol_name;
304 		
305 		for (int i = 0; name[i] != '\0'; i++)
306 		{
307 			c = name[i];
308 			/* skip if uppercase, first or previous is uppercase */
309 			if ((c == Str.asciiToupper (c) &&
310 				i > 0 && name[i-1] != Str.asciiToupper (name[i-1])) ||
311 			(i > 2 && name[i]   == Str.asciiToupper (name[i]) &&
312 			name[i-1] == Str.asciiToupper (name[i-1]) &&
313 			name[i-2] == Str.asciiToupper (name[i-2]))
314 			)
315 			
316 			symbol_name ~= '_';
317 			symbol_name ~= Str.asciiTolower (c);
318 		}
319 		symbol_name ~=  "_get_type" ;
320 		
321 		/* scan linked librarys for function symbol */
322 		foreach ( lib; importLibs )
323 		{
324 			GType function() func;
325 			Module mod = Module.open( lib, GModuleFlags.LAZY );
326 			if( mod is null )
327 				continue;
328 			
329 			scope(exit) mod.close();
330 			
331 			if ( mod.symbol( symbol_name, cast(void**)&func ) ) {
332 				return func();
333 		}
334 	}
335 	
336 	return GType.INVALID;
337 }
338 
339 /**
340  * Gets the object named name. Note that this function does not
341  * increment the reference count of the returned object.
342  * Since 2.12
343  * Params:
344  * name = name of object to get
345  * Returns: the object named name or NULL if it could not be found in the object tree.. transfer none.
346  */
347 public ObjectG getObject(string name)
348 {
349 	// GObject* gtk_builder_get_object (GtkBuilder *builder,  const gchar *name);
350 	return newFromObject( gtk_builder_get_object(gtkBuilder, Str.toStringz(name)) );
351 }
352 
353 /**
354  * Gets all objects that have been constructed by builder.
355  * Since 2.12
356  * Returns: an array containing all the objects constructed by the GtkBuilder instance.
357  */
358 public ObjectG[] getObjects()
359 {
360 	ObjectG[] objects;
361 	
362 	// GSList* gtk_builder_get_objects (GtkBuilder *builder);
363 	GSList* list = gtk_builder_get_objects(gtkBuilder);
364 	
365 	while ( list.next !is null )
366 	{
367 		objects ~= newFromObject( cast(GObject*)list.data );
368 		list = list.next;
369 	}
370 	
371 	g_slist_free(list);
372 	
373 	return objects;
374 }
375 
376 /**
377  * This function creates an D object corresponding to the Struct pointer passed in.
378  */
379 public ObjectG newFromObject(GObject* cobj)
380 {
381 	if(cobj is null)
382 	{
383 		return null;
384 	}
385 	
386 	void* dObj = g_object_get_data(cobj, Str.toStringz("GObject"));
387 	
388 	if ( dObj !is null )
389 	{
390 		return cast(ObjectG)dObj;
391 	}
392 	
393 	string type = convertClassName(Type.name((cast(GTypeInstance*)cobj).gClass.gType));
394 	ClassInfo ci = cast(ClassInfo)ClassInfo.find(type);
395 	
396 	//Gobject and Gio types both start with g, so try both.
397 	if(ci is null && startsWith(type, "gobject"))
398 	{
399 		ci = cast(ClassInfo)ClassInfo.find("gio"~ type[7..$]);
400 	}
401 	
402 	if(ci is null)
403 	{
404 		return null;
405 	}
406 	
407 	ObjectG obj = cast(ObjectG)_d_newclass(ci);
408 	
409 	obj.__ctor(cobj);
410 	
411 	return obj;
412 }
413 
414 /**
415  * Turn the name of a C Type in to the name of the corresponding D type.
416  * Note: If the prefix of the type is "G" this always usses "gobject" as
417  *     the prefix, extra care should be taken for types from GIO.
418  */
419 private string convertClassName(string gName)
420 {
421 	string conv;
422 	string prefix;
423 	
424 	if      ( startsWith(gName, "GtkSource" ) ) prefix = "Gsv";
425 	else if ( startsWith(gName, "Gtk") )        prefix = "Gtk";
426 	else if ( startsWith(gName, "Gdk") )        prefix = "Gdk";
427 	else if ( startsWith(gName, "Gst") )        prefix = "Gst";
428 	else if ( startsWith(gName, "Gda") )        prefix = "Gda";
429 	else if ( startsWith(gName, "Atk") )        prefix = "Atk";
430 	else if ( startsWith(gName, "G") )          prefix = "G";
431 	else if ( startsWith(gName, "Pango") )      prefix = "Pg";
432 	else if ( startsWith(gName, "cairo") )      prefix = "cairo";
433 	
434 	conv = gName[prefix.length..gName.length];
435 	
436 	if ( conv == "Object" ) conv ~= prefix;
437 	if ( prefix == "Pg" )   conv = "Pg" ~ gName[5..gName.length];
438 	if ( prefix == "cairo") conv = toUpper(gName[6..7]) ~ gName[7..gName.length - 2];
439 	
440 	prefix = toLower(prefix);
441 	
442 	if( prefix == "gst") prefix = "gstreamer";
443 	if( prefix == "g")   prefix = "gobject";
444 	if( prefix == "pg" ) prefix = "pango";
445 	
446 	return prefix ~"."~ conv ~"."~ conv;
447 }
448 
449 private bool startsWith(string str, string prefix)
450 {
451 	return str.length >= prefix.length && str[0..prefix.length] == prefix;
452 }
453 
454 /**
455  */
456 
457 public static GType getType()
458 {
459 	return gtk_builder_get_type();
460 }
461 
462 /**
463  * Builds the [GtkBuilder UI definition][BUILDER-UI]
464  * in the file @filename.
465  *
466  * If there is an error opening the file or parsing the description then
467  * the program will be aborted.  You should only ever attempt to parse
468  * user interface descriptions that are shipped as part of your program.
469  *
470  * Params:
471  *     filename = filename of user interface description file
472  *
473  * Return: a #GtkBuilder containing the described interface
474  *
475  * Since: 3.10
476  *
477  * Throws: ConstructionException GTK+ fails to create the object.
478  */
479 public this(string filename)
480 {
481 	auto p = gtk_builder_new_from_file(Str.toStringz(filename));
482 	
483 	if(p is null)
484 	{
485 		throw new ConstructionException("null returned by new_from_file");
486 	}
487 	
488 	this(cast(GtkBuilder*) p, true);
489 }
490 
491 /**
492  * Adds the @callback_symbol to the scope of @builder under the given @callback_name.
493  *
494  * Using this function overrides the behavior of gtk_builder_connect_signals()
495  * for any callback symbols that are added. Using this method allows for better
496  * encapsulation as it does not require that callback symbols be declared in
497  * the global namespace.
498  *
499  * Params:
500  *     callbackName = The name of the callback, as expected in the XML
501  *     callbackSymbol = The callback pointer
502  *
503  * Since: 3.10
504  */
505 public void addCallbackSymbol(string callbackName, GCallback callbackSymbol)
506 {
507 	gtk_builder_add_callback_symbol(gtkBuilder, Str.toStringz(callbackName), callbackSymbol);
508 }
509 
510 /**
511  * Parses a file containing a [GtkBuilder UI definition][BUILDER-UI]
512  * and merges it with the current contents of @builder.
513  *
514  * Most users will probably want to use gtk_builder_new_from_file().
515  *
516  * If an error occurs, 0 will be returned and @error will be assigned a
517  * #GError from the #GTK_BUILDER_ERROR, #G_MARKUP_ERROR or #G_FILE_ERROR
518  * domain.
519  *
520  * It’s not really reasonable to attempt to handle failures of this
521  * call. You should not use this function with untrusted files (ie:
522  * files that are not part of your application). Broken #GtkBuilder
523  * files can easily crash your program, and it’s possible that memory
524  * was leaked leading up to the reported failure. The only reasonable
525  * thing to do when an error is detected is to call g_error().
526  *
527  * Params:
528  *     filename = the name of the file to parse
529  *
530  * Return: A positive value on success, 0 if an error occurred
531  *
532  * Since: 2.12
533  *
534  * Throws: GException on failure.
535  */
536 public uint addFromFile(string filename)
537 {
538 	GError* err = null;
539 	
540 	auto p = gtk_builder_add_from_file(gtkBuilder, Str.toStringz(filename), &err);
541 	
542 	if (err !is null)
543 	{
544 		throw new GException( new ErrorG(err) );
545 	}
546 	
547 	return p;
548 }
549 
550 /**
551  * Parses a resource file containing a [GtkBuilder UI definition][BUILDER-UI]
552  * and merges it with the current contents of @builder.
553  *
554  * Most users will probably want to use gtk_builder_new_from_resource().
555  *
556  * If an error occurs, 0 will be returned and @error will be assigned a
557  * #GError from the #GTK_BUILDER_ERROR, #G_MARKUP_ERROR or #G_RESOURCE_ERROR
558  * domain.
559  *
560  * It’s not really reasonable to attempt to handle failures of this
561  * call.  The only reasonable thing to do when an error is detected is
562  * to call g_error().
563  *
564  * Params:
565  *     resourcePath = the path of the resource file to parse
566  *
567  * Return: A positive value on success, 0 if an error occurred
568  *
569  * Since: 3.4
570  *
571  * Throws: GException on failure.
572  */
573 public uint addFromResource(string resourcePath)
574 {
575 	GError* err = null;
576 	
577 	auto p = gtk_builder_add_from_resource(gtkBuilder, Str.toStringz(resourcePath), &err);
578 	
579 	if (err !is null)
580 	{
581 		throw new GException( new ErrorG(err) );
582 	}
583 	
584 	return p;
585 }
586 
587 /**
588  * Parses a string containing a [GtkBuilder UI definition][BUILDER-UI]
589  * and merges it with the current contents of @builder.
590  *
591  * Most users will probably want to use gtk_builder_new_from_string().
592  *
593  * Upon errors 0 will be returned and @error will be assigned a
594  * #GError from the #GTK_BUILDER_ERROR, #G_MARKUP_ERROR or
595  * #G_VARIANT_PARSE_ERROR domain.
596  *
597  * It’s not really reasonable to attempt to handle failures of this
598  * call.  The only reasonable thing to do when an error is detected is
599  * to call g_error().
600  *
601  * Params:
602  *     buffer = the string to parse
603  *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
604  *
605  * Return: A positive value on success, 0 if an error occurred
606  *
607  * Since: 2.12
608  *
609  * Throws: GException on failure.
610  */
611 public uint addFromString(string buffer, size_t length)
612 {
613 	GError* err = null;
614 	
615 	auto p = gtk_builder_add_from_string(gtkBuilder, Str.toStringz(buffer), length, &err);
616 	
617 	if (err !is null)
618 	{
619 		throw new GException( new ErrorG(err) );
620 	}
621 	
622 	return p;
623 }
624 
625 /**
626  * Parses a file containing a [GtkBuilder UI definition][BUILDER-UI]
627  * building only the requested objects and merges
628  * them with the current contents of @builder.
629  *
630  * Upon errors 0 will be returned and @error will be assigned a
631  * #GError from the #GTK_BUILDER_ERROR, #G_MARKUP_ERROR or #G_FILE_ERROR
632  * domain.
633  *
634  * If you are adding an object that depends on an object that is not
635  * its child (for instance a #GtkTreeView that depends on its
636  * #GtkTreeModel), you have to explicitly list all of them in @object_ids.
637  *
638  * Params:
639  *     filename = the name of the file to parse
640  *     objectIds = nul-terminated array of objects to build
641  *
642  * Return: A positive value on success, 0 if an error occurred
643  *
644  * Since: 2.14
645  *
646  * Throws: GException on failure.
647  */
648 public uint addObjectsFromFile(string filename, string[] objectIds)
649 {
650 	GError* err = null;
651 	
652 	auto p = gtk_builder_add_objects_from_file(gtkBuilder, Str.toStringz(filename), Str.toStringzArray(objectIds), &err);
653 	
654 	if (err !is null)
655 	{
656 		throw new GException( new ErrorG(err) );
657 	}
658 	
659 	return p;
660 }
661 
662 /**
663  * Parses a resource file containing a [GtkBuilder UI definition][BUILDER-UI]
664  * building only the requested objects and merges
665  * them with the current contents of @builder.
666  *
667  * Upon errors 0 will be returned and @error will be assigned a
668  * #GError from the #GTK_BUILDER_ERROR, #G_MARKUP_ERROR or #G_RESOURCE_ERROR
669  * domain.
670  *
671  * If you are adding an object that depends on an object that is not
672  * its child (for instance a #GtkTreeView that depends on its
673  * #GtkTreeModel), you have to explicitly list all of them in @object_ids.
674  *
675  * Params:
676  *     resourcePath = the path of the resource file to parse
677  *     objectIds = nul-terminated array of objects to build
678  *
679  * Return: A positive value on success, 0 if an error occurred
680  *
681  * Since: 3.4
682  *
683  * Throws: GException on failure.
684  */
685 public uint addObjectsFromResource(string resourcePath, string[] objectIds)
686 {
687 	GError* err = null;
688 	
689 	auto p = gtk_builder_add_objects_from_resource(gtkBuilder, Str.toStringz(resourcePath), Str.toStringzArray(objectIds), &err);
690 	
691 	if (err !is null)
692 	{
693 		throw new GException( new ErrorG(err) );
694 	}
695 	
696 	return p;
697 }
698 
699 /**
700  * Parses a string containing a [GtkBuilder UI definition][BUILDER-UI]
701  * building only the requested objects and merges
702  * them with the current contents of @builder.
703  *
704  * Upon errors 0 will be returned and @error will be assigned a
705  * #GError from the #GTK_BUILDER_ERROR or #G_MARKUP_ERROR domain.
706  *
707  * If you are adding an object that depends on an object that is not
708  * its child (for instance a #GtkTreeView that depends on its
709  * #GtkTreeModel), you have to explicitly list all of them in @object_ids.
710  *
711  * Params:
712  *     buffer = the string to parse
713  *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
714  *     objectIds = nul-terminated array of objects to build
715  *
716  * Return: A positive value on success, 0 if an error occurred
717  *
718  * Since: 2.14
719  *
720  * Throws: GException on failure.
721  */
722 public uint addObjectsFromString(string buffer, size_t length, string[] objectIds)
723 {
724 	GError* err = null;
725 	
726 	auto p = gtk_builder_add_objects_from_string(gtkBuilder, Str.toStringz(buffer), length, Str.toStringzArray(objectIds), &err);
727 	
728 	if (err !is null)
729 	{
730 		throw new GException( new ErrorG(err) );
731 	}
732 	
733 	return p;
734 }
735 
736 /**
737  * This method is a simpler variation of gtk_builder_connect_signals_full().
738  * It uses symbols explicitly added to @builder with prior calls to
739  * gtk_builder_add_callback_symbol(). In the case that symbols are not
740  * explicitly added; it uses #GModule’s introspective features (by opening the module %NULL)
741  * to look at the application’s symbol table. From here it tries to match
742  * the signal handler names given in the interface description with
743  * symbols in the application and connects the signals. Note that this
744  * function can only be called once, subsequent calls will do nothing.
745  *
746  * Note that unless gtk_builder_add_callback_symbol() is called for
747  * all signal callbacks which are referenced by the loaded XML, this
748  * function will require that #GModule be supported on the platform.
749  *
750  * If you rely on #GModule support to lookup callbacks in the symbol table,
751  * the following details should be noted:
752  *
753  * When compiling applications for Windows, you must declare signal callbacks
754  * with #G_MODULE_EXPORT, or they will not be put in the symbol table.
755  * On Linux and Unices, this is not necessary; applications should instead
756  * be compiled with the -Wl,--export-dynamic CFLAGS, and linked against
757  * gmodule-export-2.0.
758  *
759  * Params:
760  *     userData = user data to pass back with all signals
761  *
762  * Since: 2.12
763  */
764 public void connectSignals(void* userData)
765 {
766 	gtk_builder_connect_signals(gtkBuilder, userData);
767 }
768 
769 /**
770  * This function can be thought of the interpreted language binding
771  * version of gtk_builder_connect_signals(), except that it does not
772  * require GModule to function correctly.
773  *
774  * Params:
775  *     func = the function used to connect the signals
776  *     userData = arbitrary data that will be passed to the connection function
777  *
778  * Since: 2.12
779  */
780 public void connectSignalsFull(GtkBuilderConnectFunc func, void* userData)
781 {
782 	gtk_builder_connect_signals_full(gtkBuilder, func, userData);
783 }
784 
785 /**
786  * Add @object to the @builder object pool so it can be referenced just like any
787  * other object built by builder.
788  *
789  * Params:
790  *     name = the name of the object exposed to the builder
791  *     object = the object to expose
792  *
793  * Since: 3.8
794  */
795 public void exposeObject(string name, ObjectG object)
796 {
797 	gtk_builder_expose_object(gtkBuilder, Str.toStringz(name), (object is null) ? null : object.getObjectGStruct());
798 }
799 
800 /**
801  * Gets the #GtkApplication associated with the builder.
802  *
803  * The #GtkApplication is used for creating action proxies as requested
804  * from XML that the builder is loading.
805  *
806  * By default, the builder uses the default application: the one from
807  * g_application_get_default(). If you want to use another application
808  * for constructing proxies, use gtk_builder_set_application().
809  *
810  * Return: the application being used by the builder,
811  *     or %NULL
812  *
813  * Since: 3.10
814  */
815 public Application getApplication()
816 {
817 	auto p = gtk_builder_get_application(gtkBuilder);
818 	
819 	if(p is null)
820 	{
821 		return null;
822 	}
823 	
824 	return ObjectG.getDObject!(Application)(cast(GtkApplication*) p);
825 }
826 
827 /**
828  * Gets the translation domain of @builder.
829  *
830  * Return: the translation domain. This string is owned
831  *     by the builder object and must not be modified or freed.
832  *
833  * Since: 2.12
834  */
835 public string getTranslationDomain()
836 {
837 	return Str.toString(gtk_builder_get_translation_domain(gtkBuilder));
838 }
839 
840 /**
841  * Looks up a type by name, using the virtual function that
842  * #GtkBuilder has for that purpose. This is mainly used when
843  * implementing the #GtkBuildable interface on a type.
844  *
845  * Params:
846  *     typeName = type name to lookup
847  *
848  * Return: the #GType found for @type_name or #G_TYPE_INVALID
849  *     if no type was found
850  *
851  * Since: 2.12
852  */
853 public GType getTypeFromName(string typeName)
854 {
855 	return gtk_builder_get_type_from_name(gtkBuilder, Str.toStringz(typeName));
856 }
857 
858 /**
859  * Fetches a symbol previously added to @builder
860  * with gtk_builder_add_callback_symbols()
861  *
862  * This function is intended for possible use in language bindings
863  * or for any case that one might be cusomizing signal connections
864  * using gtk_builder_connect_signals_full()
865  *
866  * Params:
867  *     callbackName = The name of the callback
868  *
869  * Return: The callback symbol in @builder for @callback_name, or %NULL
870  *
871  * Since: 3.10
872  */
873 public GCallback lookupCallbackSymbol(string callbackName)
874 {
875 	return gtk_builder_lookup_callback_symbol(gtkBuilder, Str.toStringz(callbackName));
876 }
877 
878 /**
879  * Sets the application associated with @builder.
880  *
881  * You only need this function if there is more than one #GApplication
882  * in your process. @application cannot be %NULL.
883  *
884  * Params:
885  *     application = a #GtkApplication
886  *
887  * Since: 3.10
888  */
889 public void setApplication(Application application)
890 {
891 	gtk_builder_set_application(gtkBuilder, (application is null) ? null : application.getGtkApplicationStruct());
892 }
893 
894 /**
895  * Sets the translation domain of @builder.
896  * See #GtkBuilder:translation-domain.
897  *
898  * Params:
899  *     domain = the translation domain or %NULL
900  *
901  * Since: 2.12
902  */
903 public void setTranslationDomain(string domain)
904 {
905 	gtk_builder_set_translation_domain(gtkBuilder, Str.toStringz(domain));
906 }
907 
908 /**
909  * This function demarshals a value from a string. This function
910  * calls g_value_init() on the @value argument, so it need not be
911  * initialised beforehand.
912  *
913  * This function can handle char, uchar, boolean, int, uint, long,
914  * ulong, enum, flags, float, double, string, #GdkColor, #GdkRGBA and
915  * #GtkAdjustment type values. Support for #GtkWidget type values is
916  * still to come.
917  *
918  * Upon errors %FALSE will be returned and @error will be assigned a
919  * #GError from the #GTK_BUILDER_ERROR domain.
920  *
921  * Params:
922  *     pspec = the #GParamSpec for the property
923  *     str = the string representation of the value
924  *     value = the #GValue to store the result in
925  *
926  * Return: %TRUE on success
927  *
928  * Since: 2.12
929  *
930  * Throws: GException on failure.
931  */
932 public bool valueFromString(ParamSpec pspec, string str, out Value value)
933 {
934 	GValue* outvalue = new GValue;
935 	GError* err = null;
936 	
937 	auto p = gtk_builder_value_from_string(gtkBuilder, (pspec is null) ? null : pspec.getParamSpecStruct(), Str.toStringz(str), outvalue, &err) != 0;
938 	
939 	if (err !is null)
940 	{
941 		throw new GException( new ErrorG(err) );
942 	}
943 	
944 	value = ObjectG.getDObject!(Value)(outvalue);
945 	
946 	return p;
947 }
948 
949 /**
950  * Like gtk_builder_value_from_string(), this function demarshals
951  * a value from a string, but takes a #GType instead of #GParamSpec.
952  * This function calls g_value_init() on the @value argument, so it
953  * need not be initialised beforehand.
954  *
955  * Upon errors %FALSE will be returned and @error will be assigned a
956  * #GError from the #GTK_BUILDER_ERROR domain.
957  *
958  * Params:
959  *     type = the #GType of the value
960  *     str = the string representation of the value
961  *     value = the #GValue to store the result in
962  *
963  * Return: %TRUE on success
964  *
965  * Since: 2.12
966  *
967  * Throws: GException on failure.
968  */
969 public bool valueFromStringType(GType type, string str, out Value value)
970 {
971 	GValue* outvalue = new GValue;
972 	GError* err = null;
973 	
974 	auto p = gtk_builder_value_from_string_type(gtkBuilder, type, Str.toStringz(str), outvalue, &err) != 0;
975 	
976 	if (err !is null)
977 	{
978 		throw new GException( new ErrorG(err) );
979 	}
980 	
981 	value = ObjectG.getDObject!(Value)(outvalue);
982 	
983 	return p;
984 }
985 }