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.
113 Accessible_ref (Accessible *obj)
115 cspi_object_ref (obj);
120 * @obj: a pointer to the #Accessible object on which to operate.
122 * Decrement the reference count for an #Accessible object.
126 Accessible_unref (Accessible *obj)
128 cspi_object_unref (obj);
132 * Accessible_getName:
133 * @obj: a pointer to the #Accessible object on which to operate.
135 * Get the name of an #Accessible object.
137 * Returns: a UTF-8 string indicating the name of the #Accessible object.
138 * or NULL on exception
141 Accessible_getName (Accessible *obj)
145 cspi_return_val_if_fail (obj != NULL, NULL);
148 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
150 cspi_return_val_if_ev ("getName", NULL);
156 * Accessible_getDescription:
157 * @obj: a pointer to the #Accessible object on which to operate.
159 * Get the description of an #Accessible object.
161 * Returns: a UTF-8 string describing the #Accessible object.
162 * or NULL on exception
165 Accessible_getDescription (Accessible *obj)
169 cspi_return_val_if_fail (obj != NULL, NULL);
172 Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
175 cspi_return_val_if_ev ("getDescription", NULL);
181 * Accessible_getParent:
182 * @obj: a pointer to the #Accessible object to query.
184 * Get an #Accessible object's parent container.
186 * Returns: a pointer tothe #Accessible object which contains the given
187 * #Accessible instance, or NULL if the @obj has no parent container.
191 Accessible_getParent (Accessible *obj)
195 cspi_return_val_if_fail (obj != NULL, NULL);
197 retval = cspi_object_add (
198 Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
201 cspi_return_val_if_ev ("getParent", NULL);
207 * Accessible_getChildCount:
208 * @obj: a pointer to the #Accessible object on which to operate.
210 * Get the number of children contained by an #Accessible object.
212 * Returns: a #long indicating the number of #Accessible children
213 * contained by an #Accessible object. or -1 on exception
217 Accessible_getChildCount (Accessible *obj)
221 cspi_return_val_if_fail (obj != NULL, -1);
224 Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
227 cspi_return_val_if_ev ("getChildCount", -1);
233 * Accessible_getChildAtIndex:
234 * @obj: a pointer to the #Accessible object on which to operate.
235 * @childIndex: a #long indicating which child is specified.
237 * Get the #Accessible child of an #Accessible object at a given index.
239 * Returns: a pointer to the #Accessible child object at index
240 * @childIndex. or NULL on exception
243 Accessible_getChildAtIndex (Accessible *obj,
248 cspi_return_val_if_fail (obj != NULL, NULL);
250 retval = cspi_object_add (
251 Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
252 childIndex, cspi_ev ()));
258 * Accessible_getIndexInParent:
259 * @obj: a pointer to the #Accessible object on which to operate.
261 * Get the index of an #Accessible object in its containing #Accessible.
263 * Returns: a #long indicating the index of the #Accessible object
264 * in its parent (i.e. containing) #Accessible instance,
265 * or -1 if @obj has no containing parent or on exception.
268 Accessible_getIndexInParent (Accessible *obj)
272 cspi_return_val_if_fail (obj != NULL, -1);
275 Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
277 cspi_return_val_if_ev ("getIndexInparent", -1);
282 * Accessible_getRelationSet:
283 * @obj: a pointer to the #Accessible object on which to operate.
285 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
286 * relationships with other #Accessible objects.
288 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
290 AccessibleRelation **
291 Accessible_getRelationSet (Accessible *obj)
295 AccessibleRelation **relations;
296 Accessibility_RelationSet *relation_set;
298 cspi_return_val_if_fail (obj != NULL, NULL);
301 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
303 cspi_return_val_if_ev ("getRelationSet", NULL);
305 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
306 n_relations = relation_set->_length;
307 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
309 for (i = 0; i < n_relations; ++i)
311 relations[i] = cspi_object_add (CORBA_Object_duplicate (
312 relation_set->_buffer[i], cspi_ev ()));
314 relations[i] = CORBA_OBJECT_NIL;
316 CORBA_free (relation_set);
322 * Accessible_getRole:
323 * @obj: a pointer to the #Accessible object on which to operate.
325 * Get the UI role of an #Accessible object.
327 * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
331 Accessible_getRole (Accessible *obj)
335 cspi_return_val_if_fail (obj != NULL, NULL);
337 retval = AccessibleRole_getName (
338 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
340 cspi_return_val_if_ev ("getRole", NULL);
346 * Accessible_getStateSet:
347 * @obj: a pointer to the #Accessible object on which to operate.
349 * Not Yet Implemented.
351 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
354 Accessible_getStateSet (Accessible *obj)
359 /* Interface query methods */
362 * Accessible_isAction:
363 * @obj: a pointer to the #Accessible instance to query.
365 * Query whether the specified #Accessible implements #AccessibleAction.
367 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
371 Accessible_isAction (Accessible *obj)
373 return cspi_accessible_is_a (obj,
374 "IDL:Accessibility/Action:1.0");
378 * Accessible_isApplication:
379 * @obj: a pointer to the #Accessible instance to query.
381 * Query whether the specified #Accessible implements #AccessibleApplication.
383 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
387 Accessible_isApplication (Accessible *obj)
389 return cspi_accessible_is_a (obj,
390 "IDL:Accessibility/Application:1.0");
394 * Accessible_isComponent:
395 * @obj: a pointer to the #Accessible instance to query.
397 * Query whether the specified #Accessible implements #AccessibleComponent.
399 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
403 Accessible_isComponent (Accessible *obj)
405 return cspi_accessible_is_a (obj,
406 "IDL:Accessibility/Component:1.0");
410 * Accessible_isEditableText:
411 * @obj: a pointer to the #Accessible instance to query.
413 * Query whether the specified #Accessible implements #AccessibleEditableText.
415 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
419 Accessible_isEditableText (Accessible *obj)
421 return cspi_accessible_is_a (obj,
422 "IDL:Accessibility/EditableText:1.0");
426 * Accessible_isHypertext:
427 * @obj: a pointer to the #Accessible instance to query.
429 * Query whether the specified #Accessible implements #AccessibleHypertext.
431 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
435 Accessible_isHypertext (Accessible *obj)
437 return cspi_accessible_is_a (obj,
438 "IDL:Accessibility/Hypertext:1.0");
442 * Accessible_isImage:
443 * @obj: a pointer to the #Accessible instance to query.
445 * Query whether the specified #Accessible implements #AccessibleImage.
447 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
451 Accessible_isImage (Accessible *obj)
453 return cspi_accessible_is_a (obj,
454 "IDL:Accessibility/Image:1.0");
458 * Accessible_isSelection:
459 * @obj: a pointer to the #Accessible instance to query.
461 * Query whether the specified #Accessible implements #AccessibleSelection.
463 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
467 Accessible_isSelection (Accessible *obj)
469 return cspi_accessible_is_a (obj,
470 "IDL:Accessibility/Selection:1.0");
474 * Accessible_isTable:
475 * @obj: a pointer to the #Accessible instance to query.
477 * Query whether the specified #Accessible implements #AccessibleTable.
479 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
483 Accessible_isTable (Accessible *obj)
485 return cspi_accessible_is_a (obj,
486 "IDL:Accessibility/Table:1.0");
491 * @obj: a pointer to the #Accessible instance to query.
493 * Query whether the specified #Accessible implements #AccessibleText.
495 * Returns: #TRUE if @obj implements the #AccessibleText interface,
499 Accessible_isText (Accessible *obj)
501 return cspi_accessible_is_a (obj,
502 "IDL:Accessibility/Text:1.0");
506 * Accessible_isValue:
507 * @obj: a pointer to the #Accessible instance to query.
509 * Query whether the specified #Accessible implements #AccessibleValue.
511 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
515 Accessible_isValue (Accessible *obj)
517 return cspi_accessible_is_a (obj,
518 "IDL:Accessibility/Value:1.0");
522 * Accessible_getApplication:
523 * @obj: a pointer to the #Accessible instance to query.
525 * Get the #AccessibleApplication interface for an #Accessible.
527 * Returns: a pointer to an #AccessibleApplication interface instance, or
528 * NULL if @obj does not implement #AccessibleApplication.
530 AccessibleApplication *
531 Accessible_getApplication (Accessible *obj)
533 return (AccessibleApplication *) Accessible_queryInterface (
534 obj, "IDL:Accessibility/Application:1.0");
538 * Accessible_getAction:
539 * @obj: a pointer to the #Accessible instance to query.
541 * Get the #AccessibleAction interface for an #Accessible.
543 * Returns: a pointer to an #AccessibleAction interface instance, or
544 * NULL if @obj does not implement #AccessibleAction.
547 Accessible_getAction (Accessible *obj)
549 return (AccessibleAction *) Accessible_queryInterface (
550 obj, "IDL:Accessibility/Action:1.0");
554 * Accessible_getComponent:
555 * @obj: a pointer to the #Accessible instance to query.
557 * Get the #AccessibleComponent interface for an #Accessible.
559 * Returns: a pointer to an #AccessibleComponent interface instance, or
560 * NULL if @obj does not implement #AccessibleComponent.
562 AccessibleComponent *
563 Accessible_getComponent (Accessible *obj)
565 return (AccessibleComponent *) Accessible_queryInterface (
566 obj, "IDL:Accessibility/Component:1.0");
570 * Accessible_getEditableText:
571 * @obj: a pointer to the #Accessible instance to query.
573 * Get the #AccessibleEditableText interface for an #Accessible.
575 * Returns: a pointer to an #AccessibleEditableText interface instance, or
576 * NULL if @obj does not implement #AccessibleEditableText.
578 AccessibleEditableText *
579 Accessible_getEditableText (Accessible *obj)
581 return (AccessibleEditableText *) Accessible_queryInterface (
582 obj, "IDL:Accessibility/EditableText:1.0");
588 * Accessible_getHypertext:
589 * @obj: a pointer to the #Accessible instance to query.
591 * Get the #AccessibleHypertext interface for an #Accessible.
593 * Returns: a pointer to an #AccessibleHypertext interface instance, or
594 * NULL if @obj does not implement #AccessibleHypertext.
596 AccessibleHypertext *
597 Accessible_getHypertext (Accessible *obj)
599 return (AccessibleHypertext *) Accessible_queryInterface (
600 obj, "IDL:Accessibility/Hypertext:1.0");
606 * Accessible_getImage:
607 * @obj: a pointer to the #Accessible instance to query.
609 * Get the #AccessibleImage interface for an #Accessible.
611 * Returns: a pointer to an #AccessibleImage interface instance, or
612 * NULL if @obj does not implement #AccessibleImage.
615 Accessible_getImage (Accessible *obj)
617 return (AccessibleImage *) Accessible_queryInterface (
618 obj, "IDL:Accessibility/Image:1.0");
624 * Accessible_getSelection:
625 * @obj: a pointer to the #Accessible instance to query.
627 * Get the #AccessibleSelection interface for an #Accessible.
629 * Returns: a pointer to an #AccessibleSelection interface instance, or
630 * NULL if @obj does not implement #AccessibleSelection.
632 AccessibleSelection *
633 Accessible_getSelection (Accessible *obj)
635 return (AccessibleSelection *) Accessible_queryInterface (
636 obj, "IDL:Accessibility/Selection:1.0");
642 * Accessible_getTable:
643 * @obj: a pointer to the #Accessible instance to query.
645 * Get the #AccessibleTable interface for an #Accessible.
647 * Returns: a pointer to an #AccessibleTable interface instance, or
648 * NULL if @obj does not implement #AccessibleTable.
651 Accessible_getTable (Accessible *obj)
653 return (AccessibleTable *) Accessible_queryInterface (
654 obj, "IDL:Accessibility/Table:1.0");
658 * Accessible_getText:
659 * @obj: a pointer to the #Accessible instance to query.
661 * Get the #AccessibleText interface for an #Accessible.
663 * Returns: a pointer to an #AccessibleText interface instance, or
664 * NULL if @obj does not implement #AccessibleText.
667 Accessible_getText (Accessible *obj)
669 return (AccessibleText *) Accessible_queryInterface (
670 obj, "IDL:Accessibility/Text:1.0");
676 * Accessible_getValue:
677 * @obj: a pointer to the #Accessible instance to query.
679 * Get the #AccessibleValue interface for an #Accessible.
681 * Returns: a pointer to an #AccessibleValue interface instance, or
682 * NULL if @obj does not implement #AccessibleValue.
685 Accessible_getValue (Accessible *obj)
687 return (AccessibleValue *) Accessible_queryInterface (
688 obj, "IDL:Accessibility/Value:1.0");
694 * Accessible_queryInterface:
695 * @obj: a pointer to the #Accessible instance to query.
696 * @interface_name: a UTF-8 character string specifiying the requested interface.
698 * Query an #Accessible object to for a named interface.
700 * Returns: an instance of the named interface object, if it is implemented
701 * by @obj, or NULL otherwise.
705 Accessible_queryInterface (Accessible *obj,
706 const char *interface_name)
708 Bonobo_Unknown iface;
715 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
720 cspi_return_val_if_ev ("queryInterface", NULL);
723 * FIXME: we need to be fairly sure that references are going
724 * to mach up if we are going to expose QueryInterface, ie. we
725 * can't allow people to do:
726 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
727 * this should be no real problem though for this level of API
731 return cspi_object_add (iface);
736 * AccessibleRelation_ref:
737 * @obj: a pointer to the #AccessibleRelation object on which to operate.
739 * Increment the reference count for an #AccessibleRelation object.
743 AccessibleRelation_ref (AccessibleRelation *obj)
745 cspi_object_ref (obj);
749 * AccessibleRelation_unref:
750 * @obj: a pointer to the #AccessibleRelation object on which to operate.
752 * Decrement the reference count for an #AccessibleRelation object.
756 AccessibleRelation_unref (AccessibleRelation *obj)
758 cspi_object_unref (obj);
762 * AccessibleRelation_getRelationType:
763 * @obj: a pointer to the #AccessibleRelation object to query.
765 * Get the type of relationship represented by an #AccessibleRelation.
767 * Returns: an #AccessibleRelationType indicating the type of relation
768 * encapsulated in this #AccessibleRelation object.
771 AccessibleRelationType
772 AccessibleRelation_getRelationType (AccessibleRelation *obj)
774 cspi_return_val_if_fail (obj != NULL, -1);
779 * AccessibleRelation_getNTargets:
780 * @obj: a pointer to the #AccessibleRelation object to query.
782 * Get the number of objects which this relationship has as its
783 * target objects (the subject is the #Accessible from which this
784 * #AccessibleRelation originated).
786 * Returns: a short integer indicating how many target objects which the
787 * originating #Accessible object has the #AccessibleRelation
791 AccessibleRelation_getNTargets (AccessibleRelation *obj)
793 cspi_return_val_if_fail (obj != NULL, -1);
798 * AccessibleRelation_getTarget:
799 * @obj: a pointer to the #AccessibleRelation object to query.
800 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
802 * Get the @i-th target of a specified #AccessibleRelation relationship.
804 * Returns: an #Accessible which is the @i-th object with which the
805 * originating #Accessible has relationship specified in the
806 * #AccessibleRelation object.
810 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
812 cspi_return_val_if_fail (obj != NULL, NULL);
817 * AccessibleStateSet_ref:
818 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
820 * Increment the reference count for an #AccessibleStateSet object.
824 AccessibleStateSet_ref (AccessibleStateSet *obj)
826 cspi_object_ref (obj);
830 * AccessibleStateSet_unref:
831 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
833 * Decrement the reference count for an #AccessibleStateSet object.
837 AccessibleStateSet_unref (AccessibleStateSet *obj)
839 cspi_object_unref (obj);
843 * AccessibleStateSet_contains:
844 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
845 * @state: an #AccessibleState for which the specified #AccessibleStateSet
848 * Determine whether a given #AccessibleStateSet includes a given state; that is,
849 * whether @state is true for the stateset in question.
851 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
856 AccessibleStateSet_contains (AccessibleStateSet *obj,
857 AccessibleState state)
859 CORBA_boolean retval;
861 cspi_return_val_if_fail (obj != NULL, FALSE);
863 retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
866 cspi_return_val_if_ev ("contains", FALSE);
868 return (SPIBoolean) retval;
872 * AccessibleStateSet_add:
873 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
874 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
876 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
877 * given state to #TRUE in the stateset.
881 AccessibleStateSet_add (AccessibleStateSet *obj,
882 AccessibleState state)
884 cspi_return_if_fail (obj != NULL);
886 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
887 cspi_check_ev ("add");
891 * AccessibleStateSet_remove:
892 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
893 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
895 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
896 * given state to #FALSE in the stateset.)
900 AccessibleStateSet_remove (AccessibleStateSet *obj,
901 AccessibleState state)
903 cspi_return_if_fail (obj != NULL);
905 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
906 cspi_check_ev ("remove");
910 * AccessibleStateSet_equals:
911 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
912 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
914 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
915 * consist of the same #AccessibleStates). Useful for checking multiple
916 * state variables at once; construct the target state then compare against it.
918 * @see AccessibleStateSet_compare().
920 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
925 AccessibleStateSet_equals (AccessibleStateSet *obj,
926 AccessibleStateSet *obj2)
933 cspi_return_val_if_fail (obj != NULL, FALSE);
934 cspi_return_val_if_fail (obj2 != NULL, FALSE);
936 return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
937 CSPI_OBJREF (obj2), cspi_ev ());
941 * AccessibleStateSet_compare:
942 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
943 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
945 * Determine the differences between two instances of #AccessibleStateSet.
946 * Not Yet Implemented.
948 * @see AccessibleStateSet_equals().
950 * Returns: an #AccessibleStateSet object containing all states contained on one of
951 * the two sets but not the other.
955 AccessibleStateSet_compare (AccessibleStateSet *obj,
956 AccessibleStateSet *obj2)
958 cspi_return_val_if_fail (obj != NULL, NULL);
959 cspi_return_val_if_fail (obj2 != NULL, NULL);
964 * AccessibleStateSet_isEmpty:
965 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
967 * Determine whether a given #AccessibleStateSet is the empty set.
969 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
974 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
976 cspi_return_val_if_fail (obj != NULL, FALSE);
978 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/