1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #include <glib-object.h>
26 #include <glib/gi18n-lib.h>
29 #include "atkmarshal.h"
30 #include "atkprivate.h"
34 * @Short_description: The base object class for the Accessibility Toolkit API.
37 * This class is the primary class for accessibility support via the
38 * Accessibility ToolKit (ATK). Objects which are instances of
39 * #AtkObject (or instances of AtkObject-derived types) are queried
40 * for properties which relate basic (and generic) properties of a UI
41 * component such as name and description. Instances of #AtkObject
42 * may also be queried as to whether they implement other ATK
43 * interfaces (e.g. #AtkAction, #AtkComponent, etc.), as appropriate
44 * to the role which a given UI component plays in a user interface.
46 * All UI components in an application which provide useful
47 * information or services to the user must provide corresponding
48 * #AtkObject instances on request (in GTK+, for instance, usually on
49 * a call to #gtk_widget_get_accessible ()), either via ATK support
50 * built into the toolkit for the widget class or ancestor class, or
51 * in the case of custom widgets, if the inherited #AtkObject
52 * implementation is insufficient, via instances of a new #AtkObject
55 * See also: #AtkObjectFactory, #AtkRegistry. (GTK+ users see also
60 static GPtrArray
*role_names
= NULL
;
64 PROP_0
, /* gobject convention */
68 PROP_PARENT
, /* ancestry has changed */
74 PROP_TABLE_COLUMN_DESCRIPTION
,
75 PROP_TABLE_COLUMN_HEADER
,
76 PROP_TABLE_ROW_DESCRIPTION
,
77 PROP_TABLE_ROW_HEADER
,
79 PROP_TABLE_CAPTION_OBJECT
,
80 PROP_HYPERTEXT_NUM_LINKS
,
81 PROP_LAST
/* gobject convention */
90 ACTIVE_DESCENDANT_CHANGED
,
95 /* These are listed here for extraction by intltool */
98 N_("accelerator label")
105 N_("check menu item")
118 /* I know it looks wrong but that is what Java returns */
142 N_("radio menu item")
154 N_("table column header")
155 N_("table row header")
156 N_("tear off menu item")
174 N_("embedded component")
182 N_("redundant object")
185 N_("input method window")
188 N_("document spreadsheet")
189 N_("document presentation")
212 N_("description list")
213 N_("description term")
214 N_("description value")
217 static void atk_object_class_init (AtkObjectClass
*klass
);
218 static void atk_object_init (AtkObject
*accessible
,
219 AtkObjectClass
*klass
);
220 static AtkRelationSet
* atk_object_real_ref_relation_set
221 (AtkObject
*accessible
);
222 static void atk_object_real_initialize (AtkObject
*accessible
,
224 static void atk_object_real_set_property (GObject
*object
,
228 static void atk_object_real_get_property (GObject
*object
,
232 static void atk_object_finalize (GObject
*object
);
233 static const gchar
* atk_object_real_get_name (AtkObject
*object
);
234 static const gchar
* atk_object_real_get_description
236 static AtkObject
* atk_object_real_get_parent (AtkObject
*object
);
237 static AtkRole
atk_object_real_get_role (AtkObject
*object
);
238 static AtkLayer
atk_object_real_get_layer (AtkObject
*object
);
239 static AtkStateSet
* atk_object_real_ref_state_set
241 static void atk_object_real_set_name (AtkObject
*object
,
243 static void atk_object_real_set_description
245 const gchar
*description
);
246 static void atk_object_real_set_parent (AtkObject
*object
,
248 static void atk_object_real_set_role (AtkObject
*object
,
250 static void atk_object_notify (GObject
*obj
,
252 static const gchar
* atk_object_real_get_object_locale
255 static guint atk_object_signals
[LAST_SIGNAL
] = { 0, };
257 static gpointer parent_class
= NULL
;
259 static const gchar
* const atk_object_name_property_name
= "accessible-name";
260 static const gchar
* const atk_object_name_property_description
= "accessible-description";
261 static const gchar
* const atk_object_name_property_parent
= "accessible-parent";
262 static const gchar
* const atk_object_name_property_value
= "accessible-value";
263 static const gchar
* const atk_object_name_property_role
= "accessible-role";
264 static const gchar
* const atk_object_name_property_component_layer
= "accessible-component-layer";
265 static const gchar
* const atk_object_name_property_component_mdi_zorder
= "accessible-component-mdi-zorder";
266 static const gchar
* const atk_object_name_property_table_caption
= "accessible-table-caption";
267 static const gchar
* const atk_object_name_property_table_column_description
= "accessible-table-column-description";
268 static const gchar
* const atk_object_name_property_table_column_header
= "accessible-table-column-header";
269 static const gchar
* const atk_object_name_property_table_row_description
= "accessible-table-row-description";
270 static const gchar
* const atk_object_name_property_table_row_header
= "accessible-table-row-header";
271 static const gchar
* const atk_object_name_property_table_summary
= "accessible-table-summary";
272 static const gchar
* const atk_object_name_property_table_caption_object
= "accessible-table-caption-object";
273 static const gchar
* const atk_object_name_property_hypertext_num_links
= "accessible-hypertext-nlinks";
276 initialize_role_names ()
278 GTypeClass
*enum_class
;
279 GEnumValue
*enum_value
;
281 gchar
*role_name
= NULL
;
286 role_names
= g_ptr_array_new ();
287 enum_class
= g_type_class_ref (ATK_TYPE_ROLE
);
288 if (!G_IS_ENUM_CLASS(enum_class
))
291 for (i
= 0; i
< ATK_ROLE_LAST_DEFINED
; i
++)
293 enum_value
= g_enum_get_value (G_ENUM_CLASS (enum_class
), i
);
294 role_name
= g_strdup (enum_value
->value_nick
);
295 // We want the role names to be in the format "check button" and not "check-button"
296 _compact_name (role_name
);
297 g_ptr_array_add (role_names
, role_name
);
300 g_type_class_unref (enum_class
);
305 atk_object_get_type (void)
307 static GType type
= 0;
311 static const GTypeInfo typeInfo
=
313 sizeof (AtkObjectClass
),
314 (GBaseInitFunc
) NULL
,
315 (GBaseFinalizeFunc
) NULL
,
316 (GClassInitFunc
) atk_object_class_init
,
317 (GClassFinalizeFunc
) NULL
,
321 (GInstanceInitFunc
) atk_object_init
,
323 type
= g_type_register_static (G_TYPE_OBJECT
, "AtkObject", &typeInfo
, 0) ;
329 atk_object_class_init (AtkObjectClass
*klass
)
331 GObjectClass
*gobject_class
= G_OBJECT_CLASS (klass
);
333 parent_class
= g_type_class_peek_parent (klass
);
335 gobject_class
->set_property
= atk_object_real_set_property
;
336 gobject_class
->get_property
= atk_object_real_get_property
;
337 gobject_class
->finalize
= atk_object_finalize
;
338 gobject_class
->notify
= atk_object_notify
;
340 klass
->get_name
= atk_object_real_get_name
;
341 klass
->get_description
= atk_object_real_get_description
;
342 klass
->get_parent
= atk_object_real_get_parent
;
343 klass
->get_n_children
= NULL
;
344 klass
->ref_child
= NULL
;
345 klass
->get_index_in_parent
= NULL
;
346 klass
->ref_relation_set
= atk_object_real_ref_relation_set
;
347 klass
->get_role
= atk_object_real_get_role
;
348 klass
->get_layer
= atk_object_real_get_layer
;
349 klass
->get_mdi_zorder
= NULL
;
350 klass
->initialize
= atk_object_real_initialize
;
351 klass
->ref_state_set
= atk_object_real_ref_state_set
;
352 klass
->set_name
= atk_object_real_set_name
;
353 klass
->set_description
= atk_object_real_set_description
;
354 klass
->set_parent
= atk_object_real_set_parent
;
355 klass
->set_role
= atk_object_real_set_role
;
356 klass
->get_object_locale
= atk_object_real_get_object_locale
;
359 * We do not define default signal handlers here
361 klass
->children_changed
= NULL
;
362 klass
->focus_event
= NULL
;
363 klass
->property_change
= NULL
;
364 klass
->visible_data_changed
= NULL
;
365 klass
->active_descendant_changed
= NULL
;
367 _gettext_initialization ();
369 g_object_class_install_property (gobject_class
,
371 g_param_spec_string (atk_object_name_property_name
,
372 _("Accessible Name"),
373 _("Object instance’s name formatted for assistive technology access"),
376 g_object_class_install_property (gobject_class
,
378 g_param_spec_string (atk_object_name_property_description
,
379 _("Accessible Description"),
380 _("Description of an object, formatted for assistive technology access"),
383 g_object_class_install_property (gobject_class
,
385 g_param_spec_object (atk_object_name_property_parent
,
386 _("Accessible Parent"),
387 _("Parent of the current accessible as returned by atk_object_get_parent()"),
392 * AtkObject:accessible-value:
394 * Numeric value of this object, in case being and AtkValue.
396 * Deprecated: Since 2.12. Use atk_value_get_value_and_text() to get
397 * the value, and value-changed signal to be notified on their value
400 g_object_class_install_property (gobject_class
,
402 g_param_spec_double (atk_object_name_property_value
,
403 _("Accessible Value"),
404 _("Is used to notify that the value has changed"),
409 g_object_class_install_property (gobject_class
,
411 g_param_spec_enum (atk_object_name_property_role
,
412 _("Accessible Role"),
413 _("The accessible role of this object"),
417 g_object_class_install_property (gobject_class
,
419 g_param_spec_int (atk_object_name_property_component_layer
,
420 _("Accessible Layer"),
421 _("The accessible layer of this object"),
426 g_object_class_install_property (gobject_class
,
428 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
429 _("Accessible MDI Value"),
430 _("The accessible MDI value of this object"),
437 * AtkObject:accessible-table-caption:
441 * Deprecated: Since 1.3. Use table-caption-object instead.
443 g_object_class_install_property (gobject_class
,
445 g_param_spec_string (atk_object_name_property_table_caption
,
446 _("Accessible Table Caption"),
447 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
451 * AtkObject:accessible-table-column-header:
453 * Accessible table column header.
455 * Deprecated: Since 2.12. Use atk_table_get_column_header() and
456 * atk_table_set_column_header() instead.
458 g_object_class_install_property (gobject_class
,
459 PROP_TABLE_COLUMN_HEADER
,
460 g_param_spec_object (atk_object_name_property_table_column_header
,
461 _("Accessible Table Column Header"),
462 _("Is used to notify that the table column header has changed"),
467 * AtkObject:accessible-table-column-description:
469 * Accessible table column description.
471 * Deprecated: Since 2.12. Use atk_table_get_column_description()
472 * and atk_table_set_column_description() instead.
474 g_object_class_install_property (gobject_class
,
475 PROP_TABLE_COLUMN_DESCRIPTION
,
476 g_param_spec_string (atk_object_name_property_table_column_description
,
477 _("Accessible Table Column Description"),
478 _("Is used to notify that the table column description has changed"),
483 * AtkObject:accessible-table-row-header:
485 * Accessible table row header.
487 * Deprecated: Since 2.12. Use atk_table_get_row_header() and
488 * atk_table_set_row_header() instead.
490 g_object_class_install_property (gobject_class
,
491 PROP_TABLE_ROW_HEADER
,
492 g_param_spec_object (atk_object_name_property_table_row_header
,
493 _("Accessible Table Row Header"),
494 _("Is used to notify that the table row header has changed"),
498 * AtkObject:accessible-table-row-description:
500 * Accessible table row description.
502 * Deprecated: Since 2.12. Use atk_table_get_row_description() and
503 * atk_table_set_row_description() instead.
505 g_object_class_install_property (gobject_class
,
506 PROP_TABLE_ROW_DESCRIPTION
,
507 g_param_spec_string (atk_object_name_property_table_row_description
,
508 _("Accessible Table Row Description"),
509 _("Is used to notify that the table row description has changed"),
512 g_object_class_install_property (gobject_class
,
514 g_param_spec_object (atk_object_name_property_table_summary
,
515 _("Accessible Table Summary"),
516 _("Is used to notify that the table summary has changed"),
519 g_object_class_install_property (gobject_class
,
520 PROP_TABLE_CAPTION_OBJECT
,
521 g_param_spec_object (atk_object_name_property_table_caption_object
,
522 _("Accessible Table Caption Object"),
523 _("Is used to notify that the table caption has changed"),
526 g_object_class_install_property (gobject_class
,
527 PROP_HYPERTEXT_NUM_LINKS
,
528 g_param_spec_int (atk_object_name_property_hypertext_num_links
,
529 _("Number of Accessible Hypertext Links"),
530 _("The number of links which the current AtkHypertext has"),
537 * AtkObject::children-changed:
538 * @atkobject: the object which received the signal.
539 * @arg1: The index of the added or removed child. The value can be
540 * -1. This is used if the value is not known by the implementor
541 * when the child is added/removed or irrelevant.
542 * @arg2: A gpointer to the child AtkObject which was added or
543 * removed. If the child was removed, it is possible that it is not
544 * available for the implementor. In that case this pointer can be
547 * The signal "children-changed" is emitted when a child is added or
548 * removed form an object. It supports two details: "add" and
551 atk_object_signals
[CHILDREN_CHANGED
] =
552 g_signal_new ("children_changed",
553 G_TYPE_FROM_CLASS (klass
),
554 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
555 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
557 g_cclosure_marshal_VOID__UINT_POINTER
,
559 2, G_TYPE_UINT
, G_TYPE_POINTER
);
562 * AtkObject::focus-event:
563 * @atkobject: the object which received the signal
564 * @arg1: a boolean value which indicates whether the object gained
567 * The signal "focus-event" is emitted when an object gained or lost
570 * Deprecated: 2.9.4: Use the #AtkObject::state-change signal instead.
572 atk_object_signals
[FOCUS_EVENT
] =
573 g_signal_new ("focus_event",
574 G_TYPE_FROM_CLASS (klass
),
576 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
578 g_cclosure_marshal_VOID__BOOLEAN
,
582 * AtkObject::property-change:
583 * @atkobject: the object which received the signal.
584 * @arg1: an #AtkPropertyValues containing the new value of the
585 * property which changed.
587 * The signal "property-change" is emitted when an object's property
588 * value changes. @arg1 contains an #AtkPropertyValues with the name
589 * and the new value of the property whose value has changed. Note
590 * that, as with GObject notify, getting this signal does not
591 * guarantee that the value of the property has actually changed; it
592 * may also be emitted when the setter of the property is called to
593 * reinstate the previous value.
595 * Toolkit implementor note: ATK implementors should use
596 * g_object_notify() to emit property-changed
597 * notifications. #AtkObject::property-changed is needed by the
598 * implementation of atk_add_global_event_listener() because GObject
599 * notify doesn't support emission hooks.
601 atk_object_signals
[PROPERTY_CHANGE
] =
602 g_signal_new ("property_change",
603 G_TYPE_FROM_CLASS (klass
),
604 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
605 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
606 (GSignalAccumulator
) NULL
, NULL
,
607 g_cclosure_marshal_VOID__POINTER
,
612 * AtkObject::state-change:
613 * @atkobject: the object which received the signal.
614 * @arg1: The name of the state which has changed
615 * @arg2: A boolean which indicates whether the state has been set or unset.
617 * The "state-change" signal is emitted when an object's state
618 * changes. The detail value identifies the state type which has
621 atk_object_signals
[STATE_CHANGE
] =
622 g_signal_new ("state_change",
623 G_TYPE_FROM_CLASS (klass
),
624 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
625 G_STRUCT_OFFSET (AtkObjectClass
, state_change
),
626 (GSignalAccumulator
) NULL
, NULL
,
627 atk_marshal_VOID__STRING_BOOLEAN
,
633 * AtkObject::visible-data-changed:
634 * @atkobject: the object which received the signal.
636 * The "visible-data-changed" signal is emitted when the visual
637 * appearance of the object changed.
639 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
640 g_signal_new ("visible_data_changed",
641 G_TYPE_FROM_CLASS (klass
),
643 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
644 (GSignalAccumulator
) NULL
, NULL
,
645 g_cclosure_marshal_VOID__VOID
,
649 * AtkObject::active-descendant-changed:
650 * @atkobject: the object which received the signal.
651 * @arg1: the newly focused object.
653 * The "active-descendant-changed" signal is emitted by an object
654 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
655 * object in the object changes. For instance, a table will emit the
656 * signal when the cell in the table which has focus changes.
658 atk_object_signals
[ACTIVE_DESCENDANT_CHANGED
] =
659 g_signal_new ("active_descendant_changed",
660 G_TYPE_FROM_CLASS (klass
),
661 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
662 G_STRUCT_OFFSET (AtkObjectClass
, active_descendant_changed
),
664 g_cclosure_marshal_VOID__POINTER
,
670 atk_object_init (AtkObject
*accessible
,
671 AtkObjectClass
*klass
)
673 accessible
->name
= NULL
;
674 accessible
->description
= NULL
;
675 accessible
->accessible_parent
= NULL
;
676 accessible
->relation_set
= atk_relation_set_new();
677 accessible
->role
= ATK_ROLE_UNKNOWN
;
681 atk_implementor_get_type (void)
683 static GType type
= 0;
687 static const GTypeInfo typeInfo
=
689 sizeof (AtkImplementorIface
),
690 (GBaseInitFunc
) NULL
,
691 (GBaseFinalizeFunc
) NULL
,
694 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
701 * atk_object_get_name:
702 * @accessible: an #AtkObject
704 * Gets the accessible name of the accessible.
706 * Returns: a character string representing the accessible name of the object.
709 atk_object_get_name (AtkObject
*accessible
)
711 AtkObjectClass
*klass
;
713 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
715 klass
= ATK_OBJECT_GET_CLASS (accessible
);
717 return (klass
->get_name
) (accessible
);
723 * atk_object_get_description:
724 * @accessible: an #AtkObject
726 * Gets the accessible description of the accessible.
728 * Returns: a character string representing the accessible description
733 atk_object_get_description (AtkObject
*accessible
)
735 AtkObjectClass
*klass
;
737 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
739 klass
= ATK_OBJECT_GET_CLASS (accessible
);
740 if (klass
->get_description
)
741 return (klass
->get_description
) (accessible
);
747 * atk_object_get_parent:
748 * @accessible: an #AtkObject
750 * Gets the accessible parent of the accessible. By default this is
751 * the one assigned with atk_object_set_parent(), but it is assumed
752 * that ATK implementors have ways to get the parent of the object
753 * without the need of assigning it manually with
754 * atk_object_set_parent(), and will return it with this method.
756 * If you are only interested on the parent assigned with
757 * atk_object_set_parent(), use atk_object_peek_parent().
759 * Returns: (transfer none): an #AtkObject representing the accessible
760 * parent of the accessible
763 atk_object_get_parent (AtkObject
*accessible
)
765 AtkObjectClass
*klass
;
767 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
769 klass
= ATK_OBJECT_GET_CLASS (accessible
);
770 if (klass
->get_parent
)
771 return (klass
->get_parent
) (accessible
);
777 * atk_object_peek_parent:
778 * @accessible: an #AtkObject
780 * Gets the accessible parent of the accessible, if it has been
781 * manually assigned with atk_object_set_parent. Otherwise, this
782 * function returns %NULL.
784 * This method is intended as an utility for ATK implementors, and not
785 * to be exposed to accessible tools. See atk_object_get_parent() for
788 * Returns: (transfer none): an #AtkObject representing the accessible
789 * parent of the accessible if assigned
792 atk_object_peek_parent (AtkObject
*accessible
)
794 return accessible
->accessible_parent
;
798 * atk_object_get_n_accessible_children:
799 * @accessible: an #AtkObject
801 * Gets the number of accessible children of the accessible.
803 * Returns: an integer representing the number of accessible children
807 atk_object_get_n_accessible_children (AtkObject
*accessible
)
809 AtkObjectClass
*klass
;
811 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
813 klass
= ATK_OBJECT_GET_CLASS (accessible
);
814 if (klass
->get_n_children
)
815 return (klass
->get_n_children
) (accessible
);
821 * atk_object_ref_accessible_child:
822 * @accessible: an #AtkObject
823 * @i: a gint representing the position of the child, starting from 0
825 * Gets a reference to the specified accessible child of the object.
826 * The accessible children are 0-based so the first accessible child is
827 * at index 0, the second at index 1 and so on.
829 * Returns: (transfer full): an #AtkObject representing the specified
830 * accessible child of the accessible.
833 atk_object_ref_accessible_child (AtkObject
*accessible
,
836 AtkObjectClass
*klass
;
838 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
840 klass
= ATK_OBJECT_GET_CLASS (accessible
);
841 if (klass
->ref_child
)
842 return (klass
->ref_child
) (accessible
, i
);
848 * atk_object_ref_relation_set:
849 * @accessible: an #AtkObject
851 * Gets the #AtkRelationSet associated with the object.
853 * Returns: (transfer full): an #AtkRelationSet representing the relation set
857 atk_object_ref_relation_set (AtkObject
*accessible
)
859 AtkObjectClass
*klass
;
861 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
863 klass
= ATK_OBJECT_GET_CLASS (accessible
);
864 if (klass
->ref_relation_set
)
865 return (klass
->ref_relation_set
) (accessible
);
872 * @name: a character string describing the new role.
874 * Registers the role specified by @name. @name must be a meaningful
875 * name. So it should not be empty, or consisting on whitespaces.
877 * Deprecated: Since 2.12. If your application/toolkit doesn't find a
878 * suitable role for a specific object defined at #AtkRole, please
879 * submit a bug in order to add a new role to the specification.
881 * Returns: an #AtkRole for the new role if added
882 * properly. ATK_ROLE_INVALID in case of error.
885 atk_role_register (const gchar
*name
)
887 gboolean valid
= FALSE
;
889 glong length
= g_utf8_strlen (name
, -1);
891 for (i
=0; i
< length
; i
++) {
899 return ATK_ROLE_INVALID
;
902 initialize_role_names ();
904 g_ptr_array_add (role_names
, g_strdup (name
));
905 return role_names
->len
- 1;
909 * atk_object_get_role:
910 * @accessible: an #AtkObject
912 * Gets the role of the accessible.
914 * Returns: an #AtkRole which is the role of the accessible
917 atk_object_get_role (AtkObject
*accessible
)
919 AtkObjectClass
*klass
;
921 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
923 klass
= ATK_OBJECT_GET_CLASS (accessible
);
925 return (klass
->get_role
) (accessible
);
927 return ATK_ROLE_UNKNOWN
;
931 * atk_object_get_layer:
932 * @accessible: an #AtkObject
934 * Gets the layer of the accessible.
936 * Deprecated: Use atk_component_get_layer instead.
938 * Returns: an #AtkLayer which is the layer of the accessible
941 atk_object_get_layer (AtkObject
*accessible
)
943 AtkObjectClass
*klass
;
945 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
947 klass
= ATK_OBJECT_GET_CLASS (accessible
);
948 if (klass
->get_layer
)
949 return (klass
->get_layer
) (accessible
);
951 return ATK_LAYER_INVALID
;
955 * atk_object_get_mdi_zorder:
956 * @accessible: an #AtkObject
958 * Gets the zorder of the accessible. The value G_MININT will be returned
959 * if the layer of the accessible is not ATK_LAYER_MDI.
961 * Deprecated: Use atk_component_get_mdi_zorder instead.
963 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
964 * which the component is shown in relation to other components in the same
969 atk_object_get_mdi_zorder (AtkObject
*accessible
)
971 AtkObjectClass
*klass
;
973 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
975 klass
= ATK_OBJECT_GET_CLASS (accessible
);
976 if (klass
->get_mdi_zorder
)
977 return (klass
->get_mdi_zorder
) (accessible
);
983 * atk_object_ref_state_set:
984 * @accessible: an #AtkObject
986 * Gets a reference to the state set of the accessible; the caller must
987 * unreference it when it is no longer needed.
989 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
990 * set of the accessible
993 atk_object_ref_state_set (AtkObject
*accessible
)
995 AtkObjectClass
*klass
;
997 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
999 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1000 if (klass
->ref_state_set
)
1001 return (klass
->ref_state_set
) (accessible
);
1007 * atk_object_get_index_in_parent:
1008 * @accessible: an #AtkObject
1010 * Gets the 0-based index of this accessible in its parent; returns -1 if the
1011 * accessible does not have an accessible parent.
1013 * Returns: an integer which is the index of the accessible in its parent
1016 atk_object_get_index_in_parent (AtkObject
*accessible
)
1018 AtkObjectClass
*klass
;
1020 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
1022 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1023 if (klass
->get_index_in_parent
)
1024 return (klass
->get_index_in_parent
) (accessible
);
1030 * atk_object_set_name:
1031 * @accessible: an #AtkObject
1032 * @name: a character string to be set as the accessible name
1034 * Sets the accessible name of the accessible. You can't set the name
1035 * to NULL. This is reserved for the initial value. In this aspect
1036 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
1037 * a empty value you can use "".
1040 atk_object_set_name (AtkObject
*accessible
,
1043 AtkObjectClass
*klass
;
1044 gboolean notify
= FALSE
;
1046 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1047 g_return_if_fail (name
!= NULL
);
1049 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1050 if (klass
->set_name
)
1052 /* Do not notify for initial name setting. See bug 665870 */
1053 notify
= (accessible
->name
!= NULL
);
1055 (klass
->set_name
) (accessible
, name
);
1057 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
1062 * atk_object_set_description:
1063 * @accessible: an #AtkObject
1064 * @description: a character string to be set as the accessible description
1066 * Sets the accessible description of the accessible. You can't set
1067 * the description to NULL. This is reserved for the initial value. In
1068 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
1069 * the name to a empty value you can use "".
1072 atk_object_set_description (AtkObject
*accessible
,
1073 const gchar
*description
)
1075 AtkObjectClass
*klass
;
1076 gboolean notify
= FALSE
;
1078 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1079 g_return_if_fail (description
!= NULL
);
1081 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1082 if (klass
->set_description
)
1084 /* Do not notify for initial name setting. See bug 665870 */
1085 notify
= (accessible
->description
!= NULL
);
1087 (klass
->set_description
) (accessible
, description
);
1089 g_object_notify (G_OBJECT (accessible
),
1090 atk_object_name_property_description
);
1095 * atk_object_set_parent:
1096 * @accessible: an #AtkObject
1097 * @parent: an #AtkObject to be set as the accessible parent
1099 * Sets the accessible parent of the accessible. @parent can be NULL.
1102 atk_object_set_parent (AtkObject
*accessible
,
1105 AtkObjectClass
*klass
;
1107 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1109 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1110 if (klass
->set_parent
)
1112 (klass
->set_parent
) (accessible
, parent
);
1113 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
1118 * atk_object_set_role:
1119 * @accessible: an #AtkObject
1120 * @role: an #AtkRole to be set as the role
1122 * Sets the role of the accessible.
1125 atk_object_set_role (AtkObject
*accessible
,
1128 AtkObjectClass
*klass
;
1131 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1133 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1134 if (klass
->set_role
)
1136 old_role
= atk_object_get_role (accessible
);
1137 if (old_role
!= role
)
1139 (klass
->set_role
) (accessible
, role
);
1140 if (old_role
!= ATK_ROLE_UNKNOWN
)
1141 /* Do not notify for initial role setting */
1142 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
1148 * atk_object_connect_property_change_handler: (skip)
1149 * @accessible: an #AtkObject
1150 * @handler: a function to be called when a property changes its value
1152 * Deprecated: Since 2.12. Connect directly to property-change or
1155 * Returns: a #guint which is the handler id used in
1156 * atk_object_remove_property_change_handler()
1159 atk_object_connect_property_change_handler (AtkObject
*accessible
,
1160 AtkPropertyChangeHandler
*handler
)
1162 AtkObjectClass
*klass
;
1164 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
1165 g_return_val_if_fail ((handler
!= NULL
), 0);
1167 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1168 if (klass
->connect_property_change_handler
)
1169 return (klass
->connect_property_change_handler
) (accessible
, handler
);
1175 * atk_object_remove_property_change_handler:
1176 * @accessible: an #AtkObject
1177 * @handler_id: a guint which identifies the handler to be removed.
1179 * Deprecated: Since 2.12.
1181 * Removes a property change handler.
1184 atk_object_remove_property_change_handler (AtkObject
*accessible
,
1187 AtkObjectClass
*klass
;
1189 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1191 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1192 if (klass
->remove_property_change_handler
)
1193 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
1197 * atk_object_notify_state_change:
1198 * @accessible: an #AtkObject
1199 * @state: an #AtkState whose state is changed
1200 * @value: a gboolean which indicates whether the state is being set on or off
1202 * Emits a state-change signal for the specified state.
1204 * Note that as a general rule when the state of an existing object changes,
1205 * emitting a notification is expected.
1208 atk_object_notify_state_change (AtkObject
*accessible
,
1214 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1216 name
= atk_state_type_get_name (state
);
1217 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
1218 g_quark_from_string (name
),
1223 * atk_implementor_ref_accessible:
1224 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1225 * if a non-null return value is required.
1227 * Gets a reference to an object's #AtkObject implementation, if
1228 * the object implements #AtkObjectIface
1230 * Returns: (transfer full): a reference to an object's #AtkObject
1234 atk_implementor_ref_accessible (AtkImplementor
*implementor
)
1236 AtkImplementorIface
*iface
;
1237 AtkObject
*accessible
= NULL
;
1239 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor
), NULL
);
1241 iface
= ATK_IMPLEMENTOR_GET_IFACE (implementor
);
1244 accessible
= iface
->ref_accessible (implementor
);
1246 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
1253 * atk_object_get_attributes:
1254 * @accessible: An #AtkObject.
1256 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1257 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1258 * as distinct from strongly-typed object data available via other get/set methods.
1259 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1263 * Returns: (transfer full): an #AtkAttributeSet consisting of all
1264 * explicit properties/annotations applied to the object, or an empty
1265 * set if the object has no name-value pair attributes assigned to
1266 * it. This #atkattributeset should be freed by a call to
1267 * atk_attribute_set_free().
1270 atk_object_get_attributes (AtkObject
*accessible
)
1272 AtkObjectClass
*klass
;
1274 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1276 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1277 if (klass
->get_attributes
)
1278 return (klass
->get_attributes
) (accessible
);
1284 static AtkRelationSet
*
1285 atk_object_real_ref_relation_set (AtkObject
*accessible
)
1287 g_return_val_if_fail (accessible
->relation_set
, NULL
);
1288 g_object_ref (accessible
->relation_set
);
1290 return accessible
->relation_set
;
1294 atk_object_real_set_property (GObject
*object
,
1296 const GValue
*value
,
1299 AtkObject
*accessible
;
1301 accessible
= ATK_OBJECT (object
);
1306 atk_object_set_name (accessible
, g_value_get_string (value
));
1308 case PROP_DESCRIPTION
:
1309 atk_object_set_description (accessible
, g_value_get_string (value
));
1312 atk_object_set_role (accessible
, g_value_get_enum (value
));
1315 atk_object_set_parent (accessible
, g_value_get_object (value
));
1318 if (ATK_IS_VALUE (accessible
))
1319 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
1321 case PROP_TABLE_SUMMARY
:
1322 if (ATK_IS_TABLE (accessible
))
1323 atk_table_set_summary (ATK_TABLE (accessible
), g_value_get_object (value
));
1325 case PROP_TABLE_CAPTION_OBJECT
:
1326 if (ATK_IS_TABLE (accessible
))
1327 atk_table_set_caption (ATK_TABLE (accessible
), g_value_get_object (value
));
1335 atk_object_real_get_property (GObject
*object
,
1340 AtkObject
*accessible
;
1342 accessible
= ATK_OBJECT (object
);
1347 g_value_set_string (value
, atk_object_get_name (accessible
));
1349 case PROP_DESCRIPTION
:
1350 g_value_set_string (value
, atk_object_get_description (accessible
));
1353 g_value_set_enum (value
, atk_object_get_role (accessible
));
1356 if (ATK_IS_COMPONENT (accessible
))
1357 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
1359 case PROP_MDI_ZORDER
:
1360 if (ATK_IS_COMPONENT (accessible
))
1361 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
1364 g_value_set_object (value
, atk_object_get_parent (accessible
));
1367 if (ATK_IS_VALUE (accessible
))
1368 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
1370 case PROP_TABLE_SUMMARY
:
1371 if (ATK_IS_TABLE (accessible
))
1372 g_value_set_object (value
, atk_table_get_summary (ATK_TABLE (accessible
)));
1374 case PROP_TABLE_CAPTION_OBJECT
:
1375 if (ATK_IS_TABLE (accessible
))
1376 g_value_set_object (value
, atk_table_get_caption (ATK_TABLE (accessible
)));
1378 case PROP_HYPERTEXT_NUM_LINKS
:
1379 if (ATK_IS_HYPERTEXT (accessible
))
1380 g_value_set_int (value
, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible
)));
1383 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
1389 atk_object_finalize (GObject
*object
)
1391 AtkObject
*accessible
;
1393 g_return_if_fail (ATK_IS_OBJECT (object
));
1395 accessible
= ATK_OBJECT (object
);
1397 g_free (accessible
->name
);
1398 g_free (accessible
->description
);
1401 * Free memory allocated for relation set if it have been allocated.
1403 if (accessible
->relation_set
)
1404 g_object_unref (accessible
->relation_set
);
1406 if (accessible
->accessible_parent
)
1407 g_object_unref (accessible
->accessible_parent
);
1409 G_OBJECT_CLASS (parent_class
)->finalize (object
);
1413 atk_object_real_get_name (AtkObject
*object
)
1415 return object
->name
;
1419 atk_object_real_get_description (AtkObject
*object
)
1421 return object
->description
;
1425 atk_object_real_get_parent (AtkObject
*object
)
1427 return atk_object_peek_parent (object
);
1431 atk_object_real_get_role (AtkObject
*object
)
1433 return object
->role
;
1437 atk_object_real_get_layer (AtkObject
*object
)
1439 return object
->layer
;
1443 atk_object_real_ref_state_set (AtkObject
*accessible
)
1445 AtkStateSet
*state_set
;
1446 AtkObject
*focus_object
;
1448 state_set
= atk_state_set_new ();
1450 focus_object
= atk_get_focus_object ();
1451 if (focus_object
== accessible
)
1452 atk_state_set_add_state (state_set
, ATK_STATE_FOCUSED
);
1458 atk_object_real_set_name (AtkObject
*object
,
1461 g_free (object
->name
);
1462 object
->name
= g_strdup (name
);
1466 atk_object_real_set_description (AtkObject
*object
,
1467 const gchar
*description
)
1469 g_free (object
->description
);
1470 object
->description
= g_strdup (description
);
1474 atk_object_real_set_parent (AtkObject
*object
,
1477 if (object
->accessible_parent
)
1478 g_object_unref (object
->accessible_parent
);
1480 object
->accessible_parent
= parent
;
1481 if (object
->accessible_parent
)
1482 g_object_ref (object
->accessible_parent
);
1486 atk_object_real_set_role (AtkObject
*object
,
1489 object
->role
= role
;
1493 * atk_object_initialize:
1494 * @accessible: a #AtkObject
1495 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1497 * This function is called when implementing subclasses of #AtkObject.
1498 * It does initialization required for the new object. It is intended
1499 * that this function should called only in the ..._new() functions used
1500 * to create an instance of a subclass of #AtkObject
1503 atk_object_initialize (AtkObject
*accessible
,
1506 AtkObjectClass
*klass
;
1508 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1510 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1511 if (klass
->initialize
)
1512 klass
->initialize (accessible
, data
);
1516 * This function is a signal handler for notify signal which gets emitted
1517 * when a property changes value.
1519 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1520 * signal which causes the user specified AtkPropertyChangeHandler
1524 atk_object_notify (GObject
*obj
,
1527 AtkPropertyValues values
= { NULL
, };
1529 g_value_init (&values
.new_value
, pspec
->value_type
);
1530 g_object_get_property (obj
, pspec
->name
, &values
.new_value
);
1531 values
.property_name
= pspec
->name
;
1532 g_signal_emit (obj
, atk_object_signals
[PROPERTY_CHANGE
],
1533 g_quark_from_string (pspec
->name
),
1535 g_value_unset (&values
.new_value
);
1539 * atk_role_get_name:
1540 * @role: The #AtkRole whose name is required
1542 * Gets the description string describing the #AtkRole @role.
1544 * Returns: the string describing the AtkRole
1547 atk_role_get_name (AtkRole role
)
1549 g_return_val_if_fail (role
>= 0, NULL
);
1552 initialize_role_names ();
1554 if (role
< role_names
->len
)
1555 return g_ptr_array_index (role_names
, role
);
1561 * atk_role_get_localized_name:
1562 * @role: The #AtkRole whose localized name is required
1564 * Gets the localized description string describing the #AtkRole @role.
1566 * Returns: the localized string describing the AtkRole
1569 atk_role_get_localized_name (AtkRole role
)
1571 _gettext_initialization ();
1573 return dgettext (GETTEXT_PACKAGE
, atk_role_get_name (role
));
1577 atk_object_real_get_object_locale (AtkObject
*object
)
1579 return setlocale (LC_MESSAGES
, NULL
);
1583 * atk_object_get_object_locale:
1584 * @accessible: an #AtkObject
1586 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1591 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1592 * locale of @accessible.
1595 atk_object_get_object_locale (AtkObject
*accessible
)
1597 AtkObjectClass
*klass
;
1599 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1601 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1602 if (klass
->get_object_locale
)
1603 return (klass
->get_object_locale
) (accessible
);
1610 * atk_role_for_name:
1611 * @name: a string which is the (non-localized) name of an ATK role.
1613 * Get the #AtkRole type corresponding to a rolew name.
1615 * Returns: the #AtkRole enumerated type corresponding to the specified name,
1616 * or #ATK_ROLE_INVALID if no matching role is found.
1619 atk_role_for_name (const gchar
*name
)
1621 AtkRole role
= ATK_ROLE_INVALID
;
1624 g_return_val_if_fail (name
, ATK_ROLE_INVALID
);
1627 initialize_role_names ();
1629 for (i
= 0; i
< role_names
->len
; i
++)
1631 gchar
*role_name
= (gchar
*)g_ptr_array_index (role_names
, i
);
1633 g_return_val_if_fail (role_name
, ATK_ROLE_INVALID
);
1635 if (strcmp (name
, role_name
) == 0)
1646 * atk_object_add_relationship:
1647 * @object: The #AtkObject to which an AtkRelation is to be added.
1648 * @relationship: The #AtkRelationType of the relation
1649 * @target: The #AtkObject which is to be the target of the relation.
1651 * Adds a relationship of the specified type with the specified target.
1653 * Returns: TRUE if the relationship is added.
1656 atk_object_add_relationship (AtkObject
*object
,
1657 AtkRelationType relationship
,
1660 AtkObject
*array
[1];
1661 AtkRelation
*relation
;
1663 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1664 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1666 if (atk_relation_set_contains_target (object
->relation_set
,
1667 relationship
, target
))
1671 relation
= atk_relation_new (array
, 1, relationship
);
1672 atk_relation_set_add (object
->relation_set
, relation
);
1673 g_object_unref (relation
);
1679 * atk_object_remove_relationship:
1680 * @object: The #AtkObject from which an AtkRelation is to be removed.
1681 * @relationship: The #AtkRelationType of the relation
1682 * @target: The #AtkObject which is the target of the relation to be removed.
1684 * Removes a relationship of the specified type with the specified target.
1686 * Returns: TRUE if the relationship is removed.
1689 atk_object_remove_relationship (AtkObject
*object
,
1690 AtkRelationType relationship
,
1693 gboolean ret
= FALSE
;
1694 AtkRelation
*relation
;
1697 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1698 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1700 relation
= atk_relation_set_get_relation_by_type (object
->relation_set
, relationship
);
1704 ret
= atk_relation_remove_target (relation
, target
);
1705 array
= atk_relation_get_target (relation
);
1706 if (!array
|| array
->len
== 0)
1707 atk_relation_set_remove (object
->relation_set
, relation
);
1713 atk_object_real_initialize (AtkObject
*accessible
,