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  = gobject-The-Base-Object-Type.html
27  * outPack = gobject
28  * outFile = ObjectG
29  * strct   = GObject
30  * realStrct=
31  * ctorStrct=
32  * clss    = ObjectG
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_object_
41  * 	- g_
42  * omit structs:
43  * 	- GObject
44  * 	- GObjectClass
45  * omit prefixes:
46  * 	- g_weak_ref_
47  * omit code:
48  * omit signals:
49  * 	- notify
50  * imports:
51  * 	- gobject.ObjectG
52  * 	- gobject.ParamSpec
53  * 	- gobject.Value
54  * 	- gobject.Closure
55  * 	- std.gc
56  * 	- glib.Str
57  * 	- gtkc.paths
58  * 	- gtkc.Loader
59  * structWrap:
60  * 	- GClosure* -> Closure
61  * 	- GObject* -> ObjectG
62  * 	- GParamSpec* -> ParamSpec
63  * 	- GValue* -> Value
64  * module aliases:
65  * local aliases:
66  * overrides:
67  */
68 
69 module gobject.ObjectG;
70 
71 public  import gtkc.gobjecttypes;
72 
73 private import gtkc.gobject;
74 private import glib.ConstructionException;
75 private import gobject.ObjectG;
76 
77 private import gobject.Signals;
78 public  import gtkc.gdktypes;
79 
80 private import gobject.ObjectG;
81 private import gobject.ParamSpec;
82 private import gobject.Value;
83 private import gobject.Closure;
84 private import glib.Str;
85 private import gtkc.paths;
86 private import gtkc.Loader;
87 
88 
89 version(Tango) {
90 	private import tango.core.Memory;
91 
92 	version = druntime;
93 } else version(D_Version2) {
94 	private import core.memory;
95 
96 	version = druntime;
97 } else {
98 	private import std.gc;
99 }
100 
101 
102 
103 /**
104  * GObject is the fundamental type providing the common attributes and
105  * methods for all object types in GTK+, Pango and other libraries
106  * based on GObject. The GObject class provides methods for object
107  * construction and destruction, property access methods, and signal
108  * support. Signals are described in detail in Signals(3).
109  *
110  * GInitiallyUnowned is derived from GObject. The only difference between
111  * the two is that the initial reference of a GInitiallyUnowned is flagged
112  * as a floating reference.
113  * This means that it is not specifically claimed to be "owned" by
114  * any code portion. The main motivation for providing floating references is
115  * C convenience. In particular, it allows code to be written as:
116  *
117  * $(DDOC_COMMENT example)
118  *
119  * If container_add_child() will g_object_ref_sink() the
120  * passed in child, no reference of the newly created child is leaked.
121  * Without floating references, container_add_child()
122  * can only g_object_ref() the new child, so to implement this code without
123  * reference leaks, it would have to be written as:
124  *
125  * $(DDOC_COMMENT example)
126  *
127  * The floating reference can be converted into
128  * an ordinary reference by calling g_object_ref_sink().
129  * For already sunken objects (objects that don't have a floating reference
130  * anymore), g_object_ref_sink() is equivalent to g_object_ref() and returns
131  * a new reference.
132  * Since floating references are useful almost exclusively for C convenience,
133  * language bindings that provide automated reference and memory ownership
134  * maintenance (such as smart pointers or garbage collection) should not
135  * expose floating references in their API.
136  *
137  * Some object implementations may need to save an objects floating state
138  * across certain code portions (an example is GtkMenu), to achieve this,
139  * the following sequence can be used:
140  *
141  * $(DDOC_COMMENT example)
142  */
143 public class ObjectG
144 {
145 	
146 	/** the main Gtk struct */
147 	protected GObject* gObject;
148 	
149 	
150 	public GObject* getObjectGStruct()
151 	{
152 		return gObject;
153 	}
154 	
155 	
156 	/** the main Gtk struct as a void* */
157 	protected void* getStruct()
158 	{
159 		return cast(void*)gObject;
160 	}
161 	
162 	
163 	protected bool isGcRoot;
164 	
165 	/**
166 	 * Sets our main struct and passes store it on the gobject.
167 	 * Add a gabage collector root to the gtk+ struct so it doesn't get collect
168 	 */
169 	public this (GObject* gObject)
170 	{
171 		this.gObject = gObject;
172 		if ( gObject !is  null )
173 		{
174 			setDataFull("GObject", cast(void*)this, cast(GDestroyNotify)&destroyNotify);
175 			addToggleRef(cast(GToggleNotify)&toggleNotify, cast(void*)this);
176 			
177 			//If the refCount is largeer then 1 toggleNotify isn't called
178 			if (gObject.refCount > 1 && !isGcRoot)
179 			{
180 				version(druntime) GC.addRoot(cast(void*)this);
181 				else std.gc.addRoot(cast(void*)this);
182 				
183 				isGcRoot = true;
184 			}
185 			
186 			//Remove the floating reference if there is one.
187 			if (isFloating(gObject))
188 			{
189 				refSink(gObject);
190 				unref(gObject);
191 			}
192 			
193 			//When constructed via GtkBuilder set the structs.
194 			if ( getStruct() is null)
195 			{
196 				setStruct(gObject);
197 			}
198 		}
199 	}
200 	
201 	extern(C)
202 	{
203 		static void destroyNotify(ObjectG obj)
204 		{
205 			if ( obj.isGcRoot )
206 			{
207 				version(druntime) GC.removeRoot(cast(void*)obj);
208 				else std.gc.removeRoot(cast(void*)obj);
209 				
210 				obj.isGcRoot = false;
211 			}
212 			
213 			obj.gObject = null;
214 		}
215 		
216 		static void toggleNotify(ObjectG obj, GObject* object, int isLastRef)
217 		{
218 			if ( isLastRef && obj.isGcRoot )
219 			{
220 				version(druntime) GC.removeRoot(cast(void*)obj);
221 				else std.gc.removeRoot(cast(void*)obj);
222 				
223 				obj.isGcRoot = false;
224 			}
225 			else if ( !obj.isGcRoot )
226 			{
227 				version(druntime) GC.addRoot(cast(void*)obj);
228 				else std.gc.addRoot(cast(void*)obj);
229 				
230 				obj.isGcRoot = true;
231 			}
232 		}
233 	}
234 	
235 	~this()
236 	{
237 		if ( Linker.isLoaded(LIBRARY.GOBJECT) && gObject !is null )
238 		{
239 			unref();
240 		}
241 	}
242 	
243 	/**
244 	 * Gets a D Object from the objects table of associations.
245 	 * Params:
246 	 *  obj = GObject containing the associations.
247 	 * Returns: the D Object if found, or a newly constructed object if no such Object exists.
248 	 */
249 	public static RT getDObject(T, RT=T, U)(U obj)
250 	{
251 		if ( obj is null )
252 		{
253 			return null;
254 		}
255 		
256 		static if ( is(T : ObjectG) )
257 		{
258 			auto p = g_object_get_data(cast(GObject*)obj, Str.toStringz("GObject"));
259 			
260 			if ( p !is null )
261 			{
262 				static if ( is(RT == interface ) )
263 				{
264 					return cast(RT)cast(ObjectG)p;
265 				}
266 				else
267 				{
268 					return cast(RT)p;
269 				}
270 			}
271 			else
272 			{
273 				return new T(obj);
274 			}
275 		}
276 		else
277 		{
278 			return new T(obj);
279 		}
280 	}
281 	
282 	protected void setStruct(GObject* obj)
283 	{
284 		gObject = cast(GObject*)obj;
285 	}
286 	
287 	/** */
288 	public void setProperty(string propertyName, int value)
289 	{
290 		setProperty(propertyName, new Value(value));
291 	}
292 	
293 	/** */
294 	public void setProperty(string propertyName, string value)
295 	{
296 		setProperty(propertyName, new Value(value));
297 	}
298 	
299 	/** */
300 	public void setProperty(string propertyName, long value)
301 	{
302 		//We use g_object_set instead of g_object_set_property, because Value doesn't like longs and ulongs for some reason.
303 		g_object_set( gObject, Str.toStringz(propertyName), value, null);
304 	}
305 	
306 	/** */
307 	public void setProperty(string propertyName, ulong value)
308 	{
309 		g_object_set( gObject, Str.toStringz(propertyName), value, null);
310 	}
311 	
312 	public void unref()
313 	{
314 		unref(gObject);
315 	}
316 	
317 	public ObjectG doref()
318 	{
319 		doref(gObject);
320 		
321 		return this;
322 	}
323 	
324 	int[string] connectedSignals;
325 	
326 	void delegate(ParamSpec, ObjectG)[] onNotifyListeners;
327 	/**
328 	 * The notify signal is emitted on an object when one of its
329 	 * properties has been changed. Note that getting this signal
330 	 * doesn't guarantee that the value of the property has actually
331 	 * changed, it may also be emitted when the setter for the property
332 	 * is called to reinstate the previous value.
333 	 *
334 	 * This signal is typically used to obtain change notification for a
335 	 * single property.
336 	 *
337 	 * It is important to note that you must use
338 	 * canonical parameter names for the property.
339 	 *
340 	 * Params:
341 	 *     dlg          = The callback.
342 	 *     property     = Set this if you only want to receive the signal for a specific property.
343 	 *     connectFlags = The behavior of the signal's connection.
344 	 */
345 	void addOnNotify(void delegate(ParamSpec, ObjectG) dlg, string property = "", ConnectFlags connectFlags=cast(ConnectFlags)0)
346 	{
347 		string signalName;
348 		
349 		if ( property == "" )
350 		{
351 			signalName = "notify";
352 		}
353 		else
354 		{
355 			signalName = "notify::"~ property;
356 		}
357 		
358 		if ( !(signalName in connectedSignals) )
359 		{
360 			Signals.connectData(
361 			getStruct(),
362 			signalName,
363 			cast(GCallback)&callBackNotify,
364 			cast(void*)this,
365 			null,
366 			connectFlags);
367 			connectedSignals[signalName] = 1;
368 		}
369 		onNotifyListeners ~= dlg;
370 	}
371 	extern(C) static void callBackNotify(GObject* gobjectStruct, GParamSpec* pspec, ObjectG _objectG)
372 	{
373 		foreach ( void delegate(ParamSpec, ObjectG) dlg ; _objectG.onNotifyListeners )
374 		{
375 			dlg(ObjectG.getDObject!(ParamSpec)(pspec), _objectG);
376 		}
377 	}
378 	
379 	/**
380 	 */
381 	
382 	/**
383 	 * Installs a new property. This is usually done in the class initializer.
384 	 * Note that it is possible to redefine a property in a derived class,
385 	 * by installing a property with the same name. This can be useful at times,
386 	 * e.g. to change the range of allowed values or the default value.
387 	 * Params:
388 	 * oclass = a GObjectClass
389 	 * propertyId = the id for the new property
390 	 * pspec = the GParamSpec for the new property
391 	 */
392 	public static void classInstallProperty(GObjectClass* oclass, uint propertyId, ParamSpec pspec)
393 	{
394 		// void g_object_class_install_property (GObjectClass *oclass,  guint property_id,  GParamSpec *pspec);
395 		g_object_class_install_property(oclass, propertyId, (pspec is null) ? null : pspec.getParamSpecStruct());
396 	}
397 	
398 	/**
399 	 * Installs new properties from an array of GParamSpecs. This is
400 	 * usually done in the class initializer.
401 	 * The property id of each property is the index of each GParamSpec in
402 	 * the pspecs array.
403 	 * The property id of 0 is treated specially by GObject and it should not
404 	 * be used to store a GParamSpec.
405 	 * This function should be used if you plan to use a static array of
406 	 * GParamSpecs and g_object_notify_by_pspec(). For instance, this
407 	 * Since 2.26
408 	 * Params:
409 	 * oclass = a GObjectClass
410 	 * pspecs = the GParamSpecs array
411 	 * defining the new properties. [array length=n_pspecs]
412 	 */
413 	public static void classInstallProperties(GObjectClass* oclass, ParamSpec[] pspecs)
414 	{
415 		// void g_object_class_install_properties (GObjectClass *oclass,  guint n_pspecs,  GParamSpec **pspecs);
416 		
417 		GParamSpec*[] pspecsArray = new GParamSpec*[pspecs.length];
418 		for ( int i = 0; i < pspecs.length ; i++ )
419 		{
420 			pspecsArray[i] = pspecs[i].getParamSpecStruct();
421 		}
422 		
423 		g_object_class_install_properties(oclass, cast(int) pspecs.length, pspecsArray.ptr);
424 	}
425 	
426 	/**
427 	 * Looks up the GParamSpec for a property of a class.
428 	 * Params:
429 	 * oclass = a GObjectClass
430 	 * propertyName = the name of the property to look up
431 	 * Returns: the GParamSpec for the property, or NULL if the class doesn't have a property of that name. [transfer none]
432 	 */
433 	public static ParamSpec classFindProperty(GObjectClass* oclass, string propertyName)
434 	{
435 		// GParamSpec * g_object_class_find_property (GObjectClass *oclass,  const gchar *property_name);
436 		auto p = g_object_class_find_property(oclass, Str.toStringz(propertyName));
437 		
438 		if(p is null)
439 		{
440 			return null;
441 		}
442 		
443 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
444 	}
445 	
446 	/**
447 	 * Get an array of GParamSpec* for all properties of a class.
448 	 * Params:
449 	 * oclass = a GObjectClass
450 	 * Returns: an array of GParamSpec* which should be freed after use. [array length=n_properties][transfer container]
451 	 */
452 	public static ParamSpec[] classListProperties(GObjectClass* oclass)
453 	{
454 		// GParamSpec ** g_object_class_list_properties (GObjectClass *oclass,  guint *n_properties);
455 		uint nProperties;
456 		auto p = g_object_class_list_properties(oclass, &nProperties);
457 		
458 		if(p is null)
459 		{
460 			return null;
461 		}
462 		
463 		ParamSpec[] arr = new ParamSpec[nProperties];
464 		for(int i = 0; i < nProperties; i++)
465 		{
466 			arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]);
467 		}
468 		
469 		return arr;
470 	}
471 	
472 	/**
473 	 * Registers property_id as referring to a property with the
474 	 * name name in a parent class or in an interface implemented
475 	 * by oclass. This allows this class to override
476 	 * a property implementation in a parent class or to provide
477 	 * the implementation of a property from an interface.
478 	 * Note
479 	 * Internally, overriding is implemented by creating a property of type
480 	 * GParamSpecOverride; generally operations that query the properties of
481 	 * the object class, such as g_object_class_find_property() or
482 	 * g_object_class_list_properties() will return the overridden
483 	 * property. However, in one case, the construct_properties argument of
484 	 * the constructor virtual function, the GParamSpecOverride is passed
485 	 * instead, so that the param_id field of the GParamSpec will be
486 	 * correct. For virtually all uses, this makes no difference. If you
487 	 * need to get the overridden property, you can call
488 	 * g_param_spec_get_redirect_target().
489 	 * Since 2.4
490 	 * Params:
491 	 * oclass = a GObjectClass
492 	 * propertyId = the new property ID
493 	 * name = the name of a property registered in a parent class or
494 	 * in an interface of this class.
495 	 */
496 	public static void classOverrideProperty(GObjectClass* oclass, uint propertyId, string name)
497 	{
498 		// void g_object_class_override_property (GObjectClass *oclass,  guint property_id,  const gchar *name);
499 		g_object_class_override_property(oclass, propertyId, Str.toStringz(name));
500 	}
501 	
502 	/**
503 	 * Add a property to an interface; this is only useful for interfaces
504 	 * that are added to GObject-derived types. Adding a property to an
505 	 * interface forces all objects classes with that interface to have a
506 	 * compatible property. The compatible property could be a newly
507 	 * created GParamSpec, but normally
508 	 * g_object_class_override_property() will be used so that the object
509 	 * class only needs to provide an implementation and inherits the
510 	 * property description, default value, bounds, and so forth from the
511 	 * interface property.
512 	 * This function is meant to be called from the interface's default
513 	 * vtable initialization function (the class_init member of
514 	 * GTypeInfo.) It must not be called after after class_init has
515 	 * been called for any object types implementing this interface.
516 	 * Since 2.4
517 	 * Params:
518 	 * iface = any interface vtable for the interface, or the default
519 	 * vtable for the interface.
520 	 * pspec = the GParamSpec for the new property
521 	 */
522 	public static void interfaceInstallProperty(void* iface, ParamSpec pspec)
523 	{
524 		// void g_object_interface_install_property (gpointer g_iface,  GParamSpec *pspec);
525 		g_object_interface_install_property(iface, (pspec is null) ? null : pspec.getParamSpecStruct());
526 	}
527 	
528 	/**
529 	 * Find the GParamSpec with the given name for an
530 	 * interface. Generally, the interface vtable passed in as g_iface
531 	 * will be the default vtable from g_type_default_interface_ref(), or,
532 	 * if you know the interface has already been loaded,
533 	 * g_type_default_interface_peek().
534 	 * Since 2.4
535 	 * Params:
536 	 * iface = any interface vtable for the interface, or the default
537 	 * vtable for the interface
538 	 * propertyName = name of a property to lookup.
539 	 * Returns: the GParamSpec for the property of the interface with the name property_name, or NULL if no such property exists. [transfer none]
540 	 */
541 	public static ParamSpec interfaceFindProperty(void* iface, string propertyName)
542 	{
543 		// GParamSpec * g_object_interface_find_property (gpointer g_iface,  const gchar *property_name);
544 		auto p = g_object_interface_find_property(iface, Str.toStringz(propertyName));
545 		
546 		if(p is null)
547 		{
548 			return null;
549 		}
550 		
551 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
552 	}
553 	
554 	/**
555 	 * Lists the properties of an interface.Generally, the interface
556 	 * vtable passed in as g_iface will be the default vtable from
557 	 * g_type_default_interface_ref(), or, if you know the interface has
558 	 * already been loaded, g_type_default_interface_peek().
559 	 * Since 2.4
560 	 * Params:
561 	 * iface = any interface vtable for the interface, or the default
562 	 * vtable for the interface
563 	 * Returns: a pointer to an array of pointers to GParamSpec structures. The paramspecs are owned by GLib, but the array should be freed with g_free() when you are done with it. [array length=n_properties_p][transfer container]
564 	 */
565 	public static ParamSpec[] interfaceListProperties(void* iface)
566 	{
567 		// GParamSpec ** g_object_interface_list_properties (gpointer g_iface,  guint *n_properties_p);
568 		uint nPropertiesP;
569 		auto p = g_object_interface_list_properties(iface, &nPropertiesP);
570 		
571 		if(p is null)
572 		{
573 			return null;
574 		}
575 		
576 		ParamSpec[] arr = new ParamSpec[nPropertiesP];
577 		for(int i = 0; i < nPropertiesP; i++)
578 		{
579 			arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]);
580 		}
581 		
582 		return arr;
583 	}
584 	
585 	/**
586 	 * Creates a new instance of a GObject subtype and sets its properties.
587 	 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
588 	 * which are not explicitly specified are set to their default values.
589 	 * Rename to: g_object_new
590 	 * Params:
591 	 * objectType = the type id of the GObject subtype to instantiate
592 	 * parameters = an array of GParameter. [array length=n_parameters]
593 	 * Throws: ConstructionException GTK+ fails to create the object.
594 	 */
595 	public this (GType objectType, GParameter[] parameters)
596 	{
597 		// gpointer g_object_newv (GType object_type,  guint n_parameters,  GParameter *parameters);
598 		auto p = g_object_newv(objectType, cast(int) parameters.length, parameters.ptr);
599 		if(p is null)
600 		{
601 			throw new ConstructionException("null returned by g_object_newv(objectType, cast(int) parameters.length, parameters.ptr)");
602 		}
603 		this(cast(GObject*) p);
604 	}
605 	
606 	/**
607 	 * Increases the reference count of object.
608 	 * Params:
609 	 * object = a GObject. [type GObject.Object]
610 	 * Returns: the same object. [type GObject.Object][transfer none]
611 	 */
612 	public static void* doref(void* object)
613 	{
614 		// gpointer g_object_ref (gpointer object);
615 		return g_object_ref(object);
616 	}
617 	
618 	/**
619 	 * Decreases the reference count of object. When its reference count
620 	 * drops to 0, the object is finalized (i.e. its memory is freed).
621 	 * Params:
622 	 * object = a GObject. [type GObject.Object]
623 	 */
624 	public static void unref(void* object)
625 	{
626 		// void g_object_unref (gpointer object);
627 		g_object_unref(object);
628 	}
629 	
630 	/**
631 	 * Increase the reference count of object, and possibly remove the
632 	 * floating reference, if object
633 	 * has a floating reference.
634 	 * In other words, if the object is floating, then this call "assumes
635 	 * ownership" of the floating reference, converting it to a normal
636 	 * reference by clearing the floating flag while leaving the reference
637 	 * count unchanged. If the object is not floating, then this call
638 	 * adds a new normal reference increasing the reference count by one.
639 	 * Since 2.10
640 	 * Params:
641 	 * object = a GObject. [type GObject.Object]
642 	 * Returns: object. [type GObject.Object][transfer none]
643 	 */
644 	public static void* refSink(void* object)
645 	{
646 		// gpointer g_object_ref_sink (gpointer object);
647 		return g_object_ref_sink(object);
648 	}
649 	
650 	/**
651 	 * Clears a reference to a GObject.
652 	 * object_ptr must not be NULL.
653 	 * If the reference is NULL then this function does nothing.
654 	 * Otherwise, the reference count of the object is decreased and the
655 	 * pointer is set to NULL.
656 	 * This function is threadsafe and modifies the pointer atomically,
657 	 * using memory barriers where needed.
658 	 * A macro is also included that allows this function to be used without
659 	 * pointer casts.
660 	 * Since 2.28
661 	 * Params:
662 	 * objectPtr = a pointer to a GObject reference
663 	 */
664 	public static void clearObject(ref ObjectG objectPtr)
665 	{
666 		// void g_clear_object (volatile GObject **object_ptr);
667 		GObject* outobjectPtr = (objectPtr is null) ? null : objectPtr.getObjectGStruct();
668 		
669 		g_clear_object(&outobjectPtr);
670 		
671 		objectPtr = ObjectG.getDObject!(ObjectG)(outobjectPtr);
672 	}
673 	
674 	/**
675 	 * Checks whether object has a floating
676 	 * reference.
677 	 * Since 2.10
678 	 * Params:
679 	 * object = a GObject. [type GObject.Object]
680 	 * Returns: TRUE if object has a floating reference
681 	 */
682 	public static int isFloating(void* object)
683 	{
684 		// gboolean g_object_is_floating (gpointer object);
685 		return g_object_is_floating(object);
686 	}
687 	
688 	/**
689 	 * This function is intended for GObject implementations to re-enforce a
690 	 * floating object reference.
691 	 * Doing this is seldom required: all
692 	 * GInitiallyUnowneds are created with a floating reference which
693 	 * usually just needs to be sunken by calling g_object_ref_sink().
694 	 * Since 2.10
695 	 */
696 	public void forceFloating()
697 	{
698 		// void g_object_force_floating (GObject *object);
699 		g_object_force_floating(gObject);
700 	}
701 	
702 	/**
703 	 * Adds a weak reference callback to an object. Weak references are
704 	 * used for notification when an object is finalized. They are called
705 	 * "weak references" because they allow you to safely hold a pointer
706 	 * to an object without calling g_object_ref() (g_object_ref() adds a
707 	 * strong reference, that is, forces the object to stay alive).
708 	 * Note that the weak references created by this method are not
709 	 * thread-safe: they cannot safely be used in one thread if the
710 	 * object's last g_object_unref() might happen in another thread.
711 	 * Use GWeakRef if thread-safety is required.
712 	 * Params:
713 	 * notify = callback to invoke before the object is freed
714 	 * data = extra data to pass to notify
715 	 */
716 	public void weakRef(GWeakNotify notify, void* data)
717 	{
718 		// void g_object_weak_ref (GObject *object,  GWeakNotify notify,  gpointer data);
719 		g_object_weak_ref(gObject, notify, data);
720 	}
721 	
722 	/**
723 	 * Removes a weak reference callback to an object.
724 	 * Params:
725 	 * notify = callback to search for
726 	 * data = data to search for
727 	 */
728 	public void weakUnref(GWeakNotify notify, void* data)
729 	{
730 		// void g_object_weak_unref (GObject *object,  GWeakNotify notify,  gpointer data);
731 		g_object_weak_unref(gObject, notify, data);
732 	}
733 	
734 	/**
735 	 * Adds a weak reference from weak_pointer to object to indicate that
736 	 * the pointer located at weak_pointer_location is only valid during
737 	 * the lifetime of object. When the object is finalized,
738 	 * weak_pointer will be set to NULL.
739 	 * Note that as with g_object_weak_ref(), the weak references created by
740 	 * this method are not thread-safe: they cannot safely be used in one
741 	 * thread if the object's last g_object_unref() might happen in another
742 	 * thread. Use GWeakRef if thread-safety is required.
743 	 * Params:
744 	 * weakPointerLocation = The memory address of a pointer. [inout]
745 	 */
746 	public void addWeakPointer(void** weakPointerLocation)
747 	{
748 		// void g_object_add_weak_pointer (GObject *object,  gpointer *weak_pointer_location);
749 		g_object_add_weak_pointer(gObject, weakPointerLocation);
750 	}
751 	
752 	/**
753 	 * Removes a weak reference from object that was previously added
754 	 * using g_object_add_weak_pointer(). The weak_pointer_location has
755 	 * to match the one used with g_object_add_weak_pointer().
756 	 * Params:
757 	 * weakPointerLocation = The memory address of a pointer. [inout]
758 	 */
759 	public void removeWeakPointer(void** weakPointerLocation)
760 	{
761 		// void g_object_remove_weak_pointer (GObject *object,  gpointer *weak_pointer_location);
762 		g_object_remove_weak_pointer(gObject, weakPointerLocation);
763 	}
764 	
765 	/**
766 	 * Increases the reference count of the object by one and sets a
767 	 * callback to be called when all other references to the object are
768 	 * dropped, or when this is already the last reference to the object
769 	 * and another reference is established.
770 	 * This functionality is intended for binding object to a proxy
771 	 * object managed by another memory manager. This is done with two
772 	 * paired references: the strong reference added by
773 	 * g_object_add_toggle_ref() and a reverse reference to the proxy
774 	 * object which is either a strong reference or weak reference.
775 	 * The setup is that when there are no other references to object,
776 	 * only a weak reference is held in the reverse direction from object
777 	 * to the proxy object, but when there are other references held to
778 	 * object, a strong reference is held. The notify callback is called
779 	 * when the reference from object to the proxy object should be
780 	 * toggled from strong to weak (is_last_ref
781 	 * true) or weak to strong (is_last_ref false).
782 	 * Since a (normal) reference must be held to the object before
783 	 * calling g_object_add_toggle_ref(), the initial state of the reverse
784 	 * link is always strong.
785 	 * Multiple toggle references may be added to the same gobject,
786 	 * however if there are multiple toggle references to an object, none
787 	 * of them will ever be notified until all but one are removed. For
788 	 * this reason, you should only ever use a toggle reference if there
789 	 * is important state in the proxy object.
790 	 * Since 2.8
791 	 * Params:
792 	 * notify = a function to call when this reference is the
793 	 * last reference to the object, or is no longer
794 	 * the last reference.
795 	 * data = data to pass to notify
796 	 */
797 	public void addToggleRef(GToggleNotify notify, void* data)
798 	{
799 		// void g_object_add_toggle_ref (GObject *object,  GToggleNotify notify,  gpointer data);
800 		g_object_add_toggle_ref(gObject, notify, data);
801 	}
802 	
803 	/**
804 	 * Removes a reference added with g_object_add_toggle_ref(). The
805 	 * reference count of the object is decreased by one.
806 	 * Since 2.8
807 	 * Params:
808 	 * notify = a function to call when this reference is the
809 	 * last reference to the object, or is no longer
810 	 * the last reference.
811 	 * data = data to pass to notify
812 	 */
813 	public void removeToggleRef(GToggleNotify notify, void* data)
814 	{
815 		// void g_object_remove_toggle_ref (GObject *object,  GToggleNotify notify,  gpointer data);
816 		g_object_remove_toggle_ref(gObject, notify, data);
817 	}
818 	
819 	/**
820 	 * Emits a "notify" signal for the property property_name on object.
821 	 * When possible, eg. when signaling a property change from within the class
822 	 * that registered the property, you should use g_object_notify_by_pspec()
823 	 * instead.
824 	 * Params:
825 	 * propertyName = the name of a property installed on the class of object.
826 	 */
827 	public void notify(string propertyName)
828 	{
829 		// void g_object_notify (GObject *object,  const gchar *property_name);
830 		g_object_notify(gObject, Str.toStringz(propertyName));
831 	}
832 	
833 	/**
834 	 * Emits a "notify" signal for the property specified by pspec on object.
835 	 * This function omits the property name lookup, hence it is faster than
836 	 * g_object_notify().
837 	 * One way to avoid using g_object_notify() from within the
838 	 * class that registered the properties, and using g_object_notify_by_pspec()
839 	 * instead, is to store the GParamSpec used with
840 	 * Since 2.26
841 	 * Params:
842 	 * pspec = the GParamSpec of a property installed on the class of object.
843 	 */
844 	public void notifyByPspec(ParamSpec pspec)
845 	{
846 		// void g_object_notify_by_pspec (GObject *object,  GParamSpec *pspec);
847 		g_object_notify_by_pspec(gObject, (pspec is null) ? null : pspec.getParamSpecStruct());
848 	}
849 	
850 	/**
851 	 * Increases the freeze count on object. If the freeze count is
852 	 * non-zero, the emission of "notify" signals on object is
853 	 * stopped. The signals are queued until the freeze count is decreased
854 	 * to zero. Duplicate notifications are squashed so that at most one
855 	 * "notify" signal is emitted for each property modified while the
856 	 * object is frozen.
857 	 * This is necessary for accessors that modify multiple properties to prevent
858 	 * premature notification while the object is still being modified.
859 	 */
860 	public void freezeNotify()
861 	{
862 		// void g_object_freeze_notify (GObject *object);
863 		g_object_freeze_notify(gObject);
864 	}
865 	
866 	/**
867 	 * Reverts the effect of a previous call to
868 	 * g_object_freeze_notify(). The freeze count is decreased on object
869 	 * and when it reaches zero, queued "notify" signals are emitted.
870 	 * Duplicate notifications for each property are squashed so that at most one
871 	 * "notify" signal is emitted for each property.
872 	 * It is an error to call this function when the freeze count is zero.
873 	 */
874 	public void thawNotify()
875 	{
876 		// void g_object_thaw_notify (GObject *object);
877 		g_object_thaw_notify(gObject);
878 	}
879 	
880 	/**
881 	 * Gets a named field from the objects table of associations (see g_object_set_data()).
882 	 * Params:
883 	 * key = name of the key for that association
884 	 * Returns: the data if found, or NULL if no such data exists. [transfer none]
885 	 */
886 	public void* getData(string key)
887 	{
888 		// gpointer g_object_get_data (GObject *object,  const gchar *key);
889 		return g_object_get_data(gObject, Str.toStringz(key));
890 	}
891 	
892 	/**
893 	 * Each object carries around a table of associations from
894 	 * strings to pointers. This function lets you set an association.
895 	 * If the object already had an association with that name,
896 	 * the old association will be destroyed.
897 	 * Params:
898 	 * key = name of the key
899 	 * data = data to associate with that key
900 	 */
901 	public void setData(string key, void* data)
902 	{
903 		// void g_object_set_data (GObject *object,  const gchar *key,  gpointer data);
904 		g_object_set_data(gObject, Str.toStringz(key), data);
905 	}
906 	
907 	/**
908 	 * Like g_object_set_data() except it adds notification
909 	 * for when the association is destroyed, either by setting it
910 	 * to a different value or when the object is destroyed.
911 	 * Note that the destroy callback is not called if data is NULL.
912 	 * Params:
913 	 * key = name of the key
914 	 * data = data to associate with that key
915 	 * destroy = function to call when the association is destroyed
916 	 */
917 	public void setDataFull(string key, void* data, GDestroyNotify destroy)
918 	{
919 		// void g_object_set_data_full (GObject *object,  const gchar *key,  gpointer data,  GDestroyNotify destroy);
920 		g_object_set_data_full(gObject, Str.toStringz(key), data, destroy);
921 	}
922 	
923 	/**
924 	 * Remove a specified datum from the object's data associations,
925 	 * without invoking the association's destroy handler.
926 	 * Params:
927 	 * key = name of the key
928 	 * Returns: the data if found, or NULL if no such data exists. [transfer full]
929 	 */
930 	public void* stealData(string key)
931 	{
932 		// gpointer g_object_steal_data (GObject *object,  const gchar *key);
933 		return g_object_steal_data(gObject, Str.toStringz(key));
934 	}
935 	
936 	/**
937 	 * This is a variant of g_object_get_data() which returns
938 	 * a 'duplicate' of the value. dup_func defines the
939 	 * meaning of 'duplicate' in this context, it could e.g.
940 	 * take a reference on a ref-counted object.
941 	 * If the key is not set on the object then dup_func
942 	 * will be called with a NULL argument.
943 	 * Note that dup_func is called while user data of object
944 	 * is locked.
945 	 * This function can be useful to avoid races when multiple
946 	 * threads are using object data on the same key on the same
947 	 * object.
948 	 * Since 2.34
949 	 * Params:
950 	 * key = a string, naming the user data pointer
951 	 * dupFunc = function to dup the value. [allow-none]
952 	 * userData = passed as user_data to dup_func. [allow-none]
953 	 * Returns: the result of calling dup_func on the value associated with key on object, or NULL if not set. If dup_func is NULL, the value is returned unmodified.
954 	 */
955 	public void* dupData(string key, GDuplicateFunc dupFunc, void* userData)
956 	{
957 		// gpointer g_object_dup_data (GObject *object,  const gchar *key,  GDuplicateFunc dup_func,  gpointer user_data);
958 		return g_object_dup_data(gObject, Str.toStringz(key), dupFunc, userData);
959 	}
960 	
961 	/**
962 	 * Compares the user data for the key key on object with
963 	 * oldval, and if they are the same, replaces oldval with
964 	 * newval.
965 	 * This is like a typical atomic compare-and-exchange
966 	 * operation, for user data on an object.
967 	 * If the previous value was replaced then ownership of the
968 	 * old value (oldval) is passed to the caller, including
969 	 * the registered destroy notify for it (passed out in old_destroy).
970 	 * Its up to the caller to free this as he wishes, which may
971 	 * or may not include using old_destroy as sometimes replacement
972 	 * should not destroy the object in the normal way.
973 	 * Return: TRUE if the existing value for key was replaced
974 	 *  by newval, FALSE otherwise.
975 	 * Since 2.34
976 	 * Params:
977 	 * key = a string, naming the user data pointer
978 	 * oldval = the old value to compare against. [allow-none]
979 	 * newval = the new value. [allow-none]
980 	 * destroy = a destroy notify for the new value. [allow-none]
981 	 * oldDestroy = destroy notify for the existing value. [allow-none]
982 	 */
983 	public int replaceData(string key, void* oldval, void* newval, GDestroyNotify destroy, GDestroyNotify* oldDestroy)
984 	{
985 		// gboolean g_object_replace_data (GObject *object,  const gchar *key,  gpointer oldval,  gpointer newval,  GDestroyNotify destroy,  GDestroyNotify *old_destroy);
986 		return g_object_replace_data(gObject, Str.toStringz(key), oldval, newval, destroy, oldDestroy);
987 	}
988 	
989 	/**
990 	 * This function gets back user data pointers stored via
991 	 * g_object_set_qdata().
992 	 * Params:
993 	 * quark = A GQuark, naming the user data pointer
994 	 * Returns: The user data pointer set, or NULL. [transfer none]
995 	 */
996 	public void* getQdata(GQuark quark)
997 	{
998 		// gpointer g_object_get_qdata (GObject *object,  GQuark quark);
999 		return g_object_get_qdata(gObject, quark);
1000 	}
1001 	
1002 	/**
1003 	 * This sets an opaque, named pointer on an object.
1004 	 * The name is specified through a GQuark (retrived e.g. via
1005 	 * g_quark_from_static_string()), and the pointer
1006 	 * can be gotten back from the object with g_object_get_qdata()
1007 	 * until the object is finalized.
1008 	 * Setting a previously set user data pointer, overrides (frees)
1009 	 * the old pointer set, using NULL as pointer essentially
1010 	 * removes the data stored.
1011 	 * Params:
1012 	 * quark = A GQuark, naming the user data pointer
1013 	 * data = An opaque user data pointer
1014 	 */
1015 	public void setQdata(GQuark quark, void* data)
1016 	{
1017 		// void g_object_set_qdata (GObject *object,  GQuark quark,  gpointer data);
1018 		g_object_set_qdata(gObject, quark, data);
1019 	}
1020 	
1021 	/**
1022 	 * This function works like g_object_set_qdata(), but in addition,
1023 	 * a void (*destroy) (gpointer) function may be specified which is
1024 	 * called with data as argument when the object is finalized, or
1025 	 * the data is being overwritten by a call to g_object_set_qdata()
1026 	 * with the same quark.
1027 	 * Params:
1028 	 * quark = A GQuark, naming the user data pointer
1029 	 * data = An opaque user data pointer
1030 	 * destroy = Function to invoke with data as argument, when data
1031 	 * needs to be freed
1032 	 */
1033 	public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)
1034 	{
1035 		// void g_object_set_qdata_full (GObject *object,  GQuark quark,  gpointer data,  GDestroyNotify destroy);
1036 		g_object_set_qdata_full(gObject, quark, data, destroy);
1037 	}
1038 	
1039 	/**
1040 	 * This function gets back user data pointers stored via
1041 	 * g_object_set_qdata() and removes the data from object
1042 	 * without invoking its destroy() function (if any was
1043 	 * set).
1044 	 * Usually, calling this function is only required to update
1045 	 * Params:
1046 	 * quark = A GQuark, naming the user data pointer
1047 	 * Returns: The user data pointer set, or NULL. [transfer full]
1048 	 */
1049 	public void* stealQdata(GQuark quark)
1050 	{
1051 		// gpointer g_object_steal_qdata (GObject *object,  GQuark quark);
1052 		return g_object_steal_qdata(gObject, quark);
1053 	}
1054 	
1055 	/**
1056 	 * This is a variant of g_object_get_qdata() which returns
1057 	 * a 'duplicate' of the value. dup_func defines the
1058 	 * meaning of 'duplicate' in this context, it could e.g.
1059 	 * take a reference on a ref-counted object.
1060 	 * If the quark is not set on the object then dup_func
1061 	 * will be called with a NULL argument.
1062 	 * Note that dup_func is called while user data of object
1063 	 * is locked.
1064 	 * This function can be useful to avoid races when multiple
1065 	 * threads are using object data on the same key on the same
1066 	 * object.
1067 	 * Since 2.34
1068 	 * Params:
1069 	 * quark = a GQuark, naming the user data pointer
1070 	 * dupFunc = function to dup the value. [allow-none]
1071 	 * userData = passed as user_data to dup_func. [allow-none]
1072 	 * Returns: the result of calling dup_func on the value associated with quark on object, or NULL if not set. If dup_func is NULL, the value is returned unmodified.
1073 	 */
1074 	public void* dupQdata(GQuark quark, GDuplicateFunc dupFunc, void* userData)
1075 	{
1076 		// gpointer g_object_dup_qdata (GObject *object,  GQuark quark,  GDuplicateFunc dup_func,  gpointer user_data);
1077 		return g_object_dup_qdata(gObject, quark, dupFunc, userData);
1078 	}
1079 	
1080 	/**
1081 	 * Compares the user data for the key quark on object with
1082 	 * oldval, and if they are the same, replaces oldval with
1083 	 * newval.
1084 	 * This is like a typical atomic compare-and-exchange
1085 	 * operation, for user data on an object.
1086 	 * If the previous value was replaced then ownership of the
1087 	 * old value (oldval) is passed to the caller, including
1088 	 * the registered destroy notify for it (passed out in old_destroy).
1089 	 * Its up to the caller to free this as he wishes, which may
1090 	 * or may not include using old_destroy as sometimes replacement
1091 	 * should not destroy the object in the normal way.
1092 	 * Return: TRUE if the existing value for quark was replaced
1093 	 *  by newval, FALSE otherwise.
1094 	 * Since 2.34
1095 	 * Params:
1096 	 * quark = a GQuark, naming the user data pointer
1097 	 * oldval = the old value to compare against. [allow-none]
1098 	 * newval = the new value. [allow-none]
1099 	 * destroy = a destroy notify for the new value. [allow-none]
1100 	 * oldDestroy = destroy notify for the existing value. [allow-none]
1101 	 */
1102 	public int replaceQdata(GQuark quark, void* oldval, void* newval, GDestroyNotify destroy, GDestroyNotify* oldDestroy)
1103 	{
1104 		// gboolean g_object_replace_qdata (GObject *object,  GQuark quark,  gpointer oldval,  gpointer newval,  GDestroyNotify destroy,  GDestroyNotify *old_destroy);
1105 		return g_object_replace_qdata(gObject, quark, oldval, newval, destroy, oldDestroy);
1106 	}
1107 	
1108 	/**
1109 	 * Sets a property on an object.
1110 	 * Params:
1111 	 * propertyName = the name of the property to set
1112 	 * value = the value
1113 	 */
1114 	public void setProperty(string propertyName, Value value)
1115 	{
1116 		// void g_object_set_property (GObject *object,  const gchar *property_name,  const GValue *value);
1117 		g_object_set_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
1118 	}
1119 	
1120 	/**
1121 	 * Gets a property of an object. value must have been initialized to the
1122 	 * expected type of the property (or a type to which the expected type can be
1123 	 * transformed) using g_value_init().
1124 	 * In general, a copy is made of the property contents and the caller is
1125 	 * responsible for freeing the memory by calling g_value_unset().
1126 	 * Note that g_object_get_property() is really intended for language
1127 	 * bindings, g_object_get() is much more convenient for C programming.
1128 	 * Params:
1129 	 * propertyName = the name of the property to get
1130 	 * value = return location for the property value
1131 	 */
1132 	public void getProperty(string propertyName, Value value)
1133 	{
1134 		// void g_object_get_property (GObject *object,  const gchar *property_name,  GValue *value);
1135 		g_object_get_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
1136 	}
1137 	
1138 	/**
1139 	 * Creates a new instance of a GObject subtype and sets its properties.
1140 	 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
1141 	 * which are not explicitly specified are set to their default values.
1142 	 * Params:
1143 	 * objectType = the type id of the GObject subtype to instantiate
1144 	 * firstPropertyName = the name of the first property
1145 	 * varArgs = the value of the first property, followed optionally by more
1146 	 * name/value pairs, followed by NULL
1147 	 * Throws: ConstructionException GTK+ fails to create the object.
1148 	 */
1149 	public this (GType objectType, string firstPropertyName, void* varArgs)
1150 	{
1151 		// GObject * g_object_new_valist (GType object_type,  const gchar *first_property_name,  va_list var_args);
1152 		auto p = g_object_new_valist(objectType, Str.toStringz(firstPropertyName), varArgs);
1153 		if(p is null)
1154 		{
1155 			throw new ConstructionException("null returned by g_object_new_valist(objectType, Str.toStringz(firstPropertyName), varArgs)");
1156 		}
1157 		this(cast(GObject*) p);
1158 	}
1159 	
1160 	/**
1161 	 * Sets properties on an object.
1162 	 * Params:
1163 	 * firstPropertyName = name of the first property to set
1164 	 * varArgs = value for the first property, followed optionally by more
1165 	 * name/value pairs, followed by NULL
1166 	 */
1167 	public void setValist(string firstPropertyName, void* varArgs)
1168 	{
1169 		// void g_object_set_valist (GObject *object,  const gchar *first_property_name,  va_list var_args);
1170 		g_object_set_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
1171 	}
1172 	
1173 	/**
1174 	 * Gets properties of an object.
1175 	 * In general, a copy is made of the property contents and the caller
1176 	 * is responsible for freeing the memory in the appropriate manner for
1177 	 * the type, for instance by calling g_free() or g_object_unref().
1178 	 * See g_object_get().
1179 	 * Params:
1180 	 * firstPropertyName = name of the first property to get
1181 	 * varArgs = return location for the first property, followed optionally by more
1182 	 * name/return location pairs, followed by NULL
1183 	 */
1184 	public void getValist(string firstPropertyName, void* varArgs)
1185 	{
1186 		// void g_object_get_valist (GObject *object,  const gchar *first_property_name,  va_list var_args);
1187 		g_object_get_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
1188 	}
1189 	
1190 	/**
1191 	 * This function essentially limits the life time of the closure to
1192 	 * the life time of the object. That is, when the object is finalized,
1193 	 * the closure is invalidated by calling g_closure_invalidate() on
1194 	 * it, in order to prevent invocations of the closure with a finalized
1195 	 * (nonexisting) object. Also, g_object_ref() and g_object_unref() are
1196 	 * added as marshal guards to the closure, to ensure that an extra
1197 	 * reference count is held on object during invocation of the
1198 	 * closure. Usually, this function will be called on closures that
1199 	 * use this object as closure data.
1200 	 * Params:
1201 	 * closure = GClosure to watch
1202 	 */
1203 	public void watchClosure(Closure closure)
1204 	{
1205 		// void g_object_watch_closure (GObject *object,  GClosure *closure);
1206 		g_object_watch_closure(gObject, (closure is null) ? null : closure.getClosureStruct());
1207 	}
1208 	
1209 	/**
1210 	 * Releases all references to other objects. This can be used to break
1211 	 * reference cycles.
1212 	 * This functions should only be called from object system implementations.
1213 	 */
1214 	public void runDispose()
1215 	{
1216 		// void g_object_run_dispose (GObject *object);
1217 		g_object_run_dispose(gObject);
1218 	}
1219 }