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