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.
22 #include <glib-object.h>
28 #undef FOCUS_EVENT /* <windows.h> pollutes the namespace
29 * like a six hundred pound gorilla */
33 #include "atkmarshal.h"
34 #include "atk-enum-types.h"
37 static GPtrArray
*extra_roles
= NULL
;
41 PROP_0
, /* gobject convention */
45 PROP_PARENT
, /* ancestry has changed */
51 PROP_TABLE_COLUMN_DESCRIPTION
,
52 PROP_TABLE_COLUMN_HEADER
,
53 PROP_TABLE_ROW_DESCRIPTION
,
54 PROP_TABLE_ROW_HEADER
,
56 PROP_TABLE_CAPTION_OBJECT
,
57 PROP_HYPERTEXT_NUM_LINKS
,
58 PROP_LAST
/* gobject convention */
67 ACTIVE_DESCENDANT_CHANGED
,
72 /* These are listed here for extraction by intltool */
75 N_("accelerator label")
95 /* I know it looks wrong but that is what Java returns */
119 N_("radio menu item")
131 N_("table column header")
132 N_("table row header")
133 N_("tear off menu item")
151 N_("embedded component")
159 N_("redundant object")
162 N_("input method window")
165 N_("document spreadsheet")
166 N_("document presentation")
178 static const char roles
[] =
180 "accelerator label\0"
235 "table column header\0"
237 "tear off menu item\0"
255 "embedded component\0"
266 "input method window\0"
269 "document spreadsheet\0"
270 "document presentation\0"
281 static const guint16 roles_offsets
[] = {
282 0, 8, 26, 32, 42, 48, 57, 64,
283 74, 90, 104, 118, 128, 139, 152, 166,
284 171, 178, 193, 206, 219, 226, 238, 244,
285 255, 270, 275, 281, 296, 302, 315, 320,
286 330, 335, 344, 354, 366, 375, 389, 395,
287 409, 420, 433, 445, 458, 474, 484, 495,
288 506, 518, 528, 535, 546, 558, 568, 574,
289 585, 605, 622, 641, 650, 655, 669, 678,
290 687, 692, 703, 711, 720, 727, 734, 741,
291 751, 757, 769, 782, 791, 810, 816, 822,
292 830, 845, 853, 858, 866, 883, 888, 893,
293 913, 923, 933, 954, 976, 990, 1003, 1018,
294 1026, 1035, 1044, 1054, 1067
297 /* This is a static assertion */
298 typedef int _assert_roles_num
[(G_N_ELEMENTS (roles_offsets
) == ATK_ROLE_LAST_DEFINED
) ? 1 : -1];
300 static void atk_object_class_init (AtkObjectClass
*klass
);
301 static void atk_object_init (AtkObject
*accessible
,
302 AtkObjectClass
*klass
);
303 static AtkRelationSet
* atk_object_real_ref_relation_set
304 (AtkObject
*accessible
);
305 static void atk_object_real_initialize (AtkObject
*accessible
,
307 static void atk_object_real_set_property (GObject
*object
,
311 static void atk_object_real_get_property (GObject
*object
,
315 static void atk_object_finalize (GObject
*object
);
316 static const gchar
* atk_object_real_get_name (AtkObject
*object
);
317 static const gchar
* atk_object_real_get_description
319 static AtkObject
* atk_object_real_get_parent (AtkObject
*object
);
320 static AtkRole
atk_object_real_get_role (AtkObject
*object
);
321 static AtkLayer
atk_object_real_get_layer (AtkObject
*object
);
322 static AtkStateSet
* atk_object_real_ref_state_set
324 static void atk_object_real_set_name (AtkObject
*object
,
326 static void atk_object_real_set_description
328 const gchar
*description
);
329 static void atk_object_real_set_parent (AtkObject
*object
,
331 static void atk_object_real_set_role (AtkObject
*object
,
333 static guint atk_object_real_connect_property_change_handler
335 AtkPropertyChangeHandler
337 static void atk_object_real_remove_property_change_handler
340 static void atk_object_notify (GObject
*obj
,
344 static guint atk_object_signals
[LAST_SIGNAL
] = { 0, };
346 static gpointer parent_class
= NULL
;
348 static const gchar
* const atk_object_name_property_name
= "accessible-name";
349 static const gchar
* const atk_object_name_property_description
= "accessible-description";
350 static const gchar
* const atk_object_name_property_parent
= "accessible-parent";
351 static const gchar
* const atk_object_name_property_value
= "accessible-value";
352 static const gchar
* const atk_object_name_property_role
= "accessible-role";
353 static const gchar
* const atk_object_name_property_component_layer
= "accessible-component-layer";
354 static const gchar
* const atk_object_name_property_component_mdi_zorder
= "accessible-component-mdi-zorder";
355 static const gchar
* const atk_object_name_property_table_caption
= "accessible-table-caption";
356 static const gchar
* const atk_object_name_property_table_column_description
= "accessible-table-column-description";
357 static const gchar
* const atk_object_name_property_table_column_header
= "accessible-table-column-header";
358 static const gchar
* const atk_object_name_property_table_row_description
= "accessible-table-row-description";
359 static const gchar
* const atk_object_name_property_table_row_header
= "accessible-table-row-header";
360 static const gchar
* const atk_object_name_property_table_summary
= "accessible-table-summary";
361 static const gchar
* const atk_object_name_property_table_caption_object
= "accessible-table-caption-object";
362 static const gchar
* const atk_object_name_property_hypertext_num_links
= "accessible-hypertext-nlinks";
366 static HMODULE atk_dll
;
369 DllMain (HINSTANCE hinstDLL
,
375 case DLL_PROCESS_ATTACH
:
376 atk_dll
= (HMODULE
) hinstDLL
;
384 get_atk_locale_dir (void)
386 static gchar
*atk_localedir
= NULL
;
393 /* ATK_LOCALEDIR might end in either /lib/locale or
394 * /share/locale. Scan for that slash.
396 p
= ATK_LOCALEDIR
+ strlen (ATK_LOCALEDIR
);
402 root
= g_win32_get_package_installation_directory_of_module (atk_dll
);
403 temp
= g_build_filename (root
, p
, NULL
);
406 /* atk_localedir is passed to bindtextdomain() which isn't
409 atk_localedir
= g_win32_locale_filename_from_utf8 (temp
);
412 return atk_localedir
;
417 #define ATK_LOCALEDIR get_atk_locale_dir()
422 gettext_initialization (void)
425 static gboolean gettext_initialized
= FALSE
;
427 if (!gettext_initialized
)
429 const char *dir
= g_getenv ("ATK_ALT_LOCALEDIR");
431 gettext_initialized
= TRUE
;
435 bindtextdomain (GETTEXT_PACKAGE
, dir
);
436 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
437 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
444 atk_object_get_type (void)
446 static GType type
= 0;
450 static const GTypeInfo typeInfo
=
452 sizeof (AtkObjectClass
),
453 (GBaseInitFunc
) NULL
,
454 (GBaseFinalizeFunc
) NULL
,
455 (GClassInitFunc
) atk_object_class_init
,
456 (GClassFinalizeFunc
) NULL
,
460 (GInstanceInitFunc
) atk_object_init
,
462 type
= g_type_register_static (G_TYPE_OBJECT
, "AtkObject", &typeInfo
, 0) ;
468 atk_object_class_init (AtkObjectClass
*klass
)
470 GObjectClass
*gobject_class
= G_OBJECT_CLASS (klass
);
472 parent_class
= g_type_class_peek_parent (klass
);
474 gobject_class
->set_property
= atk_object_real_set_property
;
475 gobject_class
->get_property
= atk_object_real_get_property
;
476 gobject_class
->finalize
= atk_object_finalize
;
477 gobject_class
->notify
= atk_object_notify
;
479 klass
->get_name
= atk_object_real_get_name
;
480 klass
->get_description
= atk_object_real_get_description
;
481 klass
->get_parent
= atk_object_real_get_parent
;
482 klass
->get_n_children
= NULL
;
483 klass
->ref_child
= NULL
;
484 klass
->get_index_in_parent
= NULL
;
485 klass
->ref_relation_set
= atk_object_real_ref_relation_set
;
486 klass
->get_role
= atk_object_real_get_role
;
487 klass
->get_layer
= atk_object_real_get_layer
;
488 klass
->get_mdi_zorder
= NULL
;
489 klass
->initialize
= atk_object_real_initialize
;
490 klass
->ref_state_set
= atk_object_real_ref_state_set
;
491 klass
->set_name
= atk_object_real_set_name
;
492 klass
->set_description
= atk_object_real_set_description
;
493 klass
->set_parent
= atk_object_real_set_parent
;
494 klass
->set_role
= atk_object_real_set_role
;
495 klass
->connect_property_change_handler
=
496 atk_object_real_connect_property_change_handler
;
497 klass
->remove_property_change_handler
=
498 atk_object_real_remove_property_change_handler
;
501 * We do not define default signal handlers here
503 klass
->children_changed
= NULL
;
504 klass
->focus_event
= NULL
;
505 klass
->property_change
= NULL
;
506 klass
->visible_data_changed
= NULL
;
507 klass
->active_descendant_changed
= NULL
;
509 gettext_initialization ();
511 g_object_class_install_property (gobject_class
,
513 g_param_spec_string (atk_object_name_property_name
,
514 _("Accessible Name"),
515 _("Object instance\'s name formatted for assistive technology access"),
518 g_object_class_install_property (gobject_class
,
520 g_param_spec_string (atk_object_name_property_description
,
521 _("Accessible Description"),
522 _("Description of an object, formatted for assistive technology access"),
525 g_object_class_install_property (gobject_class
,
527 g_param_spec_object (atk_object_name_property_parent
,
528 _("Accessible Parent"),
529 _("Is used to notify that the parent has changed"),
532 g_object_class_install_property (gobject_class
,
534 g_param_spec_double (atk_object_name_property_value
,
535 _("Accessible Value"),
536 _("Is used to notify that the value has changed"),
541 g_object_class_install_property (gobject_class
,
543 g_param_spec_int (atk_object_name_property_role
,
544 _("Accessible Role"),
545 _("The accessible role of this object"),
550 g_object_class_install_property (gobject_class
,
552 g_param_spec_int (atk_object_name_property_component_layer
,
553 _("Accessible Layer"),
554 _("The accessible layer of this object"),
559 g_object_class_install_property (gobject_class
,
561 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
562 _("Accessible MDI Value"),
563 _("The accessible MDI value of this object"),
568 g_object_class_install_property (gobject_class
,
570 g_param_spec_string (atk_object_name_property_table_caption
,
571 _("Accessible Table Caption"),
572 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
575 g_object_class_install_property (gobject_class
,
576 PROP_TABLE_COLUMN_HEADER
,
577 g_param_spec_object (atk_object_name_property_table_column_header
,
578 _("Accessible Table Column Header"),
579 _("Is used to notify that the table column header has changed"),
582 g_object_class_install_property (gobject_class
,
583 PROP_TABLE_COLUMN_DESCRIPTION
,
584 g_param_spec_string (atk_object_name_property_table_column_description
,
585 _("Accessible Table Column Description"),
586 _("Is used to notify that the table column description has changed"),
589 g_object_class_install_property (gobject_class
,
590 PROP_TABLE_ROW_HEADER
,
591 g_param_spec_object (atk_object_name_property_table_row_header
,
592 _("Accessible Table Row Header"),
593 _("Is used to notify that the table row header has changed"),
596 g_object_class_install_property (gobject_class
,
597 PROP_TABLE_ROW_DESCRIPTION
,
598 g_param_spec_string (atk_object_name_property_table_row_description
,
599 _("Accessible Table Row Description"),
600 _("Is used to notify that the table row description has changed"),
603 g_object_class_install_property (gobject_class
,
605 g_param_spec_object (atk_object_name_property_table_summary
,
606 _("Accessible Table Summary"),
607 _("Is used to notify that the table summary has changed"),
610 g_object_class_install_property (gobject_class
,
611 PROP_TABLE_CAPTION_OBJECT
,
612 g_param_spec_object (atk_object_name_property_table_caption_object
,
613 _("Accessible Table Caption Object"),
614 _("Is used to notify that the table caption has changed"),
617 g_object_class_install_property (gobject_class
,
618 PROP_HYPERTEXT_NUM_LINKS
,
619 g_param_spec_int (atk_object_name_property_hypertext_num_links
,
620 _("Number of Accessible Hypertext Links"),
621 _("The number of links which the current AtkHypertext has"),
626 atk_object_signals
[CHILDREN_CHANGED
] =
627 g_signal_new ("children_changed",
628 G_TYPE_FROM_CLASS (klass
),
629 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
630 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
632 g_cclosure_marshal_VOID__UINT_POINTER
,
634 2, G_TYPE_UINT
, G_TYPE_POINTER
);
635 atk_object_signals
[FOCUS_EVENT
] =
636 g_signal_new ("focus_event",
637 G_TYPE_FROM_CLASS (klass
),
639 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
641 g_cclosure_marshal_VOID__BOOLEAN
,
644 atk_object_signals
[PROPERTY_CHANGE
] =
645 g_signal_new ("property_change",
646 G_TYPE_FROM_CLASS (klass
),
647 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
648 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
649 (GSignalAccumulator
) NULL
, NULL
,
650 g_cclosure_marshal_VOID__POINTER
,
653 atk_object_signals
[STATE_CHANGE
] =
654 g_signal_new ("state_change",
655 G_TYPE_FROM_CLASS (klass
),
656 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
657 G_STRUCT_OFFSET (AtkObjectClass
, state_change
),
658 (GSignalAccumulator
) NULL
, NULL
,
659 atk_marshal_VOID__STRING_BOOLEAN
,
663 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
664 g_signal_new ("visible_data_changed",
665 G_TYPE_FROM_CLASS (klass
),
667 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
668 (GSignalAccumulator
) NULL
, NULL
,
669 g_cclosure_marshal_VOID__VOID
,
671 atk_object_signals
[ACTIVE_DESCENDANT_CHANGED
] =
672 g_signal_new ("active_descendant_changed",
673 G_TYPE_FROM_CLASS (klass
),
674 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
675 G_STRUCT_OFFSET (AtkObjectClass
, active_descendant_changed
),
677 g_cclosure_marshal_VOID__POINTER
,
683 atk_object_init (AtkObject
*accessible
,
684 AtkObjectClass
*klass
)
686 accessible
->name
= NULL
;
687 accessible
->description
= NULL
;
688 accessible
->accessible_parent
= NULL
;
689 accessible
->relation_set
= atk_relation_set_new();
690 accessible
->role
= ATK_ROLE_UNKNOWN
;
694 atk_implementor_get_type (void)
696 static GType type
= 0;
700 static const GTypeInfo typeInfo
=
702 sizeof (AtkImplementorIface
),
703 (GBaseInitFunc
) NULL
,
704 (GBaseFinalizeFunc
) NULL
,
707 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
714 * atk_object_get_name:
715 * @accessible: an #AtkObject
717 * Gets the accessible name of the accessible.
719 * Returns: a character string representing the accessible name of the object.
722 atk_object_get_name (AtkObject
*accessible
)
724 AtkObjectClass
*klass
;
726 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
728 klass
= ATK_OBJECT_GET_CLASS (accessible
);
730 return (klass
->get_name
) (accessible
);
736 * atk_object_get_description:
737 * @accessible: an #AtkObject
739 * Gets the accessible description of the accessible.
741 * Returns: a character string representing the accessible description
746 atk_object_get_description (AtkObject
*accessible
)
748 AtkObjectClass
*klass
;
750 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
752 klass
= ATK_OBJECT_GET_CLASS (accessible
);
753 if (klass
->get_description
)
754 return (klass
->get_description
) (accessible
);
760 * atk_object_get_parent:
761 * @accessible: an #AtkObject
763 * Gets the accessible parent of the accessible.
765 * Returns: (transfer none): a #AtkObject representing the accessible parent
769 atk_object_get_parent (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_parent
)
777 return (klass
->get_parent
) (accessible
);
783 * atk_object_get_n_accessible_children:
784 * @accessible: an #AtkObject
786 * Gets the number of accessible children of the accessible.
788 * Returns: an integer representing the number of accessible children
792 atk_object_get_n_accessible_children (AtkObject
*accessible
)
794 AtkObjectClass
*klass
;
796 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
798 klass
= ATK_OBJECT_GET_CLASS (accessible
);
799 if (klass
->get_n_children
)
800 return (klass
->get_n_children
) (accessible
);
806 * atk_object_ref_accessible_child:
807 * @accessible: an #AtkObject
808 * @i: a gint representing the position of the child, starting from 0
810 * Gets a reference to the specified accessible child of the object.
811 * The accessible children are 0-based so the first accessible child is
812 * at index 0, the second at index 1 and so on.
814 * Returns: (transfer full): an #AtkObject representing the specified
815 * accessible child of the accessible.
818 atk_object_ref_accessible_child (AtkObject
*accessible
,
821 AtkObjectClass
*klass
;
823 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
825 klass
= ATK_OBJECT_GET_CLASS (accessible
);
826 if (klass
->ref_child
)
827 return (klass
->ref_child
) (accessible
, i
);
833 * atk_object_ref_relation_set:
834 * @accessible: an #AtkObject
836 * Gets the #AtkRelationSet associated with the object.
838 * Returns: (transfer full): an #AtkRelationSet representing the relation set
842 atk_object_ref_relation_set (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_relation_set
)
850 return (klass
->ref_relation_set
) (accessible
);
857 * @name: a character string describing the new role.
859 * Registers the role specified by @name.
861 * Returns: an #AtkRole for the new role.
864 atk_role_register (const gchar
*name
)
867 extra_roles
= g_ptr_array_new ();
869 g_ptr_array_add (extra_roles
, g_strdup (name
));
870 return extra_roles
->len
+ ATK_ROLE_LAST_DEFINED
;
874 * atk_object_get_role:
875 * @accessible: an #AtkObject
877 * Gets the role of the accessible.
879 * Returns: an #AtkRole which is the role of the accessible
882 atk_object_get_role (AtkObject
*accessible
)
884 AtkObjectClass
*klass
;
886 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
888 klass
= ATK_OBJECT_GET_CLASS (accessible
);
890 return (klass
->get_role
) (accessible
);
892 return ATK_ROLE_UNKNOWN
;
896 * atk_object_get_layer:
897 * @accessible: an #AtkObject
899 * Gets the layer of the accessible.
901 * Deprecated: Use atk_component_get_layer instead.
903 * Returns: an #AtkLayer which is the layer of the accessible
906 atk_object_get_layer (AtkObject
*accessible
)
908 AtkObjectClass
*klass
;
910 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
912 klass
= ATK_OBJECT_GET_CLASS (accessible
);
913 if (klass
->get_layer
)
914 return (klass
->get_layer
) (accessible
);
916 return ATK_LAYER_INVALID
;
920 * atk_object_get_mdi_zorder:
921 * @accessible: an #AtkObject
923 * Gets the zorder of the accessible. The value G_MININT will be returned
924 * if the layer of the accessible is not ATK_LAYER_MDI.
926 * Deprecated: Use atk_component_get_mdi_zorder instead.
928 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
929 * which the component is shown in relation to other components in the same
934 atk_object_get_mdi_zorder (AtkObject
*accessible
)
936 AtkObjectClass
*klass
;
938 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
940 klass
= ATK_OBJECT_GET_CLASS (accessible
);
941 if (klass
->get_mdi_zorder
)
942 return (klass
->get_mdi_zorder
) (accessible
);
948 * atk_object_ref_state_set:
949 * @accessible: an #AtkObject
951 * Gets a reference to the state set of the accessible; the caller must
952 * unreference it when it is no longer needed.
954 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
955 * set of the accessible
958 atk_object_ref_state_set (AtkObject
*accessible
)
960 AtkObjectClass
*klass
;
962 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
964 klass
= ATK_OBJECT_GET_CLASS (accessible
);
965 if (klass
->ref_state_set
)
966 return (klass
->ref_state_set
) (accessible
);
972 * atk_object_get_index_in_parent:
973 * @accessible: an #AtkObject
975 * Gets the 0-based index of this accessible in its parent; returns -1 if the
976 * accessible does not have an accessible parent.
978 * Returns: an integer which is the index of the accessible in its parent
981 atk_object_get_index_in_parent (AtkObject
*accessible
)
983 AtkObjectClass
*klass
;
985 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
987 klass
= ATK_OBJECT_GET_CLASS (accessible
);
988 if (klass
->get_index_in_parent
)
989 return (klass
->get_index_in_parent
) (accessible
);
995 * atk_object_set_name:
996 * @accessible: an #AtkObject
997 * @name: a character string to be set as the accessible name
999 * Sets the accessible name of the accessible.
1002 atk_object_set_name (AtkObject
*accessible
,
1005 AtkObjectClass
*klass
;
1006 gboolean notify
= FALSE
;
1008 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1009 g_return_if_fail (name
!= NULL
);
1011 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1012 if (klass
->set_name
)
1014 /* Do not notify for initial name setting. See bug 665870 */
1015 notify
= (accessible
->name
!= NULL
);
1017 (klass
->set_name
) (accessible
, name
);
1019 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
1024 * atk_object_set_description:
1025 * @accessible: an #AtkObject
1026 * @description: a character string to be set as the accessible description
1028 * Sets the accessible description of the accessible.
1031 atk_object_set_description (AtkObject
*accessible
,
1032 const gchar
*description
)
1034 AtkObjectClass
*klass
;
1035 gboolean notify
= FALSE
;
1037 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1038 g_return_if_fail (description
!= NULL
);
1040 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1041 if (klass
->set_description
)
1043 /* Do not notify for initial name setting. See bug 665870 */
1044 notify
= (accessible
->description
!= NULL
);
1046 (klass
->set_description
) (accessible
, description
);
1048 g_object_notify (G_OBJECT (accessible
),
1049 atk_object_name_property_description
);
1054 * atk_object_set_parent:
1055 * @accessible: an #AtkObject
1056 * @parent: an #AtkObject to be set as the accessible parent
1058 * Sets the accessible parent of the accessible.
1061 atk_object_set_parent (AtkObject
*accessible
,
1064 AtkObjectClass
*klass
;
1066 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1068 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1069 if (klass
->set_parent
)
1071 (klass
->set_parent
) (accessible
, parent
);
1072 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
1077 * atk_object_set_role:
1078 * @accessible: an #AtkObject
1079 * @role: an #AtkRole to be set as the role
1081 * Sets the role of the accessible.
1084 atk_object_set_role (AtkObject
*accessible
,
1087 AtkObjectClass
*klass
;
1090 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1092 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1093 if (klass
->set_role
)
1095 old_role
= atk_object_get_role (accessible
);
1096 if (old_role
!= role
)
1098 (klass
->set_role
) (accessible
, role
);
1099 if (old_role
!= ATK_ROLE_UNKNOWN
)
1100 /* Do not notify for initial role setting */
1101 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
1107 * atk_object_connect_property_change_handler:
1108 * @accessible: an #AtkObject
1109 * @handler: a function to be called when a property changes its value
1111 * Specifies a function to be called when a property changes value.
1113 * Returns: a #guint which is the handler id used in
1114 * atk_object_remove_property_change_handler()
1117 atk_object_connect_property_change_handler (AtkObject
*accessible
,
1118 AtkPropertyChangeHandler
*handler
)
1120 AtkObjectClass
*klass
;
1122 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
1123 g_return_val_if_fail ((handler
!= NULL
), 0);
1125 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1126 if (klass
->connect_property_change_handler
)
1127 return (klass
->connect_property_change_handler
) (accessible
, handler
);
1133 * atk_object_remove_property_change_handler:
1134 * @accessible: an #AtkObject
1135 * @handler_id: a guint which identifies the handler to be removed.
1137 * Removes a property change handler.
1140 atk_object_remove_property_change_handler (AtkObject
*accessible
,
1143 AtkObjectClass
*klass
;
1145 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1147 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1148 if (klass
->remove_property_change_handler
)
1149 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
1153 * atk_object_notify_state_change:
1154 * @accessible: an #AtkObject
1155 * @state: an #AtkState whose state is changed
1156 * @value: a gboolean which indicates whether the state is being set on or off
1158 * Emits a state-change signal for the specified state.
1161 atk_object_notify_state_change (AtkObject
*accessible
,
1167 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1169 name
= atk_state_type_get_name (state
);
1170 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
1171 g_quark_from_string (name
),
1176 * atk_implementor_ref_accessible:
1177 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1178 * if a non-null return value is required.
1180 * Gets a reference to an object's #AtkObject implementation, if
1181 * the object implements #AtkObjectIface
1183 * Returns: (transfer full): a reference to an object's #AtkObject
1187 atk_implementor_ref_accessible (AtkImplementor
*implementor
)
1189 AtkImplementorIface
*iface
;
1190 AtkObject
*accessible
= NULL
;
1192 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor
), NULL
);
1194 iface
= ATK_IMPLEMENTOR_GET_IFACE (implementor
);
1197 accessible
= iface
->ref_accessible (implementor
);
1199 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
1206 * atk_object_get_attributes:
1207 * @accessible: An #AtkObject.
1209 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1210 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1211 * as distinct from strongly-typed object data available via other get/set methods.
1212 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1216 * Returns: (transfer none): an #AtkAttributeSet consisting of all explicit
1217 * properties/annotations applied to the object, or an empty set if the object
1218 * has no name-value pair attributes assigned to it.
1221 atk_object_get_attributes (AtkObject
*accessible
)
1223 AtkObjectClass
*klass
;
1225 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
1227 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1228 if (klass
->get_attributes
)
1229 return (klass
->get_attributes
) (accessible
);
1235 static AtkRelationSet
*
1236 atk_object_real_ref_relation_set (AtkObject
*accessible
)
1238 g_return_val_if_fail (accessible
->relation_set
, NULL
);
1239 g_object_ref (accessible
->relation_set
);
1241 return accessible
->relation_set
;
1245 atk_object_real_set_property (GObject
*object
,
1247 const GValue
*value
,
1250 AtkObject
*accessible
;
1252 accessible
= ATK_OBJECT (object
);
1257 atk_object_set_name (accessible
, g_value_get_string (value
));
1259 case PROP_DESCRIPTION
:
1260 atk_object_set_description (accessible
, g_value_get_string (value
));
1263 atk_object_set_role (accessible
, g_value_get_int (value
));
1266 atk_object_set_parent (accessible
, g_value_get_object (value
));
1269 if (ATK_IS_VALUE (accessible
))
1270 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
1272 case PROP_TABLE_SUMMARY
:
1273 if (ATK_IS_TABLE (accessible
))
1274 atk_table_set_summary (ATK_TABLE (accessible
), g_value_get_object (value
));
1276 case PROP_TABLE_CAPTION_OBJECT
:
1277 if (ATK_IS_TABLE (accessible
))
1278 atk_table_set_caption (ATK_TABLE (accessible
), g_value_get_object (value
));
1286 atk_object_real_get_property (GObject
*object
,
1291 AtkObject
*accessible
;
1293 accessible
= ATK_OBJECT (object
);
1298 g_value_set_string (value
, atk_object_get_name (accessible
));
1300 case PROP_DESCRIPTION
:
1301 g_value_set_string (value
, atk_object_get_description (accessible
));
1304 g_value_set_int (value
, atk_object_get_role (accessible
));
1307 if (ATK_IS_COMPONENT (accessible
))
1308 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
1310 case PROP_MDI_ZORDER
:
1311 if (ATK_IS_COMPONENT (accessible
))
1312 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
1315 g_value_set_object (value
, atk_object_get_parent (accessible
));
1318 if (ATK_IS_VALUE (accessible
))
1319 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
1321 case PROP_TABLE_SUMMARY
:
1322 if (ATK_IS_TABLE (accessible
))
1323 g_value_set_object (value
, atk_table_get_summary (ATK_TABLE (accessible
)));
1325 case PROP_TABLE_CAPTION_OBJECT
:
1326 if (ATK_IS_TABLE (accessible
))
1327 g_value_set_object (value
, atk_table_get_caption (ATK_TABLE (accessible
)));
1329 case PROP_HYPERTEXT_NUM_LINKS
:
1330 if (ATK_IS_HYPERTEXT (accessible
))
1331 g_value_set_int (value
, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible
)));
1334 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
1340 atk_object_finalize (GObject
*object
)
1342 AtkObject
*accessible
;
1344 g_return_if_fail (ATK_IS_OBJECT (object
));
1346 accessible
= ATK_OBJECT (object
);
1348 g_free (accessible
->name
);
1349 g_free (accessible
->description
);
1352 * Free memory allocated for relation set if it have been allocated.
1354 if (accessible
->relation_set
)
1355 g_object_unref (accessible
->relation_set
);
1357 if (accessible
->accessible_parent
)
1358 g_object_unref (accessible
->accessible_parent
);
1360 G_OBJECT_CLASS (parent_class
)->finalize (object
);
1364 atk_object_real_get_name (AtkObject
*object
)
1366 return object
->name
;
1370 atk_object_real_get_description (AtkObject
*object
)
1372 return object
->description
;
1376 atk_object_real_get_parent (AtkObject
*object
)
1378 return object
->accessible_parent
;
1382 atk_object_real_get_role (AtkObject
*object
)
1384 return object
->role
;
1388 atk_object_real_get_layer (AtkObject
*object
)
1390 return object
->layer
;
1394 atk_object_real_ref_state_set (AtkObject
*accessible
)
1396 AtkStateSet
*state_set
;
1398 AtkObject
*focus_object
;
1400 state_set
= atk_state_set_new ();
1402 ap
= atk_object_get_parent (accessible
);
1404 if (ATK_IS_SELECTION (ap
))
1408 atk_state_set_add_state (state_set
, ATK_STATE_SELECTABLE
);
1410 i
= atk_object_get_index_in_parent (accessible
);
1412 if (atk_selection_is_child_selected(ATK_SELECTION (ap
), i
))
1413 atk_state_set_add_state (state_set
, ATK_STATE_SELECTED
);
1415 focus_object
= atk_get_focus_object ();
1416 if (focus_object
== accessible
)
1417 atk_state_set_add_state (state_set
, ATK_STATE_FOCUSED
);
1423 atk_object_real_set_name (AtkObject
*object
,
1426 g_free (object
->name
);
1427 object
->name
= g_strdup (name
);
1431 atk_object_real_set_description (AtkObject
*object
,
1432 const gchar
*description
)
1434 g_free (object
->description
);
1435 object
->description
= g_strdup (description
);
1439 atk_object_real_set_parent (AtkObject
*object
,
1442 if (object
->accessible_parent
)
1443 g_object_unref (object
->accessible_parent
);
1445 object
->accessible_parent
= parent
;
1446 if (object
->accessible_parent
)
1447 g_object_ref (object
->accessible_parent
);
1451 atk_object_real_set_role (AtkObject
*object
,
1454 object
->role
= role
;
1458 atk_object_real_connect_property_change_handler (AtkObject
*obj
,
1459 AtkPropertyChangeHandler
*handler
)
1461 return g_signal_connect_closure_by_id (obj
,
1462 atk_object_signals
[PROPERTY_CHANGE
],
1465 G_CALLBACK (handler
), NULL
,
1466 (GClosureNotify
) NULL
),
1471 atk_object_real_remove_property_change_handler (AtkObject
*obj
,
1474 g_signal_handler_disconnect (obj
, handler_id
);
1478 * atk_object_initialize:
1479 * @accessible: a #AtkObject
1480 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1482 * This function is called when implementing subclasses of #AtkObject.
1483 * It does initialization required for the new object. It is intended
1484 * that this function should called only in the ..._new() functions used
1485 * to create an instance of a subclass of #AtkObject
1488 atk_object_initialize (AtkObject
*accessible
,
1491 AtkObjectClass
*klass
;
1493 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1495 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1496 if (klass
->initialize
)
1497 klass
->initialize (accessible
, data
);
1501 * This function is a signal handler for notify signal which gets emitted
1502 * when a property changes value.
1504 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1505 * signal which causes the user specified AtkPropertyChangeHandler
1509 atk_object_notify (GObject
*obj
,
1512 AtkPropertyValues values
= { NULL
, };
1514 g_value_init (&values
.new_value
, pspec
->value_type
);
1515 g_object_get_property (obj
, pspec
->name
, &values
.new_value
);
1516 values
.property_name
= pspec
->name
;
1517 g_signal_emit (obj
, atk_object_signals
[PROPERTY_CHANGE
],
1518 g_quark_from_string (pspec
->name
),
1520 g_value_unset (&values
.new_value
);
1524 * atk_role_get_name:
1525 * @role: The #AtkRole whose name is required
1527 * Gets the description string describing the #AtkRole @role.
1529 * Returns: the string describing the AtkRole
1532 atk_role_get_name (AtkRole role
)
1534 if (role
>= 0 && role
< ATK_ROLE_LAST_DEFINED
)
1535 return roles
+ roles_offsets
[role
];
1541 n
-= ATK_ROLE_LAST_DEFINED
+ 1;
1543 if (n
>= 0 && n
< extra_roles
->len
)
1544 return g_ptr_array_index (extra_roles
, n
);
1551 * atk_role_get_localized_name:
1552 * @role: The #AtkRole whose localized name is required
1554 * Gets the localized description string describing the #AtkRole @role.
1556 * Returns: the localized string describing the AtkRole
1559 atk_role_get_localized_name (AtkRole role
)
1561 gettext_initialization ();
1563 if (role
>= 0 && role
< ATK_ROLE_LAST_DEFINED
)
1564 return dgettext (GETTEXT_PACKAGE
, roles
+ roles_offsets
[role
]);
1566 return atk_role_get_name (role
);
1570 * atk_role_for_name:
1571 * @name: a string which is the (non-localized) name of an ATK role.
1573 * Get the #AtkRole type corresponding to a rolew name.
1575 * Returns: the #AtkRole enumerated type corresponding to the specified
1577 * or #ATK_ROLE_INVALID if no matching role is found.
1580 atk_role_for_name (const gchar
*name
)
1582 AtkRole role
= ATK_ROLE_INVALID
;
1585 g_return_val_if_fail (name
, ATK_ROLE_INVALID
);
1587 for (i
= 0; i
< G_N_ELEMENTS (roles_offsets
); i
++)
1589 if (strcmp (name
, roles
+ roles_offsets
[i
]) == 0)
1595 for (i
= 0; i
< extra_roles
->len
; i
++)
1597 gchar
*extra_role
= (gchar
*)g_ptr_array_index (extra_roles
, i
);
1599 g_return_val_if_fail (extra_role
, ATK_ROLE_INVALID
);
1601 if (strcmp (name
, extra_role
) == 0)
1603 role
= i
+ 1 + ATK_ROLE_LAST_DEFINED
;
1613 * atk_object_add_relationship:
1614 * @object: The #AtkObject to which an AtkRelation is to be added.
1615 * @relationship: The #AtkRelationType of the relation
1616 * @target: The #AtkObject which is to be the target of the relation.
1618 * Adds a relationship of the specified type with the specified target.
1620 * Returns TRUE if the relationship is added.
1623 atk_object_add_relationship (AtkObject
*object
,
1624 AtkRelationType relationship
,
1627 AtkObject
*array
[1];
1628 AtkRelation
*relation
;
1630 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1631 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1633 if (atk_relation_set_contains (object
->relation_set
, relationship
))
1637 relation
= atk_relation_new (array
, 1, relationship
);
1638 atk_relation_set_add (object
->relation_set
, relation
);
1639 g_object_unref (relation
);
1645 * atk_object_remove_relationship:
1646 * @object: The #AtkObject from which an AtkRelation is to be removed.
1647 * @relationship: The #AtkRelationType of the relation
1648 * @target: The #AtkObject which is the target of the relation to be removed.
1650 * Removes a relationship of the specified type with the specified target.
1652 * Returns TRUE if the relationship is removed.
1655 atk_object_remove_relationship (AtkObject
*object
,
1656 AtkRelationType relationship
,
1659 gboolean ret
= FALSE
;
1660 AtkRelation
*relation
;
1663 g_return_val_if_fail (ATK_IS_OBJECT (object
), FALSE
);
1664 g_return_val_if_fail (ATK_IS_OBJECT (target
), FALSE
);
1666 relation
= atk_relation_set_get_relation_by_type (object
->relation_set
, relationship
);
1670 ret
= atk_relation_remove_target (relation
, target
);
1671 array
= atk_relation_get_target (relation
);
1672 if (!array
|| array
->len
== 0)
1673 atk_relation_set_remove (object
->relation_set
, relation
);
1679 atk_object_real_initialize (AtkObject
*accessible
,