1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gobject.ObjectG;
26 
27 private import core.memory;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.Binding;
31 private import gobject.Closure;
32 private import gobject.ObjectG;
33 private import gobject.ParamSpec;
34 private import gobject.Signals;
35 private import gobject.TypeInterface;
36 private import gobject.Value;
37 private import gobject.c.functions;
38 public  import gobject.c.types;
39 public  import gtkc.gobjecttypes;
40 private import gtkd.Loader;
41 private import std.algorithm;
42 private import std.traits;
43 
44 
45 /**
46  * All the fields in the GObject structure are private
47  * to the #GObject implementation and should never be accessed directly.
48  */
49 public class ObjectG
50 {
51 	/** the main Gtk struct */
52 	protected GObject* gObject;
53 	protected bool ownedRef;
54 
55 	/** Get the main Gtk struct */
56 	public GObject* getObjectGStruct(bool transferOwnership = false)
57 	{
58 		if (transferOwnership)
59 			ownedRef = false;
60 		return gObject;
61 	}
62 
63 	/** the main Gtk struct as a void* */
64 	protected void* getStruct()
65 	{
66 		return cast(void*)gObject;
67 	}
68 
69 	protected bool isGcRoot;
70 
71 	/**
72 	 * Sets our main struct and passes store it on the gobject.
73 	 * Add a gabage collector root to the gtk+ struct so it doesn't get collect
74 	 */
75 	public this (GObject* gObject, bool ownedRef = false)
76 	{
77 		this.gObject = gObject;
78 		if ( gObject !is  null )
79 		{
80 			setDataFull("GObject", cast(void*)this, cast(GDestroyNotify)&destroyNotify);
81 			addToggleRef(cast(GToggleNotify)&toggleNotify, cast(void*)this);
82 
83 			//If the refCount is larger then 1 toggleNotify isn't called
84 			if (gObject.refCount > 1 && !isGcRoot)
85 			{
86 				GC.addRoot(cast(void*)this);
87 				isGcRoot = true;
88 			}
89 
90 			//Remove the floating reference if there is one.
91 			if ( isFloating() )
92 			{
93 				refSink();
94 				unref();
95 			}
96 			//If we already owned this reference remove the one added by addToggleRef.
97 			else if ( ownedRef )
98 			{
99 				unref();
100 			}
101 		}
102 	}
103 
104 	extern(C)
105 	{
106 		static void destroyNotify(ObjectG obj)
107 		{
108 			if ( obj.isGcRoot )
109 			{
110 				GC.removeRoot(cast(void*)obj);
111 				obj.isGcRoot = false;
112 			}
113 
114 			if ( obj.gObject.refCount > 0 )
115 				obj.removeToggleRef(cast(GToggleNotify)&toggleNotify, cast(void*)obj);
116 
117 			obj.gObject = null;
118 		}
119 
120 		static void toggleNotify(ObjectG obj, GObject* object, int isLastRef)
121 		{
122 			if ( isLastRef && obj.isGcRoot )
123 			{
124 				GC.removeRoot(cast(void*)obj);
125 				obj.isGcRoot = false;
126 			}
127 			else if ( !obj.isGcRoot )
128 			{
129 				GC.addRoot(cast(void*)obj);
130 				obj.isGcRoot = true;
131 			}
132 		}
133 	}
134 
135 	~this()
136 	{
137 		static if ( isPointer!(typeof(g_object_steal_data)) )
138 			bool libLoaded = Linker.isLoaded(LIBRARY_GOBJECT);
139 		else
140 			enum libLoaded = true;
141 
142 		if ( libLoaded && gObject !is null )
143 		{
144 			// Remove the GDestroyNotify callback,
145 			// for when the D object is destroyed before the C one.
146 			g_object_steal_data(gObject, cast(char*)"GObject");
147 
148 			if ( isGcRoot )
149 			{
150 				GC.removeRoot(cast(void*)this);
151 				isGcRoot = false;
152 			}
153 
154 			// We only have a toggle ref if the C object hods a reference to the D object.
155 			if ( g_object_get_data(gObject, cast(char*)"GObject") is cast(void*)this )
156 				g_object_remove_toggle_ref(gObject, cast(GToggleNotify)&toggleNotify, cast(void*)this);
157 			else
158 				g_object_unref(gObject);
159 		}
160 	}
161 
162 	/** */
163 	T opCast(T)()
164 	{
165 		if ( !this )
166 			return null;
167 
168 		static if ( is(T : ObjectG)
169 			&& !is(T == interface)
170 			&& is(typeof(new T(cast(typeof(T.tupleof[0]))gObject, false))) )
171 		{
172 			//If a regular cast works, return the result.
173 			if ( auto r = cast(T)super )
174 				return r;
175 
176 			//Prints a warning if the cast is invalid.
177 			//g_type_check_instance_cast(cast(GTypeInstance*)gObject, T.getType());
178 
179 			//Can we cast this type to T.
180 			if ( !g_type_is_a(gObject.gTypeInstance.gClass.gType, T.getType()) )
181 				return null;
182 
183 			//Remove the GDestroyNotify callback for the original d object.
184 			g_object_steal_data(gObject, "GObject");
185 			//Remove the original object as a GC root if needed.
186 			if ( isGcRoot )
187 			{
188 				GC.removeRoot(cast(void*)this);
189 				isGcRoot = false;
190 			}
191 			//Add a reference for the original D object before we remove the toggle reference.
192 			g_object_ref(gObject);
193 			g_object_remove_toggle_ref(gObject, cast(GToggleNotify)&toggleNotify, cast(void*)this);
194 
195 			//The new object handles the memory management.
196 			return new T(cast(typeof(T.tupleof[0]))gObject, false);
197 		}
198 		else static if ( is(T == interface)
199 			&& hasStaticMember!(T, "getType")
200 			&& is(ReturnType!(T.getType) == GType) )
201 		{
202 			//If a regular cast works, return the result.
203 			if ( auto r = cast(T)super )
204 				return r;
205 
206 			//Do we implement interface T.
207 			if ( !g_type_is_a(gObject.gTypeInstance.gClass.gType, T.getType()) )
208 				return null;
209 
210 			return getInterfaceInstance!T(gObject);
211 		}
212 		else
213 			return cast(T)super;
214 	}
215 
216 	unittest
217 	{
218 		ObjectG obj = null;
219 
220 		assert( (cast(Binding)obj) is null );
221 	}
222 
223 	/**
224 	 * Gets a D Object from the objects table of associations.
225 	 * Params:
226 	 *  obj = GObject containing the associations.
227 	 * Returns: the D Object if found, or a newly constructed object if no such Object exists.
228 	 */
229 	public static RT getDObject(T, RT=T, U)(U obj, bool ownedRef = false)
230 	{
231 		if ( obj is null )
232 		{
233 			return null;
234 		}
235 
236 		static if ( is(T : ObjectG) && !is(RT == interface) )
237 		{
238 			auto p = g_object_get_data(cast(GObject*)obj, Str.toStringz("GObject"));
239 
240 			if ( p !is null )
241 				return cast(RT)cast(ObjectG)p;
242 			else
243 				return new T(obj, ownedRef);
244 		}
245 		else static if ( is(RT == interface) && hasMember!(RT, "getType") && is(ReturnType!(RT.getType) == GType) )
246 		{
247 			auto p = g_object_get_data(cast(GObject*)obj, Str.toStringz("GObject"));
248 
249 			if ( p !is null )
250 				return cast(RT)cast(ObjectG)p;
251 			else
252 				return getInterfaceInstance!RT(cast(GObject*)obj);
253 		}
254 		else
255 		{
256 			return new T(obj, ownedRef);
257 		}
258 	}
259 
260 	private static I getInterfaceInstance(I)(GObject* instance)
261 	{
262 		static class Impl: ObjectG, I
263 		{
264 			public this (GObject* gObject, bool ownedRef = false)
265 			{
266 				super(gObject, ownedRef);
267 			}
268 
269 			/** the main Gtk struct as a void* */
270 			protected override void* getStruct()
271 			{
272 				return cast(void*)gObject;
273 			}
274 
275 			// add the interface capabilities
276 			mixin("import "~ moduleName!I[0..$-2] ~"T;import "~ moduleName!I ~"; mixin "~ __traits(identifier, I)[0..$-2] ~"T!("~__traits(identifier, Impl)~");");
277 		}
278 
279 		ClassInfo ci = Impl.classinfo;
280 		Impl iface;
281 		void* p;
282 
283 		//Skip all the setup for the memory management,
284 		//and only add an extra reference for the instance returned.
285 		p = GC.malloc(ci.initializer.length, GC.BlkAttr.FINALIZE, ci);
286 		p[0..ci.initializer.length] = ci.initializer;
287 		iface = cast(Impl)p;
288 		iface.gObject = instance;
289 		iface.doref();
290 
291 		return iface;
292 	}
293 
294 	/** */
295 	public void setProperty(T)(string propertyName, T value)
296 	{
297 		setProperty(propertyName, new Value(value));
298 	}
299 
300 	deprecated("Use the member function")
301 	public static void unref(ObjectG obj)
302 	{
303 		obj.unref();
304 	}
305 
306 	deprecated("Use the member function")
307 	public static ObjectG doref(ObjectG obj)
308 	{
309 		return obj.doref();
310 	}
311 
312 	/**
313 	 * The notify signal is emitted on an object when one of its
314 	 * properties has been changed. Note that getting this signal
315 	 * doesn't guarantee that the value of the property has actually
316 	 * changed, it may also be emitted when the setter for the property
317 	 * is called to reinstate the previous value.
318 	 *
319 	 * This signal is typically used to obtain change notification for a
320 	 * single property.
321 	 *
322 	 * It is important to note that you must use
323 	 * canonical parameter names for the property.
324 	 *
325 	 * Params:
326 	 *     dlg          = The callback.
327 	 *     property     = Set this if you only want to receive the signal for a specific property.
328 	 *     connectFlags = The behavior of the signal's connection.
329 	 */
330 	gulong addOnNotify(void delegate(ParamSpec, ObjectG) dlg, string property = "", ConnectFlags connectFlags=cast(ConnectFlags)0)
331 	{
332 		string signalName;
333 
334 		if ( property == "" )
335 			signalName = "notify";
336 		else
337 			signalName = "notify::"~ property;
338 
339 		return Signals.connect(this, signalName, dlg, connectFlags ^ ConnectFlags.SWAPPED);
340 	}
341 
342 	/**
343 	 */
344 
345 	/** */
346 	public static GType getType()
347 	{
348 		return g_initially_unowned_get_type();
349 	}
350 
351 	/**
352 	 * Creates a new instance of a #GObject subtype and sets its properties.
353 	 *
354 	 * Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY)
355 	 * which are not explicitly specified are set to their default values.
356 	 *
357 	 * Params:
358 	 *     objectType = the type id of the #GObject subtype to instantiate
359 	 *     firstPropertyName = the name of the first property
360 	 *     varArgs = the value of the first property, followed optionally by more
361 	 *         name/value pairs, followed by %NULL
362 	 *
363 	 * Returns: a new instance of @object_type
364 	 *
365 	 * Throws: ConstructionException GTK+ fails to create the object.
366 	 */
367 	public this(GType objectType, string firstPropertyName, void* varArgs)
368 	{
369 		auto p = g_object_new_valist(objectType, Str.toStringz(firstPropertyName), varArgs);
370 
371 		if(p is null)
372 		{
373 			throw new ConstructionException("null returned by new_valist");
374 		}
375 
376 		this(cast(GObject*) p, true);
377 	}
378 
379 	/**
380 	 * Creates a new instance of a #GObject subtype and sets its properties using
381 	 * the provided arrays. Both arrays must have exactly @n_properties elements,
382 	 * and the names and values correspond by index.
383 	 *
384 	 * Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY)
385 	 * which are not explicitly specified are set to their default values.
386 	 *
387 	 * Params:
388 	 *     objectType = the object type to instantiate
389 	 *     names = the names of each property to be set
390 	 *     values = the values of each property to be set
391 	 *
392 	 * Returns: a new instance of
393 	 *     @object_type
394 	 *
395 	 * Since: 2.54
396 	 *
397 	 * Throws: ConstructionException GTK+ fails to create the object.
398 	 */
399 	public this(GType objectType, string[] names, Value[] values)
400 	{
401 		GValue[] valuesArray = new GValue[values.length];
402 		for ( int i = 0; i < values.length; i++ )
403 		{
404 			valuesArray[i] = *(values[i].getValueStruct());
405 		}
406 
407 		auto p = g_object_new_with_properties(objectType, cast(uint)values.length, Str.toStringzArray(names), valuesArray.ptr);
408 
409 		if(p is null)
410 		{
411 			throw new ConstructionException("null returned by new_with_properties");
412 		}
413 
414 		this(cast(GObject*) p, true);
415 	}
416 
417 	/**
418 	 * Creates a new instance of a #GObject subtype and sets its properties.
419 	 *
420 	 * Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY)
421 	 * which are not explicitly specified are set to their default values.
422 	 *
423 	 * Deprecated: Use g_object_new_with_properties() instead.
424 	 * deprecated. See #GParameter for more information.
425 	 *
426 	 * Params:
427 	 *     objectType = the type id of the #GObject subtype to instantiate
428 	 *     parameters = an array of #GParameter
429 	 *
430 	 * Returns: a new instance of
431 	 *     @object_type
432 	 *
433 	 * Throws: ConstructionException GTK+ fails to create the object.
434 	 */
435 	public this(GType objectType, GParameter[] parameters)
436 	{
437 		auto p = g_object_newv(objectType, cast(uint)parameters.length, parameters.ptr);
438 
439 		if(p is null)
440 		{
441 			throw new ConstructionException("null returned by newv");
442 		}
443 
444 		this(cast(GObject*) p, true);
445 	}
446 
447 	/** */
448 	public static size_t compatControl(size_t what, void* data)
449 	{
450 		return g_object_compat_control(what, data);
451 	}
452 
453 	/**
454 	 * Find the #GParamSpec with the given name for an
455 	 * interface. Generally, the interface vtable passed in as @g_iface
456 	 * will be the default vtable from g_type_default_interface_ref(), or,
457 	 * if you know the interface has already been loaded,
458 	 * g_type_default_interface_peek().
459 	 *
460 	 * Params:
461 	 *     gIface = any interface vtable for the
462 	 *         interface, or the default vtable for the interface
463 	 *     propertyName = name of a property to lookup.
464 	 *
465 	 * Returns: the #GParamSpec for the property of the
466 	 *     interface with the name @property_name, or %NULL if no
467 	 *     such property exists.
468 	 *
469 	 * Since: 2.4
470 	 */
471 	public static ParamSpec interfaceFindProperty(TypeInterface gIface, string propertyName)
472 	{
473 		auto p = g_object_interface_find_property((gIface is null) ? null : gIface.getTypeInterfaceStruct(), Str.toStringz(propertyName));
474 
475 		if(p is null)
476 		{
477 			return null;
478 		}
479 
480 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
481 	}
482 
483 	/**
484 	 * Add a property to an interface; this is only useful for interfaces
485 	 * that are added to GObject-derived types. Adding a property to an
486 	 * interface forces all objects classes with that interface to have a
487 	 * compatible property. The compatible property could be a newly
488 	 * created #GParamSpec, but normally
489 	 * g_object_class_override_property() will be used so that the object
490 	 * class only needs to provide an implementation and inherits the
491 	 * property description, default value, bounds, and so forth from the
492 	 * interface property.
493 	 *
494 	 * This function is meant to be called from the interface's default
495 	 * vtable initialization function (the @class_init member of
496 	 * #GTypeInfo.) It must not be called after after @class_init has
497 	 * been called for any object types implementing this interface.
498 	 *
499 	 * If @pspec is a floating reference, it will be consumed.
500 	 *
501 	 * Params:
502 	 *     gIface = any interface vtable for the
503 	 *         interface, or the default
504 	 *         vtable for the interface.
505 	 *     pspec = the #GParamSpec for the new property
506 	 *
507 	 * Since: 2.4
508 	 */
509 	public static void interfaceInstallProperty(TypeInterface gIface, ParamSpec pspec)
510 	{
511 		g_object_interface_install_property((gIface is null) ? null : gIface.getTypeInterfaceStruct(), (pspec is null) ? null : pspec.getParamSpecStruct());
512 	}
513 
514 	/**
515 	 * Lists the properties of an interface.Generally, the interface
516 	 * vtable passed in as @g_iface will be the default vtable from
517 	 * g_type_default_interface_ref(), or, if you know the interface has
518 	 * already been loaded, g_type_default_interface_peek().
519 	 *
520 	 * Params:
521 	 *     gIface = any interface vtable for the
522 	 *         interface, or the default vtable for the interface
523 	 *
524 	 * Returns: a
525 	 *     pointer to an array of pointers to #GParamSpec
526 	 *     structures. The paramspecs are owned by GLib, but the
527 	 *     array should be freed with g_free() when you are done with
528 	 *     it.
529 	 *
530 	 * Since: 2.4
531 	 */
532 	public static ParamSpec[] interfaceListProperties(TypeInterface gIface)
533 	{
534 		uint nPropertiesP;
535 
536 		auto p = g_object_interface_list_properties((gIface is null) ? null : gIface.getTypeInterfaceStruct(), &nPropertiesP);
537 
538 		if(p is null)
539 		{
540 			return null;
541 		}
542 
543 		ParamSpec[] arr = new ParamSpec[nPropertiesP];
544 		for(int i = 0; i < nPropertiesP; i++)
545 		{
546 			arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]);
547 		}
548 
549 		return arr;
550 	}
551 
552 	/**
553 	 * Increases the reference count of the object by one and sets a
554 	 * callback to be called when all other references to the object are
555 	 * dropped, or when this is already the last reference to the object
556 	 * and another reference is established.
557 	 *
558 	 * This functionality is intended for binding @object to a proxy
559 	 * object managed by another memory manager. This is done with two
560 	 * paired references: the strong reference added by
561 	 * g_object_add_toggle_ref() and a reverse reference to the proxy
562 	 * object which is either a strong reference or weak reference.
563 	 *
564 	 * The setup is that when there are no other references to @object,
565 	 * only a weak reference is held in the reverse direction from @object
566 	 * to the proxy object, but when there are other references held to
567 	 * @object, a strong reference is held. The @notify callback is called
568 	 * when the reference from @object to the proxy object should be
569 	 * "toggled" from strong to weak (@is_last_ref true) or weak to strong
570 	 * (@is_last_ref false).
571 	 *
572 	 * Since a (normal) reference must be held to the object before
573 	 * calling g_object_add_toggle_ref(), the initial state of the reverse
574 	 * link is always strong.
575 	 *
576 	 * Multiple toggle references may be added to the same gobject,
577 	 * however if there are multiple toggle references to an object, none
578 	 * of them will ever be notified until all but one are removed.  For
579 	 * this reason, you should only ever use a toggle reference if there
580 	 * is important state in the proxy object.
581 	 *
582 	 * Params:
583 	 *     notify = a function to call when this reference is the
584 	 *         last reference to the object, or is no longer
585 	 *         the last reference.
586 	 *     data = data to pass to @notify
587 	 *
588 	 * Since: 2.8
589 	 */
590 	public void addToggleRef(GToggleNotify notify, void* data)
591 	{
592 		g_object_add_toggle_ref(gObject, notify, data);
593 	}
594 
595 	/**
596 	 * Adds a weak reference from weak_pointer to @object to indicate that
597 	 * the pointer located at @weak_pointer_location is only valid during
598 	 * the lifetime of @object. When the @object is finalized,
599 	 * @weak_pointer will be set to %NULL.
600 	 *
601 	 * Note that as with g_object_weak_ref(), the weak references created by
602 	 * this method are not thread-safe: they cannot safely be used in one
603 	 * thread if the object's last g_object_unref() might happen in another
604 	 * thread. Use #GWeakRef if thread-safety is required.
605 	 *
606 	 * Params:
607 	 *     weakPointerLocation = The memory address
608 	 *         of a pointer.
609 	 */
610 	public void addWeakPointer(ref void* weakPointerLocation)
611 	{
612 		g_object_add_weak_pointer(gObject, &weakPointerLocation);
613 	}
614 
615 	/**
616 	 * Creates a binding between @source_property on @source and @target_property
617 	 * on @target. Whenever the @source_property is changed the @target_property is
618 	 * updated using the same value. For instance:
619 	 *
620 	 * |[
621 	 * g_object_bind_property (action, "active", widget, "sensitive", 0);
622 	 * ]|
623 	 *
624 	 * Will result in the "sensitive" property of the widget #GObject instance to be
625 	 * updated with the same value of the "active" property of the action #GObject
626 	 * instance.
627 	 *
628 	 * If @flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual:
629 	 * if @target_property on @target changes then the @source_property on @source
630 	 * will be updated as well.
631 	 *
632 	 * The binding will automatically be removed when either the @source or the
633 	 * @target instances are finalized. To remove the binding without affecting the
634 	 * @source and the @target you can just call g_object_unref() on the returned
635 	 * #GBinding instance.
636 	 *
637 	 * A #GObject can have multiple bindings.
638 	 *
639 	 * Params:
640 	 *     sourceProperty = the property on @source to bind
641 	 *     target = the target #GObject
642 	 *     targetProperty = the property on @target to bind
643 	 *     flags = flags to pass to #GBinding
644 	 *
645 	 * Returns: the #GBinding instance representing the
646 	 *     binding between the two #GObject instances. The binding is released
647 	 *     whenever the #GBinding reference count reaches zero.
648 	 *
649 	 * Since: 2.26
650 	 */
651 	public Binding bindProperty(string sourceProperty, ObjectG target, string targetProperty, GBindingFlags flags)
652 	{
653 		auto p = g_object_bind_property(gObject, Str.toStringz(sourceProperty), (target is null) ? null : target.getObjectGStruct(), Str.toStringz(targetProperty), flags);
654 
655 		if(p is null)
656 		{
657 			return null;
658 		}
659 
660 		return ObjectG.getDObject!(Binding)(cast(GBinding*) p);
661 	}
662 
663 	/**
664 	 * Complete version of g_object_bind_property().
665 	 *
666 	 * Creates a binding between @source_property on @source and @target_property
667 	 * on @target, allowing you to set the transformation functions to be used by
668 	 * the binding.
669 	 *
670 	 * If @flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual:
671 	 * if @target_property on @target changes then the @source_property on @source
672 	 * will be updated as well. The @transform_from function is only used in case
673 	 * of bidirectional bindings, otherwise it will be ignored
674 	 *
675 	 * The binding will automatically be removed when either the @source or the
676 	 * @target instances are finalized. To remove the binding without affecting the
677 	 * @source and the @target you can just call g_object_unref() on the returned
678 	 * #GBinding instance.
679 	 *
680 	 * A #GObject can have multiple bindings.
681 	 *
682 	 * The same @user_data parameter will be used for both @transform_to
683 	 * and @transform_from transformation functions; the @notify function will
684 	 * be called once, when the binding is removed. If you need different data
685 	 * for each transformation function, please use
686 	 * g_object_bind_property_with_closures() instead.
687 	 *
688 	 * Params:
689 	 *     sourceProperty = the property on @source to bind
690 	 *     target = the target #GObject
691 	 *     targetProperty = the property on @target to bind
692 	 *     flags = flags to pass to #GBinding
693 	 *     transformTo = the transformation function
694 	 *         from the @source to the @target, or %NULL to use the default
695 	 *     transformFrom = the transformation function
696 	 *         from the @target to the @source, or %NULL to use the default
697 	 *     userData = custom data to be passed to the transformation functions,
698 	 *         or %NULL
699 	 *     notify = a function to call when disposing the binding, to free
700 	 *         resources used by the transformation functions, or %NULL if not required
701 	 *
702 	 * Returns: the #GBinding instance representing the
703 	 *     binding between the two #GObject instances. The binding is released
704 	 *     whenever the #GBinding reference count reaches zero.
705 	 *
706 	 * Since: 2.26
707 	 */
708 	public Binding bindPropertyFull(string sourceProperty, ObjectG target, string targetProperty, GBindingFlags flags, GBindingTransformFunc transformTo, GBindingTransformFunc transformFrom, void* userData, GDestroyNotify notify)
709 	{
710 		auto p = g_object_bind_property_full(gObject, Str.toStringz(sourceProperty), (target is null) ? null : target.getObjectGStruct(), Str.toStringz(targetProperty), flags, transformTo, transformFrom, userData, notify);
711 
712 		if(p is null)
713 		{
714 			return null;
715 		}
716 
717 		return ObjectG.getDObject!(Binding)(cast(GBinding*) p);
718 	}
719 
720 	/**
721 	 * Creates a binding between @source_property on @source and @target_property
722 	 * on @target, allowing you to set the transformation functions to be used by
723 	 * the binding.
724 	 *
725 	 * This function is the language bindings friendly version of
726 	 * g_object_bind_property_full(), using #GClosures instead of
727 	 * function pointers.
728 	 *
729 	 * Params:
730 	 *     sourceProperty = the property on @source to bind
731 	 *     target = the target #GObject
732 	 *     targetProperty = the property on @target to bind
733 	 *     flags = flags to pass to #GBinding
734 	 *     transformTo = a #GClosure wrapping the transformation function
735 	 *         from the @source to the @target, or %NULL to use the default
736 	 *     transformFrom = a #GClosure wrapping the transformation function
737 	 *         from the @target to the @source, or %NULL to use the default
738 	 *
739 	 * Returns: the #GBinding instance representing the
740 	 *     binding between the two #GObject instances. The binding is released
741 	 *     whenever the #GBinding reference count reaches zero.
742 	 *
743 	 * Since: 2.26
744 	 */
745 	public Binding bindPropertyWithClosures(string sourceProperty, ObjectG target, string targetProperty, GBindingFlags flags, Closure transformTo, Closure transformFrom)
746 	{
747 		auto p = g_object_bind_property_with_closures(gObject, Str.toStringz(sourceProperty), (target is null) ? null : target.getObjectGStruct(), Str.toStringz(targetProperty), flags, (transformTo is null) ? null : transformTo.getClosureStruct(), (transformFrom is null) ? null : transformFrom.getClosureStruct());
748 
749 		if(p is null)
750 		{
751 			return null;
752 		}
753 
754 		return ObjectG.getDObject!(Binding)(cast(GBinding*) p);
755 	}
756 
757 	/**
758 	 * This is a variant of g_object_get_data() which returns
759 	 * a 'duplicate' of the value. @dup_func defines the
760 	 * meaning of 'duplicate' in this context, it could e.g.
761 	 * take a reference on a ref-counted object.
762 	 *
763 	 * If the @key is not set on the object then @dup_func
764 	 * will be called with a %NULL argument.
765 	 *
766 	 * Note that @dup_func is called while user data of @object
767 	 * is locked.
768 	 *
769 	 * This function can be useful to avoid races when multiple
770 	 * threads are using object data on the same key on the same
771 	 * object.
772 	 *
773 	 * Params:
774 	 *     key = a string, naming the user data pointer
775 	 *     dupFunc = function to dup the value
776 	 *     userData = passed as user_data to @dup_func
777 	 *
778 	 * Returns: the result of calling @dup_func on the value
779 	 *     associated with @key on @object, or %NULL if not set.
780 	 *     If @dup_func is %NULL, the value is returned
781 	 *     unmodified.
782 	 *
783 	 * Since: 2.34
784 	 */
785 	public void* dupData(string key, GDuplicateFunc dupFunc, void* userData)
786 	{
787 		return g_object_dup_data(gObject, Str.toStringz(key), dupFunc, userData);
788 	}
789 
790 	/**
791 	 * This is a variant of g_object_get_qdata() which returns
792 	 * a 'duplicate' of the value. @dup_func defines the
793 	 * meaning of 'duplicate' in this context, it could e.g.
794 	 * take a reference on a ref-counted object.
795 	 *
796 	 * If the @quark is not set on the object then @dup_func
797 	 * will be called with a %NULL argument.
798 	 *
799 	 * Note that @dup_func is called while user data of @object
800 	 * is locked.
801 	 *
802 	 * This function can be useful to avoid races when multiple
803 	 * threads are using object data on the same key on the same
804 	 * object.
805 	 *
806 	 * Params:
807 	 *     quark = a #GQuark, naming the user data pointer
808 	 *     dupFunc = function to dup the value
809 	 *     userData = passed as user_data to @dup_func
810 	 *
811 	 * Returns: the result of calling @dup_func on the value
812 	 *     associated with @quark on @object, or %NULL if not set.
813 	 *     If @dup_func is %NULL, the value is returned
814 	 *     unmodified.
815 	 *
816 	 * Since: 2.34
817 	 */
818 	public void* dupQdata(GQuark quark, GDuplicateFunc dupFunc, void* userData)
819 	{
820 		return g_object_dup_qdata(gObject, quark, dupFunc, userData);
821 	}
822 
823 	/**
824 	 * This function is intended for #GObject implementations to re-enforce
825 	 * a [floating][floating-ref] object reference. Doing this is seldom
826 	 * required: all #GInitiallyUnowneds are created with a floating reference
827 	 * which usually just needs to be sunken by calling g_object_ref_sink().
828 	 *
829 	 * Since: 2.10
830 	 */
831 	public void forceFloating()
832 	{
833 		g_object_force_floating(gObject);
834 	}
835 
836 	/**
837 	 * Increases the freeze count on @object. If the freeze count is
838 	 * non-zero, the emission of "notify" signals on @object is
839 	 * stopped. The signals are queued until the freeze count is decreased
840 	 * to zero. Duplicate notifications are squashed so that at most one
841 	 * #GObject::notify signal is emitted for each property modified while the
842 	 * object is frozen.
843 	 *
844 	 * This is necessary for accessors that modify multiple properties to prevent
845 	 * premature notification while the object is still being modified.
846 	 */
847 	public void freezeNotify()
848 	{
849 		g_object_freeze_notify(gObject);
850 	}
851 
852 	/**
853 	 * Gets a named field from the objects table of associations (see g_object_set_data()).
854 	 *
855 	 * Params:
856 	 *     key = name of the key for that association
857 	 *
858 	 * Returns: the data if found,
859 	 *     or %NULL if no such data exists.
860 	 */
861 	public void* getData(string key)
862 	{
863 		return g_object_get_data(gObject, Str.toStringz(key));
864 	}
865 
866 	/**
867 	 * Gets a property of an object. @value must have been initialized to the
868 	 * expected type of the property (or a type to which the expected type can be
869 	 * transformed) using g_value_init().
870 	 *
871 	 * In general, a copy is made of the property contents and the caller is
872 	 * responsible for freeing the memory by calling g_value_unset().
873 	 *
874 	 * Note that g_object_get_property() is really intended for language
875 	 * bindings, g_object_get() is much more convenient for C programming.
876 	 *
877 	 * Params:
878 	 *     propertyName = the name of the property to get
879 	 *     value = return location for the property value
880 	 */
881 	public void getProperty(string propertyName, Value value)
882 	{
883 		g_object_get_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
884 	}
885 
886 	/**
887 	 * This function gets back user data pointers stored via
888 	 * g_object_set_qdata().
889 	 *
890 	 * Params:
891 	 *     quark = A #GQuark, naming the user data pointer
892 	 *
893 	 * Returns: The user data pointer set, or %NULL
894 	 */
895 	public void* getQdata(GQuark quark)
896 	{
897 		return g_object_get_qdata(gObject, quark);
898 	}
899 
900 	/**
901 	 * Gets properties of an object.
902 	 *
903 	 * In general, a copy is made of the property contents and the caller
904 	 * is responsible for freeing the memory in the appropriate manner for
905 	 * the type, for instance by calling g_free() or g_object_unref().
906 	 *
907 	 * See g_object_get().
908 	 *
909 	 * Params:
910 	 *     firstPropertyName = name of the first property to get
911 	 *     varArgs = return location for the first property, followed optionally by more
912 	 *         name/return location pairs, followed by %NULL
913 	 */
914 	public void getValist(string firstPropertyName, void* varArgs)
915 	{
916 		g_object_get_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
917 	}
918 
919 	/**
920 	 * Gets @n_properties properties for an @object.
921 	 * Obtained properties will be set to @values. All properties must be valid.
922 	 * Warnings will be emitted and undefined behaviour may result if invalid
923 	 * properties are passed in.
924 	 *
925 	 * Params:
926 	 *     names = the names of each property to get
927 	 *     values = the values of each property to get
928 	 *
929 	 * Since: 2.54
930 	 */
931 	public void getv(string[] names, Value[] values)
932 	{
933 		GValue[] valuesArray = new GValue[values.length];
934 		for ( int i = 0; i < values.length; i++ )
935 		{
936 			valuesArray[i] = *(values[i].getValueStruct());
937 		}
938 
939 		g_object_getv(gObject, cast(uint)values.length, Str.toStringzArray(names), valuesArray.ptr);
940 	}
941 
942 	/**
943 	 * Checks whether @object has a [floating][floating-ref] reference.
944 	 *
945 	 * Returns: %TRUE if @object has a floating reference
946 	 *
947 	 * Since: 2.10
948 	 */
949 	public bool isFloating()
950 	{
951 		return g_object_is_floating(gObject) != 0;
952 	}
953 
954 	/**
955 	 * Emits a "notify" signal for the property @property_name on @object.
956 	 *
957 	 * When possible, eg. when signaling a property change from within the class
958 	 * that registered the property, you should use g_object_notify_by_pspec()
959 	 * instead.
960 	 *
961 	 * Note that emission of the notify signal may be blocked with
962 	 * g_object_freeze_notify(). In this case, the signal emissions are queued
963 	 * and will be emitted (in reverse order) when g_object_thaw_notify() is
964 	 * called.
965 	 *
966 	 * Params:
967 	 *     propertyName = the name of a property installed on the class of @object.
968 	 */
969 	public void notify(string propertyName)
970 	{
971 		g_object_notify(gObject, Str.toStringz(propertyName));
972 	}
973 
974 	/**
975 	 * Emits a "notify" signal for the property specified by @pspec on @object.
976 	 *
977 	 * This function omits the property name lookup, hence it is faster than
978 	 * g_object_notify().
979 	 *
980 	 * One way to avoid using g_object_notify() from within the
981 	 * class that registered the properties, and using g_object_notify_by_pspec()
982 	 * instead, is to store the GParamSpec used with
983 	 * g_object_class_install_property() inside a static array, e.g.:
984 	 *
985 	 * |[<!-- language="C" -->
986 	 * enum
987 	 * {
988 	 * PROP_0,
989 	 * PROP_FOO,
990 	 * PROP_LAST
991 	 * };
992 	 *
993 	 * static GParamSpec *properties[PROP_LAST];
994 	 *
995 	 * static void
996 	 * my_object_class_init (MyObjectClass *klass)
997 	 * {
998 	 * properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
999 	 * 0, 100,
1000 	 * 50,
1001 	 * G_PARAM_READWRITE);
1002 	 * g_object_class_install_property (gobject_class,
1003 	 * PROP_FOO,
1004 	 * properties[PROP_FOO]);
1005 	 * }
1006 	 * ]|
1007 	 *
1008 	 * and then notify a change on the "foo" property with:
1009 	 *
1010 	 * |[<!-- language="C" -->
1011 	 * g_object_notify_by_pspec (self, properties[PROP_FOO]);
1012 	 * ]|
1013 	 *
1014 	 * Params:
1015 	 *     pspec = the #GParamSpec of a property installed on the class of @object.
1016 	 *
1017 	 * Since: 2.26
1018 	 */
1019 	public void notifyByPspec(ParamSpec pspec)
1020 	{
1021 		g_object_notify_by_pspec(gObject, (pspec is null) ? null : pspec.getParamSpecStruct());
1022 	}
1023 
1024 	/**
1025 	 * Increases the reference count of @object.
1026 	 *
1027 	 * Since GLib 2.56, if `GLIB_VERSION_MAX_ALLOWED` is 2.56 or greater, the type
1028 	 * of @object will be propagated to the return type (using the GCC typeof()
1029 	 * extension), so any casting the caller needs to do on the return type must be
1030 	 * explicit.
1031 	 *
1032 	 * Returns: the same @object
1033 	 */
1034 	public ObjectG doref()
1035 	{
1036 		auto p = g_object_ref(gObject);
1037 
1038 		if(p is null)
1039 		{
1040 			return null;
1041 		}
1042 
1043 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
1044 	}
1045 
1046 	/**
1047 	 * Increase the reference count of @object, and possibly remove the
1048 	 * [floating][floating-ref] reference, if @object has a floating reference.
1049 	 *
1050 	 * In other words, if the object is floating, then this call "assumes
1051 	 * ownership" of the floating reference, converting it to a normal
1052 	 * reference by clearing the floating flag while leaving the reference
1053 	 * count unchanged.  If the object is not floating, then this call
1054 	 * adds a new normal reference increasing the reference count by one.
1055 	 *
1056 	 * Since GLib 2.56, the type of @object will be propagated to the return type
1057 	 * under the same conditions as for g_object_ref().
1058 	 *
1059 	 * Returns: @object
1060 	 *
1061 	 * Since: 2.10
1062 	 */
1063 	public ObjectG refSink()
1064 	{
1065 		auto p = g_object_ref_sink(gObject);
1066 
1067 		if(p is null)
1068 		{
1069 			return null;
1070 		}
1071 
1072 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
1073 	}
1074 
1075 	/**
1076 	 * Removes a reference added with g_object_add_toggle_ref(). The
1077 	 * reference count of the object is decreased by one.
1078 	 *
1079 	 * Params:
1080 	 *     notify = a function to call when this reference is the
1081 	 *         last reference to the object, or is no longer
1082 	 *         the last reference.
1083 	 *     data = data to pass to @notify
1084 	 *
1085 	 * Since: 2.8
1086 	 */
1087 	public void removeToggleRef(GToggleNotify notify, void* data)
1088 	{
1089 		g_object_remove_toggle_ref(gObject, notify, data);
1090 	}
1091 
1092 	/**
1093 	 * Removes a weak reference from @object that was previously added
1094 	 * using g_object_add_weak_pointer(). The @weak_pointer_location has
1095 	 * to match the one used with g_object_add_weak_pointer().
1096 	 *
1097 	 * Params:
1098 	 *     weakPointerLocation = The memory address
1099 	 *         of a pointer.
1100 	 */
1101 	public void removeWeakPointer(ref void* weakPointerLocation)
1102 	{
1103 		g_object_remove_weak_pointer(gObject, &weakPointerLocation);
1104 	}
1105 
1106 	/**
1107 	 * Compares the user data for the key @key on @object with
1108 	 * @oldval, and if they are the same, replaces @oldval with
1109 	 * @newval.
1110 	 *
1111 	 * This is like a typical atomic compare-and-exchange
1112 	 * operation, for user data on an object.
1113 	 *
1114 	 * If the previous value was replaced then ownership of the
1115 	 * old value (@oldval) is passed to the caller, including
1116 	 * the registered destroy notify for it (passed out in @old_destroy).
1117 	 * It’s up to the caller to free this as needed, which may
1118 	 * or may not include using @old_destroy as sometimes replacement
1119 	 * should not destroy the object in the normal way.
1120 	 *
1121 	 * Params:
1122 	 *     key = a string, naming the user data pointer
1123 	 *     oldval = the old value to compare against
1124 	 *     newval = the new value
1125 	 *     destroy = a destroy notify for the new value
1126 	 *     oldDestroy = destroy notify for the existing value
1127 	 *
1128 	 * Returns: %TRUE if the existing value for @key was replaced
1129 	 *     by @newval, %FALSE otherwise.
1130 	 *
1131 	 * Since: 2.34
1132 	 */
1133 	public bool replaceData(string key, void* oldval, void* newval, GDestroyNotify destroy, out GDestroyNotify oldDestroy)
1134 	{
1135 		return g_object_replace_data(gObject, Str.toStringz(key), oldval, newval, destroy, &oldDestroy) != 0;
1136 	}
1137 
1138 	/**
1139 	 * Compares the user data for the key @quark on @object with
1140 	 * @oldval, and if they are the same, replaces @oldval with
1141 	 * @newval.
1142 	 *
1143 	 * This is like a typical atomic compare-and-exchange
1144 	 * operation, for user data on an object.
1145 	 *
1146 	 * If the previous value was replaced then ownership of the
1147 	 * old value (@oldval) is passed to the caller, including
1148 	 * the registered destroy notify for it (passed out in @old_destroy).
1149 	 * It’s up to the caller to free this as needed, which may
1150 	 * or may not include using @old_destroy as sometimes replacement
1151 	 * should not destroy the object in the normal way.
1152 	 *
1153 	 * Params:
1154 	 *     quark = a #GQuark, naming the user data pointer
1155 	 *     oldval = the old value to compare against
1156 	 *     newval = the new value
1157 	 *     destroy = a destroy notify for the new value
1158 	 *     oldDestroy = destroy notify for the existing value
1159 	 *
1160 	 * Returns: %TRUE if the existing value for @quark was replaced
1161 	 *     by @newval, %FALSE otherwise.
1162 	 *
1163 	 * Since: 2.34
1164 	 */
1165 	public bool replaceQdata(GQuark quark, void* oldval, void* newval, GDestroyNotify destroy, out GDestroyNotify oldDestroy)
1166 	{
1167 		return g_object_replace_qdata(gObject, quark, oldval, newval, destroy, &oldDestroy) != 0;
1168 	}
1169 
1170 	/**
1171 	 * Releases all references to other objects. This can be used to break
1172 	 * reference cycles.
1173 	 *
1174 	 * This function should only be called from object system implementations.
1175 	 */
1176 	public void runDispose()
1177 	{
1178 		g_object_run_dispose(gObject);
1179 	}
1180 
1181 	/**
1182 	 * Each object carries around a table of associations from
1183 	 * strings to pointers.  This function lets you set an association.
1184 	 *
1185 	 * If the object already had an association with that name,
1186 	 * the old association will be destroyed.
1187 	 *
1188 	 * Params:
1189 	 *     key = name of the key
1190 	 *     data = data to associate with that key
1191 	 */
1192 	public void setData(string key, void* data)
1193 	{
1194 		g_object_set_data(gObject, Str.toStringz(key), data);
1195 	}
1196 
1197 	/**
1198 	 * Like g_object_set_data() except it adds notification
1199 	 * for when the association is destroyed, either by setting it
1200 	 * to a different value or when the object is destroyed.
1201 	 *
1202 	 * Note that the @destroy callback is not called if @data is %NULL.
1203 	 *
1204 	 * Params:
1205 	 *     key = name of the key
1206 	 *     data = data to associate with that key
1207 	 *     destroy = function to call when the association is destroyed
1208 	 */
1209 	public void setDataFull(string key, void* data, GDestroyNotify destroy)
1210 	{
1211 		g_object_set_data_full(gObject, Str.toStringz(key), data, destroy);
1212 	}
1213 
1214 	/**
1215 	 * Sets a property on an object.
1216 	 *
1217 	 * Params:
1218 	 *     propertyName = the name of the property to set
1219 	 *     value = the value
1220 	 */
1221 	public void setProperty(string propertyName, Value value)
1222 	{
1223 		g_object_set_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
1224 	}
1225 
1226 	/**
1227 	 * This sets an opaque, named pointer on an object.
1228 	 * The name is specified through a #GQuark (retrived e.g. via
1229 	 * g_quark_from_static_string()), and the pointer
1230 	 * can be gotten back from the @object with g_object_get_qdata()
1231 	 * until the @object is finalized.
1232 	 * Setting a previously set user data pointer, overrides (frees)
1233 	 * the old pointer set, using #NULL as pointer essentially
1234 	 * removes the data stored.
1235 	 *
1236 	 * Params:
1237 	 *     quark = A #GQuark, naming the user data pointer
1238 	 *     data = An opaque user data pointer
1239 	 */
1240 	public void setQdata(GQuark quark, void* data)
1241 	{
1242 		g_object_set_qdata(gObject, quark, data);
1243 	}
1244 
1245 	/**
1246 	 * This function works like g_object_set_qdata(), but in addition,
1247 	 * a void (*destroy) (gpointer) function may be specified which is
1248 	 * called with @data as argument when the @object is finalized, or
1249 	 * the data is being overwritten by a call to g_object_set_qdata()
1250 	 * with the same @quark.
1251 	 *
1252 	 * Params:
1253 	 *     quark = A #GQuark, naming the user data pointer
1254 	 *     data = An opaque user data pointer
1255 	 *     destroy = Function to invoke with @data as argument, when @data
1256 	 *         needs to be freed
1257 	 */
1258 	public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)
1259 	{
1260 		g_object_set_qdata_full(gObject, quark, data, destroy);
1261 	}
1262 
1263 	/**
1264 	 * Sets properties on an object.
1265 	 *
1266 	 * Params:
1267 	 *     firstPropertyName = name of the first property to set
1268 	 *     varArgs = value for the first property, followed optionally by more
1269 	 *         name/value pairs, followed by %NULL
1270 	 */
1271 	public void setValist(string firstPropertyName, void* varArgs)
1272 	{
1273 		g_object_set_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
1274 	}
1275 
1276 	/**
1277 	 * Sets @n_properties properties for an @object.
1278 	 * Properties to be set will be taken from @values. All properties must be
1279 	 * valid. Warnings will be emitted and undefined behaviour may result if invalid
1280 	 * properties are passed in.
1281 	 *
1282 	 * Params:
1283 	 *     names = the names of each property to be set
1284 	 *     values = the values of each property to be set
1285 	 *
1286 	 * Since: 2.54
1287 	 */
1288 	public void setv(string[] names, Value[] values)
1289 	{
1290 		GValue[] valuesArray = new GValue[values.length];
1291 		for ( int i = 0; i < values.length; i++ )
1292 		{
1293 			valuesArray[i] = *(values[i].getValueStruct());
1294 		}
1295 
1296 		g_object_setv(gObject, cast(uint)values.length, Str.toStringzArray(names), valuesArray.ptr);
1297 	}
1298 
1299 	/**
1300 	 * Remove a specified datum from the object's data associations,
1301 	 * without invoking the association's destroy handler.
1302 	 *
1303 	 * Params:
1304 	 *     key = name of the key
1305 	 *
1306 	 * Returns: the data if found, or %NULL
1307 	 *     if no such data exists.
1308 	 */
1309 	public void* stealData(string key)
1310 	{
1311 		return g_object_steal_data(gObject, Str.toStringz(key));
1312 	}
1313 
1314 	/**
1315 	 * This function gets back user data pointers stored via
1316 	 * g_object_set_qdata() and removes the @data from object
1317 	 * without invoking its destroy() function (if any was
1318 	 * set).
1319 	 * Usually, calling this function is only required to update
1320 	 * user data pointers with a destroy notifier, for example:
1321 	 * |[<!-- language="C" -->
1322 	 * void
1323 	 * object_add_to_user_list (GObject     *object,
1324 	 * const gchar *new_string)
1325 	 * {
1326 	 * // the quark, naming the object data
1327 	 * GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
1328 	 * // retrive the old string list
1329 	 * GList *list = g_object_steal_qdata (object, quark_string_list);
1330 	 *
1331 	 * // prepend new string
1332 	 * list = g_list_prepend (list, g_strdup (new_string));
1333 	 * // this changed 'list', so we need to set it again
1334 	 * g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
1335 	 * }
1336 	 * static void
1337 	 * free_string_list (gpointer data)
1338 	 * {
1339 	 * GList *node, *list = data;
1340 	 *
1341 	 * for (node = list; node; node = node->next)
1342 	 * g_free (node->data);
1343 	 * g_list_free (list);
1344 	 * }
1345 	 * ]|
1346 	 * Using g_object_get_qdata() in the above example, instead of
1347 	 * g_object_steal_qdata() would have left the destroy function set,
1348 	 * and thus the partial string list would have been freed upon
1349 	 * g_object_set_qdata_full().
1350 	 *
1351 	 * Params:
1352 	 *     quark = A #GQuark, naming the user data pointer
1353 	 *
1354 	 * Returns: The user data pointer set, or %NULL
1355 	 */
1356 	public void* stealQdata(GQuark quark)
1357 	{
1358 		return g_object_steal_qdata(gObject, quark);
1359 	}
1360 
1361 	/**
1362 	 * Reverts the effect of a previous call to
1363 	 * g_object_freeze_notify(). The freeze count is decreased on @object
1364 	 * and when it reaches zero, queued "notify" signals are emitted.
1365 	 *
1366 	 * Duplicate notifications for each property are squashed so that at most one
1367 	 * #GObject::notify signal is emitted for each property, in the reverse order
1368 	 * in which they have been queued.
1369 	 *
1370 	 * It is an error to call this function when the freeze count is zero.
1371 	 */
1372 	public void thawNotify()
1373 	{
1374 		g_object_thaw_notify(gObject);
1375 	}
1376 
1377 	/**
1378 	 * Decreases the reference count of @object. When its reference count
1379 	 * drops to 0, the object is finalized (i.e. its memory is freed).
1380 	 *
1381 	 * If the pointer to the #GObject may be reused in future (for example, if it is
1382 	 * an instance variable of another object), it is recommended to clear the
1383 	 * pointer to %NULL rather than retain a dangling pointer to a potentially
1384 	 * invalid #GObject instance. Use g_clear_object() for this.
1385 	 */
1386 	public void unref()
1387 	{
1388 		g_object_unref(gObject);
1389 	}
1390 
1391 	/**
1392 	 * This function essentially limits the life time of the @closure to
1393 	 * the life time of the object. That is, when the object is finalized,
1394 	 * the @closure is invalidated by calling g_closure_invalidate() on
1395 	 * it, in order to prevent invocations of the closure with a finalized
1396 	 * (nonexisting) object. Also, g_object_ref() and g_object_unref() are
1397 	 * added as marshal guards to the @closure, to ensure that an extra
1398 	 * reference count is held on @object during invocation of the
1399 	 * @closure.  Usually, this function will be called on closures that
1400 	 * use this @object as closure data.
1401 	 *
1402 	 * Params:
1403 	 *     closure = GClosure to watch
1404 	 */
1405 	public void watchClosure(Closure closure)
1406 	{
1407 		g_object_watch_closure(gObject, (closure is null) ? null : closure.getClosureStruct());
1408 	}
1409 
1410 	/**
1411 	 * Adds a weak reference callback to an object. Weak references are
1412 	 * used for notification when an object is finalized. They are called
1413 	 * "weak references" because they allow you to safely hold a pointer
1414 	 * to an object without calling g_object_ref() (g_object_ref() adds a
1415 	 * strong reference, that is, forces the object to stay alive).
1416 	 *
1417 	 * Note that the weak references created by this method are not
1418 	 * thread-safe: they cannot safely be used in one thread if the
1419 	 * object's last g_object_unref() might happen in another thread.
1420 	 * Use #GWeakRef if thread-safety is required.
1421 	 *
1422 	 * Params:
1423 	 *     notify = callback to invoke before the object is freed
1424 	 *     data = extra data to pass to notify
1425 	 */
1426 	public void weakRef(GWeakNotify notify, void* data)
1427 	{
1428 		g_object_weak_ref(gObject, notify, data);
1429 	}
1430 
1431 	/**
1432 	 * Removes a weak reference callback to an object.
1433 	 *
1434 	 * Params:
1435 	 *     notify = callback to search for
1436 	 *     data = data to search for
1437 	 */
1438 	public void weakUnref(GWeakNotify notify, void* data)
1439 	{
1440 		g_object_weak_unref(gObject, notify, data);
1441 	}
1442 
1443 	/**
1444 	 * Clears a reference to a #GObject.
1445 	 *
1446 	 * @object_ptr must not be %NULL.
1447 	 *
1448 	 * If the reference is %NULL then this function does nothing.
1449 	 * Otherwise, the reference count of the object is decreased and the
1450 	 * pointer is set to %NULL.
1451 	 *
1452 	 * A macro is also included that allows this function to be used without
1453 	 * pointer casts.
1454 	 *
1455 	 * Params:
1456 	 *     objectPtr = a pointer to a #GObject reference
1457 	 *
1458 	 * Since: 2.28
1459 	 */
1460 	public static void clearObject(ref ObjectG objectPtr)
1461 	{
1462 		GObject* outobjectPtr = objectPtr.getObjectGStruct();
1463 
1464 		g_clear_object(&outobjectPtr);
1465 
1466 		objectPtr = ObjectG.getDObject!(ObjectG)(outobjectPtr);
1467 	}
1468 }