1 #include <stdlib.h> /* for malloc */
2 #include <cspi/spi-private.h>
4 static const char *role_names [] =
50 "table column header",
61 /* These have no equivalent AccessibleRole enum values */
78 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
81 * AccessibleRole_getName:
82 * @role: an #AccessibleRole object to query.
84 * Get a localizeable string that indicates the name of an #AccessibleRole.
86 * Returns: a localizable string name for an #AccessibleRole enumerated type.
89 AccessibleRole_getName (AccessibleRole role)
93 return role_names [(int) role];
100 * TODO: replace with implementation linked to ATK, which
101 * now supports Role/Name mapping
107 * @obj: a pointer to the #Accessible object on which to operate.
109 * Increment the reference count for an #Accessible object.
112 Accessible_ref (Accessible *obj)
114 cspi_object_ref (obj);
119 * @obj: a pointer to the #Accessible object on which to operate.
121 * Decrement the reference count for an #Accessible object.
124 Accessible_unref (Accessible *obj)
126 cspi_object_unref (obj);
130 * Accessible_getName:
131 * @obj: a pointer to the #Accessible object on which to operate.
133 * Get the name of an #Accessible object.
135 * Returns: a UTF-8 string indicating the name of the #Accessible object.
136 * or NULL on exception
139 Accessible_getName (Accessible *obj)
143 cspi_return_val_if_fail (obj != NULL, NULL);
146 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
148 cspi_return_val_if_ev ("getName", NULL);
154 * Accessible_getDescription:
155 * @obj: a pointer to the #Accessible object on which to operate.
157 * Get the description of an #Accessible object.
159 * Returns: a UTF-8 string describing the #Accessible object.
160 * or NULL on exception
163 Accessible_getDescription (Accessible *obj)
167 cspi_return_val_if_fail (obj != NULL, NULL);
170 Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
173 cspi_return_val_if_ev ("getDescription", NULL);
179 * Accessible_getParent:
180 * @obj: a pointer to the #Accessible object to query.
182 * Get an #Accessible object's parent container.
184 * Returns: a pointer tothe #Accessible object which contains the given
185 * #Accessible instance, or NULL if the @obj has no parent container.
189 Accessible_getParent (Accessible *obj)
193 cspi_return_val_if_fail (obj != NULL, NULL);
195 retval = cspi_object_add (
196 Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
199 cspi_return_val_if_ev ("getParent", NULL);
205 * Accessible_getChildCount:
206 * @obj: a pointer to the #Accessible object on which to operate.
208 * Get the number of children contained by an #Accessible object.
210 * Returns: a #long indicating the number of #Accessible children
211 * contained by an #Accessible object. or -1 on exception
215 Accessible_getChildCount (Accessible *obj)
219 cspi_return_val_if_fail (obj != NULL, -1);
222 Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
225 cspi_return_val_if_ev ("getChildCount", -1);
231 * Accessible_getChildAtIndex:
232 * @obj: a pointer to the #Accessible object on which to operate.
233 * @childIndex: a #long indicating which child is specified.
235 * Get the #Accessible child of an #Accessible object at a given index.
237 * Returns: a pointer to the #Accessible child object at index
238 * @childIndex. or NULL on exception
241 Accessible_getChildAtIndex (Accessible *obj,
246 cspi_return_val_if_fail (obj != NULL, NULL);
248 retval = cspi_object_add (
249 Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
250 childIndex, cspi_ev ()));
256 * Accessible_getIndexInParent:
257 * @obj: a pointer to the #Accessible object on which to operate.
259 * Get the index of an #Accessible object in its containing #Accessible.
261 * Returns: a #long indicating the index of the #Accessible object
262 * in its parent (i.e. containing) #Accessible instance,
263 * or -1 if @obj has no containing parent or on exception.
266 Accessible_getIndexInParent (Accessible *obj)
270 cspi_return_val_if_fail (obj != NULL, -1);
273 Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
275 cspi_return_val_if_ev ("getIndexInparent", -1);
280 * Accessible_getRelationSet:
281 * @obj: a pointer to the #Accessible object on which to operate.
283 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
284 * relationships with other #Accessible objects.
286 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
288 AccessibleRelation **
289 Accessible_getRelationSet (Accessible *obj)
293 AccessibleRelation **relations;
294 Accessibility_RelationSet *relation_set;
296 cspi_return_val_if_fail (obj != NULL, NULL);
299 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
301 cspi_return_val_if_ev ("getRelationSet", NULL);
303 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
304 n_relations = relation_set->_length;
305 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
307 for (i = 0; i < n_relations; ++i)
309 relations[i] = cspi_object_add (CORBA_Object_duplicate (
310 relation_set->_buffer[i], cspi_ev ()));
312 relations[i] = CORBA_OBJECT_NIL;
314 CORBA_free (relation_set);
320 * Accessible_getRole:
321 * @obj: a pointer to the #Accessible object on which to operate.
323 * Get the UI role of an #Accessible object.
325 * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
329 Accessible_getRole (Accessible *obj)
333 cspi_return_val_if_fail (obj != NULL, NULL);
335 retval = AccessibleRole_getName (
336 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
338 cspi_return_val_if_ev ("getRole", NULL);
344 * Accessible_getStateSet:
345 * @obj: a pointer to the #Accessible object on which to operate.
347 * Not Yet Implemented.
349 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
352 Accessible_getStateSet (Accessible *obj)
357 /* Interface query methods */
360 * Accessible_isAction:
361 * @obj: a pointer to the #Accessible instance to query.
363 * Query whether the specified #Accessible implements #AccessibleAction.
365 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
369 Accessible_isAction (Accessible *obj)
371 return cspi_accessible_is_a (obj,
372 "IDL:Accessibility/Action:1.0");
376 * Accessible_isApplication:
377 * @obj: a pointer to the #Accessible instance to query.
379 * Query whether the specified #Accessible implements #AccessibleApplication.
381 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
385 Accessible_isApplication (Accessible *obj)
387 return cspi_accessible_is_a (obj,
388 "IDL:Accessibility/Application:1.0");
392 * Accessible_isComponent:
393 * @obj: a pointer to the #Accessible instance to query.
395 * Query whether the specified #Accessible implements #AccessibleComponent.
397 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
401 Accessible_isComponent (Accessible *obj)
403 return cspi_accessible_is_a (obj,
404 "IDL:Accessibility/Component:1.0");
408 * Accessible_isEditableText:
409 * @obj: a pointer to the #Accessible instance to query.
411 * Query whether the specified #Accessible implements #AccessibleEditableText.
413 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
417 Accessible_isEditableText (Accessible *obj)
419 return cspi_accessible_is_a (obj,
420 "IDL:Accessibility/EditableText:1.0");
424 * Accessible_isHypertext:
425 * @obj: a pointer to the #Accessible instance to query.
427 * Query whether the specified #Accessible implements #AccessibleHypertext.
429 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
433 Accessible_isHypertext (Accessible *obj)
435 return cspi_accessible_is_a (obj,
436 "IDL:Accessibility/Hypertext:1.0");
440 * Accessible_isImage:
441 * @obj: a pointer to the #Accessible instance to query.
443 * Query whether the specified #Accessible implements #AccessibleImage.
445 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
449 Accessible_isImage (Accessible *obj)
451 return cspi_accessible_is_a (obj,
452 "IDL:Accessibility/Image:1.0");
456 * Accessible_isSelection:
457 * @obj: a pointer to the #Accessible instance to query.
459 * Query whether the specified #Accessible implements #AccessibleSelection.
461 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
465 Accessible_isSelection (Accessible *obj)
467 return cspi_accessible_is_a (obj,
468 "IDL:Accessibility/Selection:1.0");
472 * Accessible_isTable:
473 * @obj: a pointer to the #Accessible instance to query.
475 * Query whether the specified #Accessible implements #AccessibleTable.
477 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
481 Accessible_isTable (Accessible *obj)
483 return cspi_accessible_is_a (obj,
484 "IDL:Accessibility/Table:1.0");
489 * @obj: a pointer to the #Accessible instance to query.
491 * Query whether the specified #Accessible implements #AccessibleText.
493 * Returns: #TRUE if @obj implements the #AccessibleText interface,
497 Accessible_isText (Accessible *obj)
499 return cspi_accessible_is_a (obj,
500 "IDL:Accessibility/Text:1.0");
504 * Accessible_isValue:
505 * @obj: a pointer to the #Accessible instance to query.
507 * Query whether the specified #Accessible implements #AccessibleValue.
509 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
513 Accessible_isValue (Accessible *obj)
515 return cspi_accessible_is_a (obj,
516 "IDL:Accessibility/Value:1.0");
520 * Accessible_getApplication:
521 * @obj: a pointer to the #Accessible instance to query.
523 * Get the #AccessibleApplication interface for an #Accessible.
525 * Returns: a pointer to an #AccessibleApplication interface instance, or
526 * NULL if @obj does not implement #AccessibleApplication.
528 AccessibleApplication *
529 Accessible_getApplication (Accessible *obj)
531 return (AccessibleApplication *) Accessible_queryInterface (
532 obj, "IDL:Accessibility/Application:1.0");
536 * Accessible_getAction:
537 * @obj: a pointer to the #Accessible instance to query.
539 * Get the #AccessibleAction interface for an #Accessible.
541 * Returns: a pointer to an #AccessibleAction interface instance, or
542 * NULL if @obj does not implement #AccessibleAction.
545 Accessible_getAction (Accessible *obj)
547 return (AccessibleAction *) Accessible_queryInterface (
548 obj, "IDL:Accessibility/Action:1.0");
552 * Accessible_getComponent:
553 * @obj: a pointer to the #Accessible instance to query.
555 * Get the #AccessibleComponent interface for an #Accessible.
557 * Returns: a pointer to an #AccessibleComponent interface instance, or
558 * NULL if @obj does not implement #AccessibleComponent.
560 AccessibleComponent *
561 Accessible_getComponent (Accessible *obj)
563 return (AccessibleComponent *) Accessible_queryInterface (
564 obj, "IDL:Accessibility/Component:1.0");
568 * Accessible_getEditableText:
569 * @obj: a pointer to the #Accessible instance to query.
571 * Get the #AccessibleEditableText interface for an #Accessible.
573 * Returns: a pointer to an #AccessibleEditableText interface instance, or
574 * NULL if @obj does not implement #AccessibleEditableText.
576 AccessibleEditableText *
577 Accessible_getEditableText (Accessible *obj)
579 return (AccessibleEditableText *) Accessible_queryInterface (
580 obj, "IDL:Accessibility/EditableText:1.0");
586 * Accessible_getHypertext:
587 * @obj: a pointer to the #Accessible instance to query.
589 * Get the #AccessibleHypertext interface for an #Accessible.
591 * Returns: a pointer to an #AccessibleHypertext interface instance, or
592 * NULL if @obj does not implement #AccessibleHypertext.
594 AccessibleHypertext *
595 Accessible_getHypertext (Accessible *obj)
597 return (AccessibleHypertext *) Accessible_queryInterface (
598 obj, "IDL:Accessibility/Hypertext:1.0");
604 * Accessible_getImage:
605 * @obj: a pointer to the #Accessible instance to query.
607 * Get the #AccessibleImage interface for an #Accessible.
609 * Returns: a pointer to an #AccessibleImage interface instance, or
610 * NULL if @obj does not implement #AccessibleImage.
613 Accessible_getImage (Accessible *obj)
615 return (AccessibleImage *) Accessible_queryInterface (
616 obj, "IDL:Accessibility/Image:1.0");
622 * Accessible_getSelection:
623 * @obj: a pointer to the #Accessible instance to query.
625 * Get the #AccessibleSelection interface for an #Accessible.
627 * Returns: a pointer to an #AccessibleSelection interface instance, or
628 * NULL if @obj does not implement #AccessibleSelection.
630 AccessibleSelection *
631 Accessible_getSelection (Accessible *obj)
633 return (AccessibleSelection *) Accessible_queryInterface (
634 obj, "IDL:Accessibility/Selection:1.0");
640 * Accessible_getTable:
641 * @obj: a pointer to the #Accessible instance to query.
643 * Get the #AccessibleTable interface for an #Accessible.
645 * Returns: a pointer to an #AccessibleTable interface instance, or
646 * NULL if @obj does not implement #AccessibleTable.
649 Accessible_getTable (Accessible *obj)
651 return (AccessibleTable *) Accessible_queryInterface (
652 obj, "IDL:Accessibility/Table:1.0");
656 * Accessible_getText:
657 * @obj: a pointer to the #Accessible instance to query.
659 * Get the #AccessibleText interface for an #Accessible.
661 * Returns: a pointer to an #AccessibleText interface instance, or
662 * NULL if @obj does not implement #AccessibleText.
665 Accessible_getText (Accessible *obj)
667 return (AccessibleText *) Accessible_queryInterface (
668 obj, "IDL:Accessibility/Text:1.0");
674 * Accessible_getValue:
675 * @obj: a pointer to the #Accessible instance to query.
677 * Get the #AccessibleValue interface for an #Accessible.
679 * Returns: a pointer to an #AccessibleValue interface instance, or
680 * NULL if @obj does not implement #AccessibleValue.
683 Accessible_getValue (Accessible *obj)
685 return (AccessibleValue *) Accessible_queryInterface (
686 obj, "IDL:Accessibility/Value:1.0");
692 * Accessible_queryInterface:
693 * @obj: a pointer to the #Accessible instance to query.
694 * @interface_name: a UTF-8 character string specifiying the requested interface.
696 * Query an #Accessible object to for a named interface.
698 * Returns: an instance of the named interface object, if it is implemented
699 * by @obj, or NULL otherwise.
703 Accessible_queryInterface (Accessible *obj,
704 const char *interface_name)
706 Bonobo_Unknown iface;
713 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
718 cspi_return_val_if_ev ("queryInterface", NULL);
721 * FIXME: we need to be fairly sure that references are going
722 * to mach up if we are going to expose QueryInterface, ie. we
723 * can't allow people to do:
724 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
725 * this should be no real problem though for this level of API
729 return cspi_object_add (iface);
734 * AccessibleRelation_ref:
735 * @obj: a pointer to the #AccessibleRelation object on which to operate.
737 * Increment the reference count for an #AccessibleRelation object.
741 AccessibleRelation_ref (AccessibleRelation *obj)
743 cspi_object_ref (obj);
747 * AccessibleRelation_unref:
748 * @obj: a pointer to the #AccessibleRelation object on which to operate.
750 * Decrement the reference count for an #AccessibleRelation object.
754 AccessibleRelation_unref (AccessibleRelation *obj)
756 cspi_object_unref (obj);
760 * AccessibleRelation_getRelationType:
761 * @obj: a pointer to the #AccessibleRelation object to query.
763 * Get the type of relationship represented by an #AccessibleRelation.
765 * Returns: an #AccessibleRelationType indicating the type of relation
766 * encapsulated in this #AccessibleRelation object.
769 AccessibleRelationType
770 AccessibleRelation_getRelationType (AccessibleRelation *obj)
772 cspi_return_val_if_fail (obj != NULL, -1);
777 * AccessibleRelation_getNTargets:
778 * @obj: a pointer to the #AccessibleRelation object to query.
780 * Get the number of objects which this relationship has as its
781 * target objects (the subject is the #Accessible from which this
782 * #AccessibleRelation originated).
784 * Returns: a short integer indicating how many target objects which the
785 * originating #Accessible object has the #AccessibleRelation
789 AccessibleRelation_getNTargets (AccessibleRelation *obj)
791 cspi_return_val_if_fail (obj != NULL, -1);
796 * AccessibleRelation_getTarget:
797 * @obj: a pointer to the #AccessibleRelation object to query.
798 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
800 * Get the @i-th target of a specified #AccessibleRelation relationship.
802 * Returns: an #Accessible which is the @i-th object with which the
803 * originating #Accessible has relationship specified in the
804 * #AccessibleRelation object.
808 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
810 cspi_return_val_if_fail (obj != NULL, NULL);
815 * AccessibleStateSet_ref:
816 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
818 * Increment the reference count for an #AccessibleStateSet object.
822 AccessibleStateSet_ref (AccessibleStateSet *obj)
824 cspi_object_ref (obj);
828 * AccessibleStateSet_unref:
829 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
831 * Decrement the reference count for an #AccessibleStateSet object.
835 AccessibleStateSet_unref (AccessibleStateSet *obj)
837 cspi_object_unref (obj);
841 * AccessibleStateSet_contains:
842 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
843 * @state: an #AccessibleState for which the specified #AccessibleStateSet
846 * Determine whether a given #AccessibleStateSet includes a given state; that is,
847 * whether @state is true for the stateset in question.
849 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
854 AccessibleStateSet_contains (AccessibleStateSet *obj,
855 AccessibleState state)
857 CORBA_boolean retval;
859 cspi_return_val_if_fail (obj != NULL, FALSE);
861 retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
864 cspi_return_val_if_ev ("contains", FALSE);
866 return (SPIBoolean) retval;
870 * AccessibleStateSet_add:
871 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
872 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
874 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
875 * given state to #TRUE in the stateset.
879 AccessibleStateSet_add (AccessibleStateSet *obj,
880 AccessibleState state)
882 cspi_return_if_fail (obj != NULL);
884 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
885 cspi_check_ev ("add");
889 * AccessibleStateSet_remove:
890 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
891 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
893 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
894 * given state to #FALSE in the stateset.)
898 AccessibleStateSet_remove (AccessibleStateSet *obj,
899 AccessibleState state)
901 cspi_return_if_fail (obj != NULL);
903 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
904 cspi_check_ev ("remove");
908 * AccessibleStateSet_equals:
909 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
910 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
912 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
913 * consist of the same #AccessibleStates). Useful for checking multiple
914 * state variables at once; construct the target state then compare against it.
916 * @see AccessibleStateSet_compare().
918 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
923 AccessibleStateSet_equals (AccessibleStateSet *obj,
924 AccessibleStateSet *obj2)
931 cspi_return_val_if_fail (obj != NULL, FALSE);
932 cspi_return_val_if_fail (obj2 != NULL, FALSE);
934 return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
935 CSPI_OBJREF (obj2), cspi_ev ());
939 * AccessibleStateSet_compare:
940 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
941 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
943 * Determine the differences between two instances of #AccessibleStateSet.
944 * Not Yet Implemented.
946 * @see AccessibleStateSet_equals().
948 * Returns: an #AccessibleStateSet object containing all states contained on one of
949 * the two sets but not the other.
953 AccessibleStateSet_compare (AccessibleStateSet *obj,
954 AccessibleStateSet *obj2)
956 cspi_return_val_if_fail (obj != NULL, NULL);
957 cspi_return_val_if_fail (obj2 != NULL, NULL);
962 * AccessibleStateSet_isEmpty:
963 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
965 * Determine whether a given #AccessibleStateSet is the empty set.
967 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
972 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
974 cspi_return_val_if_fail (obj != NULL, FALSE);
976 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/