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.
111 * Returns: (no return code implemented yet).
115 Accessible_ref (Accessible *obj)
117 cspi_object_ref (obj);
122 * @obj: a pointer to the #Accessible object on which to operate.
124 * Decrement the reference count for an #Accessible object.
128 Accessible_unref (Accessible *obj)
130 cspi_object_unref (obj);
134 * Accessible_getName:
135 * @obj: a pointer to the #Accessible object on which to operate.
137 * Get the name of an #Accessible object.
139 * Returns: a UTF-8 string indicating the name of the #Accessible object.
140 * or NULL on exception
143 Accessible_getName (Accessible *obj)
147 cspi_return_val_if_fail (obj != NULL, NULL);
150 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
152 cspi_return_val_if_ev ("getName", NULL);
158 * Accessible_getDescription:
159 * @obj: a pointer to the #Accessible object on which to operate.
161 * Get the description of an #Accessible object.
163 * Returns: a UTF-8 string describing the #Accessible object.
164 * or NULL on exception
167 Accessible_getDescription (Accessible *obj)
171 cspi_return_val_if_fail (obj != NULL, NULL);
174 Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
177 cspi_return_val_if_ev ("getDescription", NULL);
183 * Accessible_getParent:
184 * @obj: a pointer to the #Accessible object to query.
186 * Get an #Accessible object's parent container.
188 * Returns: a pointer tothe #Accessible object which contains the given
189 * #Accessible instance, or NULL if the @obj has no parent container.
193 Accessible_getParent (Accessible *obj)
197 cspi_return_val_if_fail (obj != NULL, NULL);
199 retval = cspi_object_add (
200 Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
203 cspi_return_val_if_ev ("getParent", NULL);
209 * Accessible_getChildCount:
210 * @obj: a pointer to the #Accessible object on which to operate.
212 * Get the number of children contained by an #Accessible object.
214 * Returns: a #long indicating the number of #Accessible children
215 * contained by an #Accessible object. or -1 on exception
219 Accessible_getChildCount (Accessible *obj)
223 cspi_return_val_if_fail (obj != NULL, -1);
226 Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
229 cspi_return_val_if_ev ("getChildCount", -1);
235 * Accessible_getChildAtIndex:
236 * @obj: a pointer to the #Accessible object on which to operate.
237 * @childIndex: a #long indicating which child is specified.
239 * Get the #Accessible child of an #Accessible object at a given index.
241 * Returns: a pointer to the #Accessible child object at index
242 * @childIndex. or NULL on exception
245 Accessible_getChildAtIndex (Accessible *obj,
250 cspi_return_val_if_fail (obj != NULL, NULL);
252 retval = cspi_object_add (
253 Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
254 childIndex, cspi_ev ()));
260 * Accessible_getIndexInParent:
261 * @obj: a pointer to the #Accessible object on which to operate.
263 * Get the index of an #Accessible object in its containing #Accessible.
265 * Returns: a #long indicating the index of the #Accessible object
266 * in its parent (i.e. containing) #Accessible instance,
267 * or -1 if @obj has no containing parent or on exception.
270 Accessible_getIndexInParent (Accessible *obj)
274 cspi_return_val_if_fail (obj != NULL, -1);
277 Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
279 cspi_return_val_if_ev ("getIndexInparent", -1);
284 * Accessible_getRelationSet:
285 * @obj: a pointer to the #Accessible object on which to operate.
287 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
288 * relationships with other #Accessible objects.
290 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
292 AccessibleRelation **
293 Accessible_getRelationSet (Accessible *obj)
297 AccessibleRelation **relations;
298 Accessibility_RelationSet *relation_set;
300 cspi_return_val_if_fail (obj != NULL, NULL);
303 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
305 cspi_return_val_if_ev ("getRelationSet", NULL);
307 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
308 n_relations = relation_set->_length;
309 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
311 for (i = 0; i < n_relations; ++i)
313 relations[i] = cspi_object_add (CORBA_Object_duplicate (
314 relation_set->_buffer[i], cspi_ev ()));
316 relations[i] = CORBA_OBJECT_NIL;
318 CORBA_free (relation_set);
324 * Accessible_getRole:
325 * @obj: a pointer to the #Accessible object on which to operate.
327 * Get the UI role of an #Accessible object.
329 * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
333 Accessible_getRole (Accessible *obj)
337 cspi_return_val_if_fail (obj != NULL, NULL);
339 retval = AccessibleRole_getName (
340 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
342 cspi_return_val_if_ev ("getRole", NULL);
348 * Accessible_getStateSet:
349 * @obj: a pointer to the #Accessible object on which to operate.
351 * Not Yet Implemented.
353 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
356 Accessible_getStateSet (Accessible *obj)
361 /* Interface query methods */
364 * Accessible_isAction:
365 * @obj: a pointer to the #Accessible instance to query.
367 * Query whether the specified #Accessible implements #AccessibleAction.
369 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
373 Accessible_isAction (Accessible *obj)
375 return cspi_accessible_is_a (obj,
376 "IDL:Accessibility/Action:1.0");
380 * Accessible_isApplication:
381 * @obj: a pointer to the #Accessible instance to query.
383 * Query whether the specified #Accessible implements #AccessibleApplication.
385 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
389 Accessible_isApplication (Accessible *obj)
391 return cspi_accessible_is_a (obj,
392 "IDL:Accessibility/Application:1.0");
396 * Accessible_isComponent:
397 * @obj: a pointer to the #Accessible instance to query.
399 * Query whether the specified #Accessible implements #AccessibleComponent.
401 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
405 Accessible_isComponent (Accessible *obj)
407 return cspi_accessible_is_a (obj,
408 "IDL:Accessibility/Component:1.0");
412 * Accessible_isEditableText:
413 * @obj: a pointer to the #Accessible instance to query.
415 * Query whether the specified #Accessible implements #AccessibleEditableText.
417 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
421 Accessible_isEditableText (Accessible *obj)
423 return cspi_accessible_is_a (obj,
424 "IDL:Accessibility/EditableText:1.0");
428 * Accessible_isHypertext:
429 * @obj: a pointer to the #Accessible instance to query.
431 * Query whether the specified #Accessible implements #AccessibleHypertext.
433 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
437 Accessible_isHypertext (Accessible *obj)
439 return cspi_accessible_is_a (obj,
440 "IDL:Accessibility/Hypertext:1.0");
444 * Accessible_isImage:
445 * @obj: a pointer to the #Accessible instance to query.
447 * Query whether the specified #Accessible implements #AccessibleImage.
449 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
453 Accessible_isImage (Accessible *obj)
455 return cspi_accessible_is_a (obj,
456 "IDL:Accessibility/Image:1.0");
460 * Accessible_isSelection:
461 * @obj: a pointer to the #Accessible instance to query.
463 * Query whether the specified #Accessible implements #AccessibleSelection.
465 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
469 Accessible_isSelection (Accessible *obj)
471 return cspi_accessible_is_a (obj,
472 "IDL:Accessibility/Selection:1.0");
476 * Accessible_isTable:
477 * @obj: a pointer to the #Accessible instance to query.
479 * Query whether the specified #Accessible implements #AccessibleTable.
481 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
485 Accessible_isTable (Accessible *obj)
487 return cspi_accessible_is_a (obj,
488 "IDL:Accessibility/Table:1.0");
493 * @obj: a pointer to the #Accessible instance to query.
495 * Query whether the specified #Accessible implements #AccessibleText.
497 * Returns: #TRUE if @obj implements the #AccessibleText interface,
501 Accessible_isText (Accessible *obj)
503 return cspi_accessible_is_a (obj,
504 "IDL:Accessibility/Text:1.0");
508 * Accessible_isValue:
509 * @obj: a pointer to the #Accessible instance to query.
511 * Query whether the specified #Accessible implements #AccessibleValue.
513 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
517 Accessible_isValue (Accessible *obj)
519 return cspi_accessible_is_a (obj,
520 "IDL:Accessibility/Value:1.0");
524 * Accessible_getApplication:
525 * @obj: a pointer to the #Accessible instance to query.
527 * Get the #AccessibleApplication interface for an #Accessible.
529 * Returns: a pointer to an #AccessibleApplication interface instance, or
530 * NULL if @obj does not implement #AccessibleApplication.
532 AccessibleApplication *
533 Accessible_getApplication (Accessible *obj)
535 return (AccessibleApplication *) Accessible_queryInterface (
536 obj, "IDL:Accessibility/Application:1.0");
540 * Accessible_getAction:
541 * @obj: a pointer to the #Accessible instance to query.
543 * Get the #AccessibleAction interface for an #Accessible.
545 * Returns: a pointer to an #AccessibleAction interface instance, or
546 * NULL if @obj does not implement #AccessibleAction.
549 Accessible_getAction (Accessible *obj)
551 return (AccessibleAction *) Accessible_queryInterface (
552 obj, "IDL:Accessibility/Action:1.0");
556 * Accessible_getComponent:
557 * @obj: a pointer to the #Accessible instance to query.
559 * Get the #AccessibleComponent interface for an #Accessible.
561 * Returns: a pointer to an #AccessibleComponent interface instance, or
562 * NULL if @obj does not implement #AccessibleComponent.
564 AccessibleComponent *
565 Accessible_getComponent (Accessible *obj)
567 return (AccessibleComponent *) Accessible_queryInterface (
568 obj, "IDL:Accessibility/Component:1.0");
572 * Accessible_getEditableText:
573 * @obj: a pointer to the #Accessible instance to query.
575 * Get the #AccessibleEditableText interface for an #Accessible.
577 * Returns: a pointer to an #AccessibleEditableText interface instance, or
578 * NULL if @obj does not implement #AccessibleEditableText.
580 AccessibleEditableText *
581 Accessible_getEditableText (Accessible *obj)
583 return (AccessibleEditableText *) Accessible_queryInterface (
584 obj, "IDL:Accessibility/EditableText:1.0");
590 * Accessible_getHypertext:
591 * @obj: a pointer to the #Accessible instance to query.
593 * Get the #AccessibleHypertext interface for an #Accessible.
595 * Returns: a pointer to an #AccessibleHypertext interface instance, or
596 * NULL if @obj does not implement #AccessibleHypertext.
598 AccessibleHypertext *
599 Accessible_getHypertext (Accessible *obj)
601 return (AccessibleHypertext *) Accessible_queryInterface (
602 obj, "IDL:Accessibility/Hypertext:1.0");
608 * Accessible_getImage:
609 * @obj: a pointer to the #Accessible instance to query.
611 * Get the #AccessibleImage interface for an #Accessible.
613 * Returns: a pointer to an #AccessibleImage interface instance, or
614 * NULL if @obj does not implement #AccessibleImage.
617 Accessible_getImage (Accessible *obj)
619 return (AccessibleImage *) Accessible_queryInterface (
620 obj, "IDL:Accessibility/Image:1.0");
626 * Accessible_getSelection:
627 * @obj: a pointer to the #Accessible instance to query.
629 * Get the #AccessibleSelection interface for an #Accessible.
631 * Returns: a pointer to an #AccessibleSelection interface instance, or
632 * NULL if @obj does not implement #AccessibleSelection.
634 AccessibleSelection *
635 Accessible_getSelection (Accessible *obj)
637 return (AccessibleSelection *) Accessible_queryInterface (
638 obj, "IDL:Accessibility/Selection:1.0");
644 * Accessible_getTable:
645 * @obj: a pointer to the #Accessible instance to query.
647 * Get the #AccessibleTable interface for an #Accessible.
649 * Returns: a pointer to an #AccessibleTable interface instance, or
650 * NULL if @obj does not implement #AccessibleTable.
653 Accessible_getTable (Accessible *obj)
655 return (AccessibleTable *) Accessible_queryInterface (
656 obj, "IDL:Accessibility/Table:1.0");
660 * Accessible_getText:
661 * @obj: a pointer to the #Accessible instance to query.
663 * Get the #AccessibleText interface for an #Accessible.
665 * Returns: a pointer to an #AccessibleText interface instance, or
666 * NULL if @obj does not implement #AccessibleText.
669 Accessible_getText (Accessible *obj)
671 return (AccessibleText *) Accessible_queryInterface (
672 obj, "IDL:Accessibility/Text:1.0");
678 * Accessible_getValue:
679 * @obj: a pointer to the #Accessible instance to query.
681 * Get the #AccessibleValue interface for an #Accessible.
683 * Returns: a pointer to an #AccessibleValue interface instance, or
684 * NULL if @obj does not implement #AccessibleValue.
687 Accessible_getValue (Accessible *obj)
689 return (AccessibleValue *) Accessible_queryInterface (
690 obj, "IDL:Accessibility/Value:1.0");
696 * Accessible_queryInterface:
697 * @obj: a pointer to the #Accessible instance to query.
698 * @interface_name: a UTF-8 character string specifiying the requested interface.
700 * Query an #Accessible object to for a named interface.
702 * Returns: an instance of the named interface object, if it is implemented
703 * by @obj, or NULL otherwise.
707 Accessible_queryInterface (Accessible *obj,
708 const char *interface_name)
710 Bonobo_Unknown iface;
717 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
722 cspi_return_val_if_ev ("queryInterface", NULL);
725 * FIXME: we need to be fairly sure that references are going
726 * to mach up if we are going to expose QueryInterface, ie. we
727 * can't allow people to do:
728 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
729 * this should be no real problem though for this level of API
733 return cspi_object_add (iface);
738 * AccessibleRelation_ref:
739 * @obj: a pointer to the #AccessibleRelation object on which to operate.
741 * Increment the reference count for an #AccessibleRelation object.
743 * Returns: (no return code implemented yet).
746 AccessibleRelation_ref (AccessibleRelation *obj)
748 cspi_object_ref (obj);
752 * AccessibleRelation_unref:
753 * @obj: a pointer to the #AccessibleRelation object on which to operate.
755 * Decrement the reference count for an #AccessibleRelation object.
757 * Returns: (no return code implemented yet).
760 AccessibleRelation_unref (AccessibleRelation *obj)
762 cspi_object_unref (obj);
766 * AccessibleRelation_getRelationType:
767 * @obj: a pointer to the #AccessibleRelation object to query.
769 * Get the type of relationship represented by an #AccessibleRelation.
771 * Returns: an #AccessibleRelationType indicating the type of relation
772 * encapsulated in this #AccessibleRelation object.
775 AccessibleRelationType
776 AccessibleRelation_getRelationType (AccessibleRelation *obj)
778 cspi_return_val_if_fail (obj != NULL, -1);
783 * AccessibleRelation_getNTargets:
784 * @obj: a pointer to the #AccessibleRelation object to query.
786 * Get the number of objects which this relationship has as its
787 * target objects (the subject is the #Accessible from which this
788 * #AccessibleRelation originated).
790 * Returns: a short integer indicating how many target objects which the
791 * originating #Accessible object has the #AccessibleRelation
795 AccessibleRelation_getNTargets (AccessibleRelation *obj)
797 cspi_return_val_if_fail (obj != NULL, -1);
802 * AccessibleRelation_getTarget:
803 * @obj: a pointer to the #AccessibleRelation object to query.
804 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
806 * Get the @i-th target of a specified #AccessibleRelation relationship.
808 * Returns: an #Accessible which is the @i-th object with which the
809 * originating #Accessible has relationship specified in the
810 * #AccessibleRelation object.
814 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
816 cspi_return_val_if_fail (obj != NULL, NULL);
821 * AccessibleStateSet_ref:
822 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
824 * Increment the reference count for an #AccessibleStateSet object.
826 * Returns: (no return code implemented yet).
830 AccessibleStateSet_ref (AccessibleStateSet *obj)
832 cspi_object_ref (obj);
836 * AccessibleStateSet_unref:
837 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
839 * Decrement the reference count for an #AccessibleStateSet object.
841 * Returns: (no return code implemented yet).
845 AccessibleStateSet_unref (AccessibleStateSet *obj)
847 cspi_object_unref (obj);
851 * AccessibleStateSet_contains:
852 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
853 * @state: an #AccessibleState for which the specified #AccessibleStateSet
856 * Determine whether a given #AccessibleStateSet includes a given state; that is,
857 * whether @state is true for the stateset in question.
859 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
864 AccessibleStateSet_contains (AccessibleStateSet *obj,
865 AccessibleState state)
867 CORBA_boolean retval;
869 cspi_return_val_if_fail (obj != NULL, FALSE);
871 retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
874 cspi_return_val_if_ev ("contains", FALSE);
876 return (SPIBoolean) retval;
880 * AccessibleStateSet_add:
881 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
882 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
884 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
885 * given state to #TRUE in the stateset.
889 AccessibleStateSet_add (AccessibleStateSet *obj,
890 AccessibleState state)
892 cspi_return_if_fail (obj != NULL);
894 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
895 cspi_check_ev ("add");
899 * AccessibleStateSet_remove:
900 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
901 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
903 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
904 * given state to #FALSE in the stateset.)
908 AccessibleStateSet_remove (AccessibleStateSet *obj,
909 AccessibleState state)
911 cspi_return_if_fail (obj != NULL);
913 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
914 cspi_check_ev ("remove");
918 * AccessibleStateSet_equals:
919 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
920 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
922 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
923 * consist of the same #AccessibleStates). Useful for checking multiple
924 * state variables at once; construct the target state then compare against it.
926 * @see AccessibleStateSet_compare().
928 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
933 AccessibleStateSet_equals (AccessibleStateSet *obj,
934 AccessibleStateSet *obj2)
941 cspi_return_val_if_fail (obj != NULL, FALSE);
942 cspi_return_val_if_fail (obj2 != NULL, FALSE);
944 return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
945 CSPI_OBJREF (obj2), cspi_ev ());
949 * AccessibleStateSet_compare:
950 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
951 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
953 * Determine the differences between two instances of #AccessibleStateSet.
954 * Not Yet Implemented.
956 * @see AccessibleStateSet_equals().
958 * Returns: an #AccessibleStateSet object containing all states contained on one of
959 * the two sets but not the other.
963 AccessibleStateSet_compare (AccessibleStateSet *obj,
964 AccessibleStateSet *obj2)
966 cspi_return_val_if_fail (obj != NULL, NULL);
967 cspi_return_val_if_fail (obj2 != NULL, NULL);
972 * AccessibleStateSet_isEmpty:
973 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
975 * Determine whether a given #AccessibleStateSet is the empty set.
977 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
982 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
984 cspi_return_val_if_fail (obj != NULL, FALSE);
986 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/