1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Builder;
26 
27 private import glib.ConstructionException;
28 private import glib.ErrorG;
29 private import glib.GException;
30 private import glib.ListSG;
31 private import glib.MemorySlice;
32 private import glib.Str;
33 private import glib.c.functions;
34 private import gobject.Closure;
35 private import gobject.ObjectG;
36 private import gobject.ParamSpec;
37 private import gobject.Value;
38 private import gtk.BuilderScopeIF;
39 private import gtk.c.functions;
40 public  import gtk.c.types;
41 
42 
43 /**
44  * A `GtkBuilder` reads XML descriptions of a user interface and
45  * instantiates the described objects.
46  * 
47  * To create a `GtkBuilder` from a user interface description, call
48  * [ctor@Gtk.Builder.new_from_file], [ctor@Gtk.Builder.new_from_resource]
49  * or [ctor@Gtk.Builder.new_from_string].
50  * 
51  * In the (unusual) case that you want to add user interface
52  * descriptions from multiple sources to the same `GtkBuilder` you can
53  * call [ctor@Gtk.Builder.new] to get an empty builder and populate it by
54  * (multiple) calls to [method@Gtk.Builder.add_from_file],
55  * [method@Gtk.Builder.add_from_resource] or
56  * [method@Gtk.Builder.add_from_string].
57  * 
58  * A `GtkBuilder` holds a reference to all objects that it has constructed
59  * and drops these references when it is finalized. This finalization can
60  * cause the destruction of non-widget objects or widgets which are not
61  * contained in a toplevel window. For toplevel windows constructed by a
62  * builder, it is the responsibility of the user to call
63  * [method@Gtk.Window.destroy] to get rid of them and all the widgets
64  * they contain.
65  * 
66  * The functions [method@Gtk.Builder.get_object] and
67  * [method@Gtk.Builder.get_objects] can be used to access the widgets in
68  * the interface by the names assigned to them inside the UI description.
69  * Toplevel windows returned by these functions will stay around until the
70  * user explicitly destroys them with [method@Gtk.Window.destroy]. Other
71  * widgets will either be part of a larger hierarchy constructed by the
72  * builder (in which case you should not have to worry about their lifecycle),
73  * or without a parent, in which case they have to be added to some container
74  * to make use of them. Non-widget objects need to be reffed with
75  * g_object_ref() to keep them beyond the lifespan of the builder.
76  * 
77  * # GtkBuilder UI Definitions
78  * 
79  * `GtkBuilder` parses textual descriptions of user interfaces which are
80  * specified in XML format. We refer to these descriptions as “GtkBuilder
81  * UI definitions” or just “UI definitions” if the context is clear.
82  * 
83  * The toplevel element is `<interface>`. It optionally takes a “domain”
84  * attribute, which will make the builder look for translated strings
85  * using `dgettext()` in the domain specified. This can also be done by
86  * calling [method@Gtk.Builder.set_translation_domain] on the builder.
87  * 
88  * Objects are described by `<object>` elements, which can contain
89  * `<property>` elements to set properties, `<signal>` elements which
90  * connect signals to handlers, and `<child>` elements, which describe
91  * child objects (most often widgets inside a container, but also e.g.
92  * actions in an action group, or columns in a tree model). A `<child>`
93  * element contains an `<object>` element which describes the child object.
94  * 
95  * The target toolkit version(s) are described by `<requires>` elements,
96  * the “lib” attribute specifies the widget library in question (currently
97  * the only supported value is “gtk”) and the “version” attribute specifies
98  * the target version in the form “`<major>`.`<minor>`”. `GtkBuilder` will
99  * error out if the version requirements are not met.
100  * 
101  * Typically, the specific kind of object represented by an `<object>`
102  * element is specified by the “class” attribute. If the type has not
103  * been loaded yet, GTK tries to find the `get_type()` function from the
104  * class name by applying heuristics. This works in most cases, but if
105  * necessary, it is possible to specify the name of the `get_type()`
106  * function explicitly with the "type-func" attribute.
107  * 
108  * Objects may be given a name with the “id” attribute, which allows the
109  * application to retrieve them from the builder with
110  * [method@Gtk.Builder.get_object]. An id is also necessary to use the
111  * object as property value in other parts of the UI definition. GTK
112  * reserves ids starting and ending with `___` (three consecutive
113  * underscores) for its own purposes.
114  * 
115  * Setting properties of objects is pretty straightforward with the
116  * `<property>` element: the “name” attribute specifies the name of the
117  * property, and the content of the element specifies the value.
118  * If the “translatable” attribute is set to a true value, GTK uses
119  * `gettext()` (or `dgettext()` if the builder has a translation domain set)
120  * to find a translation for the value. This happens before the value
121  * is parsed, so it can be used for properties of any type, but it is
122  * probably most useful for string properties. It is also possible to
123  * specify a context to disambiguate short strings, and comments which
124  * may help the translators.
125  * 
126  * `GtkBuilder` can parse textual representations for the most common
127  * property types: characters, strings, integers, floating-point numbers,
128  * booleans (strings like “TRUE”, “t”, “yes”, “y”, “1” are interpreted
129  * as %TRUE, strings like “FALSE”, “f”, “no”, “n”, “0” are interpreted
130  * as %FALSE), enumerations (can be specified by their name, nick or
131  * integer value), flags (can be specified by their name, nick, integer
132  * value, optionally combined with “|”, e.g.
133  * “GTK_INPUT_HINT_EMOJI|GTK_INPUT_HINT_LOWERCASE”)
134  * and colors (in a format understood by [method@Gdk.RGBA.parse]).
135  * 
136  * `GVariant`s can be specified in the format understood by
137  * g_variant_parse(), and pixbufs can be specified as a filename of an
138  * image file to load.
139  * 
140  * Objects can be referred to by their name and by default refer to
141  * objects declared in the local XML fragment and objects exposed via
142  * [method@Gtk.Builder.expose_object]. In general, `GtkBuilder` allows
143  * forward references to objects — declared in the local XML; an object
144  * doesn’t have to be constructed before it can be referred to. The
145  * exception to this rule is that an object has to be constructed before
146  * it can be used as the value of a construct-only property.
147  * 
148  * It is also possible to bind a property value to another object's
149  * property value using the attributes "bind-source" to specify the
150  * source object of the binding, and optionally, "bind-property" and
151  * "bind-flags" to specify the source property and source binding flags
152  * respectively. Internally, `GtkBuilder` implements this using `GBinding`
153  * objects. For more information see g_object_bind_property().
154  * 
155  * Sometimes it is necessary to refer to widgets which have implicitly
156  * been constructed by GTK as part of a composite widget, to set
157  * properties on them or to add further children (e.g. the content area
158  * of a `GtkDialog`). This can be achieved by setting the “internal-child”
159  * property of the `<child>` element to a true value. Note that #GtkBuilder
160  * still requires an `<object>` element for the internal child, even if it
161  * has already been constructed.
162  * 
163  * A number of widgets have different places where a child can be added
164  * (e.g. tabs vs. page content in notebooks). This can be reflected in
165  * a UI definition by specifying the “type” attribute on a `<child>`
166  * The possible values for the “type” attribute are described in the
167  * sections describing the widget-specific portions of UI definitions.
168  * 
169  * # Signal handlers and function pointers
170  * 
171  * Signal handlers are set up with the `<signal>` element. The “name”
172  * attribute specifies the name of the signal, and the “handler” attribute
173  * specifies the function to connect to the signal.
174  * The remaining attributes, “after”, “swapped” and “object”, have the
175  * same meaning as the corresponding parameters of the
176  * g_signal_connect_object() or g_signal_connect_data() functions. A
177  * “last_modification_time” attribute is also allowed, but it does not
178  * have a meaning to the builder.
179  * 
180  * If you rely on `GModule` support to lookup callbacks in the symbol table,
181  * the following details should be noted:
182  * 
183  * When compiling applications for Windows, you must declare signal callbacks
184  * with %G_MODULE_EXPORT, or they will not be put in the symbol table.
185  * On Linux and Unix, this is not necessary; applications should instead
186  * be compiled with the -Wl,--export-dynamic `CFLAGS`, and linked against
187  * `gmodule-export-2.0`.
188  * 
189  * # A GtkBuilder UI Definition
190  * 
191  * ```xml
192  * <interface>
193  * <object class="GtkDialog" id="dialog1">
194  * <child internal-child="vbox">
195  * <object class="GtkBox" id="vbox1">
196  * <child internal-child="action_area">
197  * <object class="GtkBox" id="hbuttonbox1">
198  * <child>
199  * <object class="GtkButton" id="ok_button">
200  * <property name="label">gtk-ok</property>
201  * <signal name="clicked" handler="ok_button_clicked"/>
202  * </object>
203  * </child>
204  * </object>
205  * </child>
206  * </object>
207  * </child>
208  * </object>
209  * </interface>
210  * ```
211  * 
212  * Beyond this general structure, several object classes define their
213  * own XML DTD fragments for filling in the ANY placeholders in the DTD
214  * above. Note that a custom element in a <child> element gets parsed by
215  * the custom tag handler of the parent object, while a custom element in
216  * an <object> element gets parsed by the custom tag handler of the object.
217  * 
218  * These XML fragments are explained in the documentation of the
219  * respective objects.
220  * 
221  * A `<template>` tag can be used to define a widget class’s components.
222  * See the [GtkWidget documentation](class.Widget.html#building-composite-widgets-from-template-xml) for details.
223  */
224 public class Builder : ObjectG
225 {
226 	/** the main Gtk struct */
227 	protected GtkBuilder* gtkBuilder;
228 
229 	/** Get the main Gtk struct */
230 	public GtkBuilder* getBuilderStruct(bool transferOwnership = false)
231 	{
232 		if (transferOwnership)
233 			ownedRef = false;
234 		return gtkBuilder;
235 	}
236 
237 	/** the main Gtk struct as a void* */
238 	protected override void* getStruct()
239 	{
240 		return cast(void*)gtkBuilder;
241 	}
242 
243 	/**
244 	 * Sets our main struct and passes it to the parent class.
245 	 */
246 	public this (GtkBuilder* gtkBuilder, bool ownedRef = false)
247 	{
248 		this.gtkBuilder = gtkBuilder;
249 		super(cast(GObject*)gtkBuilder, ownedRef);
250 	}
251 
252 	/**
253 	 * Gets all objects that have been constructed by @builder. Note that
254 	 * this function does not increment the reference counts of the returned
255 	 * objects.
256 	 *
257 	 * Returns: a newly-allocated #GSList containing all the objects
258 	 *     constructed by the #GtkBuilder instance. It should be freed by
259 	 *     g_slist_free()
260 	 */
261 	public ObjectG[] getObjects()
262 	{
263 		auto __p = gtk_builder_get_objects(gtkBuilder);
264 
265 		if(__p is null)
266 		{
267 			return null;
268 		}
269 
270 		return new ListSG(cast(GSList*) __p).toArray!ObjectG();
271 	}
272 
273 	/**
274 	 */
275 
276 	/** */
277 	public static GType getType()
278 	{
279 		return gtk_builder_get_type();
280 	}
281 
282 	/**
283 	 * Creates a new empty builder object.
284 	 *
285 	 * This function is only useful if you intend to make multiple calls
286 	 * to [method@Gtk.Builder.add_from_file], [method@Gtk.Builder.add_from_resource]
287 	 * or [method@Gtk.Builder.add_from_string] in order to merge multiple UI
288 	 * descriptions into a single builder.
289 	 *
290 	 * Returns: a new (empty) `GtkBuilder` object
291 	 *
292 	 * Throws: ConstructionException GTK+ fails to create the object.
293 	 */
294 	public this()
295 	{
296 		auto __p = gtk_builder_new();
297 
298 		if(__p is null)
299 		{
300 			throw new ConstructionException("null returned by new");
301 		}
302 
303 		this(cast(GtkBuilder*) __p, true);
304 	}
305 
306 	/**
307 	 * Parses the UI definition in the file @filename.
308 	 *
309 	 * If there is an error opening the file or parsing the description then
310 	 * the program will be aborted. You should only ever attempt to parse
311 	 * user interface descriptions that are shipped as part of your program.
312 	 *
313 	 * Params:
314 	 *     filename = filename of user interface description file
315 	 *
316 	 * Returns: a `GtkBuilder` containing the described interface
317 	 *
318 	 * Throws: ConstructionException GTK+ fails to create the object.
319 	 */
320 	public this(string filename)
321 	{
322 		auto __p = gtk_builder_new_from_file(Str.toStringz(filename));
323 
324 		if(__p is null)
325 		{
326 			throw new ConstructionException("null returned by new_from_file");
327 		}
328 
329 		this(cast(GtkBuilder*) __p, true);
330 	}
331 
332 	/**
333 	 * Parses a file containing a UI definition and merges it with
334 	 * the current contents of @builder.
335 	 *
336 	 * This function is useful if you need to call
337 	 * [method@Gtk.Builder.set_current_object]) to add user data to
338 	 * callbacks before loading GtkBuilder UI. Otherwise, you probably
339 	 * want [ctor@Gtk.Builder.new_from_file] instead.
340 	 *
341 	 * If an error occurs, 0 will be returned and @error will be assigned a
342 	 * `GError` from the `GTK_BUILDER_ERROR`, `G_MARKUP_ERROR` or `G_FILE_ERROR`
343 	 * domains.
344 	 *
345 	 * It’s not really reasonable to attempt to handle failures of this
346 	 * call. You should not use this function with untrusted files (ie:
347 	 * files that are not part of your application). Broken `GtkBuilder`
348 	 * files can easily crash your program, and it’s possible that memory
349 	 * was leaked leading up to the reported failure. The only reasonable
350 	 * thing to do when an error is detected is to call `g_error()`.
351 	 *
352 	 * Params:
353 	 *     filename = the name of the file to parse
354 	 *
355 	 * Returns: %TRUE on success, %FALSE if an error occurred
356 	 *
357 	 * Throws: GException on failure.
358 	 */
359 	public bool addFromFile(string filename)
360 	{
361 		GError* err = null;
362 
363 		auto __p = gtk_builder_add_from_file(gtkBuilder, Str.toStringz(filename), &err) != 0;
364 
365 		if (err !is null)
366 		{
367 			throw new GException( new ErrorG(err) );
368 		}
369 
370 		return __p;
371 	}
372 
373 	/**
374 	 * Parses a resource file containing a UI definition
375 	 * and merges it with the current contents of @builder.
376 	 *
377 	 * This function is useful if you need to call
378 	 * [method@Gtk.Builder.set_current_object] to add user data to
379 	 * callbacks before loading GtkBuilder UI. Otherwise, you probably
380 	 * want [ctor@Gtk.Builder.new_from_resource] instead.
381 	 *
382 	 * If an error occurs, 0 will be returned and @error will be assigned a
383 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_RESOURCE_ERROR
384 	 * domain.
385 	 *
386 	 * It’s not really reasonable to attempt to handle failures of this
387 	 * call.  The only reasonable thing to do when an error is detected is
388 	 * to call g_error().
389 	 *
390 	 * Params:
391 	 *     resourcePath = the path of the resource file to parse
392 	 *
393 	 * Returns: %TRUE on success, %FALSE if an error occurred
394 	 *
395 	 * Throws: GException on failure.
396 	 */
397 	public bool addFromResource(string resourcePath)
398 	{
399 		GError* err = null;
400 
401 		auto __p = gtk_builder_add_from_resource(gtkBuilder, Str.toStringz(resourcePath), &err) != 0;
402 
403 		if (err !is null)
404 		{
405 			throw new GException( new ErrorG(err) );
406 		}
407 
408 		return __p;
409 	}
410 
411 	/**
412 	 * Parses a string containing a UI definition and merges it
413 	 * with the current contents of @builder.
414 	 *
415 	 * This function is useful if you need to call
416 	 * [method@Gtk.Builder.set_current_object] to add user data to
417 	 * callbacks before loading `GtkBuilder` UI. Otherwise, you probably
418 	 * want [ctor@Gtk.Builder.new_from_string] instead.
419 	 *
420 	 * Upon errors %FALSE will be returned and @error will be assigned a
421 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or
422 	 * %G_VARIANT_PARSE_ERROR domain.
423 	 *
424 	 * It’s not really reasonable to attempt to handle failures of this
425 	 * call.  The only reasonable thing to do when an error is detected is
426 	 * to call g_error().
427 	 *
428 	 * Params:
429 	 *     buffer = the string to parse
430 	 *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
431 	 *
432 	 * Returns: %TRUE on success, %FALSE if an error occurred
433 	 *
434 	 * Throws: GException on failure.
435 	 */
436 	public bool addFromString(string buffer, ptrdiff_t length)
437 	{
438 		GError* err = null;
439 
440 		auto __p = gtk_builder_add_from_string(gtkBuilder, Str.toStringz(buffer), length, &err) != 0;
441 
442 		if (err !is null)
443 		{
444 			throw new GException( new ErrorG(err) );
445 		}
446 
447 		return __p;
448 	}
449 
450 	/**
451 	 * Parses a file containing a UI definition building only the
452 	 * requested objects and merges them with the current contents
453 	 * of @builder.
454 	 *
455 	 * Upon errors, 0 will be returned and @error will be assigned a
456 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_FILE_ERROR
457 	 * domain.
458 	 *
459 	 * If you are adding an object that depends on an object that is not
460 	 * its child (for instance a `GtkTreeView` that depends on its
461 	 * `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
462 	 *
463 	 * Params:
464 	 *     filename = the name of the file to parse
465 	 *     objectIds = nul-terminated array of objects to build
466 	 *
467 	 * Returns: %TRUE on success, %FALSE if an error occurred
468 	 *
469 	 * Throws: GException on failure.
470 	 */
471 	public bool addObjectsFromFile(string filename, string[] objectIds)
472 	{
473 		GError* err = null;
474 
475 		auto __p = gtk_builder_add_objects_from_file(gtkBuilder, Str.toStringz(filename), Str.toStringzArray(objectIds), &err) != 0;
476 
477 		if (err !is null)
478 		{
479 			throw new GException( new ErrorG(err) );
480 		}
481 
482 		return __p;
483 	}
484 
485 	/**
486 	 * Parses a resource file containing a UI definition, building
487 	 * only the requested objects and merges them with the current
488 	 * contents of @builder.
489 	 *
490 	 * Upon errors, 0 will be returned and @error will be assigned a
491 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_RESOURCE_ERROR
492 	 * domain.
493 	 *
494 	 * If you are adding an object that depends on an object that is not
495 	 * its child (for instance a `GtkTreeView` that depends on its
496 	 * `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
497 	 *
498 	 * Params:
499 	 *     resourcePath = the path of the resource file to parse
500 	 *     objectIds = nul-terminated array of objects to build
501 	 *
502 	 * Returns: %TRUE on success, %FALSE if an error occurred
503 	 *
504 	 * Throws: GException on failure.
505 	 */
506 	public bool addObjectsFromResource(string resourcePath, string[] objectIds)
507 	{
508 		GError* err = null;
509 
510 		auto __p = gtk_builder_add_objects_from_resource(gtkBuilder, Str.toStringz(resourcePath), Str.toStringzArray(objectIds), &err) != 0;
511 
512 		if (err !is null)
513 		{
514 			throw new GException( new ErrorG(err) );
515 		}
516 
517 		return __p;
518 	}
519 
520 	/**
521 	 * Parses a string containing a UI definition, building only the
522 	 * requested objects and merges them with the current contents of
523 	 * @builder.
524 	 *
525 	 * Upon errors %FALSE will be returned and @error will be assigned a
526 	 * `GError` from the %GTK_BUILDER_ERROR or %G_MARKUP_ERROR domain.
527 	 *
528 	 * If you are adding an object that depends on an object that is not
529 	 * its child (for instance a `GtkTreeView` that depends on its
530 	 * `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
531 	 *
532 	 * Params:
533 	 *     buffer = the string to parse
534 	 *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
535 	 *     objectIds = nul-terminated array of objects to build
536 	 *
537 	 * Returns: %TRUE on success, %FALSE if an error occurred
538 	 *
539 	 * Throws: GException on failure.
540 	 */
541 	public bool addObjectsFromString(string buffer, ptrdiff_t length, string[] objectIds)
542 	{
543 		GError* err = null;
544 
545 		auto __p = gtk_builder_add_objects_from_string(gtkBuilder, Str.toStringz(buffer), length, Str.toStringzArray(objectIds), &err) != 0;
546 
547 		if (err !is null)
548 		{
549 			throw new GException( new ErrorG(err) );
550 		}
551 
552 		return __p;
553 	}
554 
555 	/**
556 	 * Creates a closure to invoke the function called @function_name.
557 	 *
558 	 * This is using the create_closure() implementation of @builder's
559 	 * [class@Gtk.BuilderScope].
560 	 *
561 	 * If no closure could be created, %NULL will be returned and @error
562 	 * will be set.
563 	 *
564 	 * Params:
565 	 *     functionName = name of the function to look up
566 	 *     flags = closure creation flags
567 	 *     object = Object to create the closure with
568 	 *
569 	 * Returns: A new closure for invoking @function_name
570 	 *
571 	 * Throws: GException on failure.
572 	 */
573 	public Closure createClosure(string functionName, GtkBuilderClosureFlags flags, ObjectG object)
574 	{
575 		GError* err = null;
576 
577 		auto __p = gtk_builder_create_closure(gtkBuilder, Str.toStringz(functionName), flags, (object is null) ? null : object.getObjectGStruct(), &err);
578 
579 		if (err !is null)
580 		{
581 			throw new GException( new ErrorG(err) );
582 		}
583 
584 		if(__p is null)
585 		{
586 			return null;
587 		}
588 
589 		return ObjectG.getDObject!(Closure)(cast(GClosure*) __p, true);
590 	}
591 
592 	/**
593 	 * Add @object to the @builder object pool so it can be
594 	 * referenced just like any other object built by builder.
595 	 *
596 	 * Params:
597 	 *     name = the name of the object exposed to the builder
598 	 *     object = the object to expose
599 	 */
600 	public void exposeObject(string name, ObjectG object)
601 	{
602 		gtk_builder_expose_object(gtkBuilder, Str.toStringz(name), (object is null) ? null : object.getObjectGStruct());
603 	}
604 
605 	/**
606 	 * Main private entry point for building composite components
607 	 * from template XML.
608 	 *
609 	 * This is exported purely to let `gtk-builder-tool` validate
610 	 * templates, applications have no need to call this function.
611 	 *
612 	 * Params:
613 	 *     object = the object that is being extended
614 	 *     templateType = the type that the template is for
615 	 *     buffer = the string to parse
616 	 *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
617 	 *
618 	 * Returns: A positive value on success, 0 if an error occurred
619 	 *
620 	 * Throws: GException on failure.
621 	 */
622 	public bool extendWithTemplate(ObjectG object, GType templateType, string buffer, ptrdiff_t length)
623 	{
624 		GError* err = null;
625 
626 		auto __p = gtk_builder_extend_with_template(gtkBuilder, (object is null) ? null : object.getObjectGStruct(), templateType, Str.toStringz(buffer), length, &err) != 0;
627 
628 		if (err !is null)
629 		{
630 			throw new GException( new ErrorG(err) );
631 		}
632 
633 		return __p;
634 	}
635 
636 	/**
637 	 * Gets the current object set via gtk_builder_set_current_object().
638 	 *
639 	 * Returns: the current object
640 	 */
641 	public ObjectG getCurrentObject()
642 	{
643 		auto __p = gtk_builder_get_current_object(gtkBuilder);
644 
645 		if(__p is null)
646 		{
647 			return null;
648 		}
649 
650 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p);
651 	}
652 
653 	/**
654 	 * Gets the object named @name.
655 	 *
656 	 * Note that this function does not increment the reference count
657 	 * of the returned object.
658 	 *
659 	 * Params:
660 	 *     name = name of object to get
661 	 *
662 	 * Returns: the object named @name
663 	 *     or %NULL if it could not be found in the object tree.
664 	 */
665 	public ObjectG getObject(string name)
666 	{
667 		auto __p = gtk_builder_get_object(gtkBuilder, Str.toStringz(name));
668 
669 		if(__p is null)
670 		{
671 			return null;
672 		}
673 
674 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p);
675 	}
676 
677 	/**
678 	 * Gets the scope in use that was set via gtk_builder_set_scope().
679 	 *
680 	 * Returns: the current scope
681 	 */
682 	public BuilderScopeIF getScope()
683 	{
684 		auto __p = gtk_builder_get_scope(gtkBuilder);
685 
686 		if(__p is null)
687 		{
688 			return null;
689 		}
690 
691 		return ObjectG.getDObject!(BuilderScopeIF)(cast(GtkBuilderScope*) __p);
692 	}
693 
694 	/**
695 	 * Gets the translation domain of @builder.
696 	 *
697 	 * Returns: the translation domain
698 	 *     or %NULL. This string is owned by the builder object and
699 	 *     must not be modified or freed.
700 	 */
701 	public string getTranslationDomain()
702 	{
703 		return Str.toString(gtk_builder_get_translation_domain(gtkBuilder));
704 	}
705 
706 	/**
707 	 * Looks up a type by name.
708 	 *
709 	 * This is using the virtual function that `GtkBuilder` has
710 	 * for that purpose. This is mainly used when implementing
711 	 * the `GtkBuildable` interface on a type.
712 	 *
713 	 * Params:
714 	 *     typeName = type name to lookup
715 	 *
716 	 * Returns: the `GType` found for @type_name or %G_TYPE_INVALID
717 	 *     if no type was found
718 	 */
719 	public GType getTypeFromName(string typeName)
720 	{
721 		return gtk_builder_get_type_from_name(gtkBuilder, Str.toStringz(typeName));
722 	}
723 
724 	/**
725 	 * Sets the current object for the @builder.
726 	 *
727 	 * The current object can be thought of as the `this` object that the
728 	 * builder is working for and will often be used as the default object
729 	 * when an object is optional.
730 	 *
731 	 * [method@Gtk.Widget.init_template] for example will set the current
732 	 * object to the widget the template is inited for. For functions like
733 	 * [ctor@Gtk.Builder.new_from_resource], the current object will be %NULL.
734 	 *
735 	 * Params:
736 	 *     currentObject = the new current object or
737 	 *         %NULL for none
738 	 */
739 	public void setCurrentObject(ObjectG currentObject)
740 	{
741 		gtk_builder_set_current_object(gtkBuilder, (currentObject is null) ? null : currentObject.getObjectGStruct());
742 	}
743 
744 	/**
745 	 * Sets the scope the builder should operate in.
746 	 *
747 	 * If @scope is %NULL a new [class@Gtk.BuilderCScope] will be created.
748 	 *
749 	 * Params:
750 	 *     scope_ = the scope to use or
751 	 *         %NULL for the default
752 	 */
753 	public void setScope(BuilderScopeIF scope_)
754 	{
755 		gtk_builder_set_scope(gtkBuilder, (scope_ is null) ? null : scope_.getBuilderScopeStruct());
756 	}
757 
758 	/**
759 	 * Sets the translation domain of @builder.
760 	 *
761 	 * Params:
762 	 *     domain = the translation domain or %NULL
763 	 */
764 	public void setTranslationDomain(string domain)
765 	{
766 		gtk_builder_set_translation_domain(gtkBuilder, Str.toStringz(domain));
767 	}
768 
769 	/**
770 	 * Demarshals a value from a string.
771 	 *
772 	 * This function calls g_value_init() on the @value argument,
773 	 * so it need not be initialised beforehand.
774 	 *
775 	 * Can handle char, uchar, boolean, int, uint, long,
776 	 * ulong, enum, flags, float, double, string, `GdkRGBA` and
777 	 * `GtkAdjustment` type values.
778 	 *
779 	 * Upon errors %FALSE will be returned and @error will be
780 	 * assigned a `GError` from the %GTK_BUILDER_ERROR domain.
781 	 *
782 	 * Params:
783 	 *     pspec = the `GParamSpec` for the property
784 	 *     string_ = the string representation of the value
785 	 *     value = the `GValue` to store the result in
786 	 *
787 	 * Returns: %TRUE on success
788 	 *
789 	 * Throws: GException on failure.
790 	 */
791 	public bool valueFromString(ParamSpec pspec, string string_, out Value value)
792 	{
793 		GValue* outvalue = sliceNew!GValue();
794 		GError* err = null;
795 
796 		auto __p = gtk_builder_value_from_string(gtkBuilder, (pspec is null) ? null : pspec.getParamSpecStruct(), Str.toStringz(string_), outvalue, &err) != 0;
797 
798 		if (err !is null)
799 		{
800 			throw new GException( new ErrorG(err) );
801 		}
802 
803 		value = ObjectG.getDObject!(Value)(outvalue, true);
804 
805 		return __p;
806 	}
807 
808 	/**
809 	 * Demarshals a value from a string.
810 	 *
811 	 * Unlike [method@Gtk.Builder.value_from_string], this function
812 	 * takes a `GType` instead of `GParamSpec`.
813 	 *
814 	 * Calls g_value_init() on the @value argument, so it
815 	 * need not be initialised beforehand.
816 	 *
817 	 * Upon errors %FALSE will be returned and @error will be
818 	 * assigned a `GError` from the %GTK_BUILDER_ERROR domain.
819 	 *
820 	 * Params:
821 	 *     type = the `GType` of the value
822 	 *     string_ = the string representation of the value
823 	 *     value = the #GValue to store the result in
824 	 *
825 	 * Returns: %TRUE on success
826 	 *
827 	 * Throws: GException on failure.
828 	 */
829 	public bool valueFromStringType(GType type, string string_, out Value value)
830 	{
831 		GValue* outvalue = sliceNew!GValue();
832 		GError* err = null;
833 
834 		auto __p = gtk_builder_value_from_string_type(gtkBuilder, type, Str.toStringz(string_), outvalue, &err) != 0;
835 
836 		if (err !is null)
837 		{
838 			throw new GException( new ErrorG(err) );
839 		}
840 
841 		value = ObjectG.getDObject!(Value)(outvalue, true);
842 
843 		return __p;
844 	}
845 }