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