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"
38 static GPtrArray
*extra_roles
= NULL
;
42 PROP_0
, /* gobject convention */
46 PROP_PARENT
, /* ancestry has changed */
52 PROP_TABLE_COLUMN_DESCRIPTION
,
53 PROP_TABLE_COLUMN_HEADER
,
54 PROP_TABLE_ROW_DESCRIPTION
,
55 PROP_TABLE_ROW_HEADER
,
57 PROP_TABLE_CAPTION_OBJECT
,
58 PROP_HYPERTEXT_NUM_LINKS
,
59 PROP_LAST
/* gobject convention */
68 ACTIVE_DESCENDANT_CHANGED
,
73 /* These are listed here for extraction by intltool */
76 N_("accelerator label")
96 /* I know it looks wrong but that is what Java returns */
120 N_("radio menu item")
132 N_("table column header")
133 N_("table row header")
134 N_("tear off menu item")
152 N_("embedded component")
160 N_("redundant object")
163 N_("input method window")
166 N_("document spreadsheet")
167 N_("document presentation")
179 static const char roles
[] =
181 "accelerator label\0"
236 "table column header\0"
238 "tear off menu item\0"
256 "embedded component\0"
267 "input method window\0"
270 "document spreadsheet\0"
271 "document presentation\0"
283 static const guint16 roles_offsets
[] = {
284 0, 8, 26, 32, 42, 48, 57, 64,
285 74, 90, 104, 118, 128, 139, 152, 166,
286 171, 178, 193, 206, 219, 226, 238, 244,
287 255, 270, 275, 281, 296, 302, 315, 320,
288 330, 335, 344, 354, 366, 375, 389, 395,
289 409, 420, 433, 445, 458, 474, 484, 495,
290 506, 518, 528, 535, 546, 558, 568, 574,
291 585, 605, 622, 641, 650, 655, 669, 678,
292 687, 692, 703, 711, 720, 727, 734, 741,
293 751, 757, 769, 782, 791, 810, 816, 822,
294 830, 845, 853, 858, 866, 883, 888, 893,
295 913, 923, 933, 954, 976, 990, 1003, 1018,
296 1026, 1035, 1044, 1054, 1067, 1075
299 /* This is a static assertion */
300 typedef int _assert_roles_num
[(G_N_ELEMENTS (roles_offsets
) == ATK_ROLE_LAST_DEFINED
) ? 1 : -1];
302 static void atk_object_class_init (AtkObjectClass
*klass
);
303 static void atk_object_init (AtkObject
*accessible
,
304 AtkObjectClass
*klass
);
305 static AtkRelationSet
* atk_object_real_ref_relation_set
306 (AtkObject
*accessible
);
307 static void atk_object_real_initialize (AtkObject
*accessible
,
309 static void atk_object_real_set_property (GObject
*object
,
313 static void atk_object_real_get_property (GObject
*object
,
317 static void atk_object_finalize (GObject
*object
);
318 static const gchar
* atk_object_real_get_name (AtkObject
*object
);
319 static const gchar
* atk_object_real_get_description
321 static AtkObject
* atk_object_real_get_parent (AtkObject
*object
);
322 static AtkRole
atk_object_real_get_role (AtkObject
*object
);
323 static AtkLayer
atk_object_real_get_layer (AtkObject
*object
);
324 static AtkStateSet
* atk_object_real_ref_state_set
326 static void atk_object_real_set_name (AtkObject
*object
,
328 static void atk_object_real_set_description
330 const gchar
*description
);
331 static void atk_object_real_set_parent (AtkObject
*object
,
333 static void atk_object_real_set_role (AtkObject
*object
,
335 static guint atk_object_real_connect_property_change_handler
337 AtkPropertyChangeHandler
339 static void atk_object_real_remove_property_change_handler
342 static void atk_object_notify (GObject
*obj
,
344 static const gchar
* atk_object_real_get_object_locale
347 static guint atk_object_signals
[LAST_SIGNAL
] = { 0, };
349 static gpointer parent_class
= NULL
;
351 static const gchar
* const atk_object_name_property_name
= "accessible-name";
352 static const gchar
* const atk_object_name_property_description
= "accessible-description";
353 static const gchar
* const atk_object_name_property_parent
= "accessible-parent";
354 static const gchar
* const atk_object_name_property_value
= "accessible-value";
355 static const gchar
* const atk_object_name_property_role
= "accessible-role";
356 static const gchar
* const atk_object_name_property_component_layer
= "accessible-component-layer";
357 static const gchar
* const atk_object_name_property_component_mdi_zorder
= "accessible-component-mdi-zorder";
358 static const gchar
* const atk_object_name_property_table_caption
= "accessible-table-caption";
359 static const gchar
* const atk_object_name_property_table_column_description
= "accessible-table-column-description";
360 static const gchar
* const atk_object_name_property_table_column_header
= "accessible-table-column-header";
361 static const gchar
* const atk_object_name_property_table_row_description
= "accessible-table-row-description";
362 static const gchar
* const atk_object_name_property_table_row_header
= "accessible-table-row-header";
363 static const gchar
* const atk_object_name_property_table_summary
= "accessible-table-summary";
364 static const gchar
* const atk_object_name_property_table_caption_object
= "accessible-table-caption-object";
365 static const gchar
* const atk_object_name_property_hypertext_num_links
= "accessible-hypertext-nlinks";
369 static HMODULE atk_dll
;
372 DllMain (HINSTANCE hinstDLL
,
378 case DLL_PROCESS_ATTACH
:
379 atk_dll
= (HMODULE
) hinstDLL
;
387 get_atk_locale_dir (void)
389 static gchar
*atk_localedir
= NULL
;
396 /* ATK_LOCALEDIR might end in either /lib/locale or
397 * /share/locale. Scan for that slash.
399 p
= ATK_LOCALEDIR
+ strlen (ATK_LOCALEDIR
);
405 root
= g_win32_get_package_installation_directory_of_module (atk_dll
);
406 temp
= g_build_filename (root
, p
, NULL
);
409 /* atk_localedir is passed to bindtextdomain() which isn't
412 atk_localedir
= g_win32_locale_filename_from_utf8 (temp
);
415 return atk_localedir
;
420 #define ATK_LOCALEDIR get_atk_locale_dir()
425 gettext_initialization (void)
428 static gboolean gettext_initialized
= FALSE
;
430 if (!gettext_initialized
)
432 const char *dir
= g_getenv ("ATK_ALT_LOCALEDIR");
434 gettext_initialized
= TRUE
;
438 bindtextdomain (GETTEXT_PACKAGE
, dir
);
439 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
440 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
447 atk_object_get_type (void)
449 static GType type
= 0;
453 static const GTypeInfo typeInfo
=
455 sizeof (AtkObjectClass
),
456 (GBaseInitFunc
) NULL
,
457 (GBaseFinalizeFunc
) NULL
,
458 (GClassInitFunc
) atk_object_class_init
,
459 (GClassFinalizeFunc
) NULL
,
463 (GInstanceInitFunc
) atk_object_init
,
465 type
= g_type_register_static (G_TYPE_OBJECT
, "AtkObject", &typeInfo
, 0) ;
471 atk_object_class_init (AtkObjectClass
*klass
)
473 GObjectClass
*gobject_class
= G_OBJECT_CLASS (klass
);
475 parent_class
= g_type_class_peek_parent (klass
);
477 gobject_class
->set_property
= atk_object_real_set_property
;
478 gobject_class
->get_property
= atk_object_real_get_property
;
479 gobject_class
->finalize
= atk_object_finalize
;
480 gobject_class
->notify
= atk_object_notify
;
482 klass
->get_name
= atk_object_real_get_name
;
483 klass
->get_description
= atk_object_real_get_description
;
484 klass
->get_parent
= atk_object_real_get_parent
;
485 klass
->get_n_children
= NULL
;
486 klass
->ref_child
= NULL
;
487 klass
->get_index_in_parent
= NULL
;
488 klass
->ref_relation_set
= atk_object_real_ref_relation_set
;
489 klass
->get_role
= atk_object_real_get_role
;
490 klass
->get_layer
= atk_object_real_get_layer
;
491 klass
->get_mdi_zorder
= NULL
;
492 klass
->initialize
= atk_object_real_initialize
;
493 klass
->ref_state_set
= atk_object_real_ref_state_set
;
494 klass
->set_name
= atk_object_real_set_name
;
495 klass
->set_description
= atk_object_real_set_description
;
496 klass
->set_parent
= atk_object_real_set_parent
;
497 klass
->set_role
= atk_object_real_set_role
;
498 klass
->connect_property_change_handler
=
499 atk_object_real_connect_property_change_handler
;
500 klass
->remove_property_change_handler
=
501 atk_object_real_remove_property_change_handler
;
502 klass
->get_object_locale
= atk_object_real_get_object_locale
;
505 * We do not define default signal handlers here
507 klass
->children_changed
= NULL
;
508 klass
->focus_event
= NULL
;
509 klass
->property_change
= NULL
;
510 klass
->visible_data_changed
= NULL
;
511 klass
->active_descendant_changed
= NULL
;
513 gettext_initialization ();
515 g_object_class_install_property (gobject_class
,
517 g_param_spec_string (atk_object_name_property_name
,
518 _("Accessible Name"),
519 _("Object instance\'s name formatted for assistive technology access"),
522 g_object_class_install_property (gobject_class
,
524 g_param_spec_string (atk_object_name_property_description
,
525 _("Accessible Description"),
526 _("Description of an object, formatted for assistive technology access"),
529 g_object_class_install_property (gobject_class
,
531 g_param_spec_object (atk_object_name_property_parent
,
532 _("Accessible Parent"),
533 _("Is used to notify that the parent has changed"),
536 g_object_class_install_property (gobject_class
,
538 g_param_spec_double (atk_object_name_property_value
,
539 _("Accessible Value"),
540 _("Is used to notify that the value has changed"),
545 g_object_class_install_property (gobject_class
,
547 g_param_spec_int (atk_object_name_property_role
,
548 _("Accessible Role"),
549 _("The accessible role of this object"),
554 g_object_class_install_property (gobject_class
,
556 g_param_spec_int (atk_object_name_property_component_layer
,
557 _("Accessible Layer"),
558 _("The accessible layer of this object"),
563 g_object_class_install_property (gobject_class
,
565 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
566 _("Accessible MDI Value"),
567 _("The accessible MDI value of this object"),
572 g_object_class_install_property (gobject_class
,
574 g_param_spec_string (atk_object_name_property_table_caption
,
575 _("Accessible Table Caption"),
576 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
579 g_object_class_install_property (gobject_class
,
580 PROP_TABLE_COLUMN_HEADER
,
581 g_param_spec_object (atk_object_name_property_table_column_header
,
582 _("Accessible Table Column Header"),
583 _("Is used to notify that the table column header has changed"),
586 g_object_class_install_property (gobject_class
,
587 PROP_TABLE_COLUMN_DESCRIPTION
,
588 g_param_spec_string (atk_object_name_property_table_column_description
,
589 _("Accessible Table Column Description"),
590 _("Is used to notify that the table column description has changed"),
593 g_object_class_install_property (gobject_class
,
594 PROP_TABLE_ROW_HEADER
,
595 g_param_spec_object (atk_object_name_property_table_row_header
,
596 _("Accessible Table Row Header"),
597 _("Is used to notify that the table row header has changed"),
600 g_object_class_install_property (gobject_class
,
601 PROP_TABLE_ROW_DESCRIPTION
,
602 g_param_spec_string (atk_object_name_property_table_row_description
,
603 _("Accessible Table Row Description"),
604 _("Is used to notify that the table row description has changed"),
607 g_object_class_install_property (gobject_class
,
609 g_param_spec_object (atk_object_name_property_table_summary
,
610 _("Accessible Table Summary"),
611 _("Is used to notify that the table summary has changed"),
614 g_object_class_install_property (gobject_class
,
615 PROP_TABLE_CAPTION_OBJECT
,
616 g_param_spec_object (atk_object_name_property_table_caption_object
,
617 _("Accessible Table Caption Object"),
618 _("Is used to notify that the table caption has changed"),
621 g_object_class_install_property (gobject_class
,
622 PROP_HYPERTEXT_NUM_LINKS
,
623 g_param_spec_int (atk_object_name_property_hypertext_num_links
,
624 _("Number of Accessible Hypertext Links"),
625 _("The number of links which the current AtkHypertext has"),
630 atk_object_signals
[CHILDREN_CHANGED
] =
631 g_signal_new ("children_changed",
632 G_TYPE_FROM_CLASS (klass
),
633 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
634 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
636 g_cclosure_marshal_VOID__UINT_POINTER
,
638 2, G_TYPE_UINT
, G_TYPE_POINTER
);
639 atk_object_signals
[FOCUS_EVENT
] =
640 g_signal_new ("focus_event",
641 G_TYPE_FROM_CLASS (klass
),
643 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
645 g_cclosure_marshal_VOID__BOOLEAN
,
648 atk_object_signals
[PROPERTY_CHANGE
] =
649 g_signal_new ("property_change",
650 G_TYPE_FROM_CLASS (klass
),
651 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
652 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
653 (GSignalAccumulator
) NULL
, NULL
,
654 g_cclosure_marshal_VOID__POINTER
,
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
,
667 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
668 g_signal_new ("visible_data_changed",
669 G_TYPE_FROM_CLASS (klass
),
671 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
672 (GSignalAccumulator
) NULL
, NULL
,
673 g_cclosure_marshal_VOID__VOID
,
675 atk_object_signals
[ACTIVE_DESCENDANT_CHANGED
] =
676 g_signal_new ("active_descendant_changed",
677 G_TYPE_FROM_CLASS (klass
),
678 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
679 G_STRUCT_OFFSET (AtkObjectClass
, active_descendant_changed
),
681 g_cclosure_marshal_VOID__POINTER
,
687 atk_object_init (AtkObject
*accessible
,
688 AtkObjectClass
*klass
)
690 accessible
->name
= NULL
;
691 accessible
->description
= NULL
;
692 accessible
->accessible_parent
= NULL
;
693 accessible
->relation_set
= atk_relation_set_new();
694 accessible
->role
= ATK_ROLE_UNKNOWN
;
698 atk_implementor_get_type (void)
700 static GType type
= 0;
704 static const GTypeInfo typeInfo
=
706 sizeof (AtkImplementorIface
),
707 (GBaseInitFunc
) NULL
,
708 (GBaseFinalizeFunc
) NULL
,
711 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
718 * atk_object_get_name:
719 * @accessible: an #AtkObject
721 * Gets the accessible name of the accessible.
723 * Returns: a character string representing the accessible name of the object.
726 atk_object_get_name (AtkObject
*accessible
)
728 AtkObjectClass
*klass
;
730 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
732 klass
= ATK_OBJECT_GET_CLASS (accessible
);
734 return (klass
->get_name
) (accessible
);
740 * atk_object_get_description:
741 * @accessible: an #AtkObject
743 * Gets the accessible description of the accessible.
745 * Returns: a character string representing the accessible description
750 atk_object_get_description (AtkObject
*accessible
)
752 AtkObjectClass
*klass
;
754 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
756 klass
= ATK_OBJECT_GET_CLASS (accessible
);
757 if (klass
->get_description
)
758 return (klass
->get_description
) (accessible
);
764 * atk_object_get_parent:
765 * @accessible: an #AtkObject
767 * Gets the accessible parent of the accessible.
769 * Returns: (transfer none): a #AtkObject representing the accessible parent
773 atk_object_get_parent (AtkObject
*accessible
)
775 AtkObjectClass
*klass
;
777 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
779 klass
= ATK_OBJECT_GET_CLASS (accessible
);
780 if (klass
->get_parent
)
781 return (klass
->get_parent
) (accessible
);
787 * atk_object_get_n_accessible_children:
788 * @accessible: an #AtkObject
790 * Gets the number of accessible children of the accessible.
792 * Returns: an integer representing the number of accessible children
796 atk_object_get_n_accessible_children (AtkObject
*accessible
)
798 AtkObjectClass
*klass
;
800 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
802 klass
= ATK_OBJECT_GET_CLASS (accessible
);
803 if (klass
->get_n_children
)
804 return (klass
->get_n_children
) (accessible
);
810 * atk_object_ref_accessible_child:
811 * @accessible: an #AtkObject
812 * @i: a gint representing the position of the child, starting from 0
814 * Gets a reference to the specified accessible child of the object.
815 * The accessible children are 0-based so the first accessible child is
816 * at index 0, the second at index 1 and so on.
818 * Returns: (transfer full): an #AtkObject representing the specified
819 * accessible child of the accessible.
822 atk_object_ref_accessible_child (AtkObject
*accessible
,
825 AtkObjectClass
*klass
;
827 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
829 klass
= ATK_OBJECT_GET_CLASS (accessible
);
830 if (klass
->ref_child
)
831 return (klass
->ref_child
) (accessible
, i
);
837 * atk_object_ref_relation_set:
838 * @accessible: an #AtkObject
840 * Gets the #AtkRelationSet associated with the object.
842 * Returns: (transfer full): an #AtkRelationSet representing the relation set
846 atk_object_ref_relation_set (AtkObject
*accessible
)
848 AtkObjectClass
*klass
;
850 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
852 klass
= ATK_OBJECT_GET_CLASS (accessible
);
853 if (klass
->ref_relation_set
)
854 return (klass
->ref_relation_set
) (accessible
);
861 * @name: a character string describing the new role.
863 * Registers the role specified by @name.
865 * Returns: an #AtkRole for the new role.
868 atk_role_register (const gchar
*name
)
871 extra_roles
= g_ptr_array_new ();
873 g_ptr_array_add (extra_roles
, g_strdup (name
));
874 return extra_roles
->len
+ ATK_ROLE_LAST_DEFINED
;
878 * atk_object_get_role:
879 * @accessible: an #AtkObject
881 * Gets the role of the accessible.
883 * Returns: an #AtkRole which is the role of the accessible
886 atk_object_get_role (AtkObject
*accessible
)
888 AtkObjectClass
*klass
;
890 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
892 klass
= ATK_OBJECT_GET_CLASS (accessible
);
894 return (klass
->get_role
) (accessible
);
896 return ATK_ROLE_UNKNOWN
;
900 * atk_object_get_layer:
901 * @accessible: an #AtkObject
903 * Gets the layer of the accessible.
905 * Deprecated: Use atk_component_get_layer instead.
907 * Returns: an #AtkLayer which is the layer of the accessible
910 atk_object_get_layer (AtkObject
*accessible
)
912 AtkObjectClass
*klass
;
914 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
916 klass
= ATK_OBJECT_GET_CLASS (accessible
);
917 if (klass
->get_layer
)
918 return (klass
->get_layer
) (accessible
);
920 return ATK_LAYER_INVALID
;
924 * atk_object_get_mdi_zorder:
925 * @accessible: an #AtkObject
927 * Gets the zorder of the accessible. The value G_MININT will be returned
928 * if the layer of the accessible is not ATK_LAYER_MDI.
930 * Deprecated: Use atk_component_get_mdi_zorder instead.
932 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
933 * which the component is shown in relation to other components in the same
938 atk_object_get_mdi_zorder (AtkObject
*accessible
)
940 AtkObjectClass
*klass
;
942 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
944 klass
= ATK_OBJECT_GET_CLASS (accessible
);
945 if (klass
->get_mdi_zorder
)
946 return (klass
->get_mdi_zorder
) (accessible
);
952 * atk_object_ref_state_set:
953 * @accessible: an #AtkObject
955 * Gets a reference to the state set of the accessible; the caller must
956 * unreference it when it is no longer needed.
958 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
959 * set of the accessible
962 atk_object_ref_state_set (AtkObject
*accessible
)
964 AtkObjectClass
*klass
;
966 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
968 klass
= ATK_OBJECT_GET_CLASS (accessible
);
969 if (klass
->ref_state_set
)
970 return (klass
->ref_state_set
) (accessible
);
976 * atk_object_get_index_in_parent:
977 * @accessible: an #AtkObject
979 * Gets the 0-based index of this accessible in its parent; returns -1 if the
980 * accessible does not have an accessible parent.
982 * Returns: an integer which is the index of the accessible in its parent
985 atk_object_get_index_in_parent (AtkObject
*accessible
)
987 AtkObjectClass
*klass
;
989 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
991 klass
= ATK_OBJECT_GET_CLASS (accessible
);
992 if (klass
->get_index_in_parent
)
993 return (klass
->get_index_in_parent
) (accessible
);
999 * atk_object_set_name:
1000 * @accessible: an #AtkObject
1001 * @name: a character string to be set as the accessible name
1003 * Sets the accessible name of the accessible. You can't set the name
1004 * to NULL. This is reserved for the initial value. In this aspect
1005 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
1006 * a empty value you can use "".
1009 atk_object_set_name (AtkObject
*accessible
,
1012 AtkObjectClass
*klass
;
1013 gboolean notify
= FALSE
;
1015 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1016 g_return_if_fail (name
!= NULL
);
1018 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1019 if (klass
->set_name
)
1021 /* Do not notify for initial name setting. See bug 665870 */
1022 notify
= (accessible
->name
!= NULL
);
1024 (klass
->set_name
) (accessible
, name
);
1026 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
1031 * atk_object_set_description:
1032 * @accessible: an #AtkObject
1033 * @description: a character string to be set as the accessible description
1035 * Sets the accessible description of the accessible. You can't set
1036 * the description to NULL. This is reserved for the initial value. In
1037 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
1038 * the name to a empty value you can use "".
1041 atk_object_set_description (AtkObject
*accessible
,
1042 const gchar
*description
)
1044 AtkObjectClass
*klass
;
1045 gboolean notify
= FALSE
;
1047 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1048 g_return_if_fail (description
!= NULL
);
1050 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1051 if (klass
->set_description
)
1053 /* Do not notify for initial name setting. See bug 665870 */
1054 notify
= (accessible
->description
!= NULL
);
1056 (klass
->set_description
) (accessible
, description
);
1058 g_object_notify (G_OBJECT (accessible
),
1059 atk_object_name_property_description
);
1064 * atk_object_set_parent:
1065 * @accessible: an #AtkObject
1066 * @parent: an #AtkObject to be set as the accessible parent
1068 * Sets the accessible parent of the accessible.
1071 atk_object_set_parent (AtkObject
*accessible
,
1074 AtkObjectClass
*klass
;
1076 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1078 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1079 if (klass
->set_parent
)
1081 (klass
->set_parent
) (accessible
, parent
);
1082 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
1087 * atk_object_set_role:
1088 * @accessible: an #AtkObject
1089 * @role: an #AtkRole to be set as the role
1091 * Sets the role of the accessible.
1094 atk_object_set_role (AtkObject
*accessible
,
1097 AtkObjectClass
*klass
;
1100 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1102 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1103 if (klass
->set_role
)
1105 old_role
= atk_object_get_role (accessible
);
1106 if (old_role
!= role
)
1108 (klass
->set_role
) (accessible
, role
);
1109 if (old_role
!= ATK_ROLE_UNKNOWN
)
1110 /* Do not notify for initial role setting */
1111 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
1117 * atk_object_connect_property_change_handler:
1118 * @accessible: an #AtkObject
1119 * @handler: a function to be called when a property changes its value
1121 * Specifies a function to be called when a property changes value.
1123 * Returns: a #guint which is the handler id used in
1124 * atk_object_remove_property_change_handler()
1127 atk_object_connect_property_change_handler (AtkObject
*accessible
,
1128 AtkPropertyChangeHandler
*handler
)
1130 AtkObjectClass
*klass
;
1132 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
1133 g_return_val_if_fail ((handler
!= NULL
), 0);
1135 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1136 if (klass
->connect_property_change_handler
)
1137 return (klass
->connect_property_change_handler
) (accessible
, handler
);
1143 * atk_object_remove_property_change_handler:
1144 * @accessible: an #AtkObject
1145 * @handler_id: a guint which identifies the handler to be removed.
1147 * Removes a property change handler.
1150 atk_object_remove_property_change_handler (AtkObject
*accessible
,
1153 AtkObjectClass
*klass
;
1155 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1157 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1158 if (klass
->remove_property_change_handler
)
1159 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
1163 * atk_object_notify_state_change:
1164 * @accessible: an #AtkObject
1165 * @state: an #AtkState whose state is changed
1166 * @value: a gboolean which indicates whether the state is being set on or off
1168 * Emits a state-change signal for the specified state.
1171 atk_object_notify_state_change (AtkObject
*accessible
,
1177 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1179 name
= atk_state_type_get_name (state
);
1180 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
1181 g_quark_from_string (name
),
1186 * atk_implementor_ref_accessible:
1187 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1188 * if a non-null return value is required.
1190 * Gets a reference to an object's #AtkObject implementation, if
1191 * the object implements #AtkObjectIface
1193 * Returns: (transfer full): a reference to an object's #AtkObject
1197 atk_implementor_ref_accessible (AtkImplementor
*implementor
)
1199 AtkImplementorIface
*iface
;
1200 AtkObject
*accessible
= NULL
;
1202 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor
), NULL
);
1204 iface
= ATK_IMPLEMENTOR_GET_IFACE (implementor
);
1207 accessible
= iface
->ref_accessible (implementor
);
1209 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
1216 * atk_object_get_attributes:
1217 * @accessible: An #AtkObject.
1219 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1220 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1221 * as distinct from strongly-typed object data available via other get/set methods.
1222 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1226 * Returns: (transfer none): an #AtkAttributeSet consisting of all explicit
1227 * properties/annotations applied to the object, or an empty set if the object
1228 * has no name-value pair attributes assigned to it.
1231 atk_object_get_attributes (AtkObject
*accessible
)
1233 AtkObjectClass
*klass
;
1235 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1237 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1238 if (klass
->get_attributes
)
1239 return (klass
->get_attributes
) (accessible
);
1245 static AtkRelationSet
*
1246 atk_object_real_ref_relation_set (AtkObject
*accessible
)
1248 g_return_val_if_fail (accessible
->relation_set
, NULL
);
1249 g_object_ref (accessible
->relation_set
);
1251 return accessible
->relation_set
;
1255 atk_object_real_set_property (GObject
*object
,
1257 const GValue
*value
,
1260 AtkObject
*accessible
;
1262 accessible
= ATK_OBJECT (object
);
1267 atk_object_set_name (accessible
, g_value_get_string (value
));
1269 case PROP_DESCRIPTION
:
1270 atk_object_set_description (accessible
, g_value_get_string (value
));
1273 atk_object_set_role (accessible
, g_value_get_int (value
));
1276 atk_object_set_parent (accessible
, g_value_get_object (value
));
1279 if (ATK_IS_VALUE (accessible
))
1280 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
1282 case PROP_TABLE_SUMMARY
:
1283 if (ATK_IS_TABLE (accessible
))
1284 atk_table_set_summary (ATK_TABLE (accessible
), g_value_get_object (value
));
1286 case PROP_TABLE_CAPTION_OBJECT
:
1287 if (ATK_IS_TABLE (accessible
))
1288 atk_table_set_caption (ATK_TABLE (accessible
), g_value_get_object (value
));
1296 atk_object_real_get_property (GObject
*object
,
1301 AtkObject
*accessible
;
1303 accessible
= ATK_OBJECT (object
);
1308 g_value_set_string (value
, atk_object_get_name (accessible
));
1310 case PROP_DESCRIPTION
:
1311 g_value_set_string (value
, atk_object_get_description (accessible
));
1314 g_value_set_int (value
, atk_object_get_role (accessible
));
1317 if (ATK_IS_COMPONENT (accessible
))
1318 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
1320 case PROP_MDI_ZORDER
:
1321 if (ATK_IS_COMPONENT (accessible
))
1322 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
1325 g_value_set_object (value
, atk_object_get_parent (accessible
));
1328 if (ATK_IS_VALUE (accessible
))
1329 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
1331 case PROP_TABLE_SUMMARY
:
1332 if (ATK_IS_TABLE (accessible
))
1333 g_value_set_object (value
, atk_table_get_summary (ATK_TABLE (accessible
)));
1335 case PROP_TABLE_CAPTION_OBJECT
:
1336 if (ATK_IS_TABLE (accessible
))
1337 g_value_set_object (value
, atk_table_get_caption (ATK_TABLE (accessible
)));
1339 case PROP_HYPERTEXT_NUM_LINKS
:
1340 if (ATK_IS_HYPERTEXT (accessible
))
1341 g_value_set_int (value
, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible
)));
1344 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
1350 atk_object_finalize (GObject
*object
)
1352 AtkObject
*accessible
;
1354 g_return_if_fail (ATK_IS_OBJECT (object
));
1356 accessible
= ATK_OBJECT (object
);
1358 g_free (accessible
->name
);
1359 g_free (accessible
->description
);
1362 * Free memory allocated for relation set if it have been allocated.
1364 if (accessible
->relation_set
)
1365 g_object_unref (accessible
->relation_set
);
1367 if (accessible
->accessible_parent
)
1368 g_object_unref (accessible
->accessible_parent
);
1370 G_OBJECT_CLASS (parent_class
)->finalize (object
);
1374 atk_object_real_get_name (AtkObject
*object
)
1376 return object
->name
;
1380 atk_object_real_get_description (AtkObject
*object
)
1382 return object
->description
;
1386 atk_object_real_get_parent (AtkObject
*object
)
1388 return object
->accessible_parent
;
1392 atk_object_real_get_role (AtkObject
*object
)
1394 return object
->role
;
1398 atk_object_real_get_layer (AtkObject
*object
)
1400 return object
->layer
;
1404 atk_object_real_ref_state_set (AtkObject
*accessible
)
1406 AtkStateSet
*state_set
;
1407 AtkObject
*focus_object
;
1409 state_set
= atk_state_set_new ();
1411 focus_object
= atk_get_focus_object ();
1412 if (focus_object
== accessible
)
1413 atk_state_set_add_state (state_set
, ATK_STATE_FOCUSED
);
1419 atk_object_real_set_name (AtkObject
*object
,
1422 g_free (object
->name
);
1423 object
->name
= g_strdup (name
);
1427 atk_object_real_set_description (AtkObject
*object
,
1428 const gchar
*description
)
1430 g_free (object
->description
);
1431 object
->description
= g_strdup (description
);
1435 atk_object_real_set_parent (AtkObject
*object
,
1438 if (object
->accessible_parent
)
1439 g_object_unref (object
->accessible_parent
);
1441 object
->accessible_parent
= parent
;
1442 if (object
->accessible_parent
)
1443 g_object_ref (object
->accessible_parent
);
1447 atk_object_real_set_role (AtkObject
*object
,
1450 object
->role
= role
;
1454 atk_object_real_connect_property_change_handler (AtkObject
*obj
,
1455 AtkPropertyChangeHandler
*handler
)
1457 return g_signal_connect_closure_by_id (obj
,
1458 atk_object_signals
[PROPERTY_CHANGE
],
1461 G_CALLBACK (handler
), NULL
,
1462 (GClosureNotify
) NULL
),
1467 atk_object_real_remove_property_change_handler (AtkObject
*obj
,
1470 g_signal_handler_disconnect (obj
, handler_id
);
1474 * atk_object_initialize:
1475 * @accessible: a #AtkObject
1476 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1478 * This function is called when implementing subclasses of #AtkObject.
1479 * It does initialization required for the new object. It is intended
1480 * that this function should called only in the ..._new() functions used
1481 * to create an instance of a subclass of #AtkObject
1484 atk_object_initialize (AtkObject
*accessible
,
1487 AtkObjectClass
*klass
;
1489 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1491 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1492 if (klass
->initialize
)
1493 klass
->initialize (accessible
, data
);
1497 * This function is a signal handler for notify signal which gets emitted
1498 * when a property changes value.
1500 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1501 * signal which causes the user specified AtkPropertyChangeHandler
1505 atk_object_notify (GObject
*obj
,
1508 AtkPropertyValues values
= { NULL
, };
1510 g_value_init (&values
.new_value
, pspec
->value_type
);
1511 g_object_get_property (obj
, pspec
->name
, &values
.new_value
);
1512 values
.property_name
= pspec
->name
;
1513 g_signal_emit (obj
, atk_object_signals
[PROPERTY_CHANGE
],
1514 g_quark_from_string (pspec
->name
),
1516 g_value_unset (&values
.new_value
);
1520 * atk_role_get_name:
1521 * @role: The #AtkRole whose name is required
1523 * Gets the description string describing the #AtkRole @role.
1525 * Returns: the string describing the AtkRole
1528 atk_role_get_name (AtkRole role
)
1530 if (role
>= 0 && role
< ATK_ROLE_LAST_DEFINED
)
1531 return roles
+ roles_offsets
[role
];
1537 n
-= ATK_ROLE_LAST_DEFINED
+ 1;
1539 if (n
>= 0 && n
< extra_roles
->len
)
1540 return g_ptr_array_index (extra_roles
, n
);
1547 * atk_role_get_localized_name:
1548 * @role: The #AtkRole whose localized name is required
1550 * Gets the localized description string describing the #AtkRole @role.
1552 * Returns: the localized string describing the AtkRole
1555 atk_role_get_localized_name (AtkRole role
)
1557 gettext_initialization ();
1559 if (role
>= 0 && role
< ATK_ROLE_LAST_DEFINED
)
1560 return dgettext (GETTEXT_PACKAGE
, roles
+ roles_offsets
[role
]);
1562 return atk_role_get_name (role
);
1566 atk_object_real_get_object_locale (AtkObject
*object
)
1568 return setlocale (LC_MESSAGES
, NULL
);
1572 * atk_object_get_object_locale:
1573 * @accessible: an #AtkObject
1575 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1580 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1581 * locale of @accessible.
1584 atk_object_get_object_locale (AtkObject
*accessible
)
1586 AtkObjectClass
*klass
;
1588 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1590 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1591 if (klass
->get_object_locale
)
1592 return (klass
->get_object_locale
) (accessible
);
1599 * atk_role_for_name:
1600 * @name: a string which is the (non-localized) name of an ATK role.
1602 * Get the #AtkRole type corresponding to a rolew name.
1604 * Returns: the #AtkRole enumerated type corresponding to the specified
1606 * or #ATK_ROLE_INVALID if no matching role is found.
1609 atk_role_for_name (const gchar
*name
)
1611 AtkRole role
= ATK_ROLE_INVALID
;
1614 g_return_val_if_fail (name
, ATK_ROLE_INVALID
);
1616 for (i
= 0; i
< G_N_ELEMENTS (roles_offsets
); i
++)
1618 if (strcmp (name
, roles
+ roles_offsets
[i
]) == 0)
1624 for (i
= 0; i
< extra_roles
->len
; i
++)
1626 gchar
*extra_role
= (gchar
*)g_ptr_array_index (extra_roles
, i
);
1628 g_return_val_if_fail (extra_role
, ATK_ROLE_INVALID
);
1630 if (strcmp (name
, extra_role
) == 0)
1632 role
= i
+ 1 + ATK_ROLE_LAST_DEFINED
;
1642 * atk_object_add_relationship:
1643 * @object: The #AtkObject to which an AtkRelation is to be added.
1644 * @relationship: The #AtkRelationType of the relation
1645 * @target: The #AtkObject which is to be the target of the relation.
1647 * Adds a relationship of the specified type with the specified target.
1649 * Returns TRUE if the relationship is added.
1652 atk_object_add_relationship (AtkObject
*object
,
1653 AtkRelationType relationship
,
1656 AtkObject
*array
[1];
1657 AtkRelation
*relation
;
1659 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1660 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1662 if (atk_relation_set_contains_target (object
->relation_set
,
1663 relationship
, target
))
1667 relation
= atk_relation_new (array
, 1, relationship
);
1668 atk_relation_set_add (object
->relation_set
, relation
);
1669 g_object_unref (relation
);
1675 * atk_object_remove_relationship:
1676 * @object: The #AtkObject from which an AtkRelation is to be removed.
1677 * @relationship: The #AtkRelationType of the relation
1678 * @target: The #AtkObject which is the target of the relation to be removed.
1680 * Removes a relationship of the specified type with the specified target.
1682 * Returns TRUE if the relationship is removed.
1685 atk_object_remove_relationship (AtkObject
*object
,
1686 AtkRelationType relationship
,
1689 gboolean ret
= FALSE
;
1690 AtkRelation
*relation
;
1693 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1694 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1696 relation
= atk_relation_set_get_relation_by_type (object
->relation_set
, relationship
);
1700 ret
= atk_relation_remove_target (relation
, target
);
1701 array
= atk_relation_get_target (relation
);
1702 if (!array
|| array
->len
== 0)
1703 atk_relation_set_remove (object
->relation_set
, relation
);
1709 atk_object_real_initialize (AtkObject
*accessible
,