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