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