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_int (atk_object_name_property_role
,
412 _("Accessible Role"),
413 _("The accessible role of this object"),
418 g_object_class_install_property (gobject_class
,
420 g_param_spec_int (atk_object_name_property_component_layer
,
421 _("Accessible Layer"),
422 _("The accessible layer of this object"),
427 g_object_class_install_property (gobject_class
,
429 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
430 _("Accessible MDI Value"),
431 _("The accessible MDI value of this object"),
438 * AtkObject:accessible-table-caption:
442 * Deprecated: Since 1.3. Use table-caption-object instead.
444 g_object_class_install_property (gobject_class
,
446 g_param_spec_string (atk_object_name_property_table_caption
,
447 _("Accessible Table Caption"),
448 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
452 * AtkObject:accessible-table-column-header:
454 * Accessible table column header.
456 * Deprecated: Since 2.12. Use atk_table_get_column_header() and
457 * atk_table_set_column_header() instead.
459 g_object_class_install_property (gobject_class
,
460 PROP_TABLE_COLUMN_HEADER
,
461 g_param_spec_object (atk_object_name_property_table_column_header
,
462 _("Accessible Table Column Header"),
463 _("Is used to notify that the table column header has changed"),
468 * AtkObject:accessible-table-column-description:
470 * Accessible table column description.
472 * Deprecated: Since 2.12. Use atk_table_get_column_description()
473 * and atk_table_set_column_description() instead.
475 g_object_class_install_property (gobject_class
,
476 PROP_TABLE_COLUMN_DESCRIPTION
,
477 g_param_spec_string (atk_object_name_property_table_column_description
,
478 _("Accessible Table Column Description"),
479 _("Is used to notify that the table column description has changed"),
484 * AtkObject:accessible-table-row-header:
486 * Accessible table row header.
488 * Deprecated: Since 2.12. Use atk_table_get_row_header() and
489 * atk_table_set_row_header() instead.
491 g_object_class_install_property (gobject_class
,
492 PROP_TABLE_ROW_HEADER
,
493 g_param_spec_object (atk_object_name_property_table_row_header
,
494 _("Accessible Table Row Header"),
495 _("Is used to notify that the table row header has changed"),
499 * AtkObject:accessible-table-row-description:
501 * Accessible table row description.
503 * Deprecated: Since 2.12. Use atk_table_get_row_description() and
504 * atk_table_set_row_description() instead.
506 g_object_class_install_property (gobject_class
,
507 PROP_TABLE_ROW_DESCRIPTION
,
508 g_param_spec_string (atk_object_name_property_table_row_description
,
509 _("Accessible Table Row Description"),
510 _("Is used to notify that the table row description has changed"),
513 g_object_class_install_property (gobject_class
,
515 g_param_spec_object (atk_object_name_property_table_summary
,
516 _("Accessible Table Summary"),
517 _("Is used to notify that the table summary has changed"),
520 g_object_class_install_property (gobject_class
,
521 PROP_TABLE_CAPTION_OBJECT
,
522 g_param_spec_object (atk_object_name_property_table_caption_object
,
523 _("Accessible Table Caption Object"),
524 _("Is used to notify that the table caption has changed"),
527 g_object_class_install_property (gobject_class
,
528 PROP_HYPERTEXT_NUM_LINKS
,
529 g_param_spec_int (atk_object_name_property_hypertext_num_links
,
530 _("Number of Accessible Hypertext Links"),
531 _("The number of links which the current AtkHypertext has"),
538 * AtkObject::children-changed:
539 * @atkobject: the object which received the signal.
540 * @arg1: The index of the added or removed child. The value can be
541 * -1. This is used if the value is not known by the implementor
542 * when the child is added/removed or irrelevant.
543 * @arg2: A gpointer to the child AtkObject which was added or
544 * removed. If the child was removed, it is possible that it is not
545 * available for the implementor. In that case this pointer can be
548 * The signal "children-changed" is emitted when a child is added or
549 * removed form an object. It supports two details: "add" and
552 atk_object_signals
[CHILDREN_CHANGED
] =
553 g_signal_new ("children_changed",
554 G_TYPE_FROM_CLASS (klass
),
555 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
556 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
558 g_cclosure_marshal_VOID__UINT_POINTER
,
560 2, G_TYPE_UINT
, G_TYPE_POINTER
);
563 * AtkObject::focus-event:
564 * @atkobject: the object which received the signal
565 * @arg1: a boolean value which indicates whether the object gained
568 * The signal "focus-event" is emitted when an object gained or lost
571 * Deprecated: Since 2.9.4. Use #AtkObject::state-change signal instead.
573 atk_object_signals
[FOCUS_EVENT
] =
574 g_signal_new ("focus_event",
575 G_TYPE_FROM_CLASS (klass
),
577 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
579 g_cclosure_marshal_VOID__BOOLEAN
,
583 * AtkObject::property-change:
584 * @atkobject: the object which received the signal.
585 * @arg1: an #AtkPropertyValues containing the new value of the
586 * property which changed.
588 * The signal "property-change" is emitted when an object's property
589 * value changes. @arg1 contains an #AtkPropertyValues with the name
590 * and the new value of the property whose value has changed. Note
591 * that, as with GObject notify, getting this signal does not
592 * guarantee that the value of the property has actually changed; it
593 * may also be emitted when the setter of the property is called to
594 * reinstate the previous value.
596 * Toolkit implementor note: ATK implementors should use
597 * g_object_notify() to emit property-changed
598 * notifications. #AtkObject::property-changed is needed by the
599 * implementation of atk_add_global_event_listener() because GObject
600 * notify doesn't support emission hooks.
602 atk_object_signals
[PROPERTY_CHANGE
] =
603 g_signal_new ("property_change",
604 G_TYPE_FROM_CLASS (klass
),
605 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
606 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
607 (GSignalAccumulator
) NULL
, NULL
,
608 g_cclosure_marshal_VOID__POINTER
,
613 * AtkObject::state-change:
614 * @atkobject: the object which received the signal.
615 * @arg1: The name of the state which has changed
616 * @arg2: A boolean which indicates whether the state has been set or unset.
618 * The "state-change" signal is emitted when an object's state
619 * changes. The detail value identifies the state type which has
622 atk_object_signals
[STATE_CHANGE
] =
623 g_signal_new ("state_change",
624 G_TYPE_FROM_CLASS (klass
),
625 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
626 G_STRUCT_OFFSET (AtkObjectClass
, state_change
),
627 (GSignalAccumulator
) NULL
, NULL
,
628 atk_marshal_VOID__STRING_BOOLEAN
,
634 * AtkObject::visible-data-changed:
635 * @atkobject: the object which received the signal.
637 * The "visible-data-changed" signal is emitted when the visual
638 * appearance of the object changed.
640 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
641 g_signal_new ("visible_data_changed",
642 G_TYPE_FROM_CLASS (klass
),
644 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
645 (GSignalAccumulator
) NULL
, NULL
,
646 g_cclosure_marshal_VOID__VOID
,
650 * AtkObject::active-descendant-changed:
651 * @atkobject: the object which received the signal.
652 * @arg1: the newly focused object.
654 * The "active-descendant-changed" signal is emitted by an object
655 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
656 * object in the object changes. For instance, a table will emit the
657 * signal when the cell in the table which has focus changes.
659 atk_object_signals
[ACTIVE_DESCENDANT_CHANGED
] =
660 g_signal_new ("active_descendant_changed",
661 G_TYPE_FROM_CLASS (klass
),
662 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
663 G_STRUCT_OFFSET (AtkObjectClass
, active_descendant_changed
),
665 g_cclosure_marshal_VOID__POINTER
,
671 atk_object_init (AtkObject
*accessible
,
672 AtkObjectClass
*klass
)
674 accessible
->name
= NULL
;
675 accessible
->description
= NULL
;
676 accessible
->accessible_parent
= NULL
;
677 accessible
->relation_set
= atk_relation_set_new();
678 accessible
->role
= ATK_ROLE_UNKNOWN
;
682 atk_implementor_get_type (void)
684 static GType type
= 0;
688 static const GTypeInfo typeInfo
=
690 sizeof (AtkImplementorIface
),
691 (GBaseInitFunc
) NULL
,
692 (GBaseFinalizeFunc
) NULL
,
695 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
702 * atk_object_get_name:
703 * @accessible: an #AtkObject
705 * Gets the accessible name of the accessible.
707 * Returns: a character string representing the accessible name of the object.
710 atk_object_get_name (AtkObject
*accessible
)
712 AtkObjectClass
*klass
;
714 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
716 klass
= ATK_OBJECT_GET_CLASS (accessible
);
718 return (klass
->get_name
) (accessible
);
724 * atk_object_get_description:
725 * @accessible: an #AtkObject
727 * Gets the accessible description of the accessible.
729 * Returns: a character string representing the accessible description
734 atk_object_get_description (AtkObject
*accessible
)
736 AtkObjectClass
*klass
;
738 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
740 klass
= ATK_OBJECT_GET_CLASS (accessible
);
741 if (klass
->get_description
)
742 return (klass
->get_description
) (accessible
);
748 * atk_object_get_parent:
749 * @accessible: an #AtkObject
751 * Gets the accessible parent of the accessible. By default this is
752 * the one assigned with atk_object_set_parent(), but it is assumed
753 * that ATK implementors have ways to get the parent of the object
754 * without the need of assigning it manually with
755 * atk_object_set_parent(), and will return it with this method.
757 * If you are only interested on the parent assigned with
758 * atk_object_set_parent(), use atk_object_peek_parent().
760 * Returns: (transfer none): an #AtkObject representing the accessible
761 * parent of the accessible
764 atk_object_get_parent (AtkObject
*accessible
)
766 AtkObjectClass
*klass
;
768 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
770 klass
= ATK_OBJECT_GET_CLASS (accessible
);
771 if (klass
->get_parent
)
772 return (klass
->get_parent
) (accessible
);
778 * atk_object_peek_parent:
779 * @accessible: an #AtkObject
781 * Gets the accessible parent of the accessible, if it has been
782 * manually assigned with atk_object_set_parent. Otherwise, this
783 * function returns %NULL.
785 * This method is intended as an utility for ATK implementors, and not
786 * to be exposed to accessible tools. See atk_object_get_parent() for
789 * Returns: (transfer none): an #AtkObject representing the accessible
790 * parent of the accessible if assigned
793 atk_object_peek_parent (AtkObject
*accessible
)
795 return accessible
->accessible_parent
;
799 * atk_object_get_n_accessible_children:
800 * @accessible: an #AtkObject
802 * Gets the number of accessible children of the accessible.
804 * Returns: an integer representing the number of accessible children
808 atk_object_get_n_accessible_children (AtkObject
*accessible
)
810 AtkObjectClass
*klass
;
812 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
814 klass
= ATK_OBJECT_GET_CLASS (accessible
);
815 if (klass
->get_n_children
)
816 return (klass
->get_n_children
) (accessible
);
822 * atk_object_ref_accessible_child:
823 * @accessible: an #AtkObject
824 * @i: a gint representing the position of the child, starting from 0
826 * Gets a reference to the specified accessible child of the object.
827 * The accessible children are 0-based so the first accessible child is
828 * at index 0, the second at index 1 and so on.
830 * Returns: (transfer full): an #AtkObject representing the specified
831 * accessible child of the accessible.
834 atk_object_ref_accessible_child (AtkObject
*accessible
,
837 AtkObjectClass
*klass
;
839 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
841 klass
= ATK_OBJECT_GET_CLASS (accessible
);
842 if (klass
->ref_child
)
843 return (klass
->ref_child
) (accessible
, i
);
849 * atk_object_ref_relation_set:
850 * @accessible: an #AtkObject
852 * Gets the #AtkRelationSet associated with the object.
854 * Returns: (transfer full): an #AtkRelationSet representing the relation set
858 atk_object_ref_relation_set (AtkObject
*accessible
)
860 AtkObjectClass
*klass
;
862 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
864 klass
= ATK_OBJECT_GET_CLASS (accessible
);
865 if (klass
->ref_relation_set
)
866 return (klass
->ref_relation_set
) (accessible
);
873 * @name: a character string describing the new role.
875 * Registers the role specified by @name. @name must be a meaningful
876 * name. So it should not be empty, or consisting on whitespaces.
878 * Deprecated: Since 2.12. If your application/toolkit doesn't find a
879 * suitable role for a specific object defined at #AtkRole, please
880 * submit a bug in order to add a new role to the specification.
882 * Returns: an #AtkRole for the new role if added
883 * properly. ATK_ROLE_INVALID in case of error.
886 atk_role_register (const gchar
*name
)
888 gboolean valid
= FALSE
;
890 glong length
= g_utf8_strlen (name
, -1);
892 for (i
=0; i
< length
; i
++) {
900 return ATK_ROLE_INVALID
;
903 initialize_role_names ();
905 g_ptr_array_add (role_names
, g_strdup (name
));
906 return role_names
->len
- 1;
910 * atk_object_get_role:
911 * @accessible: an #AtkObject
913 * Gets the role of the accessible.
915 * Returns: an #AtkRole which is the role of the accessible
918 atk_object_get_role (AtkObject
*accessible
)
920 AtkObjectClass
*klass
;
922 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
924 klass
= ATK_OBJECT_GET_CLASS (accessible
);
926 return (klass
->get_role
) (accessible
);
928 return ATK_ROLE_UNKNOWN
;
932 * atk_object_get_layer:
933 * @accessible: an #AtkObject
935 * Gets the layer of the accessible.
937 * Deprecated: Use atk_component_get_layer instead.
939 * Returns: an #AtkLayer which is the layer of the accessible
942 atk_object_get_layer (AtkObject
*accessible
)
944 AtkObjectClass
*klass
;
946 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
948 klass
= ATK_OBJECT_GET_CLASS (accessible
);
949 if (klass
->get_layer
)
950 return (klass
->get_layer
) (accessible
);
952 return ATK_LAYER_INVALID
;
956 * atk_object_get_mdi_zorder:
957 * @accessible: an #AtkObject
959 * Gets the zorder of the accessible. The value G_MININT will be returned
960 * if the layer of the accessible is not ATK_LAYER_MDI.
962 * Deprecated: Use atk_component_get_mdi_zorder instead.
964 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
965 * which the component is shown in relation to other components in the same
970 atk_object_get_mdi_zorder (AtkObject
*accessible
)
972 AtkObjectClass
*klass
;
974 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
976 klass
= ATK_OBJECT_GET_CLASS (accessible
);
977 if (klass
->get_mdi_zorder
)
978 return (klass
->get_mdi_zorder
) (accessible
);
984 * atk_object_ref_state_set:
985 * @accessible: an #AtkObject
987 * Gets a reference to the state set of the accessible; the caller must
988 * unreference it when it is no longer needed.
990 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
991 * set of the accessible
994 atk_object_ref_state_set (AtkObject
*accessible
)
996 AtkObjectClass
*klass
;
998 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1000 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1001 if (klass
->ref_state_set
)
1002 return (klass
->ref_state_set
) (accessible
);
1008 * atk_object_get_index_in_parent:
1009 * @accessible: an #AtkObject
1011 * Gets the 0-based index of this accessible in its parent; returns -1 if the
1012 * accessible does not have an accessible parent.
1014 * Returns: an integer which is the index of the accessible in its parent
1017 atk_object_get_index_in_parent (AtkObject
*accessible
)
1019 AtkObjectClass
*klass
;
1021 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
1023 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1024 if (klass
->get_index_in_parent
)
1025 return (klass
->get_index_in_parent
) (accessible
);
1031 * atk_object_set_name:
1032 * @accessible: an #AtkObject
1033 * @name: a character string to be set as the accessible name
1035 * Sets the accessible name of the accessible. You can't set the name
1036 * to NULL. This is reserved for the initial value. In this aspect
1037 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
1038 * a empty value you can use "".
1041 atk_object_set_name (AtkObject
*accessible
,
1044 AtkObjectClass
*klass
;
1045 gboolean notify
= FALSE
;
1047 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1048 g_return_if_fail (name
!= NULL
);
1050 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1051 if (klass
->set_name
)
1053 /* Do not notify for initial name setting. See bug 665870 */
1054 notify
= (accessible
->name
!= NULL
);
1056 (klass
->set_name
) (accessible
, name
);
1058 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
1063 * atk_object_set_description:
1064 * @accessible: an #AtkObject
1065 * @description: a character string to be set as the accessible description
1067 * Sets the accessible description of the accessible. You can't set
1068 * the description to NULL. This is reserved for the initial value. In
1069 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
1070 * the name to a empty value you can use "".
1073 atk_object_set_description (AtkObject
*accessible
,
1074 const gchar
*description
)
1076 AtkObjectClass
*klass
;
1077 gboolean notify
= FALSE
;
1079 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1080 g_return_if_fail (description
!= NULL
);
1082 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1083 if (klass
->set_description
)
1085 /* Do not notify for initial name setting. See bug 665870 */
1086 notify
= (accessible
->description
!= NULL
);
1088 (klass
->set_description
) (accessible
, description
);
1090 g_object_notify (G_OBJECT (accessible
),
1091 atk_object_name_property_description
);
1096 * atk_object_set_parent:
1097 * @accessible: an #AtkObject
1098 * @parent: an #AtkObject to be set as the accessible parent
1100 * Sets the accessible parent of the accessible. @parent can be NULL.
1103 atk_object_set_parent (AtkObject
*accessible
,
1106 AtkObjectClass
*klass
;
1108 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1110 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1111 if (klass
->set_parent
)
1113 (klass
->set_parent
) (accessible
, parent
);
1114 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
1119 * atk_object_set_role:
1120 * @accessible: an #AtkObject
1121 * @role: an #AtkRole to be set as the role
1123 * Sets the role of the accessible.
1126 atk_object_set_role (AtkObject
*accessible
,
1129 AtkObjectClass
*klass
;
1132 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1134 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1135 if (klass
->set_role
)
1137 old_role
= atk_object_get_role (accessible
);
1138 if (old_role
!= role
)
1140 (klass
->set_role
) (accessible
, role
);
1141 if (old_role
!= ATK_ROLE_UNKNOWN
)
1142 /* Do not notify for initial role setting */
1143 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
1149 * atk_object_connect_property_change_handler:
1150 * @accessible: an #AtkObject
1151 * @handler: a function to be called when a property changes its value
1153 * Deprecated: Since 2.12. Connect directly to property-change or
1156 * Returns: a #guint which is the handler id used in
1157 * atk_object_remove_property_change_handler()
1160 atk_object_connect_property_change_handler (AtkObject
*accessible
,
1161 AtkPropertyChangeHandler
*handler
)
1163 AtkObjectClass
*klass
;
1165 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
1166 g_return_val_if_fail ((handler
!= NULL
), 0);
1168 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1169 if (klass
->connect_property_change_handler
)
1170 return (klass
->connect_property_change_handler
) (accessible
, handler
);
1176 * atk_object_remove_property_change_handler:
1177 * @accessible: an #AtkObject
1178 * @handler_id: a guint which identifies the handler to be removed.
1180 * Deprecated: Since 2.12.
1182 * Removes a property change handler.
1185 atk_object_remove_property_change_handler (AtkObject
*accessible
,
1188 AtkObjectClass
*klass
;
1190 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1192 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1193 if (klass
->remove_property_change_handler
)
1194 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
1198 * atk_object_notify_state_change:
1199 * @accessible: an #AtkObject
1200 * @state: an #AtkState whose state is changed
1201 * @value: a gboolean which indicates whether the state is being set on or off
1203 * Emits a state-change signal for the specified state.
1206 atk_object_notify_state_change (AtkObject
*accessible
,
1212 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1214 name
= atk_state_type_get_name (state
);
1215 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
1216 g_quark_from_string (name
),
1221 * atk_implementor_ref_accessible:
1222 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1223 * if a non-null return value is required.
1225 * Gets a reference to an object's #AtkObject implementation, if
1226 * the object implements #AtkObjectIface
1228 * Returns: (transfer full): a reference to an object's #AtkObject
1232 atk_implementor_ref_accessible (AtkImplementor
*implementor
)
1234 AtkImplementorIface
*iface
;
1235 AtkObject
*accessible
= NULL
;
1237 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor
), NULL
);
1239 iface
= ATK_IMPLEMENTOR_GET_IFACE (implementor
);
1242 accessible
= iface
->ref_accessible (implementor
);
1244 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
1251 * atk_object_get_attributes:
1252 * @accessible: An #AtkObject.
1254 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1255 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1256 * as distinct from strongly-typed object data available via other get/set methods.
1257 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1261 * Returns: (transfer full): an #AtkAttributeSet consisting of all
1262 * explicit properties/annotations applied to the object, or an empty
1263 * set if the object has no name-value pair attributes assigned to
1264 * it. This #atkattributeset should be freed by a call to
1265 * atk_attribute_set_free().
1268 atk_object_get_attributes (AtkObject
*accessible
)
1270 AtkObjectClass
*klass
;
1272 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1274 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1275 if (klass
->get_attributes
)
1276 return (klass
->get_attributes
) (accessible
);
1282 static AtkRelationSet
*
1283 atk_object_real_ref_relation_set (AtkObject
*accessible
)
1285 g_return_val_if_fail (accessible
->relation_set
, NULL
);
1286 g_object_ref (accessible
->relation_set
);
1288 return accessible
->relation_set
;
1292 atk_object_real_set_property (GObject
*object
,
1294 const GValue
*value
,
1297 AtkObject
*accessible
;
1299 accessible
= ATK_OBJECT (object
);
1304 atk_object_set_name (accessible
, g_value_get_string (value
));
1306 case PROP_DESCRIPTION
:
1307 atk_object_set_description (accessible
, g_value_get_string (value
));
1310 atk_object_set_role (accessible
, g_value_get_int (value
));
1313 atk_object_set_parent (accessible
, g_value_get_object (value
));
1316 if (ATK_IS_VALUE (accessible
))
1317 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
1319 case PROP_TABLE_SUMMARY
:
1320 if (ATK_IS_TABLE (accessible
))
1321 atk_table_set_summary (ATK_TABLE (accessible
), g_value_get_object (value
));
1323 case PROP_TABLE_CAPTION_OBJECT
:
1324 if (ATK_IS_TABLE (accessible
))
1325 atk_table_set_caption (ATK_TABLE (accessible
), g_value_get_object (value
));
1333 atk_object_real_get_property (GObject
*object
,
1338 AtkObject
*accessible
;
1340 accessible
= ATK_OBJECT (object
);
1345 g_value_set_string (value
, atk_object_get_name (accessible
));
1347 case PROP_DESCRIPTION
:
1348 g_value_set_string (value
, atk_object_get_description (accessible
));
1351 g_value_set_int (value
, atk_object_get_role (accessible
));
1354 if (ATK_IS_COMPONENT (accessible
))
1355 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
1357 case PROP_MDI_ZORDER
:
1358 if (ATK_IS_COMPONENT (accessible
))
1359 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
1362 g_value_set_object (value
, atk_object_get_parent (accessible
));
1365 if (ATK_IS_VALUE (accessible
))
1366 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
1368 case PROP_TABLE_SUMMARY
:
1369 if (ATK_IS_TABLE (accessible
))
1370 g_value_set_object (value
, atk_table_get_summary (ATK_TABLE (accessible
)));
1372 case PROP_TABLE_CAPTION_OBJECT
:
1373 if (ATK_IS_TABLE (accessible
))
1374 g_value_set_object (value
, atk_table_get_caption (ATK_TABLE (accessible
)));
1376 case PROP_HYPERTEXT_NUM_LINKS
:
1377 if (ATK_IS_HYPERTEXT (accessible
))
1378 g_value_set_int (value
, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible
)));
1381 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
1387 atk_object_finalize (GObject
*object
)
1389 AtkObject
*accessible
;
1391 g_return_if_fail (ATK_IS_OBJECT (object
));
1393 accessible
= ATK_OBJECT (object
);
1395 g_free (accessible
->name
);
1396 g_free (accessible
->description
);
1399 * Free memory allocated for relation set if it have been allocated.
1401 if (accessible
->relation_set
)
1402 g_object_unref (accessible
->relation_set
);
1404 if (accessible
->accessible_parent
)
1405 g_object_unref (accessible
->accessible_parent
);
1407 G_OBJECT_CLASS (parent_class
)->finalize (object
);
1411 atk_object_real_get_name (AtkObject
*object
)
1413 return object
->name
;
1417 atk_object_real_get_description (AtkObject
*object
)
1419 return object
->description
;
1423 atk_object_real_get_parent (AtkObject
*object
)
1425 return atk_object_peek_parent (object
);
1429 atk_object_real_get_role (AtkObject
*object
)
1431 return object
->role
;
1435 atk_object_real_get_layer (AtkObject
*object
)
1437 return object
->layer
;
1441 atk_object_real_ref_state_set (AtkObject
*accessible
)
1443 AtkStateSet
*state_set
;
1444 AtkObject
*focus_object
;
1446 state_set
= atk_state_set_new ();
1448 focus_object
= atk_get_focus_object ();
1449 if (focus_object
== accessible
)
1450 atk_state_set_add_state (state_set
, ATK_STATE_FOCUSED
);
1456 atk_object_real_set_name (AtkObject
*object
,
1459 g_free (object
->name
);
1460 object
->name
= g_strdup (name
);
1464 atk_object_real_set_description (AtkObject
*object
,
1465 const gchar
*description
)
1467 g_free (object
->description
);
1468 object
->description
= g_strdup (description
);
1472 atk_object_real_set_parent (AtkObject
*object
,
1475 if (object
->accessible_parent
)
1476 g_object_unref (object
->accessible_parent
);
1478 object
->accessible_parent
= parent
;
1479 if (object
->accessible_parent
)
1480 g_object_ref (object
->accessible_parent
);
1484 atk_object_real_set_role (AtkObject
*object
,
1487 object
->role
= role
;
1491 * atk_object_initialize:
1492 * @accessible: a #AtkObject
1493 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1495 * This function is called when implementing subclasses of #AtkObject.
1496 * It does initialization required for the new object. It is intended
1497 * that this function should called only in the ..._new() functions used
1498 * to create an instance of a subclass of #AtkObject
1501 atk_object_initialize (AtkObject
*accessible
,
1504 AtkObjectClass
*klass
;
1506 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1508 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1509 if (klass
->initialize
)
1510 klass
->initialize (accessible
, data
);
1514 * This function is a signal handler for notify signal which gets emitted
1515 * when a property changes value.
1517 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1518 * signal which causes the user specified AtkPropertyChangeHandler
1522 atk_object_notify (GObject
*obj
,
1525 AtkPropertyValues values
= { NULL
, };
1527 g_value_init (&values
.new_value
, pspec
->value_type
);
1528 g_object_get_property (obj
, pspec
->name
, &values
.new_value
);
1529 values
.property_name
= pspec
->name
;
1530 g_signal_emit (obj
, atk_object_signals
[PROPERTY_CHANGE
],
1531 g_quark_from_string (pspec
->name
),
1533 g_value_unset (&values
.new_value
);
1537 * atk_role_get_name:
1538 * @role: The #AtkRole whose name is required
1540 * Gets the description string describing the #AtkRole @role.
1542 * Returns: the string describing the AtkRole
1545 atk_role_get_name (AtkRole role
)
1547 g_return_val_if_fail (role
>= 0, NULL
);
1550 initialize_role_names ();
1552 if (role
< role_names
->len
)
1553 return g_ptr_array_index (role_names
, role
);
1559 * atk_role_get_localized_name:
1560 * @role: The #AtkRole whose localized name is required
1562 * Gets the localized description string describing the #AtkRole @role.
1564 * Returns: the localized string describing the AtkRole
1567 atk_role_get_localized_name (AtkRole role
)
1569 _gettext_initialization ();
1571 return dgettext (GETTEXT_PACKAGE
, atk_role_get_name (role
));
1575 atk_object_real_get_object_locale (AtkObject
*object
)
1577 return setlocale (LC_MESSAGES
, NULL
);
1581 * atk_object_get_object_locale:
1582 * @accessible: an #AtkObject
1584 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1589 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1590 * locale of @accessible.
1593 atk_object_get_object_locale (AtkObject
*accessible
)
1595 AtkObjectClass
*klass
;
1597 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1599 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1600 if (klass
->get_object_locale
)
1601 return (klass
->get_object_locale
) (accessible
);
1608 * atk_role_for_name:
1609 * @name: a string which is the (non-localized) name of an ATK role.
1611 * Get the #AtkRole type corresponding to a rolew name.
1613 * Returns: the #AtkRole enumerated type corresponding to the specified name,
1614 * or #ATK_ROLE_INVALID if no matching role is found.
1617 atk_role_for_name (const gchar
*name
)
1619 AtkRole role
= ATK_ROLE_INVALID
;
1622 g_return_val_if_fail (name
, ATK_ROLE_INVALID
);
1625 initialize_role_names ();
1627 for (i
= 0; i
< role_names
->len
; i
++)
1629 gchar
*role_name
= (gchar
*)g_ptr_array_index (role_names
, i
);
1631 g_return_val_if_fail (role_name
, ATK_ROLE_INVALID
);
1633 if (strcmp (name
, role_name
) == 0)
1644 * atk_object_add_relationship:
1645 * @object: The #AtkObject to which an AtkRelation is to be added.
1646 * @relationship: The #AtkRelationType of the relation
1647 * @target: The #AtkObject which is to be the target of the relation.
1649 * Adds a relationship of the specified type with the specified target.
1651 * Returns: TRUE if the relationship is added.
1654 atk_object_add_relationship (AtkObject
*object
,
1655 AtkRelationType relationship
,
1658 AtkObject
*array
[1];
1659 AtkRelation
*relation
;
1661 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1662 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1664 if (atk_relation_set_contains_target (object
->relation_set
,
1665 relationship
, target
))
1669 relation
= atk_relation_new (array
, 1, relationship
);
1670 atk_relation_set_add (object
->relation_set
, relation
);
1671 g_object_unref (relation
);
1677 * atk_object_remove_relationship:
1678 * @object: The #AtkObject from which an AtkRelation is to be removed.
1679 * @relationship: The #AtkRelationType of the relation
1680 * @target: The #AtkObject which is the target of the relation to be removed.
1682 * Removes a relationship of the specified type with the specified target.
1684 * Returns: TRUE if the relationship is removed.
1687 atk_object_remove_relationship (AtkObject
*object
,
1688 AtkRelationType relationship
,
1691 gboolean ret
= FALSE
;
1692 AtkRelation
*relation
;
1695 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1696 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1698 relation
= atk_relation_set_get_relation_by_type (object
->relation_set
, relationship
);
1702 ret
= atk_relation_remove_target (relation
, target
);
1703 array
= atk_relation_get_target (relation
);
1704 if (!array
|| array
->len
== 0)
1705 atk_relation_set_remove (object
->relation_set
, relation
);
1711 atk_object_real_initialize (AtkObject
*accessible
,