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