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  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * 	- gtk_builder_get_object
46  * 	- gtk_builder_get_objects
47  * 	- gtk_builder_new
48  * omit signals:
49  * imports:
50  * 	- glib.ErrorG
51  * 	- glib.GException
52  * 	- glib.ListSG
53  * 	- glib.Str
54  * 	- gobject.ObjectG
55  * 	- gobject.ParamSpec
56  * 	- gobject.Value
57  * 	- std.string
58  * 	- gtkc.glib;
59  * 	- gtkc.gobject
60  * 	- gtkc.paths
61  * 	- glib.Module
62  * 	- gobject.Type
63  * structWrap:
64  * 	- GObject* -> ObjectG
65  * 	- GParamSpec* -> ParamSpec
66  * 	- GSList* -> ListSG
67  * 	- GValue* -> Value
68  * module aliases:
69  * local aliases:
70  * overrides:
71  */
72 
73 module gtk.Builder;
74 
75 public  import gtkc.gtktypes;
76 
77 private import gtkc.gtk;
78 private import glib.ConstructionException;
79 private import gobject.ObjectG;
80 
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 gtkc.glib;;
90 private import gtkc.gobject;
91 private import gtkc.paths;
92 private import glib.Module;
93 private import gobject.Type;
94 
95 
96 version(Tango) {
97 	private import tango.text.Util;
98 	private import tango.text.Unicode;
99 } else {
100 	private import std.string;
101 }
102 
103 
104 private import gobject.ObjectG;
105 
106 /**
107  * Description
108  * A GtkBuilder is an auxiliary object that reads textual descriptions
109  * of a user interface and instantiates the described objects. To pass a
110  * description to a GtkBuilder, call gtk_builder_add_from_file() or
111  * gtk_builder_add_from_string(). These functions can be called multiple
112  * times; the builder merges the content of all descriptions.
113  * A GtkBuilder holds a reference to all objects that it has constructed
114  * and drops these references when it is finalized. This finalization can
115  * cause the destruction of non-widget objects or widgets which are not
116  * contained in a toplevel window. For toplevel windows constructed by a
117  * builder, it is the responsibility of the user to call gtk_widget_destroy()
118  * to get rid of them and all the widgets they contain.
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  * The function gtk_builder_connect_signals() and variants thereof can be
130  * used to connect handlers to the named signals in the description.
131  * GtkBuilder UI Definitions
132  * GtkBuilder parses textual descriptions of user interfaces which
133  * are specified in an XML format which can be roughly described
134  * by the DTD below. We refer to these descriptions as
135  * GtkBuilder UI definitions or just
136  * UI definitions if the context is clear.
137  * Do not confuse GtkBuilder UI Definitions with
138  * GtkUIManager UI Definitions,
139  * which are more limited in scope.
140  * <!ELEMENT interface (requires|object)* >
141  * <!ELEMENT object (property|signal|child|ANY)* >
142  * <!ELEMENT property PCDATA >
143  * <!ELEMENT signal EMPTY >
144  * <!ELEMENT requires EMPTY >
145  * <!ELEMENT child (object|ANY*) >
146  * <!ATTLIST interface domain 	 #IMPLIED >
147  * <!ATTLIST object id 	 #REQUIRED
148  *  class 	 #REQUIRED
149  *  type-func 	 #IMPLIED
150  *  constructor 	 #IMPLIED >
151  * <!ATTLIST requires lib 	 #REQUIRED
152  *  version 	 #REQUIRED >
153  * <!ATTLIST property name 	 #REQUIRED
154  *  translatable 	 #IMPLIED
155  *  comments #IMPLIED
156  *  context #IMPLIED >
157  * <!ATTLIST signal name 	 #REQUIRED
158  *  handler 	 #REQUIRED
159  *  after 	 #IMPLIED
160  *  swapped 	 #IMPLIED
161  *  object 	 #IMPLIED
162  *  last_modification_time #IMPLIED >
163  * <!ATTLIST child type 	 #IMPLIED
164  *  internal-child 	 #IMPLIED >
165  * The toplevel element is <interface>.
166  * It optionally takes a "domain" attribute, which will make
167  * the builder look for translated strings using dgettext() in the
168  * domain specified. This can also be done by calling
169  * gtk_builder_set_translation_domain() on the builder.
170  * Objects are described by <object> elements, which can
171  * contain <property> elements to set properties, <signal>
172  * elements which connect signals to handlers, and <child>
173  * elements, which describe child objects (most often widgets
174  * inside a container, but also e.g. actions in an action group,
175  * or columns in a tree model). A <child> element contains
176  * an <object> element which describes the child object.
177  * The target toolkit version(s) are described by <requires>
178  * elements, the "lib" attribute specifies the widget library in
179  * question (currently the only supported value is "gtk+") and the "version"
180  * attribute specifies the target version in the form "<major>.<minor>".
181  * The builder will error out if the version requirements are not met.
182  * Typically, the specific kind of object represented by an
183  * <object> element is specified by the "class" attribute.
184  * If the type has not been loaded yet, GTK+ tries to find the
185  * _get_type() from the class name by applying
186  * heuristics. This works in most cases, but if necessary, it is
187  * possible to specify the name of the _get_type()
188  * explictly with the "type-func" attribute. As a special case,
189  * GtkBuilder allows to use an object that has been constructed
190  * by a GtkUIManager in another part of the UI definition by
191  * specifying the id of the GtkUIManager in the "constructor"
192  * attribute and the name of the object in the "id" attribute.
193  * Objects must be given a name with the "id" attribute, which
194  * allows the application to retrieve them from the builder with
195  * gtk_builder_get_object(). An id is also necessary to use the
196  * object as property value in other parts of the UI definition.
197  * Note
198  * Prior to 2.20, GtkBuilder was setting the "name"
199  * property of constructed widgets to the "id" attribute. In GTK+
200  * 2.20 or newer, you have to use gtk_buildable_get_name() instead
201  * of gtk_widget_get_name() to obtain the "id", or set the "name"
202  * property in your UI definition.
203  * Setting properties of objects is pretty straightforward with
204  * the <property> element: the "name" attribute specifies
205  * the name of the property, and the content of the element
206  * specifies the value. If the "translatable" attribute is
207  * set to a true value, GTK+ uses gettext() (or dgettext() if
208  * the builder has a translation domain set) to find a translation
209  * for the value. This happens before the value is parsed, so
210  * it can be used for properties of any type, but it is probably
211  * most useful for string properties. It is also possible to
212  * specify a context to disambiguate short strings, and comments
213  * which may help the translators.
214  * GtkBuilder can parse textual representations for the most
215  * common property types: characters, strings, integers, floating-point
216  * numbers, booleans (strings like "TRUE", "t", "yes", "y", "1" are
217  * interpreted as TRUE, strings like "FALSE, "f", "no", "n", "0" are
218  * interpreted as FALSE), enumerations (can be specified by their
219  * name, nick or integer value), flags (can be specified by their name,
220  * nick, integer value, optionally combined with "|", e.g.
221  * "GTK_VISIBLE|GTK_REALIZED") and colors (in a format understood by
222  * gdk_color_parse()). Objects can be referred to by their name.
223  * Pixbufs can be specified as a filename of an image file to load.
224  * In general, GtkBuilder allows forward references to objects —
225  * an object doesn't have to constructed before it can be referred to.
226  * The exception to this rule is that an object has to be constructed
227  * before it can be used as the value of a construct-only property.
228  * Signal handlers are set up with the <signal> element.
229  * The "name" attribute specifies the name of the signal, and the
230  * "handler" attribute specifies the function to connect to the signal.
231  * By default, GTK+ tries to find the handler using g_module_symbol(),
232  * but this can be changed by passing a custom GtkBuilderConnectFunc
233  * to gtk_builder_connect_signals_full(). The remaining attributes,
234  * "after", "swapped" and "object", have the same meaning as the
235  * corresponding parameters of the g_signal_connect_object() or
236  * g_signal_connect_data() functions. A "last_modification_time" attribute
237  * is also allowed, but it does not have a meaning to the builder.
238  * Sometimes it is necessary to refer to widgets which have implicitly
239  * been constructed by GTK+ as part of a composite widget, to set
240  * properties on them or to add further children (e.g. the vbox
241  * of a GtkDialog). This can be achieved by setting the "internal-child"
242  * propery of the <child> element to a true value. Note that
243  * GtkBuilder still requires an <object> element for the internal
244  * child, even if it has already been constructed.
245  * A number of widgets have different places where a child can be
246  * added (e.g. tabs vs. page content in notebooks). This can be reflected
247  * in a UI definition by specifying the "type" attribute on a <child>
248  * The possible values for the "type" attribute are described in
249  * the sections describing the widget-specific portions of UI definitions.
250  * $(DDOC_COMMENT example)
251  * Beyond this general structure, several object classes define
252  * their own XML DTD fragments for filling in the ANY placeholders
253  * in the DTD above. Note that a custom element in a <child>
254  * element gets parsed by the custom tag handler of the parent
255  * object, while a custom element in an <object> element
256  * gets parsed by the custom tag handler of the object.
257  * These XML fragments are explained in the documentation of the
258  * respective objects, see
259  * GtkWidget,
260  * GtkLabel,
261  * GtkWindow,
262  * GtkContainer,
263  * GtkDialog,
264  * GtkCellLayout,
265  * GtkColorSelectionDialog,
266  * GtkFontSelectionDialog,
267  * GtkComboBoxEntry,
268  * GtkExpander,
269  * GtkFrame,
270  * GtkListStore,
271  * GtkTreeStore,
272  * GtkNotebook,
273  * GtkSizeGroup,
274  * GtkTreeView,
275  * GtkUIManager,
276  * GtkActionGroup.
277  * GtkMenuItem,
278  * GtkAssistant,
279  * GtkScale.
280  */
281 public class Builder : ObjectG
282 {
283 	
284 	/** the main Gtk struct */
285 	protected GtkBuilder* gtkBuilder;
286 	
287 	
288 	public GtkBuilder* getBuilderStruct()
289 	{
290 		return gtkBuilder;
291 	}
292 	
293 	
294 	/** the main Gtk struct as a void* */
295 	protected override void* getStruct()
296 	{
297 		return cast(void*)gtkBuilder;
298 	}
299 	
300 	/**
301 	 * Sets our main struct and passes it to the parent class
302 	 */
303 	public this (GtkBuilder* gtkBuilder)
304 	{
305 		super(cast(GObject*)gtkBuilder);
306 		this.gtkBuilder = gtkBuilder;
307 	}
308 	
309 	protected override void setStruct(GObject* obj)
310 	{
311 		super.setStruct(obj);
312 		gtkBuilder = cast(GtkBuilder*)obj;
313 	}
314 	
315 	private struct GtkBuilderClass
316 	{
317 		GObjectClass parentClass;
318 		extern(C) GType function( GtkBuilder*, char* ) get_type_from_name;
319 		
320 		/* Padding for future expansion */
321 		extern(C) void  function()  _gtk_reserved1;
322 		extern(C) void  function()  _gtk_reserved2;
323 		extern(C) void  function()  _gtk_reserved3;
324 		extern(C) void  function()  _gtk_reserved4;
325 		extern(C) void  function()  _gtk_reserved5;
326 		extern(C) void  function()  _gtk_reserved6;
327 		extern(C) void  function()  _gtk_reserved7;
328 		extern(C) void  function()  _gtk_reserved8;
329 	}
330 	
331 	/**
332 	 * Creates a new builder object.
333 	 * Since 2.12
334 	 * Throws: ConstructionException GTK+ fails to create the object.
335 	 */
336 	public this ()
337 	{
338 		// GtkBuilder* gtk_builder_new (void);
339 		auto p = gtk_builder_new();
340 		if(p is null)
341 		{
342 			throw new ConstructionException("null returned by gtk_builder_new()");
343 		}
344 		this(cast(GtkBuilder*) p);
345 		
346 		GtkBuilderClass* klass = Type.getInstanceClass!(GtkBuilderClass)( this );
347 		klass.get_type_from_name = &gtk_builder_real_get_type_from_name_override;
348 	}
349 	
350 	/**
351 	 * This function is a modification of _gtk_builder_resolve_type_lazily from "gtk/gtkbuilder.c".
352 	 * It is needed because it assumes we are linking at compile time to the gtk libs.
353 	 * specifically the NULL in g_module_open( NULL, 0 );
354 	 * It replaces the default function pointer "get_type_from_name" in GtkBuilderClass.
355 	 */
356 	extern(C) private static GType gtk_builder_real_get_type_from_name_override ( GtkBuilder* builder, char *name )
357 	{
358 		GType gtype;
359 		gtype = g_type_from_name( name );
360 		if (gtype != GType.INVALID)
361 		{
362 			return gtype;
363 		}
364 		
365 		/*
366 		 * Try to map a type name to a _get_type function
367 		 * and call it, eg:
368 		 *
369 		 * GtkWindow -> gtk_window_get_type
370 		 * GtkHBox -> gtk_hbox_get_type
371 		 * GtkUIManager -> gtk_ui_manager_get_type
372 		 *
373 		 */
374 		char   c;
375 		string symbol_name;
376 		
377 		for (int i = 0; name[i] != '\0'; i++)
378 		{
379 			c = name[i];
380 			/* skip if uppercase, first or previous is uppercase */
381 			if ((c == Str.asciiToupper (c) &&
382 			i > 0 && name[i-1] != Str.asciiToupper (name[i-1])) ||
383 			(i > 2 && name[i]   == Str.asciiToupper (name[i]) &&
384 			name[i-1] == Str.asciiToupper (name[i-1]) &&
385 			name[i-2] == Str.asciiToupper (name[i-2]))
386 			)
387 			
388 			symbol_name ~= '_';
389 			symbol_name ~= Str.asciiTolower (c);
390 		}
391 		symbol_name ~=  "_get_type" ;
392 		
393 		/* scan linked librarys for function symbol */
394 		foreach ( lib; importLibs )
395 		{
396 			GType function() func;
397 			Module mod = Module.open( libPath ~ lib, GModuleFlags.BIND_LAZY );
398 			if( mod is null )
399 			continue;
400 			
401 			scope(exit) mod.close();
402 			
403 			if ( mod.symbol( symbol_name, cast(void**) &func ) ) {
404 				return func();
405 			}
406 		}
407 		
408 		return GType.INVALID;
409 	}
410 	
411 	/**
412 	 * Gets the object named name. Note that this function does not
413 	 * increment the reference count of the returned object.
414 	 * Since 2.12
415 	 * Params:
416 	 * name = name of object to get
417 	 * Returns: the object named name or NULL if it could not be found in the object tree.. transfer none.
418 	 */
419 	public ObjectG getObject(string name)
420 	{
421 		// GObject* gtk_builder_get_object (GtkBuilder *builder,  const gchar *name);
422 		return newFromObject( gtk_builder_get_object(gtkBuilder, Str.toStringz(name)) );
423 	}
424 	
425 	/**
426 	 * Gets all objects that have been constructed by builder.
427 	 * Since 2.12
428 	 * Returns: an array containing all the objects constructed by the GtkBuilder instance.
429 	 */
430 	public ObjectG[] getObjects()
431 	{
432 		ObjectG[] objects;
433 		
434 		// GSList* gtk_builder_get_objects (GtkBuilder *builder);
435 		GSList* list = gtk_builder_get_objects(gtkBuilder);
436 		
437 		while ( list.next !is null )
438 		{
439 			objects ~= newFromObject( cast(GObject*)list.data );
440 			list = list.next;
441 		}
442 		
443 		g_slist_free(list);
444 		
445 		return objects;
446 	}
447 	
448 	/**
449 	 * This function creates an D object corresponding to the Struct pointer passed in.
450 	 */
451 	public ObjectG newFromObject(GObject* cobj)
452 	{
453 		version(LDC)
454 		{
455 			version(D_Version2)
456 			{
457 				alias ClassInfo.find findClassInfo;
458 			}
459 		}
460 		else
461 		{
462 			alias ClassInfo.find findClassInfo;
463 		}
464 		
465 		if(cobj is null)
466 		{
467 			return null;
468 		}
469 		
470 		void* dObj = g_object_get_data(cobj, Str.toStringz("GObject"));
471 		
472 		if ( dObj !is null )
473 		{
474 			return cast(ObjectG)dObj;
475 		}
476 		
477 		string type = convertClassName(Type.name((cast(GTypeInstance*)cobj).gClass.gType));
478 		ClassInfo ci = cast(ClassInfo)findClassInfo(type);
479 		
480 		//Gobject and Gio types both start with g, so try both.
481 		if(ci is null && startsWith(type, "gobject"))
482 		{
483 			ci = cast(ClassInfo)findClassInfo("gio"~ type[7..$]);
484 		}
485 		
486 		if(ci is null)
487 		{
488 			return null;
489 		}
490 		
491 		ObjectG obj = cast(ObjectG)gtkc.gtktypes._d_newclass(ci);
492 		
493 		version(D_Version2)
494 		{
495 			obj.__ctor(cobj);
496 		}
497 		else
498 		{
499 			obj._ctor(cobj);
500 		}
501 		
502 		return obj;
503 	}
504 	
505 	/**
506 	 * Turn the name of a C Type in to the name of the corresponding D type.
507 	 * Note: If the prefix of the type is "G" this always usses "gobject" as
508 	 *     the prefix, extra care should be taken for types from GIO.
509 	 */
510 	private string convertClassName(string gName)
511 	{
512 		string conv;
513 		string prefix;
514 		
515 		version(Tango)
516 		{
517 			alias toUpper toupper;
518 			alias toLower tolower;
519 		}
520 		version(D_Version2)
521 		{
522 			alias toUpper toupper;
523 			alias toLower tolower;
524 		}
525 		
526 		if      ( startsWith(gName, "GtkSource" ) ) prefix = "Gsv";
527 		else if ( startsWith(gName, "Gtk") )        prefix = "Gtk";
528 		else if ( startsWith(gName, "Gdk") )        prefix = "Gdk";
529 		else if ( startsWith(gName, "Gst") )        prefix = "Gst";
530 		else if ( startsWith(gName, "Gda") )        prefix = "Gda";
531 		else if ( startsWith(gName, "Atk") )        prefix = "Atk";
532 		else if ( startsWith(gName, "G") )          prefix = "G";
533 		else if ( startsWith(gName, "Pango") )      prefix = "Pg";
534 		else if ( startsWith(gName, "cairo") )      prefix = "cairo";
535 		
536 		conv = gName[prefix.length..gName.length];
537 		
538 		if ( conv == "Object" ) conv ~= prefix;
539 		if ( prefix == "Pg" )   conv = "Pg" ~ gName[5..gName.length];
540 		if ( prefix == "cairo") conv = toupper(gName[6..7]) ~ gName[7..gName.length - 2];
541 		
542 		prefix = tolower(prefix);
543 		
544 		if( prefix == "gst") prefix = "gstreamer";
545 		if( prefix == "g")   prefix = "gobject";
546 		if( prefix == "pg" ) prefix = "pango";
547 		
548 		return prefix ~"."~ conv ~"."~ conv;
549 	}
550 	
551 	private bool startsWith(string str, string prefix)
552 	{
553 		return str.length >= prefix.length && str[0..prefix.length] == prefix;
554 	}
555 	
556 	version(LDC)
557 	{
558 		//version( !D_Version2 )
559 		version(D_Version2) {} else
560 		{
561 			private Object _d_newclass(ClassInfo ci)
562 			{
563 				void* p = cast(void*)_d_allocclass(ci);
564 				(cast(byte*) p)[0 .. ci.init.length] = ci.init[];
565 				
566 				return cast(Object) p;
567 			}
568 			
569 			private ClassInfo findClassInfo(string classname)
570 			{
571 				foreach ( m; ModuleInfo )
572 				{
573 					foreach ( c; m.localClasses )
574 					{
575 						if ( c.name == classname )
576 						return c;
577 					}
578 				}
579 				
580 				return null;
581 			}
582 		}
583 	}
584 	
585 	/**
586 	 */
587 	
588 	/**
589 	 * Parses a file containing a GtkBuilder
590 	 * UI definition and merges it with the current contents of builder.
591 	 * Upon errors 0 will be returned and error will be assigned a
592 	 * GError from the GTK_BUILDER_ERROR, G_MARKUP_ERROR or G_FILE_ERROR
593 	 * domain.
594 	 * Since 2.12
595 	 * Params:
596 	 * filename = the name of the file to parse
597 	 * Returns: A positive value on success, 0 if an error occurred
598 	 * Throws: GException on failure.
599 	 */
600 	public uint addFromFile(string filename)
601 	{
602 		// guint gtk_builder_add_from_file (GtkBuilder *builder,  const gchar *filename,  GError **error);
603 		GError* err = null;
604 		
605 		auto p = gtk_builder_add_from_file(gtkBuilder, Str.toStringz(filename), &err);
606 		
607 		if (err !is null)
608 		{
609 			throw new GException( new ErrorG(err) );
610 		}
611 		
612 		return p;
613 	}
614 	
615 	/**
616 	 * Parses a string containing a GtkBuilder
617 	 * UI definition and merges it with the current contents of builder.
618 	 * Upon errors 0 will be returned and error will be assigned a
619 	 * GError from the GTK_BUILDER_ERROR or G_MARKUP_ERROR domain.
620 	 * Since 2.12
621 	 * Params:
622 	 * buffer = the string to parse
623 	 * length = the length of buffer (may be -1 if buffer is nul-terminated)
624 	 * Returns: A positive value on success, 0 if an error occurred
625 	 * Throws: GException on failure.
626 	 */
627 	public uint addFromString(string buffer, gsize length)
628 	{
629 		// guint gtk_builder_add_from_string (GtkBuilder *builder,  const gchar *buffer,  gsize length,  GError **error);
630 		GError* err = null;
631 		
632 		auto p = gtk_builder_add_from_string(gtkBuilder, Str.toStringz(buffer), length, &err);
633 		
634 		if (err !is null)
635 		{
636 			throw new GException( new ErrorG(err) );
637 		}
638 		
639 		return p;
640 	}
641 	
642 	/**
643 	 * Parses a file containing a GtkBuilder
644 	 * UI definition building only the requested objects and merges
645 	 * them with the current contents of builder.
646 	 * Upon errors 0 will be returned and error will be assigned a
647 	 * GError from the GTK_BUILDER_ERROR, G_MARKUP_ERROR or G_FILE_ERROR
648 	 * domain.
649 	 * Note
650 	 * If you are adding an object that depends on an object that is not
651 	 * its child (for instance a GtkTreeView that depends on its
652 	 * GtkTreeModel), you have to explicitely list all of them in object_ids.
653 	 * Since 2.14
654 	 * Params:
655 	 * filename = the name of the file to parse
656 	 * objectIds = nul-terminated array of objects to build
657 	 * Returns: A positive value on success, 0 if an error occurred
658 	 * Throws: GException on failure.
659 	 */
660 	public uint addObjectsFromFile(string filename, string[] objectIds)
661 	{
662 		// guint gtk_builder_add_objects_from_file (GtkBuilder *builder,  const gchar *filename,  gchar **object_ids,  GError **error);
663 		GError* err = null;
664 		
665 		auto p = gtk_builder_add_objects_from_file(gtkBuilder, Str.toStringz(filename), Str.toStringzArray(objectIds), &err);
666 		
667 		if (err !is null)
668 		{
669 			throw new GException( new ErrorG(err) );
670 		}
671 		
672 		return p;
673 	}
674 	
675 	/**
676 	 * Parses a string containing a GtkBuilder
677 	 * UI definition building only the requested objects and merges
678 	 * them with the current contents of builder.
679 	 * Upon errors 0 will be returned and error will be assigned a
680 	 * GError from the GTK_BUILDER_ERROR or G_MARKUP_ERROR domain.
681 	 * Note
682 	 * If you are adding an object that depends on an object that is not
683 	 * its child (for instance a GtkTreeView that depends on its
684 	 * GtkTreeModel), you have to explicitely list all of them in object_ids.
685 	 * Since 2.14
686 	 * Params:
687 	 * buffer = the string to parse
688 	 * length = the length of buffer (may be -1 if buffer is nul-terminated)
689 	 * objectIds = nul-terminated array of objects to build
690 	 * Returns: A positive value on success, 0 if an error occurred
691 	 * Throws: GException on failure.
692 	 */
693 	public uint addObjectsFromString(string buffer, gsize length, string[] objectIds)
694 	{
695 		// guint gtk_builder_add_objects_from_string (GtkBuilder *builder,  const gchar *buffer,  gsize length,  gchar **object_ids,  GError **error);
696 		GError* err = null;
697 		
698 		auto p = gtk_builder_add_objects_from_string(gtkBuilder, Str.toStringz(buffer), length, Str.toStringzArray(objectIds), &err);
699 		
700 		if (err !is null)
701 		{
702 			throw new GException( new ErrorG(err) );
703 		}
704 		
705 		return p;
706 	}
707 	
708 	/**
709 	 * This method is a simpler variation of gtk_builder_connect_signals_full().
710 	 * It uses GModule's introspective features (by opening the module NULL)
711 	 * to look at the application's symbol table. From here it tries to match
712 	 * the signal handler names given in the interface description with
713 	 * symbols in the application and connects the signals.
714 	 * Note that this function will not work correctly if GModule is not
715 	 * supported on the platform.
716 	 * When compiling applications for Windows, you must declare signal callbacks
717 	 * with G_MODULE_EXPORT, or they will not be put in the symbol table.
718 	 * On Linux and Unices, this is not necessary; applications should instead
719 	 * be compiled with the -Wl,--export-dynamic CFLAGS, and linked against
720 	 * gmodule-export-2.0.
721 	 * Since 2.12
722 	 * Params:
723 	 * userData = a pointer to a structure sent in as user data to all signals
724 	 */
725 	public void connectSignals(void* userData)
726 	{
727 		// void gtk_builder_connect_signals (GtkBuilder *builder,  gpointer user_data);
728 		gtk_builder_connect_signals(gtkBuilder, userData);
729 	}
730 	
731 	/**
732 	 * This function can be thought of the interpreted language binding
733 	 * version of gtk_builder_connect_signals(), except that it does not
734 	 * require GModule to function correctly.
735 	 * Since 2.12
736 	 * Params:
737 	 * func = the function used to connect the signals. [scope call]
738 	 * userData = arbitrary data that will be passed to the connection function
739 	 */
740 	public void connectSignalsFull(GtkBuilderConnectFunc func, void* userData)
741 	{
742 		// void gtk_builder_connect_signals_full (GtkBuilder *builder,  GtkBuilderConnectFunc func,  gpointer user_data);
743 		gtk_builder_connect_signals_full(gtkBuilder, func, userData);
744 	}
745 	
746 	/**
747 	 * Sets the translation domain of builder.
748 	 * See "translation-domain".
749 	 * Since 2.12
750 	 * Params:
751 	 * domain = the translation domain or NULL. [allow-none]
752 	 */
753 	public void setTranslationDomain(string domain)
754 	{
755 		// void gtk_builder_set_translation_domain (GtkBuilder *builder,  const gchar *domain);
756 		gtk_builder_set_translation_domain(gtkBuilder, Str.toStringz(domain));
757 	}
758 	
759 	/**
760 	 * Gets the translation domain of builder.
761 	 * Since 2.12
762 	 * Returns: the translation domain. This string is owned by the builder object and must not be modified or freed.
763 	 */
764 	public string getTranslationDomain()
765 	{
766 		// const gchar * gtk_builder_get_translation_domain (GtkBuilder *builder);
767 		return Str.toString(gtk_builder_get_translation_domain(gtkBuilder));
768 	}
769 	
770 	/**
771 	 * Looks up a type by name, using the virtual function that
772 	 * GtkBuilder has for that purpose. This is mainly used when
773 	 * implementing the GtkBuildable interface on a type.
774 	 * Since 2.12
775 	 * Params:
776 	 * typeName = type name to lookup
777 	 * Returns: the GType found for type_name or G_TYPE_INVALID if no type was found
778 	 */
779 	public GType getTypeFromName(string typeName)
780 	{
781 		// GType gtk_builder_get_type_from_name (GtkBuilder *builder,  const char *type_name);
782 		return gtk_builder_get_type_from_name(gtkBuilder, Str.toStringz(typeName));
783 	}
784 	
785 	/**
786 	 * This function demarshals a value from a string. This function
787 	 * calls g_value_init() on the value argument, so it need not be
788 	 * initialised beforehand.
789 	 * This function can handle char, uchar, boolean, int, uint, long,
790 	 * ulong, enum, flags, float, double, string, GdkColor and
791 	 * GtkAdjustment type values. Support for GtkWidget type values is
792 	 * still to come.
793 	 * Upon errors FALSE will be returned and error will be assigned a
794 	 * GError from the GTK_BUILDER_ERROR domain.
795 	 * Since 2.12
796 	 * Params:
797 	 * pspec = the GParamSpec for the property
798 	 * string = the string representation of the value
799 	 * value = the GValue to store the result in. [out]
800 	 * Returns: TRUE on success
801 	 * Throws: GException on failure.
802 	 */
803 	public int valueFromString(ParamSpec pspec, string string, Value value)
804 	{
805 		// gboolean gtk_builder_value_from_string (GtkBuilder *builder,  GParamSpec *pspec,  const gchar *string,  GValue *value,  GError **error);
806 		GError* err = null;
807 		
808 		auto p = gtk_builder_value_from_string(gtkBuilder, (pspec is null) ? null : pspec.getParamSpecStruct(), Str.toStringz(string), (value is null) ? null : value.getValueStruct(), &err);
809 		
810 		if (err !is null)
811 		{
812 			throw new GException( new ErrorG(err) );
813 		}
814 		
815 		return p;
816 	}
817 	
818 	/**
819 	 * Like gtk_builder_value_from_string(), this function demarshals
820 	 * a value from a string, but takes a GType instead of GParamSpec.
821 	 * This function calls g_value_init() on the value argument, so it
822 	 * need not be initialised beforehand.
823 	 * Upon errors FALSE will be returned and error will be assigned a
824 	 * GError from the GTK_BUILDER_ERROR domain.
825 	 * Since 2.12
826 	 * Params:
827 	 * type = the GType of the value
828 	 * string = the string representation of the value
829 	 * value = the GValue to store the result in. [out]
830 	 * Returns: TRUE on success
831 	 * Throws: GException on failure.
832 	 */
833 	public int valueFromStringType(GType type, string string, Value value)
834 	{
835 		// gboolean gtk_builder_value_from_string_type (GtkBuilder *builder,  GType type,  const gchar *string,  GValue *value,  GError **error);
836 		GError* err = null;
837 		
838 		auto p = gtk_builder_value_from_string_type(gtkBuilder, type, Str.toStringz(string), (value is null) ? null : value.getValueStruct(), &err);
839 		
840 		if (err !is null)
841 		{
842 			throw new GException( new ErrorG(err) );
843 		}
844 		
845 		return p;
846 	}
847 }