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.
23 #include <glib-object.h>
29 #undef FOCUS_EVENT /* <windows.h> pollutes the namespace
30 * like a six hundred pound gorilla */
34 #include "atkmarshal.h"
35 #include "atk-enum-types.h"
40 * @Short_description: The base object class for the Accessibility Toolkit API.
43 * This class is the primary class for accessibility support via the
44 * Accessibility ToolKit (ATK). Objects which are instances of
45 * #AtkObject (or instances of AtkObject-derived types) are queried
46 * for properties which relate basic (and generic) properties of a UI
47 * component such as name and description. Instances of #AtkObject
48 * may also be queried as to whether they implement other ATK
49 * interfaces (e.g. #AtkAction, #AtkComponent, etc.), as appropriate
50 * to the role which a given UI component plays in a user interface.
52 * All UI components in an application which provide useful
53 * information or services to the user must provide corresponding
54 * #AtkObject instances on request (in GTK+, for instance, usually on
55 * a call to #gtk_widget_get_accessible ()), either via ATK support
56 * built into the toolkit for the widget class or ancestor class, or
57 * in the case of custom widgets, if the inherited #AtkObject
58 * implementation is insufficient, via instances of a new #AtkObject
61 * See also: #AtkObjectFactory, #AtkRegistry. (GTK+ users see also
66 static GPtrArray
*role_names
= NULL
;
70 PROP_0
, /* gobject convention */
74 PROP_PARENT
, /* ancestry has changed */
80 PROP_TABLE_COLUMN_DESCRIPTION
,
81 PROP_TABLE_COLUMN_HEADER
,
82 PROP_TABLE_ROW_DESCRIPTION
,
83 PROP_TABLE_ROW_HEADER
,
85 PROP_TABLE_CAPTION_OBJECT
,
86 PROP_HYPERTEXT_NUM_LINKS
,
87 PROP_LAST
/* gobject convention */
96 ACTIVE_DESCENDANT_CHANGED
,
101 /* These are listed here for extraction by intltool */
104 N_("accelerator label")
111 N_("check menu item")
124 /* I know it looks wrong but that is what Java returns */
148 N_("radio menu item")
160 N_("table column header")
161 N_("table row header")
162 N_("tear off menu item")
180 N_("embedded component")
188 N_("redundant object")
191 N_("input method window")
194 N_("document spreadsheet")
195 N_("document presentation")
210 static void atk_object_class_init (AtkObjectClass
*klass
);
211 static void atk_object_init (AtkObject
*accessible
,
212 AtkObjectClass
*klass
);
213 static AtkRelationSet
* atk_object_real_ref_relation_set
214 (AtkObject
*accessible
);
215 static void atk_object_real_initialize (AtkObject
*accessible
,
217 static void atk_object_real_set_property (GObject
*object
,
221 static void atk_object_real_get_property (GObject
*object
,
225 static void atk_object_finalize (GObject
*object
);
226 static const gchar
* atk_object_real_get_name (AtkObject
*object
);
227 static const gchar
* atk_object_real_get_description
229 static AtkObject
* atk_object_real_get_parent (AtkObject
*object
);
230 static AtkRole
atk_object_real_get_role (AtkObject
*object
);
231 static AtkLayer
atk_object_real_get_layer (AtkObject
*object
);
232 static AtkStateSet
* atk_object_real_ref_state_set
234 static void atk_object_real_set_name (AtkObject
*object
,
236 static void atk_object_real_set_description
238 const gchar
*description
);
239 static void atk_object_real_set_parent (AtkObject
*object
,
241 static void atk_object_real_set_role (AtkObject
*object
,
243 static guint atk_object_real_connect_property_change_handler
245 AtkPropertyChangeHandler
247 static void atk_object_real_remove_property_change_handler
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";
277 static HMODULE atk_dll
;
280 DllMain (HINSTANCE hinstDLL
,
286 case DLL_PROCESS_ATTACH
:
287 atk_dll
= (HMODULE
) hinstDLL
;
295 get_atk_locale_dir (void)
297 static gchar
*atk_localedir
= NULL
;
304 /* ATK_LOCALEDIR might end in either /lib/locale or
305 * /share/locale. Scan for that slash.
307 p
= ATK_LOCALEDIR
+ strlen (ATK_LOCALEDIR
);
313 root
= g_win32_get_package_installation_directory_of_module (atk_dll
);
314 temp
= g_build_filename (root
, p
, NULL
);
317 /* atk_localedir is passed to bindtextdomain() which isn't
320 atk_localedir
= g_win32_locale_filename_from_utf8 (temp
);
323 return atk_localedir
;
328 #define ATK_LOCALEDIR get_atk_locale_dir()
333 gettext_initialization (void)
336 static gboolean gettext_initialized
= FALSE
;
338 if (!gettext_initialized
)
340 const char *dir
= g_getenv ("ATK_ALT_LOCALEDIR");
342 gettext_initialized
= TRUE
;
346 bindtextdomain (GETTEXT_PACKAGE
, dir
);
347 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
348 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
355 compact_role_name (gchar
*role_name
)
357 gchar
*p
= role_name
;
368 initialize_role_names ()
370 GTypeClass
*enum_class
;
371 GEnumValue
*enum_value
;
373 gchar
*role_name
= NULL
;
378 role_names
= g_ptr_array_new ();
379 enum_class
= g_type_class_ref (ATK_TYPE_ROLE
);
380 if (!G_IS_ENUM_CLASS(enum_class
))
383 for (i
= 0; i
< ATK_ROLE_LAST_DEFINED
; i
++)
385 enum_value
= g_enum_get_value (G_ENUM_CLASS (enum_class
), i
);
386 role_name
= g_strdup (enum_value
->value_nick
);
387 // We want the role names to be in the format "check button" and not "check-button"
388 compact_role_name (role_name
);
389 g_ptr_array_add (role_names
, role_name
);
392 g_type_class_unref (enum_class
);
397 atk_object_get_type (void)
399 static GType type
= 0;
403 static const GTypeInfo typeInfo
=
405 sizeof (AtkObjectClass
),
406 (GBaseInitFunc
) NULL
,
407 (GBaseFinalizeFunc
) NULL
,
408 (GClassInitFunc
) atk_object_class_init
,
409 (GClassFinalizeFunc
) NULL
,
413 (GInstanceInitFunc
) atk_object_init
,
415 type
= g_type_register_static (G_TYPE_OBJECT
, "AtkObject", &typeInfo
, 0) ;
421 atk_object_class_init (AtkObjectClass
*klass
)
423 GObjectClass
*gobject_class
= G_OBJECT_CLASS (klass
);
425 parent_class
= g_type_class_peek_parent (klass
);
427 gobject_class
->set_property
= atk_object_real_set_property
;
428 gobject_class
->get_property
= atk_object_real_get_property
;
429 gobject_class
->finalize
= atk_object_finalize
;
430 gobject_class
->notify
= atk_object_notify
;
432 klass
->get_name
= atk_object_real_get_name
;
433 klass
->get_description
= atk_object_real_get_description
;
434 klass
->get_parent
= atk_object_real_get_parent
;
435 klass
->get_n_children
= NULL
;
436 klass
->ref_child
= NULL
;
437 klass
->get_index_in_parent
= NULL
;
438 klass
->ref_relation_set
= atk_object_real_ref_relation_set
;
439 klass
->get_role
= atk_object_real_get_role
;
440 klass
->get_layer
= atk_object_real_get_layer
;
441 klass
->get_mdi_zorder
= NULL
;
442 klass
->initialize
= atk_object_real_initialize
;
443 klass
->ref_state_set
= atk_object_real_ref_state_set
;
444 klass
->set_name
= atk_object_real_set_name
;
445 klass
->set_description
= atk_object_real_set_description
;
446 klass
->set_parent
= atk_object_real_set_parent
;
447 klass
->set_role
= atk_object_real_set_role
;
448 klass
->connect_property_change_handler
=
449 atk_object_real_connect_property_change_handler
;
450 klass
->remove_property_change_handler
=
451 atk_object_real_remove_property_change_handler
;
452 klass
->get_object_locale
= atk_object_real_get_object_locale
;
455 * We do not define default signal handlers here
457 klass
->children_changed
= NULL
;
458 klass
->focus_event
= NULL
;
459 klass
->property_change
= NULL
;
460 klass
->visible_data_changed
= NULL
;
461 klass
->active_descendant_changed
= NULL
;
463 gettext_initialization ();
465 g_object_class_install_property (gobject_class
,
467 g_param_spec_string (atk_object_name_property_name
,
468 _("Accessible Name"),
469 _("Object instance\'s name formatted for assistive technology access"),
472 g_object_class_install_property (gobject_class
,
474 g_param_spec_string (atk_object_name_property_description
,
475 _("Accessible Description"),
476 _("Description of an object, formatted for assistive technology access"),
479 g_object_class_install_property (gobject_class
,
481 g_param_spec_object (atk_object_name_property_parent
,
482 _("Accessible Parent"),
483 _("Is used to notify that the parent has changed"),
486 g_object_class_install_property (gobject_class
,
488 g_param_spec_double (atk_object_name_property_value
,
489 _("Accessible Value"),
490 _("Is used to notify that the value has changed"),
495 g_object_class_install_property (gobject_class
,
497 g_param_spec_int (atk_object_name_property_role
,
498 _("Accessible Role"),
499 _("The accessible role of this object"),
504 g_object_class_install_property (gobject_class
,
506 g_param_spec_int (atk_object_name_property_component_layer
,
507 _("Accessible Layer"),
508 _("The accessible layer of this object"),
513 g_object_class_install_property (gobject_class
,
515 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
516 _("Accessible MDI Value"),
517 _("The accessible MDI value of this object"),
522 g_object_class_install_property (gobject_class
,
524 g_param_spec_string (atk_object_name_property_table_caption
,
525 _("Accessible Table Caption"),
526 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
529 g_object_class_install_property (gobject_class
,
530 PROP_TABLE_COLUMN_HEADER
,
531 g_param_spec_object (atk_object_name_property_table_column_header
,
532 _("Accessible Table Column Header"),
533 _("Is used to notify that the table column header has changed"),
536 g_object_class_install_property (gobject_class
,
537 PROP_TABLE_COLUMN_DESCRIPTION
,
538 g_param_spec_string (atk_object_name_property_table_column_description
,
539 _("Accessible Table Column Description"),
540 _("Is used to notify that the table column description has changed"),
543 g_object_class_install_property (gobject_class
,
544 PROP_TABLE_ROW_HEADER
,
545 g_param_spec_object (atk_object_name_property_table_row_header
,
546 _("Accessible Table Row Header"),
547 _("Is used to notify that the table row header has changed"),
550 g_object_class_install_property (gobject_class
,
551 PROP_TABLE_ROW_DESCRIPTION
,
552 g_param_spec_string (atk_object_name_property_table_row_description
,
553 _("Accessible Table Row Description"),
554 _("Is used to notify that the table row description has changed"),
557 g_object_class_install_property (gobject_class
,
559 g_param_spec_object (atk_object_name_property_table_summary
,
560 _("Accessible Table Summary"),
561 _("Is used to notify that the table summary has changed"),
564 g_object_class_install_property (gobject_class
,
565 PROP_TABLE_CAPTION_OBJECT
,
566 g_param_spec_object (atk_object_name_property_table_caption_object
,
567 _("Accessible Table Caption Object"),
568 _("Is used to notify that the table caption has changed"),
571 g_object_class_install_property (gobject_class
,
572 PROP_HYPERTEXT_NUM_LINKS
,
573 g_param_spec_int (atk_object_name_property_hypertext_num_links
,
574 _("Number of Accessible Hypertext Links"),
575 _("The number of links which the current AtkHypertext has"),
582 * AtkObject::children-changed:
583 * @atkobject: the object which received the signal.
584 * @arg1: The index of the added or removed child. The value can be
585 * -1. This is used if the value is not known by the implementor
586 * when the child is added/removed or irrelevant.
587 * @arg2: A gpointer to the child AtkObject which was added or
588 * removed. If the child was removed, it is possible that it is not
589 * available for the implementor. In that case this pointer can be
592 * The signal "children-changed" is emitted when a child is added or
593 * removed form an object. It supports two details: "add" and
596 atk_object_signals
[CHILDREN_CHANGED
] =
597 g_signal_new ("children_changed",
598 G_TYPE_FROM_CLASS (klass
),
599 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
600 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
602 g_cclosure_marshal_VOID__UINT_POINTER
,
604 2, G_TYPE_UINT
, G_TYPE_POINTER
);
607 * AtkObject::focus-event:
608 * @atkobject: the object which received the signal
609 * @arg1: a boolean value which indicates whether the object gained
612 * The signal "focus-event" is emitted when an object gained or lost
615 * Deprecated: Since 2.9.4. Use #AtkObject::state-change signal instead.
617 atk_object_signals
[FOCUS_EVENT
] =
618 g_signal_new ("focus_event",
619 G_TYPE_FROM_CLASS (klass
),
621 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
623 g_cclosure_marshal_VOID__BOOLEAN
,
627 * AtkObject::property-change:
628 * @atkobject: the object which received the signal.
629 * @arg1: The new value of the property which changed.
631 * The signal "property-change" is emitted when an object's property
632 * value changes. The detail identifies the name of the property
633 * whose value has changed.
635 atk_object_signals
[PROPERTY_CHANGE
] =
636 g_signal_new ("property_change",
637 G_TYPE_FROM_CLASS (klass
),
638 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
639 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
640 (GSignalAccumulator
) NULL
, NULL
,
641 g_cclosure_marshal_VOID__POINTER
,
646 * AtkObject::state-change:
647 * @atkobject: the object which received the signal.
648 * @arg1: The name of the state which has changed
649 * @arg2: A boolean which indicates whether the state has been set or unset.
651 * The "state-change" signal is emitted when an object's state
652 * changes. The detail value identifies the state type which has
655 atk_object_signals
[STATE_CHANGE
] =
656 g_signal_new ("state_change",
657 G_TYPE_FROM_CLASS (klass
),
658 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
659 G_STRUCT_OFFSET (AtkObjectClass
, state_change
),
660 (GSignalAccumulator
) NULL
, NULL
,
661 atk_marshal_VOID__STRING_BOOLEAN
,
667 * AtkObject::visible-data-changed:
668 * @atkobject: the object which received the signal.
670 * The "visible-data-changed" signal is emitted when the visual
671 * appearance of the object changed.
673 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
674 g_signal_new ("visible_data_changed",
675 G_TYPE_FROM_CLASS (klass
),
677 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
678 (GSignalAccumulator
) NULL
, NULL
,
679 g_cclosure_marshal_VOID__VOID
,
683 * AtkObject::active-descendant-changed:
684 * @atkobject: the object which received the signal.
685 * @arg1: the newly focused object.
687 * The "active-descendant-changed" signal is emitted by an object
688 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
689 * object in the object changes. For instance, a table will emit the
690 * signal when the cell in the table which has focus changes.
692 atk_object_signals
[ACTIVE_DESCENDANT_CHANGED
] =
693 g_signal_new ("active_descendant_changed",
694 G_TYPE_FROM_CLASS (klass
),
695 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
696 G_STRUCT_OFFSET (AtkObjectClass
, active_descendant_changed
),
698 g_cclosure_marshal_VOID__POINTER
,
704 atk_object_init (AtkObject
*accessible
,
705 AtkObjectClass
*klass
)
707 accessible
->name
= NULL
;
708 accessible
->description
= NULL
;
709 accessible
->accessible_parent
= NULL
;
710 accessible
->relation_set
= atk_relation_set_new();
711 accessible
->role
= ATK_ROLE_UNKNOWN
;
715 atk_implementor_get_type (void)
717 static GType type
= 0;
721 static const GTypeInfo typeInfo
=
723 sizeof (AtkImplementorIface
),
724 (GBaseInitFunc
) NULL
,
725 (GBaseFinalizeFunc
) NULL
,
728 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
735 * atk_object_get_name:
736 * @accessible: an #AtkObject
738 * Gets the accessible name of the accessible.
740 * Returns: a character string representing the accessible name of the object.
743 atk_object_get_name (AtkObject
*accessible
)
745 AtkObjectClass
*klass
;
747 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
749 klass
= ATK_OBJECT_GET_CLASS (accessible
);
751 return (klass
->get_name
) (accessible
);
757 * atk_object_get_description:
758 * @accessible: an #AtkObject
760 * Gets the accessible description of the accessible.
762 * Returns: a character string representing the accessible description
767 atk_object_get_description (AtkObject
*accessible
)
769 AtkObjectClass
*klass
;
771 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
773 klass
= ATK_OBJECT_GET_CLASS (accessible
);
774 if (klass
->get_description
)
775 return (klass
->get_description
) (accessible
);
781 * atk_object_get_parent:
782 * @accessible: an #AtkObject
784 * Gets the accessible parent of the accessible.
786 * Returns: (transfer none): a #AtkObject representing the accessible parent
790 atk_object_get_parent (AtkObject
*accessible
)
792 AtkObjectClass
*klass
;
794 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
796 klass
= ATK_OBJECT_GET_CLASS (accessible
);
797 if (klass
->get_parent
)
798 return (klass
->get_parent
) (accessible
);
804 * atk_object_get_n_accessible_children:
805 * @accessible: an #AtkObject
807 * Gets the number of accessible children of the accessible.
809 * Returns: an integer representing the number of accessible children
813 atk_object_get_n_accessible_children (AtkObject
*accessible
)
815 AtkObjectClass
*klass
;
817 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
819 klass
= ATK_OBJECT_GET_CLASS (accessible
);
820 if (klass
->get_n_children
)
821 return (klass
->get_n_children
) (accessible
);
827 * atk_object_ref_accessible_child:
828 * @accessible: an #AtkObject
829 * @i: a gint representing the position of the child, starting from 0
831 * Gets a reference to the specified accessible child of the object.
832 * The accessible children are 0-based so the first accessible child is
833 * at index 0, the second at index 1 and so on.
835 * Returns: (transfer full): an #AtkObject representing the specified
836 * accessible child of the accessible.
839 atk_object_ref_accessible_child (AtkObject
*accessible
,
842 AtkObjectClass
*klass
;
844 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
846 klass
= ATK_OBJECT_GET_CLASS (accessible
);
847 if (klass
->ref_child
)
848 return (klass
->ref_child
) (accessible
, i
);
854 * atk_object_ref_relation_set:
855 * @accessible: an #AtkObject
857 * Gets the #AtkRelationSet associated with the object.
859 * Returns: (transfer full): an #AtkRelationSet representing the relation set
863 atk_object_ref_relation_set (AtkObject
*accessible
)
865 AtkObjectClass
*klass
;
867 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
869 klass
= ATK_OBJECT_GET_CLASS (accessible
);
870 if (klass
->ref_relation_set
)
871 return (klass
->ref_relation_set
) (accessible
);
878 * @name: a character string describing the new role.
880 * Registers the role specified by @name.
882 * Returns: an #AtkRole for the new role.
885 atk_role_register (const gchar
*name
)
888 initialize_role_names ();
890 g_ptr_array_add (role_names
, g_strdup (name
));
891 return role_names
->len
- 1;
895 * atk_object_get_role:
896 * @accessible: an #AtkObject
898 * Gets the role of the accessible.
900 * Returns: an #AtkRole which is the role of the accessible
903 atk_object_get_role (AtkObject
*accessible
)
905 AtkObjectClass
*klass
;
907 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
909 klass
= ATK_OBJECT_GET_CLASS (accessible
);
911 return (klass
->get_role
) (accessible
);
913 return ATK_ROLE_UNKNOWN
;
917 * atk_object_get_layer:
918 * @accessible: an #AtkObject
920 * Gets the layer of the accessible.
922 * Deprecated: Use atk_component_get_layer instead.
924 * Returns: an #AtkLayer which is the layer of the accessible
927 atk_object_get_layer (AtkObject
*accessible
)
929 AtkObjectClass
*klass
;
931 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
933 klass
= ATK_OBJECT_GET_CLASS (accessible
);
934 if (klass
->get_layer
)
935 return (klass
->get_layer
) (accessible
);
937 return ATK_LAYER_INVALID
;
941 * atk_object_get_mdi_zorder:
942 * @accessible: an #AtkObject
944 * Gets the zorder of the accessible. The value G_MININT will be returned
945 * if the layer of the accessible is not ATK_LAYER_MDI.
947 * Deprecated: Use atk_component_get_mdi_zorder instead.
949 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
950 * which the component is shown in relation to other components in the same
955 atk_object_get_mdi_zorder (AtkObject
*accessible
)
957 AtkObjectClass
*klass
;
959 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
961 klass
= ATK_OBJECT_GET_CLASS (accessible
);
962 if (klass
->get_mdi_zorder
)
963 return (klass
->get_mdi_zorder
) (accessible
);
969 * atk_object_ref_state_set:
970 * @accessible: an #AtkObject
972 * Gets a reference to the state set of the accessible; the caller must
973 * unreference it when it is no longer needed.
975 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
976 * set of the accessible
979 atk_object_ref_state_set (AtkObject
*accessible
)
981 AtkObjectClass
*klass
;
983 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
985 klass
= ATK_OBJECT_GET_CLASS (accessible
);
986 if (klass
->ref_state_set
)
987 return (klass
->ref_state_set
) (accessible
);
993 * atk_object_get_index_in_parent:
994 * @accessible: an #AtkObject
996 * Gets the 0-based index of this accessible in its parent; returns -1 if the
997 * accessible does not have an accessible parent.
999 * Returns: an integer which is the index of the accessible in its parent
1002 atk_object_get_index_in_parent (AtkObject
*accessible
)
1004 AtkObjectClass
*klass
;
1006 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
1008 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1009 if (klass
->get_index_in_parent
)
1010 return (klass
->get_index_in_parent
) (accessible
);
1016 * atk_object_set_name:
1017 * @accessible: an #AtkObject
1018 * @name: a character string to be set as the accessible name
1020 * Sets the accessible name of the accessible. You can't set the name
1021 * to NULL. This is reserved for the initial value. In this aspect
1022 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
1023 * a empty value you can use "".
1026 atk_object_set_name (AtkObject
*accessible
,
1029 AtkObjectClass
*klass
;
1030 gboolean notify
= FALSE
;
1032 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1033 g_return_if_fail (name
!= NULL
);
1035 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1036 if (klass
->set_name
)
1038 /* Do not notify for initial name setting. See bug 665870 */
1039 notify
= (accessible
->name
!= NULL
);
1041 (klass
->set_name
) (accessible
, name
);
1043 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
1048 * atk_object_set_description:
1049 * @accessible: an #AtkObject
1050 * @description: a character string to be set as the accessible description
1052 * Sets the accessible description of the accessible. You can't set
1053 * the description to NULL. This is reserved for the initial value. In
1054 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
1055 * the name to a empty value you can use "".
1058 atk_object_set_description (AtkObject
*accessible
,
1059 const gchar
*description
)
1061 AtkObjectClass
*klass
;
1062 gboolean notify
= FALSE
;
1064 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1065 g_return_if_fail (description
!= NULL
);
1067 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1068 if (klass
->set_description
)
1070 /* Do not notify for initial name setting. See bug 665870 */
1071 notify
= (accessible
->description
!= NULL
);
1073 (klass
->set_description
) (accessible
, description
);
1075 g_object_notify (G_OBJECT (accessible
),
1076 atk_object_name_property_description
);
1081 * atk_object_set_parent:
1082 * @accessible: an #AtkObject
1083 * @parent: an #AtkObject to be set as the accessible parent
1085 * Sets the accessible parent of the accessible.
1088 atk_object_set_parent (AtkObject
*accessible
,
1091 AtkObjectClass
*klass
;
1093 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1095 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1096 if (klass
->set_parent
)
1098 (klass
->set_parent
) (accessible
, parent
);
1099 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
1104 * atk_object_set_role:
1105 * @accessible: an #AtkObject
1106 * @role: an #AtkRole to be set as the role
1108 * Sets the role of the accessible.
1111 atk_object_set_role (AtkObject
*accessible
,
1114 AtkObjectClass
*klass
;
1117 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1119 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1120 if (klass
->set_role
)
1122 old_role
= atk_object_get_role (accessible
);
1123 if (old_role
!= role
)
1125 (klass
->set_role
) (accessible
, role
);
1126 if (old_role
!= ATK_ROLE_UNKNOWN
)
1127 /* Do not notify for initial role setting */
1128 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
1134 * atk_object_connect_property_change_handler:
1135 * @accessible: an #AtkObject
1136 * @handler: a function to be called when a property changes its value
1138 * Specifies a function to be called when a property changes value.
1140 * Returns: a #guint which is the handler id used in
1141 * atk_object_remove_property_change_handler()
1144 atk_object_connect_property_change_handler (AtkObject
*accessible
,
1145 AtkPropertyChangeHandler
*handler
)
1147 AtkObjectClass
*klass
;
1149 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
1150 g_return_val_if_fail ((handler
!= NULL
), 0);
1152 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1153 if (klass
->connect_property_change_handler
)
1154 return (klass
->connect_property_change_handler
) (accessible
, handler
);
1160 * atk_object_remove_property_change_handler:
1161 * @accessible: an #AtkObject
1162 * @handler_id: a guint which identifies the handler to be removed.
1164 * Removes a property change handler.
1167 atk_object_remove_property_change_handler (AtkObject
*accessible
,
1170 AtkObjectClass
*klass
;
1172 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1174 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1175 if (klass
->remove_property_change_handler
)
1176 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
1180 * atk_object_notify_state_change:
1181 * @accessible: an #AtkObject
1182 * @state: an #AtkState whose state is changed
1183 * @value: a gboolean which indicates whether the state is being set on or off
1185 * Emits a state-change signal for the specified state.
1188 atk_object_notify_state_change (AtkObject
*accessible
,
1194 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1196 name
= atk_state_type_get_name (state
);
1197 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
1198 g_quark_from_string (name
),
1203 * atk_implementor_ref_accessible:
1204 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1205 * if a non-null return value is required.
1207 * Gets a reference to an object's #AtkObject implementation, if
1208 * the object implements #AtkObjectIface
1210 * Returns: (transfer full): a reference to an object's #AtkObject
1214 atk_implementor_ref_accessible (AtkImplementor
*implementor
)
1216 AtkImplementorIface
*iface
;
1217 AtkObject
*accessible
= NULL
;
1219 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor
), NULL
);
1221 iface
= ATK_IMPLEMENTOR_GET_IFACE (implementor
);
1224 accessible
= iface
->ref_accessible (implementor
);
1226 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
1233 * atk_object_get_attributes:
1234 * @accessible: An #AtkObject.
1236 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1237 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1238 * as distinct from strongly-typed object data available via other get/set methods.
1239 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1243 * Returns: (transfer full): an #AtkAttributeSet consisting of all
1244 * explicit properties/annotations applied to the object, or an empty
1245 * set if the object has no name-value pair attributes assigned to
1246 * it. This #atkattributeset should be freed by a call to
1247 * atk_attribute_set_free().
1250 atk_object_get_attributes (AtkObject
*accessible
)
1252 AtkObjectClass
*klass
;
1254 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1256 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1257 if (klass
->get_attributes
)
1258 return (klass
->get_attributes
) (accessible
);
1264 static AtkRelationSet
*
1265 atk_object_real_ref_relation_set (AtkObject
*accessible
)
1267 g_return_val_if_fail (accessible
->relation_set
, NULL
);
1268 g_object_ref (accessible
->relation_set
);
1270 return accessible
->relation_set
;
1274 atk_object_real_set_property (GObject
*object
,
1276 const GValue
*value
,
1279 AtkObject
*accessible
;
1281 accessible
= ATK_OBJECT (object
);
1286 atk_object_set_name (accessible
, g_value_get_string (value
));
1288 case PROP_DESCRIPTION
:
1289 atk_object_set_description (accessible
, g_value_get_string (value
));
1292 atk_object_set_role (accessible
, g_value_get_int (value
));
1295 atk_object_set_parent (accessible
, g_value_get_object (value
));
1298 if (ATK_IS_VALUE (accessible
))
1299 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
1301 case PROP_TABLE_SUMMARY
:
1302 if (ATK_IS_TABLE (accessible
))
1303 atk_table_set_summary (ATK_TABLE (accessible
), g_value_get_object (value
));
1305 case PROP_TABLE_CAPTION_OBJECT
:
1306 if (ATK_IS_TABLE (accessible
))
1307 atk_table_set_caption (ATK_TABLE (accessible
), g_value_get_object (value
));
1315 atk_object_real_get_property (GObject
*object
,
1320 AtkObject
*accessible
;
1322 accessible
= ATK_OBJECT (object
);
1327 g_value_set_string (value
, atk_object_get_name (accessible
));
1329 case PROP_DESCRIPTION
:
1330 g_value_set_string (value
, atk_object_get_description (accessible
));
1333 g_value_set_int (value
, atk_object_get_role (accessible
));
1336 if (ATK_IS_COMPONENT (accessible
))
1337 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
1339 case PROP_MDI_ZORDER
:
1340 if (ATK_IS_COMPONENT (accessible
))
1341 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
1344 g_value_set_object (value
, atk_object_get_parent (accessible
));
1347 if (ATK_IS_VALUE (accessible
))
1348 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
1350 case PROP_TABLE_SUMMARY
:
1351 if (ATK_IS_TABLE (accessible
))
1352 g_value_set_object (value
, atk_table_get_summary (ATK_TABLE (accessible
)));
1354 case PROP_TABLE_CAPTION_OBJECT
:
1355 if (ATK_IS_TABLE (accessible
))
1356 g_value_set_object (value
, atk_table_get_caption (ATK_TABLE (accessible
)));
1358 case PROP_HYPERTEXT_NUM_LINKS
:
1359 if (ATK_IS_HYPERTEXT (accessible
))
1360 g_value_set_int (value
, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible
)));
1363 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
1369 atk_object_finalize (GObject
*object
)
1371 AtkObject
*accessible
;
1373 g_return_if_fail (ATK_IS_OBJECT (object
));
1375 accessible
= ATK_OBJECT (object
);
1377 g_free (accessible
->name
);
1378 g_free (accessible
->description
);
1381 * Free memory allocated for relation set if it have been allocated.
1383 if (accessible
->relation_set
)
1384 g_object_unref (accessible
->relation_set
);
1386 if (accessible
->accessible_parent
)
1387 g_object_unref (accessible
->accessible_parent
);
1389 G_OBJECT_CLASS (parent_class
)->finalize (object
);
1393 atk_object_real_get_name (AtkObject
*object
)
1395 return object
->name
;
1399 atk_object_real_get_description (AtkObject
*object
)
1401 return object
->description
;
1405 atk_object_real_get_parent (AtkObject
*object
)
1407 return object
->accessible_parent
;
1411 atk_object_real_get_role (AtkObject
*object
)
1413 return object
->role
;
1417 atk_object_real_get_layer (AtkObject
*object
)
1419 return object
->layer
;
1423 atk_object_real_ref_state_set (AtkObject
*accessible
)
1425 AtkStateSet
*state_set
;
1426 AtkObject
*focus_object
;
1428 state_set
= atk_state_set_new ();
1430 focus_object
= atk_get_focus_object ();
1431 if (focus_object
== accessible
)
1432 atk_state_set_add_state (state_set
, ATK_STATE_FOCUSED
);
1438 atk_object_real_set_name (AtkObject
*object
,
1441 g_free (object
->name
);
1442 object
->name
= g_strdup (name
);
1446 atk_object_real_set_description (AtkObject
*object
,
1447 const gchar
*description
)
1449 g_free (object
->description
);
1450 object
->description
= g_strdup (description
);
1454 atk_object_real_set_parent (AtkObject
*object
,
1457 if (object
->accessible_parent
)
1458 g_object_unref (object
->accessible_parent
);
1460 object
->accessible_parent
= parent
;
1461 if (object
->accessible_parent
)
1462 g_object_ref (object
->accessible_parent
);
1466 atk_object_real_set_role (AtkObject
*object
,
1469 object
->role
= role
;
1473 atk_object_real_connect_property_change_handler (AtkObject
*obj
,
1474 AtkPropertyChangeHandler
*handler
)
1476 return g_signal_connect_closure_by_id (obj
,
1477 atk_object_signals
[PROPERTY_CHANGE
],
1480 G_CALLBACK (handler
), NULL
,
1481 (GClosureNotify
) NULL
),
1486 atk_object_real_remove_property_change_handler (AtkObject
*obj
,
1489 g_signal_handler_disconnect (obj
, handler_id
);
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
,