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