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")
212 static void atk_object_class_init (AtkObjectClass
*klass
);
213 static void atk_object_init (AtkObject
*accessible
,
214 AtkObjectClass
*klass
);
215 static AtkRelationSet
* atk_object_real_ref_relation_set
216 (AtkObject
*accessible
);
217 static void atk_object_real_initialize (AtkObject
*accessible
,
219 static void atk_object_real_set_property (GObject
*object
,
223 static void atk_object_real_get_property (GObject
*object
,
227 static void atk_object_finalize (GObject
*object
);
228 static const gchar
* atk_object_real_get_name (AtkObject
*object
);
229 static const gchar
* atk_object_real_get_description
231 static AtkObject
* atk_object_real_get_parent (AtkObject
*object
);
232 static AtkRole
atk_object_real_get_role (AtkObject
*object
);
233 static AtkLayer
atk_object_real_get_layer (AtkObject
*object
);
234 static AtkStateSet
* atk_object_real_ref_state_set
236 static void atk_object_real_set_name (AtkObject
*object
,
238 static void atk_object_real_set_description
240 const gchar
*description
);
241 static void atk_object_real_set_parent (AtkObject
*object
,
243 static void atk_object_real_set_role (AtkObject
*object
,
245 static guint atk_object_real_connect_property_change_handler
247 AtkPropertyChangeHandler
249 static void atk_object_real_remove_property_change_handler
252 static void atk_object_notify (GObject
*obj
,
254 static const gchar
* atk_object_real_get_object_locale
257 static guint atk_object_signals
[LAST_SIGNAL
] = { 0, };
259 static gpointer parent_class
= NULL
;
261 static const gchar
* const atk_object_name_property_name
= "accessible-name";
262 static const gchar
* const atk_object_name_property_description
= "accessible-description";
263 static const gchar
* const atk_object_name_property_parent
= "accessible-parent";
264 static const gchar
* const atk_object_name_property_value
= "accessible-value";
265 static const gchar
* const atk_object_name_property_role
= "accessible-role";
266 static const gchar
* const atk_object_name_property_component_layer
= "accessible-component-layer";
267 static const gchar
* const atk_object_name_property_component_mdi_zorder
= "accessible-component-mdi-zorder";
268 static const gchar
* const atk_object_name_property_table_caption
= "accessible-table-caption";
269 static const gchar
* const atk_object_name_property_table_column_description
= "accessible-table-column-description";
270 static const gchar
* const atk_object_name_property_table_column_header
= "accessible-table-column-header";
271 static const gchar
* const atk_object_name_property_table_row_description
= "accessible-table-row-description";
272 static const gchar
* const atk_object_name_property_table_row_header
= "accessible-table-row-header";
273 static const gchar
* const atk_object_name_property_table_summary
= "accessible-table-summary";
274 static const gchar
* const atk_object_name_property_table_caption_object
= "accessible-table-caption-object";
275 static const gchar
* const atk_object_name_property_hypertext_num_links
= "accessible-hypertext-nlinks";
279 static HMODULE atk_dll
;
282 DllMain (HINSTANCE hinstDLL
,
288 case DLL_PROCESS_ATTACH
:
289 atk_dll
= (HMODULE
) hinstDLL
;
297 get_atk_locale_dir (void)
299 static gchar
*atk_localedir
= NULL
;
306 /* ATK_LOCALEDIR might end in either /lib/locale or
307 * /share/locale. Scan for that slash.
309 p
= ATK_LOCALEDIR
+ strlen (ATK_LOCALEDIR
);
315 root
= g_win32_get_package_installation_directory_of_module (atk_dll
);
316 temp
= g_build_filename (root
, p
, NULL
);
319 /* atk_localedir is passed to bindtextdomain() which isn't
322 atk_localedir
= g_win32_locale_filename_from_utf8 (temp
);
325 return atk_localedir
;
330 #define ATK_LOCALEDIR get_atk_locale_dir()
335 gettext_initialization (void)
338 static gboolean gettext_initialized
= FALSE
;
340 if (!gettext_initialized
)
342 const char *dir
= g_getenv ("ATK_ALT_LOCALEDIR");
344 gettext_initialized
= TRUE
;
348 bindtextdomain (GETTEXT_PACKAGE
, dir
);
349 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
350 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
357 compact_role_name (gchar
*role_name
)
359 gchar
*p
= role_name
;
370 initialize_role_names ()
372 GTypeClass
*enum_class
;
373 GEnumValue
*enum_value
;
375 gchar
*role_name
= NULL
;
380 role_names
= g_ptr_array_new ();
381 enum_class
= g_type_class_ref (ATK_TYPE_ROLE
);
382 if (!G_IS_ENUM_CLASS(enum_class
))
385 for (i
= 0; i
< ATK_ROLE_LAST_DEFINED
; i
++)
387 enum_value
= g_enum_get_value (G_ENUM_CLASS (enum_class
), i
);
388 role_name
= g_strdup (enum_value
->value_nick
);
389 // We want the role names to be in the format "check button" and not "check-button"
390 compact_role_name (role_name
);
391 g_ptr_array_add (role_names
, role_name
);
394 g_type_class_unref (enum_class
);
399 atk_object_get_type (void)
401 static GType type
= 0;
405 static const GTypeInfo typeInfo
=
407 sizeof (AtkObjectClass
),
408 (GBaseInitFunc
) NULL
,
409 (GBaseFinalizeFunc
) NULL
,
410 (GClassInitFunc
) atk_object_class_init
,
411 (GClassFinalizeFunc
) NULL
,
415 (GInstanceInitFunc
) atk_object_init
,
417 type
= g_type_register_static (G_TYPE_OBJECT
, "AtkObject", &typeInfo
, 0) ;
423 atk_object_class_init (AtkObjectClass
*klass
)
425 GObjectClass
*gobject_class
= G_OBJECT_CLASS (klass
);
427 parent_class
= g_type_class_peek_parent (klass
);
429 gobject_class
->set_property
= atk_object_real_set_property
;
430 gobject_class
->get_property
= atk_object_real_get_property
;
431 gobject_class
->finalize
= atk_object_finalize
;
432 gobject_class
->notify
= atk_object_notify
;
434 klass
->get_name
= atk_object_real_get_name
;
435 klass
->get_description
= atk_object_real_get_description
;
436 klass
->get_parent
= atk_object_real_get_parent
;
437 klass
->get_n_children
= NULL
;
438 klass
->ref_child
= NULL
;
439 klass
->get_index_in_parent
= NULL
;
440 klass
->ref_relation_set
= atk_object_real_ref_relation_set
;
441 klass
->get_role
= atk_object_real_get_role
;
442 klass
->get_layer
= atk_object_real_get_layer
;
443 klass
->get_mdi_zorder
= NULL
;
444 klass
->initialize
= atk_object_real_initialize
;
445 klass
->ref_state_set
= atk_object_real_ref_state_set
;
446 klass
->set_name
= atk_object_real_set_name
;
447 klass
->set_description
= atk_object_real_set_description
;
448 klass
->set_parent
= atk_object_real_set_parent
;
449 klass
->set_role
= atk_object_real_set_role
;
450 klass
->connect_property_change_handler
=
451 atk_object_real_connect_property_change_handler
;
452 klass
->remove_property_change_handler
=
453 atk_object_real_remove_property_change_handler
;
454 klass
->get_object_locale
= atk_object_real_get_object_locale
;
457 * We do not define default signal handlers here
459 klass
->children_changed
= NULL
;
460 klass
->focus_event
= NULL
;
461 klass
->property_change
= NULL
;
462 klass
->visible_data_changed
= NULL
;
463 klass
->active_descendant_changed
= NULL
;
465 gettext_initialization ();
467 g_object_class_install_property (gobject_class
,
469 g_param_spec_string (atk_object_name_property_name
,
470 _("Accessible Name"),
471 _("Object instance\'s name formatted for assistive technology access"),
474 g_object_class_install_property (gobject_class
,
476 g_param_spec_string (atk_object_name_property_description
,
477 _("Accessible Description"),
478 _("Description of an object, formatted for assistive technology access"),
481 g_object_class_install_property (gobject_class
,
483 g_param_spec_object (atk_object_name_property_parent
,
484 _("Accessible Parent"),
485 _("Is used to notify that the parent has changed"),
488 g_object_class_install_property (gobject_class
,
490 g_param_spec_double (atk_object_name_property_value
,
491 _("Accessible Value"),
492 _("Is used to notify that the value has changed"),
497 g_object_class_install_property (gobject_class
,
499 g_param_spec_int (atk_object_name_property_role
,
500 _("Accessible Role"),
501 _("The accessible role of this object"),
506 g_object_class_install_property (gobject_class
,
508 g_param_spec_int (atk_object_name_property_component_layer
,
509 _("Accessible Layer"),
510 _("The accessible layer of this object"),
515 g_object_class_install_property (gobject_class
,
517 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
518 _("Accessible MDI Value"),
519 _("The accessible MDI value of this object"),
524 g_object_class_install_property (gobject_class
,
526 g_param_spec_string (atk_object_name_property_table_caption
,
527 _("Accessible Table Caption"),
528 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
531 g_object_class_install_property (gobject_class
,
532 PROP_TABLE_COLUMN_HEADER
,
533 g_param_spec_object (atk_object_name_property_table_column_header
,
534 _("Accessible Table Column Header"),
535 _("Is used to notify that the table column header has changed"),
538 g_object_class_install_property (gobject_class
,
539 PROP_TABLE_COLUMN_DESCRIPTION
,
540 g_param_spec_string (atk_object_name_property_table_column_description
,
541 _("Accessible Table Column Description"),
542 _("Is used to notify that the table column description has changed"),
545 g_object_class_install_property (gobject_class
,
546 PROP_TABLE_ROW_HEADER
,
547 g_param_spec_object (atk_object_name_property_table_row_header
,
548 _("Accessible Table Row Header"),
549 _("Is used to notify that the table row header has changed"),
552 g_object_class_install_property (gobject_class
,
553 PROP_TABLE_ROW_DESCRIPTION
,
554 g_param_spec_string (atk_object_name_property_table_row_description
,
555 _("Accessible Table Row Description"),
556 _("Is used to notify that the table row description has changed"),
559 g_object_class_install_property (gobject_class
,
561 g_param_spec_object (atk_object_name_property_table_summary
,
562 _("Accessible Table Summary"),
563 _("Is used to notify that the table summary has changed"),
566 g_object_class_install_property (gobject_class
,
567 PROP_TABLE_CAPTION_OBJECT
,
568 g_param_spec_object (atk_object_name_property_table_caption_object
,
569 _("Accessible Table Caption Object"),
570 _("Is used to notify that the table caption has changed"),
573 g_object_class_install_property (gobject_class
,
574 PROP_HYPERTEXT_NUM_LINKS
,
575 g_param_spec_int (atk_object_name_property_hypertext_num_links
,
576 _("Number of Accessible Hypertext Links"),
577 _("The number of links which the current AtkHypertext has"),
584 * AtkObject::children-changed:
585 * @atkobject: the object which received the signal.
586 * @arg1: The index of the added or removed child. The value can be
587 * -1. This is used if the value is not known by the implementor
588 * when the child is added/removed or irrelevant.
589 * @arg2: A gpointer to the child AtkObject which was added or
590 * removed. If the child was removed, it is possible that it is not
591 * available for the implementor. In that case this pointer can be
594 * The signal "children-changed" is emitted when a child is added or
595 * removed form an object. It supports two details: "add" and
598 atk_object_signals
[CHILDREN_CHANGED
] =
599 g_signal_new ("children_changed",
600 G_TYPE_FROM_CLASS (klass
),
601 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
602 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
604 g_cclosure_marshal_VOID__UINT_POINTER
,
606 2, G_TYPE_UINT
, G_TYPE_POINTER
);
609 * AtkObject::focus-event:
610 * @atkobject: the object which received the signal
611 * @arg1: a boolean value which indicates whether the object gained
614 * The signal "focus-event" is emitted when an object gained or lost
617 * Deprecated: Since 2.9.4. Use #AtkObject::state-change signal instead.
619 atk_object_signals
[FOCUS_EVENT
] =
620 g_signal_new ("focus_event",
621 G_TYPE_FROM_CLASS (klass
),
623 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
625 g_cclosure_marshal_VOID__BOOLEAN
,
629 * AtkObject::property-change:
630 * @atkobject: the object which received the signal.
631 * @arg1: The new value of the property which changed.
633 * The signal "property-change" is emitted when an object's property
634 * value changes. The detail identifies the name of the property
635 * whose value has changed.
637 atk_object_signals
[PROPERTY_CHANGE
] =
638 g_signal_new ("property_change",
639 G_TYPE_FROM_CLASS (klass
),
640 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
641 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
642 (GSignalAccumulator
) NULL
, NULL
,
643 g_cclosure_marshal_VOID__POINTER
,
648 * AtkObject::state-change:
649 * @atkobject: the object which received the signal.
650 * @arg1: The name of the state which has changed
651 * @arg2: A boolean which indicates whether the state has been set or unset.
653 * The "state-change" signal is emitted when an object's state
654 * changes. The detail value identifies the state type which has
657 atk_object_signals
[STATE_CHANGE
] =
658 g_signal_new ("state_change",
659 G_TYPE_FROM_CLASS (klass
),
660 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
661 G_STRUCT_OFFSET (AtkObjectClass
, state_change
),
662 (GSignalAccumulator
) NULL
, NULL
,
663 atk_marshal_VOID__STRING_BOOLEAN
,
669 * AtkObject::visible-data-changed:
670 * @atkobject: the object which received the signal.
672 * The "visible-data-changed" signal is emitted when the visual
673 * appearance of the object changed.
675 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
676 g_signal_new ("visible_data_changed",
677 G_TYPE_FROM_CLASS (klass
),
679 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
680 (GSignalAccumulator
) NULL
, NULL
,
681 g_cclosure_marshal_VOID__VOID
,
685 * AtkObject::active-descendant-changed:
686 * @atkobject: the object which received the signal.
687 * @arg1: the newly focused object.
689 * The "active-descendant-changed" signal is emitted by an object
690 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
691 * object in the object changes. For instance, a table will emit the
692 * signal when the cell in the table which has focus changes.
694 atk_object_signals
[ACTIVE_DESCENDANT_CHANGED
] =
695 g_signal_new ("active_descendant_changed",
696 G_TYPE_FROM_CLASS (klass
),
697 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
698 G_STRUCT_OFFSET (AtkObjectClass
, active_descendant_changed
),
700 g_cclosure_marshal_VOID__POINTER
,
706 atk_object_init (AtkObject
*accessible
,
707 AtkObjectClass
*klass
)
709 accessible
->name
= NULL
;
710 accessible
->description
= NULL
;
711 accessible
->accessible_parent
= NULL
;
712 accessible
->relation_set
= atk_relation_set_new();
713 accessible
->role
= ATK_ROLE_UNKNOWN
;
717 atk_implementor_get_type (void)
719 static GType type
= 0;
723 static const GTypeInfo typeInfo
=
725 sizeof (AtkImplementorIface
),
726 (GBaseInitFunc
) NULL
,
727 (GBaseFinalizeFunc
) NULL
,
730 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
737 * atk_object_get_name:
738 * @accessible: an #AtkObject
740 * Gets the accessible name of the accessible.
742 * Returns: a character string representing the accessible name of the object.
745 atk_object_get_name (AtkObject
*accessible
)
747 AtkObjectClass
*klass
;
749 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
751 klass
= ATK_OBJECT_GET_CLASS (accessible
);
753 return (klass
->get_name
) (accessible
);
759 * atk_object_get_description:
760 * @accessible: an #AtkObject
762 * Gets the accessible description of the accessible.
764 * Returns: a character string representing the accessible description
769 atk_object_get_description (AtkObject
*accessible
)
771 AtkObjectClass
*klass
;
773 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
775 klass
= ATK_OBJECT_GET_CLASS (accessible
);
776 if (klass
->get_description
)
777 return (klass
->get_description
) (accessible
);
783 * atk_object_get_parent:
784 * @accessible: an #AtkObject
786 * Gets the accessible parent of the accessible.
788 * Returns: (transfer none): a #AtkObject representing the accessible parent
792 atk_object_get_parent (AtkObject
*accessible
)
794 AtkObjectClass
*klass
;
796 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
798 klass
= ATK_OBJECT_GET_CLASS (accessible
);
799 if (klass
->get_parent
)
800 return (klass
->get_parent
) (accessible
);
806 * atk_object_get_n_accessible_children:
807 * @accessible: an #AtkObject
809 * Gets the number of accessible children of the accessible.
811 * Returns: an integer representing the number of accessible children
815 atk_object_get_n_accessible_children (AtkObject
*accessible
)
817 AtkObjectClass
*klass
;
819 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
821 klass
= ATK_OBJECT_GET_CLASS (accessible
);
822 if (klass
->get_n_children
)
823 return (klass
->get_n_children
) (accessible
);
829 * atk_object_ref_accessible_child:
830 * @accessible: an #AtkObject
831 * @i: a gint representing the position of the child, starting from 0
833 * Gets a reference to the specified accessible child of the object.
834 * The accessible children are 0-based so the first accessible child is
835 * at index 0, the second at index 1 and so on.
837 * Returns: (transfer full): an #AtkObject representing the specified
838 * accessible child of the accessible.
841 atk_object_ref_accessible_child (AtkObject
*accessible
,
844 AtkObjectClass
*klass
;
846 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
848 klass
= ATK_OBJECT_GET_CLASS (accessible
);
849 if (klass
->ref_child
)
850 return (klass
->ref_child
) (accessible
, i
);
856 * atk_object_ref_relation_set:
857 * @accessible: an #AtkObject
859 * Gets the #AtkRelationSet associated with the object.
861 * Returns: (transfer full): an #AtkRelationSet representing the relation set
865 atk_object_ref_relation_set (AtkObject
*accessible
)
867 AtkObjectClass
*klass
;
869 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
871 klass
= ATK_OBJECT_GET_CLASS (accessible
);
872 if (klass
->ref_relation_set
)
873 return (klass
->ref_relation_set
) (accessible
);
880 * @name: a character string describing the new role.
882 * Registers the role specified by @name.
884 * Returns: an #AtkRole for the new role.
887 atk_role_register (const gchar
*name
)
890 initialize_role_names ();
892 g_ptr_array_add (role_names
, g_strdup (name
));
893 return role_names
->len
- 1;
897 * atk_object_get_role:
898 * @accessible: an #AtkObject
900 * Gets the role of the accessible.
902 * Returns: an #AtkRole which is the role of the accessible
905 atk_object_get_role (AtkObject
*accessible
)
907 AtkObjectClass
*klass
;
909 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
911 klass
= ATK_OBJECT_GET_CLASS (accessible
);
913 return (klass
->get_role
) (accessible
);
915 return ATK_ROLE_UNKNOWN
;
919 * atk_object_get_layer:
920 * @accessible: an #AtkObject
922 * Gets the layer of the accessible.
924 * Deprecated: Use atk_component_get_layer instead.
926 * Returns: an #AtkLayer which is the layer of the accessible
929 atk_object_get_layer (AtkObject
*accessible
)
931 AtkObjectClass
*klass
;
933 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
935 klass
= ATK_OBJECT_GET_CLASS (accessible
);
936 if (klass
->get_layer
)
937 return (klass
->get_layer
) (accessible
);
939 return ATK_LAYER_INVALID
;
943 * atk_object_get_mdi_zorder:
944 * @accessible: an #AtkObject
946 * Gets the zorder of the accessible. The value G_MININT will be returned
947 * if the layer of the accessible is not ATK_LAYER_MDI.
949 * Deprecated: Use atk_component_get_mdi_zorder instead.
951 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
952 * which the component is shown in relation to other components in the same
957 atk_object_get_mdi_zorder (AtkObject
*accessible
)
959 AtkObjectClass
*klass
;
961 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
963 klass
= ATK_OBJECT_GET_CLASS (accessible
);
964 if (klass
->get_mdi_zorder
)
965 return (klass
->get_mdi_zorder
) (accessible
);
971 * atk_object_ref_state_set:
972 * @accessible: an #AtkObject
974 * Gets a reference to the state set of the accessible; the caller must
975 * unreference it when it is no longer needed.
977 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
978 * set of the accessible
981 atk_object_ref_state_set (AtkObject
*accessible
)
983 AtkObjectClass
*klass
;
985 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
987 klass
= ATK_OBJECT_GET_CLASS (accessible
);
988 if (klass
->ref_state_set
)
989 return (klass
->ref_state_set
) (accessible
);
995 * atk_object_get_index_in_parent:
996 * @accessible: an #AtkObject
998 * Gets the 0-based index of this accessible in its parent; returns -1 if the
999 * accessible does not have an accessible parent.
1001 * Returns: an integer which is the index of the accessible in its parent
1004 atk_object_get_index_in_parent (AtkObject
*accessible
)
1006 AtkObjectClass
*klass
;
1008 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
1010 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1011 if (klass
->get_index_in_parent
)
1012 return (klass
->get_index_in_parent
) (accessible
);
1018 * atk_object_set_name:
1019 * @accessible: an #AtkObject
1020 * @name: a character string to be set as the accessible name
1022 * Sets the accessible name of the accessible. You can't set the name
1023 * to NULL. This is reserved for the initial value. In this aspect
1024 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
1025 * a empty value you can use "".
1028 atk_object_set_name (AtkObject
*accessible
,
1031 AtkObjectClass
*klass
;
1032 gboolean notify
= FALSE
;
1034 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1035 g_return_if_fail (name
!= NULL
);
1037 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1038 if (klass
->set_name
)
1040 /* Do not notify for initial name setting. See bug 665870 */
1041 notify
= (accessible
->name
!= NULL
);
1043 (klass
->set_name
) (accessible
, name
);
1045 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
1050 * atk_object_set_description:
1051 * @accessible: an #AtkObject
1052 * @description: a character string to be set as the accessible description
1054 * Sets the accessible description of the accessible. You can't set
1055 * the description to NULL. This is reserved for the initial value. In
1056 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
1057 * the name to a empty value you can use "".
1060 atk_object_set_description (AtkObject
*accessible
,
1061 const gchar
*description
)
1063 AtkObjectClass
*klass
;
1064 gboolean notify
= FALSE
;
1066 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1067 g_return_if_fail (description
!= NULL
);
1069 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1070 if (klass
->set_description
)
1072 /* Do not notify for initial name setting. See bug 665870 */
1073 notify
= (accessible
->description
!= NULL
);
1075 (klass
->set_description
) (accessible
, description
);
1077 g_object_notify (G_OBJECT (accessible
),
1078 atk_object_name_property_description
);
1083 * atk_object_set_parent:
1084 * @accessible: an #AtkObject
1085 * @parent: an #AtkObject to be set as the accessible parent
1087 * Sets the accessible parent of the accessible.
1090 atk_object_set_parent (AtkObject
*accessible
,
1093 AtkObjectClass
*klass
;
1095 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1097 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1098 if (klass
->set_parent
)
1100 (klass
->set_parent
) (accessible
, parent
);
1101 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
1106 * atk_object_set_role:
1107 * @accessible: an #AtkObject
1108 * @role: an #AtkRole to be set as the role
1110 * Sets the role of the accessible.
1113 atk_object_set_role (AtkObject
*accessible
,
1116 AtkObjectClass
*klass
;
1119 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1121 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1122 if (klass
->set_role
)
1124 old_role
= atk_object_get_role (accessible
);
1125 if (old_role
!= role
)
1127 (klass
->set_role
) (accessible
, role
);
1128 if (old_role
!= ATK_ROLE_UNKNOWN
)
1129 /* Do not notify for initial role setting */
1130 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
1136 * atk_object_connect_property_change_handler:
1137 * @accessible: an #AtkObject
1138 * @handler: a function to be called when a property changes its value
1140 * Specifies a function to be called when a property changes value.
1142 * Returns: a #guint which is the handler id used in
1143 * atk_object_remove_property_change_handler()
1146 atk_object_connect_property_change_handler (AtkObject
*accessible
,
1147 AtkPropertyChangeHandler
*handler
)
1149 AtkObjectClass
*klass
;
1151 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
1152 g_return_val_if_fail ((handler
!= NULL
), 0);
1154 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1155 if (klass
->connect_property_change_handler
)
1156 return (klass
->connect_property_change_handler
) (accessible
, handler
);
1162 * atk_object_remove_property_change_handler:
1163 * @accessible: an #AtkObject
1164 * @handler_id: a guint which identifies the handler to be removed.
1166 * Removes a property change handler.
1169 atk_object_remove_property_change_handler (AtkObject
*accessible
,
1172 AtkObjectClass
*klass
;
1174 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1176 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1177 if (klass
->remove_property_change_handler
)
1178 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
1182 * atk_object_notify_state_change:
1183 * @accessible: an #AtkObject
1184 * @state: an #AtkState whose state is changed
1185 * @value: a gboolean which indicates whether the state is being set on or off
1187 * Emits a state-change signal for the specified state.
1190 atk_object_notify_state_change (AtkObject
*accessible
,
1196 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1198 name
= atk_state_type_get_name (state
);
1199 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
1200 g_quark_from_string (name
),
1205 * atk_implementor_ref_accessible:
1206 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1207 * if a non-null return value is required.
1209 * Gets a reference to an object's #AtkObject implementation, if
1210 * the object implements #AtkObjectIface
1212 * Returns: (transfer full): a reference to an object's #AtkObject
1216 atk_implementor_ref_accessible (AtkImplementor
*implementor
)
1218 AtkImplementorIface
*iface
;
1219 AtkObject
*accessible
= NULL
;
1221 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor
), NULL
);
1223 iface
= ATK_IMPLEMENTOR_GET_IFACE (implementor
);
1226 accessible
= iface
->ref_accessible (implementor
);
1228 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
1235 * atk_object_get_attributes:
1236 * @accessible: An #AtkObject.
1238 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1239 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1240 * as distinct from strongly-typed object data available via other get/set methods.
1241 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1245 * Returns: (transfer full): an #AtkAttributeSet consisting of all
1246 * explicit properties/annotations applied to the object, or an empty
1247 * set if the object has no name-value pair attributes assigned to
1248 * it. This #atkattributeset should be freed by a call to
1249 * atk_attribute_set_free().
1252 atk_object_get_attributes (AtkObject
*accessible
)
1254 AtkObjectClass
*klass
;
1256 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1258 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1259 if (klass
->get_attributes
)
1260 return (klass
->get_attributes
) (accessible
);
1266 static AtkRelationSet
*
1267 atk_object_real_ref_relation_set (AtkObject
*accessible
)
1269 g_return_val_if_fail (accessible
->relation_set
, NULL
);
1270 g_object_ref (accessible
->relation_set
);
1272 return accessible
->relation_set
;
1276 atk_object_real_set_property (GObject
*object
,
1278 const GValue
*value
,
1281 AtkObject
*accessible
;
1283 accessible
= ATK_OBJECT (object
);
1288 atk_object_set_name (accessible
, g_value_get_string (value
));
1290 case PROP_DESCRIPTION
:
1291 atk_object_set_description (accessible
, g_value_get_string (value
));
1294 atk_object_set_role (accessible
, g_value_get_int (value
));
1297 atk_object_set_parent (accessible
, g_value_get_object (value
));
1300 if (ATK_IS_VALUE (accessible
))
1301 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
1303 case PROP_TABLE_SUMMARY
:
1304 if (ATK_IS_TABLE (accessible
))
1305 atk_table_set_summary (ATK_TABLE (accessible
), g_value_get_object (value
));
1307 case PROP_TABLE_CAPTION_OBJECT
:
1308 if (ATK_IS_TABLE (accessible
))
1309 atk_table_set_caption (ATK_TABLE (accessible
), g_value_get_object (value
));
1317 atk_object_real_get_property (GObject
*object
,
1322 AtkObject
*accessible
;
1324 accessible
= ATK_OBJECT (object
);
1329 g_value_set_string (value
, atk_object_get_name (accessible
));
1331 case PROP_DESCRIPTION
:
1332 g_value_set_string (value
, atk_object_get_description (accessible
));
1335 g_value_set_int (value
, atk_object_get_role (accessible
));
1338 if (ATK_IS_COMPONENT (accessible
))
1339 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
1341 case PROP_MDI_ZORDER
:
1342 if (ATK_IS_COMPONENT (accessible
))
1343 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
1346 g_value_set_object (value
, atk_object_get_parent (accessible
));
1349 if (ATK_IS_VALUE (accessible
))
1350 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
1352 case PROP_TABLE_SUMMARY
:
1353 if (ATK_IS_TABLE (accessible
))
1354 g_value_set_object (value
, atk_table_get_summary (ATK_TABLE (accessible
)));
1356 case PROP_TABLE_CAPTION_OBJECT
:
1357 if (ATK_IS_TABLE (accessible
))
1358 g_value_set_object (value
, atk_table_get_caption (ATK_TABLE (accessible
)));
1360 case PROP_HYPERTEXT_NUM_LINKS
:
1361 if (ATK_IS_HYPERTEXT (accessible
))
1362 g_value_set_int (value
, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible
)));
1365 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
1371 atk_object_finalize (GObject
*object
)
1373 AtkObject
*accessible
;
1375 g_return_if_fail (ATK_IS_OBJECT (object
));
1377 accessible
= ATK_OBJECT (object
);
1379 g_free (accessible
->name
);
1380 g_free (accessible
->description
);
1383 * Free memory allocated for relation set if it have been allocated.
1385 if (accessible
->relation_set
)
1386 g_object_unref (accessible
->relation_set
);
1388 if (accessible
->accessible_parent
)
1389 g_object_unref (accessible
->accessible_parent
);
1391 G_OBJECT_CLASS (parent_class
)->finalize (object
);
1395 atk_object_real_get_name (AtkObject
*object
)
1397 return object
->name
;
1401 atk_object_real_get_description (AtkObject
*object
)
1403 return object
->description
;
1407 atk_object_real_get_parent (AtkObject
*object
)
1409 return object
->accessible_parent
;
1413 atk_object_real_get_role (AtkObject
*object
)
1415 return object
->role
;
1419 atk_object_real_get_layer (AtkObject
*object
)
1421 return object
->layer
;
1425 atk_object_real_ref_state_set (AtkObject
*accessible
)
1427 AtkStateSet
*state_set
;
1428 AtkObject
*focus_object
;
1430 state_set
= atk_state_set_new ();
1432 focus_object
= atk_get_focus_object ();
1433 if (focus_object
== accessible
)
1434 atk_state_set_add_state (state_set
, ATK_STATE_FOCUSED
);
1440 atk_object_real_set_name (AtkObject
*object
,
1443 g_free (object
->name
);
1444 object
->name
= g_strdup (name
);
1448 atk_object_real_set_description (AtkObject
*object
,
1449 const gchar
*description
)
1451 g_free (object
->description
);
1452 object
->description
= g_strdup (description
);
1456 atk_object_real_set_parent (AtkObject
*object
,
1459 if (object
->accessible_parent
)
1460 g_object_unref (object
->accessible_parent
);
1462 object
->accessible_parent
= parent
;
1463 if (object
->accessible_parent
)
1464 g_object_ref (object
->accessible_parent
);
1468 atk_object_real_set_role (AtkObject
*object
,
1471 object
->role
= role
;
1475 atk_object_real_connect_property_change_handler (AtkObject
*obj
,
1476 AtkPropertyChangeHandler
*handler
)
1478 return g_signal_connect_closure_by_id (obj
,
1479 atk_object_signals
[PROPERTY_CHANGE
],
1482 G_CALLBACK (handler
), NULL
,
1483 (GClosureNotify
) NULL
),
1488 atk_object_real_remove_property_change_handler (AtkObject
*obj
,
1491 g_signal_handler_disconnect (obj
, handler_id
);
1495 * atk_object_initialize:
1496 * @accessible: a #AtkObject
1497 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1499 * This function is called when implementing subclasses of #AtkObject.
1500 * It does initialization required for the new object. It is intended
1501 * that this function should called only in the ..._new() functions used
1502 * to create an instance of a subclass of #AtkObject
1505 atk_object_initialize (AtkObject
*accessible
,
1508 AtkObjectClass
*klass
;
1510 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1512 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1513 if (klass
->initialize
)
1514 klass
->initialize (accessible
, data
);
1518 * This function is a signal handler for notify signal which gets emitted
1519 * when a property changes value.
1521 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1522 * signal which causes the user specified AtkPropertyChangeHandler
1526 atk_object_notify (GObject
*obj
,
1529 AtkPropertyValues values
= { NULL
, };
1531 g_value_init (&values
.new_value
, pspec
->value_type
);
1532 g_object_get_property (obj
, pspec
->name
, &values
.new_value
);
1533 values
.property_name
= pspec
->name
;
1534 g_signal_emit (obj
, atk_object_signals
[PROPERTY_CHANGE
],
1535 g_quark_from_string (pspec
->name
),
1537 g_value_unset (&values
.new_value
);
1541 * atk_role_get_name:
1542 * @role: The #AtkRole whose name is required
1544 * Gets the description string describing the #AtkRole @role.
1546 * Returns: the string describing the AtkRole
1549 atk_role_get_name (AtkRole role
)
1551 g_return_val_if_fail (role
>= 0, NULL
);
1554 initialize_role_names ();
1556 if (role
< role_names
->len
)
1557 return g_ptr_array_index (role_names
, role
);
1563 * atk_role_get_localized_name:
1564 * @role: The #AtkRole whose localized name is required
1566 * Gets the localized description string describing the #AtkRole @role.
1568 * Returns: the localized string describing the AtkRole
1571 atk_role_get_localized_name (AtkRole role
)
1573 gettext_initialization ();
1575 return dgettext (GETTEXT_PACKAGE
, atk_role_get_name (role
));
1579 atk_object_real_get_object_locale (AtkObject
*object
)
1581 return setlocale (LC_MESSAGES
, NULL
);
1585 * atk_object_get_object_locale:
1586 * @accessible: an #AtkObject
1588 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1593 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1594 * locale of @accessible.
1597 atk_object_get_object_locale (AtkObject
*accessible
)
1599 AtkObjectClass
*klass
;
1601 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1603 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1604 if (klass
->get_object_locale
)
1605 return (klass
->get_object_locale
) (accessible
);
1612 * atk_role_for_name:
1613 * @name: a string which is the (non-localized) name of an ATK role.
1615 * Get the #AtkRole type corresponding to a rolew name.
1617 * Returns: the #AtkRole enumerated type corresponding to the specified name,
1618 * or #ATK_ROLE_INVALID if no matching role is found.
1621 atk_role_for_name (const gchar
*name
)
1623 AtkRole role
= ATK_ROLE_INVALID
;
1626 g_return_val_if_fail (name
, ATK_ROLE_INVALID
);
1629 initialize_role_names ();
1631 for (i
= 0; i
< role_names
->len
; i
++)
1633 gchar
*role_name
= (gchar
*)g_ptr_array_index (role_names
, i
);
1635 g_return_val_if_fail (role_name
, ATK_ROLE_INVALID
);
1637 if (strcmp (name
, role_name
) == 0)
1648 * atk_object_add_relationship:
1649 * @object: The #AtkObject to which an AtkRelation is to be added.
1650 * @relationship: The #AtkRelationType of the relation
1651 * @target: The #AtkObject which is to be the target of the relation.
1653 * Adds a relationship of the specified type with the specified target.
1655 * Returns: TRUE if the relationship is added.
1658 atk_object_add_relationship (AtkObject
*object
,
1659 AtkRelationType relationship
,
1662 AtkObject
*array
[1];
1663 AtkRelation
*relation
;
1665 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1666 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1668 if (atk_relation_set_contains_target (object
->relation_set
,
1669 relationship
, target
))
1673 relation
= atk_relation_new (array
, 1, relationship
);
1674 atk_relation_set_add (object
->relation_set
, relation
);
1675 g_object_unref (relation
);
1681 * atk_object_remove_relationship:
1682 * @object: The #AtkObject from which an AtkRelation is to be removed.
1683 * @relationship: The #AtkRelationType of the relation
1684 * @target: The #AtkObject which is the target of the relation to be removed.
1686 * Removes a relationship of the specified type with the specified target.
1688 * Returns: TRUE if the relationship is removed.
1691 atk_object_remove_relationship (AtkObject
*object
,
1692 AtkRelationType relationship
,
1695 gboolean ret
= FALSE
;
1696 AtkRelation
*relation
;
1699 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1700 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1702 relation
= atk_relation_set_get_relation_by_type (object
->relation_set
, relationship
);
1706 ret
= atk_relation_remove_target (relation
, target
);
1707 array
= atk_relation_get_target (relation
);
1708 if (!array
|| array
->len
== 0)
1709 atk_relation_set_remove (object
->relation_set
, relation
);
1715 atk_object_real_initialize (AtkObject
*accessible
,