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 atk.ObjectAtk;
26 
27 private import atk.RelationSet;
28 private import atk.StateSet;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gtkc.atk;
33 public  import gtkc.atktypes;
34 public  import gtkc.gdktypes;
35 private import std.algorithm;
36 
37 
38 /**
39  * This class is the primary class for accessibility support via the
40  * Accessibility ToolKit (ATK).  Objects which are instances of
41  * #AtkObject (or instances of AtkObject-derived types) are queried
42  * for properties which relate basic (and generic) properties of a UI
43  * component such as name and description.  Instances of #AtkObject
44  * may also be queried as to whether they implement other ATK
45  * interfaces (e.g. #AtkAction, #AtkComponent, etc.), as appropriate
46  * to the role which a given UI component plays in a user interface.
47  * 
48  * All UI components in an application which provide useful
49  * information or services to the user must provide corresponding
50  * #AtkObject instances on request (in GTK+, for instance, usually on
51  * a call to #gtk_widget_get_accessible ()), either via ATK support
52  * built into the toolkit for the widget class or ancestor class, or
53  * in the case of custom widgets, if the inherited #AtkObject
54  * implementation is insufficient, via instances of a new #AtkObject
55  * subclass.
56  * 
57  * See also: #AtkObjectFactory, #AtkRegistry.  (GTK+ users see also
58  * #GtkAccessible).
59  */
60 public class ObjectAtk : ObjectG
61 {
62 	/** the main Gtk struct */
63 	protected AtkObject* atkObject;
64 
65 	/** Get the main Gtk struct */
66 	public AtkObject* getObjectAtkStruct()
67 	{
68 		return atkObject;
69 	}
70 
71 	/** the main Gtk struct as a void* */
72 	protected override void* getStruct()
73 	{
74 		return cast(void*)atkObject;
75 	}
76 
77 	protected override void setStruct(GObject* obj)
78 	{
79 		atkObject = cast(AtkObject*)obj;
80 		super.setStruct(obj);
81 	}
82 
83 	/**
84 	 * Sets our main struct and passes it to the parent class.
85 	 */
86 	public this (AtkObject* atkObject, bool ownedRef = false)
87 	{
88 		this.atkObject = atkObject;
89 		super(cast(GObject*)atkObject, ownedRef);
90 	}
91 
92 
93 	/** */
94 	public static GType getType()
95 	{
96 		return atk_object_get_type();
97 	}
98 
99 	/**
100 	 * Adds a relationship of the specified type with the specified target.
101 	 *
102 	 * Params:
103 	 *     relationship = The #AtkRelationType of the relation
104 	 *     target = The #AtkObject which is to be the target of the relation.
105 	 *
106 	 * Return: TRUE if the relationship is added.
107 	 */
108 	public bool addRelationship(AtkRelationType relationship, ObjectAtk target)
109 	{
110 		return atk_object_add_relationship(atkObject, relationship, (target is null) ? null : target.getObjectAtkStruct()) != 0;
111 	}
112 
113 	/**
114 	 *
115 	 *
116 	 * Deprecated: Since 2.12. Connect directly to property-change or
117 	 * notify signals.
118 	 *
119 	 * Params:
120 	 *     handler = a function to be called when a property changes its value
121 	 *
122 	 * Return: a #guint which is the handler id used in
123 	 *     atk_object_remove_property_change_handler()
124 	 */
125 	public uint connectPropertyChangeHandler(AtkPropertyChangeHandler* handler)
126 	{
127 		return atk_object_connect_property_change_handler(atkObject, handler);
128 	}
129 
130 	/**
131 	 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
132 	 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
133 	 * as distinct from strongly-typed object data available via other get/set methods.
134 	 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
135 	 *
136 	 * Return: an #AtkAttributeSet consisting of all
137 	 *     explicit properties/annotations applied to the object, or an empty
138 	 *     set if the object has no name-value pair attributes assigned to
139 	 *     it. This #atkattributeset should be freed by a call to
140 	 *     atk_attribute_set_free().
141 	 *
142 	 * Since: 1.12
143 	 */
144 	public AtkAttributeSet* getAttributes()
145 	{
146 		return atk_object_get_attributes(atkObject);
147 	}
148 
149 	/**
150 	 * Gets the accessible description of the accessible.
151 	 *
152 	 * Return: a character string representing the accessible description
153 	 *     of the accessible.
154 	 */
155 	public string getDescription()
156 	{
157 		return Str.toString(atk_object_get_description(atkObject));
158 	}
159 
160 	/**
161 	 * Gets the 0-based index of this accessible in its parent; returns -1 if the
162 	 * accessible does not have an accessible parent.
163 	 *
164 	 * Return: an integer which is the index of the accessible in its parent
165 	 */
166 	public int getIndexInParent()
167 	{
168 		return atk_object_get_index_in_parent(atkObject);
169 	}
170 
171 	/**
172 	 * Gets the layer of the accessible.
173 	 *
174 	 * Deprecated: Use atk_component_get_layer instead.
175 	 *
176 	 * Return: an #AtkLayer which is the layer of the accessible
177 	 */
178 	public AtkLayer getLayer()
179 	{
180 		return atk_object_get_layer(atkObject);
181 	}
182 
183 	/**
184 	 * Gets the zorder of the accessible. The value G_MININT will be returned
185 	 * if the layer of the accessible is not ATK_LAYER_MDI.
186 	 *
187 	 * Deprecated: Use atk_component_get_mdi_zorder instead.
188 	 *
189 	 * Return: a gint which is the zorder of the accessible, i.e. the depth at
190 	 *     which the component is shown in relation to other components in the same
191 	 *     container.
192 	 */
193 	public int getMdiZorder()
194 	{
195 		return atk_object_get_mdi_zorder(atkObject);
196 	}
197 
198 	/**
199 	 * Gets the number of accessible children of the accessible.
200 	 *
201 	 * Return: an integer representing the number of accessible children
202 	 *     of the accessible.
203 	 */
204 	public int getNAccessibleChildren()
205 	{
206 		return atk_object_get_n_accessible_children(atkObject);
207 	}
208 
209 	/**
210 	 * Gets the accessible name of the accessible.
211 	 *
212 	 * Return: a character string representing the accessible name of the object.
213 	 */
214 	public string getName()
215 	{
216 		return Str.toString(atk_object_get_name(atkObject));
217 	}
218 
219 	/**
220 	 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
221 	 * of @accessible.
222 	 *
223 	 * Return: a UTF-8 string indicating the POSIX-style LC_MESSAGES
224 	 *     locale of @accessible.
225 	 *
226 	 * Since: 2.8
227 	 */
228 	public string getObjectLocale()
229 	{
230 		return Str.toString(atk_object_get_object_locale(atkObject));
231 	}
232 
233 	/**
234 	 * Gets the accessible parent of the accessible. By default this is
235 	 * the one assigned with atk_object_set_parent(), but it is assumed
236 	 * that ATK implementors have ways to get the parent of the object
237 	 * without the need of assigning it manually with
238 	 * atk_object_set_parent(), and will return it with this method.
239 	 *
240 	 * If you are only interested on the parent assigned with
241 	 * atk_object_set_parent(), use atk_object_peek_parent().
242 	 *
243 	 * Return: an #AtkObject representing the accessible
244 	 *     parent of the accessible
245 	 */
246 	public ObjectAtk getParent()
247 	{
248 		auto p = atk_object_get_parent(atkObject);
249 		
250 		if(p is null)
251 		{
252 			return null;
253 		}
254 		
255 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p);
256 	}
257 
258 	/**
259 	 * Gets the role of the accessible.
260 	 *
261 	 * Return: an #AtkRole which is the role of the accessible
262 	 */
263 	public AtkRole getRole()
264 	{
265 		return atk_object_get_role(atkObject);
266 	}
267 
268 	/**
269 	 * This function is called when implementing subclasses of #AtkObject.
270 	 * It does initialization required for the new object. It is intended
271 	 * that this function should called only in the ..._new() functions used
272 	 * to create an instance of a subclass of #AtkObject
273 	 *
274 	 * Params:
275 	 *     data = a #gpointer which identifies the object for which the AtkObject was created.
276 	 */
277 	public void initialize(void* data)
278 	{
279 		atk_object_initialize(atkObject, data);
280 	}
281 
282 	/**
283 	 * Emits a state-change signal for the specified state.
284 	 *
285 	 * Note that as a general rule when the state of an existing object changes,
286 	 * emitting a notification is expected.
287 	 *
288 	 * Params:
289 	 *     state = an #AtkState whose state is changed
290 	 *     value = a gboolean which indicates whether the state is being set on or off
291 	 */
292 	public void notifyStateChange(AtkState state, bool value)
293 	{
294 		atk_object_notify_state_change(atkObject, state, value);
295 	}
296 
297 	/**
298 	 * Gets the accessible parent of the accessible, if it has been
299 	 * manually assigned with atk_object_set_parent. Otherwise, this
300 	 * function returns %NULL.
301 	 *
302 	 * This method is intended as an utility for ATK implementors, and not
303 	 * to be exposed to accessible tools. See atk_object_get_parent() for
304 	 * further reference.
305 	 *
306 	 * Return: an #AtkObject representing the accessible
307 	 *     parent of the accessible if assigned
308 	 */
309 	public ObjectAtk peekParent()
310 	{
311 		auto p = atk_object_peek_parent(atkObject);
312 		
313 		if(p is null)
314 		{
315 			return null;
316 		}
317 		
318 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p);
319 	}
320 
321 	/**
322 	 * Gets a reference to the specified accessible child of the object.
323 	 * The accessible children are 0-based so the first accessible child is
324 	 * at index 0, the second at index 1 and so on.
325 	 *
326 	 * Params:
327 	 *     i = a gint representing the position of the child, starting from 0
328 	 *
329 	 * Return: an #AtkObject representing the specified
330 	 *     accessible child of the accessible.
331 	 */
332 	public ObjectAtk refAccessibleChild(int i)
333 	{
334 		auto p = atk_object_ref_accessible_child(atkObject, i);
335 		
336 		if(p is null)
337 		{
338 			return null;
339 		}
340 		
341 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p, true);
342 	}
343 
344 	/**
345 	 * Gets the #AtkRelationSet associated with the object.
346 	 *
347 	 * Return: an #AtkRelationSet representing the relation set
348 	 *     of the object.
349 	 */
350 	public RelationSet refRelationSet()
351 	{
352 		auto p = atk_object_ref_relation_set(atkObject);
353 		
354 		if(p is null)
355 		{
356 			return null;
357 		}
358 		
359 		return ObjectG.getDObject!(RelationSet)(cast(AtkRelationSet*) p, true);
360 	}
361 
362 	/**
363 	 * Gets a reference to the state set of the accessible; the caller must
364 	 * unreference it when it is no longer needed.
365 	 *
366 	 * Return: a reference to an #AtkStateSet which is the state
367 	 *     set of the accessible
368 	 */
369 	public StateSet refStateSet()
370 	{
371 		auto p = atk_object_ref_state_set(atkObject);
372 		
373 		if(p is null)
374 		{
375 			return null;
376 		}
377 		
378 		return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true);
379 	}
380 
381 	/**
382 	 *
383 	 *
384 	 * Deprecated: Since 2.12.
385 	 *
386 	 * Removes a property change handler.
387 	 *
388 	 * Params:
389 	 *     handlerId = a guint which identifies the handler to be removed.
390 	 */
391 	public void removePropertyChangeHandler(uint handlerId)
392 	{
393 		atk_object_remove_property_change_handler(atkObject, handlerId);
394 	}
395 
396 	/**
397 	 * Removes a relationship of the specified type with the specified target.
398 	 *
399 	 * Params:
400 	 *     relationship = The #AtkRelationType of the relation
401 	 *     target = The #AtkObject which is the target of the relation to be removed.
402 	 *
403 	 * Return: TRUE if the relationship is removed.
404 	 */
405 	public bool removeRelationship(AtkRelationType relationship, ObjectAtk target)
406 	{
407 		return atk_object_remove_relationship(atkObject, relationship, (target is null) ? null : target.getObjectAtkStruct()) != 0;
408 	}
409 
410 	/**
411 	 * Sets the accessible description of the accessible. You can't set
412 	 * the description to NULL. This is reserved for the initial value. In
413 	 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
414 	 * the name to a empty value you can use "".
415 	 *
416 	 * Params:
417 	 *     description = a character string to be set as the accessible description
418 	 */
419 	public void setDescription(string description)
420 	{
421 		atk_object_set_description(atkObject, Str.toStringz(description));
422 	}
423 
424 	/**
425 	 * Sets the accessible name of the accessible. You can't set the name
426 	 * to NULL. This is reserved for the initial value. In this aspect
427 	 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
428 	 * a empty value you can use "".
429 	 *
430 	 * Params:
431 	 *     name = a character string to be set as the accessible name
432 	 */
433 	public void setName(string name)
434 	{
435 		atk_object_set_name(atkObject, Str.toStringz(name));
436 	}
437 
438 	/**
439 	 * Sets the accessible parent of the accessible. @parent can be NULL.
440 	 *
441 	 * Params:
442 	 *     parent = an #AtkObject to be set as the accessible parent
443 	 */
444 	public void setParent(ObjectAtk parent)
445 	{
446 		atk_object_set_parent(atkObject, (parent is null) ? null : parent.getObjectAtkStruct());
447 	}
448 
449 	/**
450 	 * Sets the role of the accessible.
451 	 *
452 	 * Params:
453 	 *     role = an #AtkRole to be set as the role
454 	 */
455 	public void setRole(AtkRole role)
456 	{
457 		atk_object_set_role(atkObject, role);
458 	}
459 
460 	protected class OnActiveDescendantChangedDelegateWrapper
461 	{
462 		void delegate(void*, ObjectAtk) dlg;
463 		gulong handlerId;
464 		ConnectFlags flags;
465 		this(void delegate(void*, ObjectAtk) dlg, gulong handlerId, ConnectFlags flags)
466 		{
467 			this.dlg = dlg;
468 			this.handlerId = handlerId;
469 			this.flags = flags;
470 		}
471 	}
472 	protected OnActiveDescendantChangedDelegateWrapper[] onActiveDescendantChangedListeners;
473 
474 	/**
475 	 * The "active-descendant-changed" signal is emitted by an object
476 	 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
477 	 * object in the object changes. For instance, a table will emit the
478 	 * signal when the cell in the table which has focus changes.
479 	 *
480 	 * Params:
481 	 *     arg1 = the newly focused object.
482 	 */
483 	gulong addOnActiveDescendantChanged(void delegate(void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
484 	{
485 		onActiveDescendantChangedListeners ~= new OnActiveDescendantChangedDelegateWrapper(dlg, 0, connectFlags);
486 		onActiveDescendantChangedListeners[onActiveDescendantChangedListeners.length - 1].handlerId = Signals.connectData(
487 			this,
488 			"active-descendant-changed",
489 			cast(GCallback)&callBackActiveDescendantChanged,
490 			cast(void*)onActiveDescendantChangedListeners[onActiveDescendantChangedListeners.length - 1],
491 			cast(GClosureNotify)&callBackActiveDescendantChangedDestroy,
492 			connectFlags);
493 		return onActiveDescendantChangedListeners[onActiveDescendantChangedListeners.length - 1].handlerId;
494 	}
495 	
496 	extern(C) static void callBackActiveDescendantChanged(AtkObject* objectatkStruct, void* arg1,OnActiveDescendantChangedDelegateWrapper wrapper)
497 	{
498 		wrapper.dlg(arg1, wrapper.outer);
499 	}
500 	
501 	extern(C) static void callBackActiveDescendantChangedDestroy(OnActiveDescendantChangedDelegateWrapper wrapper, GClosure* closure)
502 	{
503 		wrapper.outer.internalRemoveOnActiveDescendantChanged(wrapper);
504 	}
505 
506 	protected void internalRemoveOnActiveDescendantChanged(OnActiveDescendantChangedDelegateWrapper source)
507 	{
508 		foreach(index, wrapper; onActiveDescendantChangedListeners)
509 		{
510 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
511 			{
512 				onActiveDescendantChangedListeners[index] = null;
513 				onActiveDescendantChangedListeners = std.algorithm.remove(onActiveDescendantChangedListeners, index);
514 				break;
515 			}
516 		}
517 	}
518 	
519 
520 	protected class OnChildrenChangedDelegateWrapper
521 	{
522 		void delegate(uint, void*, ObjectAtk) dlg;
523 		gulong handlerId;
524 		ConnectFlags flags;
525 		this(void delegate(uint, void*, ObjectAtk) dlg, gulong handlerId, ConnectFlags flags)
526 		{
527 			this.dlg = dlg;
528 			this.handlerId = handlerId;
529 			this.flags = flags;
530 		}
531 	}
532 	protected OnChildrenChangedDelegateWrapper[] onChildrenChangedListeners;
533 
534 	/**
535 	 * The signal "children-changed" is emitted when a child is added or
536 	 * removed form an object. It supports two details: "add" and
537 	 * "remove"
538 	 *
539 	 * Params:
540 	 *     arg1 = The index of the added or removed child. The value can be
541 	 *         -1. This is used if the value is not known by the implementor
542 	 *         when the child is added/removed or irrelevant.
543 	 *     arg2 = A gpointer to the child AtkObject which was added or
544 	 *         removed. If the child was removed, it is possible that it is not
545 	 *         available for the implementor. In that case this pointer can be
546 	 *         NULL.
547 	 */
548 	gulong addOnChildrenChanged(void delegate(uint, void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
549 	{
550 		onChildrenChangedListeners ~= new OnChildrenChangedDelegateWrapper(dlg, 0, connectFlags);
551 		onChildrenChangedListeners[onChildrenChangedListeners.length - 1].handlerId = Signals.connectData(
552 			this,
553 			"children-changed",
554 			cast(GCallback)&callBackChildrenChanged,
555 			cast(void*)onChildrenChangedListeners[onChildrenChangedListeners.length - 1],
556 			cast(GClosureNotify)&callBackChildrenChangedDestroy,
557 			connectFlags);
558 		return onChildrenChangedListeners[onChildrenChangedListeners.length - 1].handlerId;
559 	}
560 	
561 	extern(C) static void callBackChildrenChanged(AtkObject* objectatkStruct, uint arg1, void* arg2,OnChildrenChangedDelegateWrapper wrapper)
562 	{
563 		wrapper.dlg(arg1, arg2, wrapper.outer);
564 	}
565 	
566 	extern(C) static void callBackChildrenChangedDestroy(OnChildrenChangedDelegateWrapper wrapper, GClosure* closure)
567 	{
568 		wrapper.outer.internalRemoveOnChildrenChanged(wrapper);
569 	}
570 
571 	protected void internalRemoveOnChildrenChanged(OnChildrenChangedDelegateWrapper source)
572 	{
573 		foreach(index, wrapper; onChildrenChangedListeners)
574 		{
575 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
576 			{
577 				onChildrenChangedListeners[index] = null;
578 				onChildrenChangedListeners = std.algorithm.remove(onChildrenChangedListeners, index);
579 				break;
580 			}
581 		}
582 	}
583 	
584 
585 	protected class OnFocusDelegateWrapper
586 	{
587 		void delegate(bool, ObjectAtk) dlg;
588 		gulong handlerId;
589 		ConnectFlags flags;
590 		this(void delegate(bool, ObjectAtk) dlg, gulong handlerId, ConnectFlags flags)
591 		{
592 			this.dlg = dlg;
593 			this.handlerId = handlerId;
594 			this.flags = flags;
595 		}
596 	}
597 	protected OnFocusDelegateWrapper[] onFocusListeners;
598 
599 	/**
600 	 * The signal "focus-event" is emitted when an object gained or lost
601 	 * focus.
602 	 *
603 	 * Deprecated: Use the #AtkObject::state-change signal instead.
604 	 *
605 	 * Params:
606 	 *     arg1 = a boolean value which indicates whether the object gained
607 	 *         or lost focus.
608 	 */
609 	gulong addOnFocus(void delegate(bool, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
610 	{
611 		onFocusListeners ~= new OnFocusDelegateWrapper(dlg, 0, connectFlags);
612 		onFocusListeners[onFocusListeners.length - 1].handlerId = Signals.connectData(
613 			this,
614 			"focus-event",
615 			cast(GCallback)&callBackFocus,
616 			cast(void*)onFocusListeners[onFocusListeners.length - 1],
617 			cast(GClosureNotify)&callBackFocusDestroy,
618 			connectFlags);
619 		return onFocusListeners[onFocusListeners.length - 1].handlerId;
620 	}
621 	
622 	extern(C) static void callBackFocus(AtkObject* objectatkStruct, bool arg1,OnFocusDelegateWrapper wrapper)
623 	{
624 		wrapper.dlg(arg1, wrapper.outer);
625 	}
626 	
627 	extern(C) static void callBackFocusDestroy(OnFocusDelegateWrapper wrapper, GClosure* closure)
628 	{
629 		wrapper.outer.internalRemoveOnFocus(wrapper);
630 	}
631 
632 	protected void internalRemoveOnFocus(OnFocusDelegateWrapper source)
633 	{
634 		foreach(index, wrapper; onFocusListeners)
635 		{
636 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
637 			{
638 				onFocusListeners[index] = null;
639 				onFocusListeners = std.algorithm.remove(onFocusListeners, index);
640 				break;
641 			}
642 		}
643 	}
644 	
645 
646 	protected class OnPropertyChangeDelegateWrapper
647 	{
648 		void delegate(void*, ObjectAtk) dlg;
649 		gulong handlerId;
650 		ConnectFlags flags;
651 		this(void delegate(void*, ObjectAtk) dlg, gulong handlerId, ConnectFlags flags)
652 		{
653 			this.dlg = dlg;
654 			this.handlerId = handlerId;
655 			this.flags = flags;
656 		}
657 	}
658 	protected OnPropertyChangeDelegateWrapper[] onPropertyChangeListeners;
659 
660 	/**
661 	 * The signal "property-change" is emitted when an object's property
662 	 * value changes. @arg1 contains an #AtkPropertyValues with the name
663 	 * and the new value of the property whose value has changed. Note
664 	 * that, as with GObject notify, getting this signal does not
665 	 * guarantee that the value of the property has actually changed; it
666 	 * may also be emitted when the setter of the property is called to
667 	 * reinstate the previous value.
668 	 *
669 	 * Toolkit implementor note: ATK implementors should use
670 	 * g_object_notify() to emit property-changed
671 	 * notifications. #AtkObject::property-changed is needed by the
672 	 * implementation of atk_add_global_event_listener() because GObject
673 	 * notify doesn't support emission hooks.
674 	 *
675 	 * Params:
676 	 *     arg1 = an #AtkPropertyValues containing the new value of the
677 	 *         property which changed.
678 	 */
679 	gulong addOnPropertyChange(void delegate(void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
680 	{
681 		onPropertyChangeListeners ~= new OnPropertyChangeDelegateWrapper(dlg, 0, connectFlags);
682 		onPropertyChangeListeners[onPropertyChangeListeners.length - 1].handlerId = Signals.connectData(
683 			this,
684 			"property-change",
685 			cast(GCallback)&callBackPropertyChange,
686 			cast(void*)onPropertyChangeListeners[onPropertyChangeListeners.length - 1],
687 			cast(GClosureNotify)&callBackPropertyChangeDestroy,
688 			connectFlags);
689 		return onPropertyChangeListeners[onPropertyChangeListeners.length - 1].handlerId;
690 	}
691 	
692 	extern(C) static void callBackPropertyChange(AtkObject* objectatkStruct, void* arg1,OnPropertyChangeDelegateWrapper wrapper)
693 	{
694 		wrapper.dlg(arg1, wrapper.outer);
695 	}
696 	
697 	extern(C) static void callBackPropertyChangeDestroy(OnPropertyChangeDelegateWrapper wrapper, GClosure* closure)
698 	{
699 		wrapper.outer.internalRemoveOnPropertyChange(wrapper);
700 	}
701 
702 	protected void internalRemoveOnPropertyChange(OnPropertyChangeDelegateWrapper source)
703 	{
704 		foreach(index, wrapper; onPropertyChangeListeners)
705 		{
706 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
707 			{
708 				onPropertyChangeListeners[index] = null;
709 				onPropertyChangeListeners = std.algorithm.remove(onPropertyChangeListeners, index);
710 				break;
711 			}
712 		}
713 	}
714 	
715 
716 	protected class OnStateChangeDelegateWrapper
717 	{
718 		void delegate(string, bool, ObjectAtk) dlg;
719 		gulong handlerId;
720 		ConnectFlags flags;
721 		this(void delegate(string, bool, ObjectAtk) dlg, gulong handlerId, ConnectFlags flags)
722 		{
723 			this.dlg = dlg;
724 			this.handlerId = handlerId;
725 			this.flags = flags;
726 		}
727 	}
728 	protected OnStateChangeDelegateWrapper[] onStateChangeListeners;
729 
730 	/**
731 	 * The "state-change" signal is emitted when an object's state
732 	 * changes.  The detail value identifies the state type which has
733 	 * changed.
734 	 *
735 	 * Params:
736 	 *     arg1 = The name of the state which has changed
737 	 *     arg2 = A boolean which indicates whether the state has been set or unset.
738 	 */
739 	gulong addOnStateChange(void delegate(string, bool, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
740 	{
741 		onStateChangeListeners ~= new OnStateChangeDelegateWrapper(dlg, 0, connectFlags);
742 		onStateChangeListeners[onStateChangeListeners.length - 1].handlerId = Signals.connectData(
743 			this,
744 			"state-change",
745 			cast(GCallback)&callBackStateChange,
746 			cast(void*)onStateChangeListeners[onStateChangeListeners.length - 1],
747 			cast(GClosureNotify)&callBackStateChangeDestroy,
748 			connectFlags);
749 		return onStateChangeListeners[onStateChangeListeners.length - 1].handlerId;
750 	}
751 	
752 	extern(C) static void callBackStateChange(AtkObject* objectatkStruct, char* arg1, bool arg2,OnStateChangeDelegateWrapper wrapper)
753 	{
754 		wrapper.dlg(Str.toString(arg1), arg2, wrapper.outer);
755 	}
756 	
757 	extern(C) static void callBackStateChangeDestroy(OnStateChangeDelegateWrapper wrapper, GClosure* closure)
758 	{
759 		wrapper.outer.internalRemoveOnStateChange(wrapper);
760 	}
761 
762 	protected void internalRemoveOnStateChange(OnStateChangeDelegateWrapper source)
763 	{
764 		foreach(index, wrapper; onStateChangeListeners)
765 		{
766 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
767 			{
768 				onStateChangeListeners[index] = null;
769 				onStateChangeListeners = std.algorithm.remove(onStateChangeListeners, index);
770 				break;
771 			}
772 		}
773 	}
774 	
775 
776 	protected class OnVisibleDataChangedDelegateWrapper
777 	{
778 		void delegate(ObjectAtk) dlg;
779 		gulong handlerId;
780 		ConnectFlags flags;
781 		this(void delegate(ObjectAtk) dlg, gulong handlerId, ConnectFlags flags)
782 		{
783 			this.dlg = dlg;
784 			this.handlerId = handlerId;
785 			this.flags = flags;
786 		}
787 	}
788 	protected OnVisibleDataChangedDelegateWrapper[] onVisibleDataChangedListeners;
789 
790 	/**
791 	 * The "visible-data-changed" signal is emitted when the visual
792 	 * appearance of the object changed.
793 	 */
794 	gulong addOnVisibleDataChanged(void delegate(ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
795 	{
796 		onVisibleDataChangedListeners ~= new OnVisibleDataChangedDelegateWrapper(dlg, 0, connectFlags);
797 		onVisibleDataChangedListeners[onVisibleDataChangedListeners.length - 1].handlerId = Signals.connectData(
798 			this,
799 			"visible-data-changed",
800 			cast(GCallback)&callBackVisibleDataChanged,
801 			cast(void*)onVisibleDataChangedListeners[onVisibleDataChangedListeners.length - 1],
802 			cast(GClosureNotify)&callBackVisibleDataChangedDestroy,
803 			connectFlags);
804 		return onVisibleDataChangedListeners[onVisibleDataChangedListeners.length - 1].handlerId;
805 	}
806 	
807 	extern(C) static void callBackVisibleDataChanged(AtkObject* objectatkStruct,OnVisibleDataChangedDelegateWrapper wrapper)
808 	{
809 		wrapper.dlg(wrapper.outer);
810 	}
811 	
812 	extern(C) static void callBackVisibleDataChangedDestroy(OnVisibleDataChangedDelegateWrapper wrapper, GClosure* closure)
813 	{
814 		wrapper.outer.internalRemoveOnVisibleDataChanged(wrapper);
815 	}
816 
817 	protected void internalRemoveOnVisibleDataChanged(OnVisibleDataChangedDelegateWrapper source)
818 	{
819 		foreach(index, wrapper; onVisibleDataChangedListeners)
820 		{
821 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
822 			{
823 				onVisibleDataChangedListeners[index] = null;
824 				onVisibleDataChangedListeners = std.algorithm.remove(onVisibleDataChangedListeners, index);
825 				break;
826 			}
827 		}
828 	}
829 	
830 
831 	/**
832 	 * Get the #AtkRole type corresponding to a rolew name.
833 	 *
834 	 * Params:
835 	 *     name = a string which is the (non-localized) name of an ATK role.
836 	 *
837 	 * Return: the #AtkRole enumerated type corresponding to the specified name,
838 	 *     or #ATK_ROLE_INVALID if no matching role is found.
839 	 */
840 	public static AtkRole roleForName(string name)
841 	{
842 		return atk_role_for_name(Str.toStringz(name));
843 	}
844 
845 	/**
846 	 * Gets the localized description string describing the #AtkRole @role.
847 	 *
848 	 * Params:
849 	 *     role = The #AtkRole whose localized name is required
850 	 *
851 	 * Return: the localized string describing the AtkRole
852 	 */
853 	public static string roleGetLocalizedName(AtkRole role)
854 	{
855 		return Str.toString(atk_role_get_localized_name(role));
856 	}
857 
858 	/**
859 	 * Gets the description string describing the #AtkRole @role.
860 	 *
861 	 * Params:
862 	 *     role = The #AtkRole whose name is required
863 	 *
864 	 * Return: the string describing the AtkRole
865 	 */
866 	public static string roleGetName(AtkRole role)
867 	{
868 		return Str.toString(atk_role_get_name(role));
869 	}
870 
871 	/**
872 	 * Registers the role specified by @name. @name must be a meaningful
873 	 * name. So it should not be empty, or consisting on whitespaces.
874 	 *
875 	 * Deprecated: Since 2.12. If your application/toolkit doesn't find a
876 	 * suitable role for a specific object defined at #AtkRole, please
877 	 * submit a bug in order to add a new role to the specification.
878 	 *
879 	 * Params:
880 	 *     name = a character string describing the new role.
881 	 *
882 	 * Return: an #AtkRole for the new role if added
883 	 *     properly. ATK_ROLE_INVALID in case of error.
884 	 */
885 	public static AtkRole roleRegister(string name)
886 	{
887 		return atk_role_register(Str.toStringz(name));
888 	}
889 }