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")
207 static void atk_object_class_init (AtkObjectClass
*klass
);
208 static void atk_object_init (AtkObject
*accessible
,
209 AtkObjectClass
*klass
);
210 static AtkRelationSet
* atk_object_real_ref_relation_set
211 (AtkObject
*accessible
);
212 static void atk_object_real_initialize (AtkObject
*accessible
,
214 static void atk_object_real_set_property (GObject
*object
,
218 static void atk_object_real_get_property (GObject
*object
,
222 static void atk_object_finalize (GObject
*object
);
223 static const gchar
* atk_object_real_get_name (AtkObject
*object
);
224 static const gchar
* atk_object_real_get_description
226 static AtkObject
* atk_object_real_get_parent (AtkObject
*object
);
227 static AtkRole
atk_object_real_get_role (AtkObject
*object
);
228 static AtkLayer
atk_object_real_get_layer (AtkObject
*object
);
229 static AtkStateSet
* atk_object_real_ref_state_set
231 static void atk_object_real_set_name (AtkObject
*object
,
233 static void atk_object_real_set_description
235 const gchar
*description
);
236 static void atk_object_real_set_parent (AtkObject
*object
,
238 static void atk_object_real_set_role (AtkObject
*object
,
240 static guint atk_object_real_connect_property_change_handler
242 AtkPropertyChangeHandler
244 static void atk_object_real_remove_property_change_handler
247 static void atk_object_notify (GObject
*obj
,
249 static const gchar
* atk_object_real_get_object_locale
252 static guint atk_object_signals
[LAST_SIGNAL
] = { 0, };
254 static gpointer parent_class
= NULL
;
256 static const gchar
* const atk_object_name_property_name
= "accessible-name";
257 static const gchar
* const atk_object_name_property_description
= "accessible-description";
258 static const gchar
* const atk_object_name_property_parent
= "accessible-parent";
259 static const gchar
* const atk_object_name_property_value
= "accessible-value";
260 static const gchar
* const atk_object_name_property_role
= "accessible-role";
261 static const gchar
* const atk_object_name_property_component_layer
= "accessible-component-layer";
262 static const gchar
* const atk_object_name_property_component_mdi_zorder
= "accessible-component-mdi-zorder";
263 static const gchar
* const atk_object_name_property_table_caption
= "accessible-table-caption";
264 static const gchar
* const atk_object_name_property_table_column_description
= "accessible-table-column-description";
265 static const gchar
* const atk_object_name_property_table_column_header
= "accessible-table-column-header";
266 static const gchar
* const atk_object_name_property_table_row_description
= "accessible-table-row-description";
267 static const gchar
* const atk_object_name_property_table_row_header
= "accessible-table-row-header";
268 static const gchar
* const atk_object_name_property_table_summary
= "accessible-table-summary";
269 static const gchar
* const atk_object_name_property_table_caption_object
= "accessible-table-caption-object";
270 static const gchar
* const atk_object_name_property_hypertext_num_links
= "accessible-hypertext-nlinks";
274 static HMODULE atk_dll
;
277 DllMain (HINSTANCE hinstDLL
,
283 case DLL_PROCESS_ATTACH
:
284 atk_dll
= (HMODULE
) hinstDLL
;
292 get_atk_locale_dir (void)
294 static gchar
*atk_localedir
= NULL
;
301 /* ATK_LOCALEDIR might end in either /lib/locale or
302 * /share/locale. Scan for that slash.
304 p
= ATK_LOCALEDIR
+ strlen (ATK_LOCALEDIR
);
310 root
= g_win32_get_package_installation_directory_of_module (atk_dll
);
311 temp
= g_build_filename (root
, p
, NULL
);
314 /* atk_localedir is passed to bindtextdomain() which isn't
317 atk_localedir
= g_win32_locale_filename_from_utf8 (temp
);
320 return atk_localedir
;
325 #define ATK_LOCALEDIR get_atk_locale_dir()
330 gettext_initialization (void)
333 static gboolean gettext_initialized
= FALSE
;
335 if (!gettext_initialized
)
337 const char *dir
= g_getenv ("ATK_ALT_LOCALEDIR");
339 gettext_initialized
= TRUE
;
343 bindtextdomain (GETTEXT_PACKAGE
, dir
);
344 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
345 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
352 compact_role_name (gchar
*role_name
)
354 gchar
*p
= role_name
;
365 initialize_role_names ()
367 GTypeClass
*enum_class
;
368 GEnumValue
*enum_value
;
370 gchar
*role_name
= NULL
;
375 role_names
= g_ptr_array_new ();
376 enum_class
= g_type_class_ref (ATK_TYPE_ROLE
);
377 if (!G_IS_ENUM_CLASS(enum_class
))
380 for (i
= 0; i
< ATK_ROLE_LAST_DEFINED
; i
++)
382 enum_value
= g_enum_get_value (G_ENUM_CLASS (enum_class
), i
);
383 role_name
= g_strdup (enum_value
->value_nick
);
384 // We want the role names to be in the format "check button" and not "check-button"
385 compact_role_name (role_name
);
386 g_ptr_array_add (role_names
, role_name
);
389 g_type_class_unref (enum_class
);
394 atk_object_get_type (void)
396 static GType type
= 0;
400 static const GTypeInfo typeInfo
=
402 sizeof (AtkObjectClass
),
403 (GBaseInitFunc
) NULL
,
404 (GBaseFinalizeFunc
) NULL
,
405 (GClassInitFunc
) atk_object_class_init
,
406 (GClassFinalizeFunc
) NULL
,
410 (GInstanceInitFunc
) atk_object_init
,
412 type
= g_type_register_static (G_TYPE_OBJECT
, "AtkObject", &typeInfo
, 0) ;
418 atk_object_class_init (AtkObjectClass
*klass
)
420 GObjectClass
*gobject_class
= G_OBJECT_CLASS (klass
);
422 parent_class
= g_type_class_peek_parent (klass
);
424 gobject_class
->set_property
= atk_object_real_set_property
;
425 gobject_class
->get_property
= atk_object_real_get_property
;
426 gobject_class
->finalize
= atk_object_finalize
;
427 gobject_class
->notify
= atk_object_notify
;
429 klass
->get_name
= atk_object_real_get_name
;
430 klass
->get_description
= atk_object_real_get_description
;
431 klass
->get_parent
= atk_object_real_get_parent
;
432 klass
->get_n_children
= NULL
;
433 klass
->ref_child
= NULL
;
434 klass
->get_index_in_parent
= NULL
;
435 klass
->ref_relation_set
= atk_object_real_ref_relation_set
;
436 klass
->get_role
= atk_object_real_get_role
;
437 klass
->get_layer
= atk_object_real_get_layer
;
438 klass
->get_mdi_zorder
= NULL
;
439 klass
->initialize
= atk_object_real_initialize
;
440 klass
->ref_state_set
= atk_object_real_ref_state_set
;
441 klass
->set_name
= atk_object_real_set_name
;
442 klass
->set_description
= atk_object_real_set_description
;
443 klass
->set_parent
= atk_object_real_set_parent
;
444 klass
->set_role
= atk_object_real_set_role
;
445 klass
->connect_property_change_handler
=
446 atk_object_real_connect_property_change_handler
;
447 klass
->remove_property_change_handler
=
448 atk_object_real_remove_property_change_handler
;
449 klass
->get_object_locale
= atk_object_real_get_object_locale
;
452 * We do not define default signal handlers here
454 klass
->children_changed
= NULL
;
455 klass
->focus_event
= NULL
;
456 klass
->property_change
= NULL
;
457 klass
->visible_data_changed
= NULL
;
458 klass
->active_descendant_changed
= NULL
;
460 gettext_initialization ();
462 g_object_class_install_property (gobject_class
,
464 g_param_spec_string (atk_object_name_property_name
,
465 _("Accessible Name"),
466 _("Object instance\'s name formatted for assistive technology access"),
469 g_object_class_install_property (gobject_class
,
471 g_param_spec_string (atk_object_name_property_description
,
472 _("Accessible Description"),
473 _("Description of an object, formatted for assistive technology access"),
476 g_object_class_install_property (gobject_class
,
478 g_param_spec_object (atk_object_name_property_parent
,
479 _("Accessible Parent"),
480 _("Is used to notify that the parent has changed"),
483 g_object_class_install_property (gobject_class
,
485 g_param_spec_double (atk_object_name_property_value
,
486 _("Accessible Value"),
487 _("Is used to notify that the value has changed"),
492 g_object_class_install_property (gobject_class
,
494 g_param_spec_int (atk_object_name_property_role
,
495 _("Accessible Role"),
496 _("The accessible role of this object"),
501 g_object_class_install_property (gobject_class
,
503 g_param_spec_int (atk_object_name_property_component_layer
,
504 _("Accessible Layer"),
505 _("The accessible layer of this object"),
510 g_object_class_install_property (gobject_class
,
512 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
513 _("Accessible MDI Value"),
514 _("The accessible MDI value of this object"),
519 g_object_class_install_property (gobject_class
,
521 g_param_spec_string (atk_object_name_property_table_caption
,
522 _("Accessible Table Caption"),
523 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
526 g_object_class_install_property (gobject_class
,
527 PROP_TABLE_COLUMN_HEADER
,
528 g_param_spec_object (atk_object_name_property_table_column_header
,
529 _("Accessible Table Column Header"),
530 _("Is used to notify that the table column header has changed"),
533 g_object_class_install_property (gobject_class
,
534 PROP_TABLE_COLUMN_DESCRIPTION
,
535 g_param_spec_string (atk_object_name_property_table_column_description
,
536 _("Accessible Table Column Description"),
537 _("Is used to notify that the table column description has changed"),
540 g_object_class_install_property (gobject_class
,
541 PROP_TABLE_ROW_HEADER
,
542 g_param_spec_object (atk_object_name_property_table_row_header
,
543 _("Accessible Table Row Header"),
544 _("Is used to notify that the table row header has changed"),
547 g_object_class_install_property (gobject_class
,
548 PROP_TABLE_ROW_DESCRIPTION
,
549 g_param_spec_string (atk_object_name_property_table_row_description
,
550 _("Accessible Table Row Description"),
551 _("Is used to notify that the table row description has changed"),
554 g_object_class_install_property (gobject_class
,
556 g_param_spec_object (atk_object_name_property_table_summary
,
557 _("Accessible Table Summary"),
558 _("Is used to notify that the table summary has changed"),
561 g_object_class_install_property (gobject_class
,
562 PROP_TABLE_CAPTION_OBJECT
,
563 g_param_spec_object (atk_object_name_property_table_caption_object
,
564 _("Accessible Table Caption Object"),
565 _("Is used to notify that the table caption has changed"),
568 g_object_class_install_property (gobject_class
,
569 PROP_HYPERTEXT_NUM_LINKS
,
570 g_param_spec_int (atk_object_name_property_hypertext_num_links
,
571 _("Number of Accessible Hypertext Links"),
572 _("The number of links which the current AtkHypertext has"),
579 * AtkObject::children-changed:
580 * @atkobject: the object which received the signal.
581 * @arg1: The index of the added or removed child
582 * @arg2: A gpointer to the child AtkObject which was added or removed
584 * The signal "children-changed" is emitted when a child is added or
585 * removed form an object. It supports two details: "add" and
588 atk_object_signals
[CHILDREN_CHANGED
] =
589 g_signal_new ("children_changed",
590 G_TYPE_FROM_CLASS (klass
),
591 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
592 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
594 g_cclosure_marshal_VOID__UINT_POINTER
,
596 2, G_TYPE_UINT
, G_TYPE_POINTER
);
599 * AtkObject::focus-event:
600 * @atkobject: the object which received the signal
601 * @arg1: a boolean value which indicates whether the object gained
604 * The signal "focus-event" is emitted when an object gained or lost
607 * Deprecated: Since 2.9.4. Use #AtkObject::state-change signal instead.
609 atk_object_signals
[FOCUS_EVENT
] =
610 g_signal_new ("focus_event",
611 G_TYPE_FROM_CLASS (klass
),
613 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
615 g_cclosure_marshal_VOID__BOOLEAN
,
619 * AtkObject::property-change:
620 * @atkobject: the object which received the signal.
621 * @arg1: The new value of the property which changed.
623 * The signal "property-change" is emitted when an object's property
624 * value changes. The detail identifies the name of the property
625 * whose value has changed.
627 atk_object_signals
[PROPERTY_CHANGE
] =
628 g_signal_new ("property_change",
629 G_TYPE_FROM_CLASS (klass
),
630 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
631 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
632 (GSignalAccumulator
) NULL
, NULL
,
633 g_cclosure_marshal_VOID__POINTER
,
638 * AtkObject::state-change:
639 * @atkobject: the object which received the signal.
640 * @arg1: The name of the state which has changed
641 * @arg2: A boolean which indicates whether the state has been set or unset.
643 * The "state-change" signal is emitted when an object's state
644 * changes. The detail value identifies the state type which has
647 atk_object_signals
[STATE_CHANGE
] =
648 g_signal_new ("state_change",
649 G_TYPE_FROM_CLASS (klass
),
650 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
651 G_STRUCT_OFFSET (AtkObjectClass
, state_change
),
652 (GSignalAccumulator
) NULL
, NULL
,
653 atk_marshal_VOID__STRING_BOOLEAN
,
659 * AtkObject::visible-data-changed:
660 * @atkobject: the object which received the signal.
662 * The "visible-data-changed" signal is emitted when the visual
663 * appearance of the object changed.
665 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
666 g_signal_new ("visible_data_changed",
667 G_TYPE_FROM_CLASS (klass
),
669 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
670 (GSignalAccumulator
) NULL
, NULL
,
671 g_cclosure_marshal_VOID__VOID
,
675 * AtkObject::active-descendant-changed:
676 * @atkobject: the object which received the signal.
677 * @arg1: the newly focused object.
679 * The "active-descendant-changed" signal is emitted by an object
680 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
681 * object in the object changes. For instance, a table will emit the
682 * signal when the cell in the table which has focus changes.
684 atk_object_signals
[ACTIVE_DESCENDANT_CHANGED
] =
685 g_signal_new ("active_descendant_changed",
686 G_TYPE_FROM_CLASS (klass
),
687 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
688 G_STRUCT_OFFSET (AtkObjectClass
, active_descendant_changed
),
690 g_cclosure_marshal_VOID__POINTER
,
696 atk_object_init (AtkObject
*accessible
,
697 AtkObjectClass
*klass
)
699 accessible
->name
= NULL
;
700 accessible
->description
= NULL
;
701 accessible
->accessible_parent
= NULL
;
702 accessible
->relation_set
= atk_relation_set_new();
703 accessible
->role
= ATK_ROLE_UNKNOWN
;
707 atk_implementor_get_type (void)
709 static GType type
= 0;
713 static const GTypeInfo typeInfo
=
715 sizeof (AtkImplementorIface
),
716 (GBaseInitFunc
) NULL
,
717 (GBaseFinalizeFunc
) NULL
,
720 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
727 * atk_object_get_name:
728 * @accessible: an #AtkObject
730 * Gets the accessible name of the accessible.
732 * Returns: a character string representing the accessible name of the object.
735 atk_object_get_name (AtkObject
*accessible
)
737 AtkObjectClass
*klass
;
739 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
741 klass
= ATK_OBJECT_GET_CLASS (accessible
);
743 return (klass
->get_name
) (accessible
);
749 * atk_object_get_description:
750 * @accessible: an #AtkObject
752 * Gets the accessible description of the accessible.
754 * Returns: a character string representing the accessible description
759 atk_object_get_description (AtkObject
*accessible
)
761 AtkObjectClass
*klass
;
763 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
765 klass
= ATK_OBJECT_GET_CLASS (accessible
);
766 if (klass
->get_description
)
767 return (klass
->get_description
) (accessible
);
773 * atk_object_get_parent:
774 * @accessible: an #AtkObject
776 * Gets the accessible parent of the accessible.
778 * Returns: (transfer none): a #AtkObject representing the accessible parent
782 atk_object_get_parent (AtkObject
*accessible
)
784 AtkObjectClass
*klass
;
786 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
788 klass
= ATK_OBJECT_GET_CLASS (accessible
);
789 if (klass
->get_parent
)
790 return (klass
->get_parent
) (accessible
);
796 * atk_object_get_n_accessible_children:
797 * @accessible: an #AtkObject
799 * Gets the number of accessible children of the accessible.
801 * Returns: an integer representing the number of accessible children
805 atk_object_get_n_accessible_children (AtkObject
*accessible
)
807 AtkObjectClass
*klass
;
809 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
811 klass
= ATK_OBJECT_GET_CLASS (accessible
);
812 if (klass
->get_n_children
)
813 return (klass
->get_n_children
) (accessible
);
819 * atk_object_ref_accessible_child:
820 * @accessible: an #AtkObject
821 * @i: a gint representing the position of the child, starting from 0
823 * Gets a reference to the specified accessible child of the object.
824 * The accessible children are 0-based so the first accessible child is
825 * at index 0, the second at index 1 and so on.
827 * Returns: (transfer full): an #AtkObject representing the specified
828 * accessible child of the accessible.
831 atk_object_ref_accessible_child (AtkObject
*accessible
,
834 AtkObjectClass
*klass
;
836 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
838 klass
= ATK_OBJECT_GET_CLASS (accessible
);
839 if (klass
->ref_child
)
840 return (klass
->ref_child
) (accessible
, i
);
846 * atk_object_ref_relation_set:
847 * @accessible: an #AtkObject
849 * Gets the #AtkRelationSet associated with the object.
851 * Returns: (transfer full): an #AtkRelationSet representing the relation set
855 atk_object_ref_relation_set (AtkObject
*accessible
)
857 AtkObjectClass
*klass
;
859 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
861 klass
= ATK_OBJECT_GET_CLASS (accessible
);
862 if (klass
->ref_relation_set
)
863 return (klass
->ref_relation_set
) (accessible
);
870 * @name: a character string describing the new role.
872 * Registers the role specified by @name.
874 * Returns: an #AtkRole for the new role.
877 atk_role_register (const gchar
*name
)
880 initialize_role_names ();
882 g_ptr_array_add (role_names
, g_strdup (name
));
883 return role_names
->len
- 1;
887 * atk_object_get_role:
888 * @accessible: an #AtkObject
890 * Gets the role of the accessible.
892 * Returns: an #AtkRole which is the role of the accessible
895 atk_object_get_role (AtkObject
*accessible
)
897 AtkObjectClass
*klass
;
899 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
901 klass
= ATK_OBJECT_GET_CLASS (accessible
);
903 return (klass
->get_role
) (accessible
);
905 return ATK_ROLE_UNKNOWN
;
909 * atk_object_get_layer:
910 * @accessible: an #AtkObject
912 * Gets the layer of the accessible.
914 * Deprecated: Use atk_component_get_layer instead.
916 * Returns: an #AtkLayer which is the layer of the accessible
919 atk_object_get_layer (AtkObject
*accessible
)
921 AtkObjectClass
*klass
;
923 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
925 klass
= ATK_OBJECT_GET_CLASS (accessible
);
926 if (klass
->get_layer
)
927 return (klass
->get_layer
) (accessible
);
929 return ATK_LAYER_INVALID
;
933 * atk_object_get_mdi_zorder:
934 * @accessible: an #AtkObject
936 * Gets the zorder of the accessible. The value G_MININT will be returned
937 * if the layer of the accessible is not ATK_LAYER_MDI.
939 * Deprecated: Use atk_component_get_mdi_zorder instead.
941 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
942 * which the component is shown in relation to other components in the same
947 atk_object_get_mdi_zorder (AtkObject
*accessible
)
949 AtkObjectClass
*klass
;
951 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
953 klass
= ATK_OBJECT_GET_CLASS (accessible
);
954 if (klass
->get_mdi_zorder
)
955 return (klass
->get_mdi_zorder
) (accessible
);
961 * atk_object_ref_state_set:
962 * @accessible: an #AtkObject
964 * Gets a reference to the state set of the accessible; the caller must
965 * unreference it when it is no longer needed.
967 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
968 * set of the accessible
971 atk_object_ref_state_set (AtkObject
*accessible
)
973 AtkObjectClass
*klass
;
975 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
977 klass
= ATK_OBJECT_GET_CLASS (accessible
);
978 if (klass
->ref_state_set
)
979 return (klass
->ref_state_set
) (accessible
);
985 * atk_object_get_index_in_parent:
986 * @accessible: an #AtkObject
988 * Gets the 0-based index of this accessible in its parent; returns -1 if the
989 * accessible does not have an accessible parent.
991 * Returns: an integer which is the index of the accessible in its parent
994 atk_object_get_index_in_parent (AtkObject
*accessible
)
996 AtkObjectClass
*klass
;
998 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
1000 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1001 if (klass
->get_index_in_parent
)
1002 return (klass
->get_index_in_parent
) (accessible
);
1008 * atk_object_set_name:
1009 * @accessible: an #AtkObject
1010 * @name: a character string to be set as the accessible name
1012 * Sets the accessible name of the accessible. You can't set the name
1013 * to NULL. This is reserved for the initial value. In this aspect
1014 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
1015 * a empty value you can use "".
1018 atk_object_set_name (AtkObject
*accessible
,
1021 AtkObjectClass
*klass
;
1022 gboolean notify
= FALSE
;
1024 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1025 g_return_if_fail (name
!= NULL
);
1027 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1028 if (klass
->set_name
)
1030 /* Do not notify for initial name setting. See bug 665870 */
1031 notify
= (accessible
->name
!= NULL
);
1033 (klass
->set_name
) (accessible
, name
);
1035 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
1040 * atk_object_set_description:
1041 * @accessible: an #AtkObject
1042 * @description: a character string to be set as the accessible description
1044 * Sets the accessible description of the accessible. You can't set
1045 * the description to NULL. This is reserved for the initial value. In
1046 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
1047 * the name to a empty value you can use "".
1050 atk_object_set_description (AtkObject
*accessible
,
1051 const gchar
*description
)
1053 AtkObjectClass
*klass
;
1054 gboolean notify
= FALSE
;
1056 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1057 g_return_if_fail (description
!= NULL
);
1059 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1060 if (klass
->set_description
)
1062 /* Do not notify for initial name setting. See bug 665870 */
1063 notify
= (accessible
->description
!= NULL
);
1065 (klass
->set_description
) (accessible
, description
);
1067 g_object_notify (G_OBJECT (accessible
),
1068 atk_object_name_property_description
);
1073 * atk_object_set_parent:
1074 * @accessible: an #AtkObject
1075 * @parent: an #AtkObject to be set as the accessible parent
1077 * Sets the accessible parent of the accessible.
1080 atk_object_set_parent (AtkObject
*accessible
,
1083 AtkObjectClass
*klass
;
1085 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1087 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1088 if (klass
->set_parent
)
1090 (klass
->set_parent
) (accessible
, parent
);
1091 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
1096 * atk_object_set_role:
1097 * @accessible: an #AtkObject
1098 * @role: an #AtkRole to be set as the role
1100 * Sets the role of the accessible.
1103 atk_object_set_role (AtkObject
*accessible
,
1106 AtkObjectClass
*klass
;
1109 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1111 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1112 if (klass
->set_role
)
1114 old_role
= atk_object_get_role (accessible
);
1115 if (old_role
!= role
)
1117 (klass
->set_role
) (accessible
, role
);
1118 if (old_role
!= ATK_ROLE_UNKNOWN
)
1119 /* Do not notify for initial role setting */
1120 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
1126 * atk_object_connect_property_change_handler:
1127 * @accessible: an #AtkObject
1128 * @handler: a function to be called when a property changes its value
1130 * Specifies a function to be called when a property changes value.
1132 * Returns: a #guint which is the handler id used in
1133 * atk_object_remove_property_change_handler()
1136 atk_object_connect_property_change_handler (AtkObject
*accessible
,
1137 AtkPropertyChangeHandler
*handler
)
1139 AtkObjectClass
*klass
;
1141 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
1142 g_return_val_if_fail ((handler
!= NULL
), 0);
1144 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1145 if (klass
->connect_property_change_handler
)
1146 return (klass
->connect_property_change_handler
) (accessible
, handler
);
1152 * atk_object_remove_property_change_handler:
1153 * @accessible: an #AtkObject
1154 * @handler_id: a guint which identifies the handler to be removed.
1156 * Removes a property change handler.
1159 atk_object_remove_property_change_handler (AtkObject
*accessible
,
1162 AtkObjectClass
*klass
;
1164 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1166 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1167 if (klass
->remove_property_change_handler
)
1168 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
1172 * atk_object_notify_state_change:
1173 * @accessible: an #AtkObject
1174 * @state: an #AtkState whose state is changed
1175 * @value: a gboolean which indicates whether the state is being set on or off
1177 * Emits a state-change signal for the specified state.
1180 atk_object_notify_state_change (AtkObject
*accessible
,
1186 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1188 name
= atk_state_type_get_name (state
);
1189 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
1190 g_quark_from_string (name
),
1195 * atk_implementor_ref_accessible:
1196 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1197 * if a non-null return value is required.
1199 * Gets a reference to an object's #AtkObject implementation, if
1200 * the object implements #AtkObjectIface
1202 * Returns: (transfer full): a reference to an object's #AtkObject
1206 atk_implementor_ref_accessible (AtkImplementor
*implementor
)
1208 AtkImplementorIface
*iface
;
1209 AtkObject
*accessible
= NULL
;
1211 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor
), NULL
);
1213 iface
= ATK_IMPLEMENTOR_GET_IFACE (implementor
);
1216 accessible
= iface
->ref_accessible (implementor
);
1218 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
1225 * atk_object_get_attributes:
1226 * @accessible: An #AtkObject.
1228 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1229 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1230 * as distinct from strongly-typed object data available via other get/set methods.
1231 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1235 * Returns: (transfer full): an #AtkAttributeSet consisting of all
1236 * explicit properties/annotations applied to the object, or an empty
1237 * set if the object has no name-value pair attributes assigned to
1238 * it. This #atkattributeset should be freed by a call to
1239 * atk_attribute_set_free().
1242 atk_object_get_attributes (AtkObject
*accessible
)
1244 AtkObjectClass
*klass
;
1246 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1248 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1249 if (klass
->get_attributes
)
1250 return (klass
->get_attributes
) (accessible
);
1256 static AtkRelationSet
*
1257 atk_object_real_ref_relation_set (AtkObject
*accessible
)
1259 g_return_val_if_fail (accessible
->relation_set
, NULL
);
1260 g_object_ref (accessible
->relation_set
);
1262 return accessible
->relation_set
;
1266 atk_object_real_set_property (GObject
*object
,
1268 const GValue
*value
,
1271 AtkObject
*accessible
;
1273 accessible
= ATK_OBJECT (object
);
1278 atk_object_set_name (accessible
, g_value_get_string (value
));
1280 case PROP_DESCRIPTION
:
1281 atk_object_set_description (accessible
, g_value_get_string (value
));
1284 atk_object_set_role (accessible
, g_value_get_int (value
));
1287 atk_object_set_parent (accessible
, g_value_get_object (value
));
1290 if (ATK_IS_VALUE (accessible
))
1291 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
1293 case PROP_TABLE_SUMMARY
:
1294 if (ATK_IS_TABLE (accessible
))
1295 atk_table_set_summary (ATK_TABLE (accessible
), g_value_get_object (value
));
1297 case PROP_TABLE_CAPTION_OBJECT
:
1298 if (ATK_IS_TABLE (accessible
))
1299 atk_table_set_caption (ATK_TABLE (accessible
), g_value_get_object (value
));
1307 atk_object_real_get_property (GObject
*object
,
1312 AtkObject
*accessible
;
1314 accessible
= ATK_OBJECT (object
);
1319 g_value_set_string (value
, atk_object_get_name (accessible
));
1321 case PROP_DESCRIPTION
:
1322 g_value_set_string (value
, atk_object_get_description (accessible
));
1325 g_value_set_int (value
, atk_object_get_role (accessible
));
1328 if (ATK_IS_COMPONENT (accessible
))
1329 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
1331 case PROP_MDI_ZORDER
:
1332 if (ATK_IS_COMPONENT (accessible
))
1333 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
1336 g_value_set_object (value
, atk_object_get_parent (accessible
));
1339 if (ATK_IS_VALUE (accessible
))
1340 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
1342 case PROP_TABLE_SUMMARY
:
1343 if (ATK_IS_TABLE (accessible
))
1344 g_value_set_object (value
, atk_table_get_summary (ATK_TABLE (accessible
)));
1346 case PROP_TABLE_CAPTION_OBJECT
:
1347 if (ATK_IS_TABLE (accessible
))
1348 g_value_set_object (value
, atk_table_get_caption (ATK_TABLE (accessible
)));
1350 case PROP_HYPERTEXT_NUM_LINKS
:
1351 if (ATK_IS_HYPERTEXT (accessible
))
1352 g_value_set_int (value
, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible
)));
1355 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
1361 atk_object_finalize (GObject
*object
)
1363 AtkObject
*accessible
;
1365 g_return_if_fail (ATK_IS_OBJECT (object
));
1367 accessible
= ATK_OBJECT (object
);
1369 g_free (accessible
->name
);
1370 g_free (accessible
->description
);
1373 * Free memory allocated for relation set if it have been allocated.
1375 if (accessible
->relation_set
)
1376 g_object_unref (accessible
->relation_set
);
1378 if (accessible
->accessible_parent
)
1379 g_object_unref (accessible
->accessible_parent
);
1381 G_OBJECT_CLASS (parent_class
)->finalize (object
);
1385 atk_object_real_get_name (AtkObject
*object
)
1387 return object
->name
;
1391 atk_object_real_get_description (AtkObject
*object
)
1393 return object
->description
;
1397 atk_object_real_get_parent (AtkObject
*object
)
1399 return object
->accessible_parent
;
1403 atk_object_real_get_role (AtkObject
*object
)
1405 return object
->role
;
1409 atk_object_real_get_layer (AtkObject
*object
)
1411 return object
->layer
;
1415 atk_object_real_ref_state_set (AtkObject
*accessible
)
1417 AtkStateSet
*state_set
;
1418 AtkObject
*focus_object
;
1420 state_set
= atk_state_set_new ();
1422 focus_object
= atk_get_focus_object ();
1423 if (focus_object
== accessible
)
1424 atk_state_set_add_state (state_set
, ATK_STATE_FOCUSED
);
1430 atk_object_real_set_name (AtkObject
*object
,
1433 g_free (object
->name
);
1434 object
->name
= g_strdup (name
);
1438 atk_object_real_set_description (AtkObject
*object
,
1439 const gchar
*description
)
1441 g_free (object
->description
);
1442 object
->description
= g_strdup (description
);
1446 atk_object_real_set_parent (AtkObject
*object
,
1449 if (object
->accessible_parent
)
1450 g_object_unref (object
->accessible_parent
);
1452 object
->accessible_parent
= parent
;
1453 if (object
->accessible_parent
)
1454 g_object_ref (object
->accessible_parent
);
1458 atk_object_real_set_role (AtkObject
*object
,
1461 object
->role
= role
;
1465 atk_object_real_connect_property_change_handler (AtkObject
*obj
,
1466 AtkPropertyChangeHandler
*handler
)
1468 return g_signal_connect_closure_by_id (obj
,
1469 atk_object_signals
[PROPERTY_CHANGE
],
1472 G_CALLBACK (handler
), NULL
,
1473 (GClosureNotify
) NULL
),
1478 atk_object_real_remove_property_change_handler (AtkObject
*obj
,
1481 g_signal_handler_disconnect (obj
, handler_id
);
1485 * atk_object_initialize:
1486 * @accessible: a #AtkObject
1487 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1489 * This function is called when implementing subclasses of #AtkObject.
1490 * It does initialization required for the new object. It is intended
1491 * that this function should called only in the ..._new() functions used
1492 * to create an instance of a subclass of #AtkObject
1495 atk_object_initialize (AtkObject
*accessible
,
1498 AtkObjectClass
*klass
;
1500 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1502 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1503 if (klass
->initialize
)
1504 klass
->initialize (accessible
, data
);
1508 * This function is a signal handler for notify signal which gets emitted
1509 * when a property changes value.
1511 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1512 * signal which causes the user specified AtkPropertyChangeHandler
1516 atk_object_notify (GObject
*obj
,
1519 AtkPropertyValues values
= { NULL
, };
1521 g_value_init (&values
.new_value
, pspec
->value_type
);
1522 g_object_get_property (obj
, pspec
->name
, &values
.new_value
);
1523 values
.property_name
= pspec
->name
;
1524 g_signal_emit (obj
, atk_object_signals
[PROPERTY_CHANGE
],
1525 g_quark_from_string (pspec
->name
),
1527 g_value_unset (&values
.new_value
);
1531 * atk_role_get_name:
1532 * @role: The #AtkRole whose name is required
1534 * Gets the description string describing the #AtkRole @role.
1536 * Returns: the string describing the AtkRole
1539 atk_role_get_name (AtkRole role
)
1541 g_return_val_if_fail (role
>= 0, NULL
);
1544 initialize_role_names ();
1546 if (role
< role_names
->len
)
1547 return g_ptr_array_index (role_names
, role
);
1553 * atk_role_get_localized_name:
1554 * @role: The #AtkRole whose localized name is required
1556 * Gets the localized description string describing the #AtkRole @role.
1558 * Returns: the localized string describing the AtkRole
1561 atk_role_get_localized_name (AtkRole role
)
1563 gettext_initialization ();
1565 return dgettext (GETTEXT_PACKAGE
, atk_role_get_name (role
));
1569 atk_object_real_get_object_locale (AtkObject
*object
)
1571 return setlocale (LC_MESSAGES
, NULL
);
1575 * atk_object_get_object_locale:
1576 * @accessible: an #AtkObject
1578 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1583 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1584 * locale of @accessible.
1587 atk_object_get_object_locale (AtkObject
*accessible
)
1589 AtkObjectClass
*klass
;
1591 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1593 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1594 if (klass
->get_object_locale
)
1595 return (klass
->get_object_locale
) (accessible
);
1602 * atk_role_for_name:
1603 * @name: a string which is the (non-localized) name of an ATK role.
1605 * Get the #AtkRole type corresponding to a rolew name.
1607 * Returns: the #AtkRole enumerated type corresponding to the specified name,
1608 * or #ATK_ROLE_INVALID if no matching role is found.
1611 atk_role_for_name (const gchar
*name
)
1613 AtkRole role
= ATK_ROLE_INVALID
;
1616 g_return_val_if_fail (name
, ATK_ROLE_INVALID
);
1619 initialize_role_names ();
1621 for (i
= 0; i
< role_names
->len
; i
++)
1623 gchar
*role_name
= (gchar
*)g_ptr_array_index (role_names
, i
);
1625 g_return_val_if_fail (role_name
, ATK_ROLE_INVALID
);
1627 if (strcmp (name
, role_name
) == 0)
1638 * atk_object_add_relationship:
1639 * @object: The #AtkObject to which an AtkRelation is to be added.
1640 * @relationship: The #AtkRelationType of the relation
1641 * @target: The #AtkObject which is to be the target of the relation.
1643 * Adds a relationship of the specified type with the specified target.
1645 * Returns: TRUE if the relationship is added.
1648 atk_object_add_relationship (AtkObject
*object
,
1649 AtkRelationType relationship
,
1652 AtkObject
*array
[1];
1653 AtkRelation
*relation
;
1655 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1656 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1658 if (atk_relation_set_contains_target (object
->relation_set
,
1659 relationship
, target
))
1663 relation
= atk_relation_new (array
, 1, relationship
);
1664 atk_relation_set_add (object
->relation_set
, relation
);
1665 g_object_unref (relation
);
1671 * atk_object_remove_relationship:
1672 * @object: The #AtkObject from which an AtkRelation is to be removed.
1673 * @relationship: The #AtkRelationType of the relation
1674 * @target: The #AtkObject which is the target of the relation to be removed.
1676 * Removes a relationship of the specified type with the specified target.
1678 * Returns: TRUE if the relationship is removed.
1681 atk_object_remove_relationship (AtkObject
*object
,
1682 AtkRelationType relationship
,
1685 gboolean ret
= FALSE
;
1686 AtkRelation
*relation
;
1689 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1690 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1692 relation
= atk_relation_set_get_relation_by_type (object
->relation_set
, relationship
);
1696 ret
= atk_relation_remove_target (relation
, target
);
1697 array
= atk_relation_get_target (relation
);
1698 if (!array
|| array
->len
== 0)
1699 atk_relation_set_remove (object
->relation_set
, relation
);
1705 atk_object_real_initialize (AtkObject
*accessible
,