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);
123 * @obj: a pointer to the #Accessible object on which to operate.
125 * Decrement the reference count for an #Accessible object.
127 * Returns: (no return code implemented yet).
131 Accessible_unref (Accessible *obj)
133 cspi_object_unref (obj);
138 * Accessible_getName:
139 * @obj: a pointer to the #Accessible object on which to operate.
141 * Get the name of an #Accessible object.
143 * Returns: a UTF-8 string indicating the name of the #Accessible object.
147 Accessible_getName (Accessible *obj)
151 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
152 cspi_check_ev (cspi_ev (), "getName");
157 * Accessible_getDescription:
158 * @obj: a pointer to the #Accessible object on which to operate.
160 * Get the description of an #Accessible object.
162 * Returns: a UTF-8 string describing the #Accessible object.
166 Accessible_getDescription (Accessible *obj)
168 char *retval = (char *)
169 Accessibility_Accessible__get_description (CSPI_OBJREF (obj), cspi_ev ());
170 cspi_check_ev (cspi_ev (), "getDescription");
175 * Accessible_getParent:
176 * @obj: a pointer to the #Accessible object to query.
178 * Get an #Accessible object's parent container.
180 * Returns: a pointer tothe #Accessible object which contains the given
181 * #Accessible instance, or NULL if the @obj has no parent container.
185 Accessible_getParent (Accessible *obj)
188 cspi_object_add (Accessibility_Accessible__get_parent (CSPI_OBJREF (obj), cspi_ev ()));
189 cspi_check_ev (cspi_ev (), "getParent");
194 * Accessible_getChildCount:
195 * @obj: a pointer to the #Accessible object on which to operate.
197 * Get the number of children contained by an #Accessible object.
199 * Returns: a #long indicating the number of #Accessible children
200 * contained by an #Accessible object.
204 Accessible_getChildCount (Accessible *obj)
206 long retval = (long) Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj), cspi_ev ());
207 cspi_check_ev (cspi_ev (), "getChildCount");
212 * Accessible_getChildAtIndex:
213 * @obj: a pointer to the #Accessible object on which to operate.
214 * @childIndex: a #long indicating which child is specified.
216 * Get the #Accessible child of an #Accessible object at a given index.
218 * Returns: a pointer to the #Accessible child object at index
223 Accessible_getChildAtIndex (Accessible *obj,
226 Accessible *retval = cspi_object_add_check (Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj), childIndex, cspi_ev ()));
231 * Accessible_getIndexInParent:
232 * @obj: a pointer to the #Accessible object on which to operate.
234 * Get the index of an #Accessible object in its containing #Accessible.
236 * Returns: a #long indicating the index of the #Accessible object
237 * in its parent (i.e. containing) #Accessible instance,
238 * or -1 if @obj has no containing parent.
242 Accessible_getIndexInParent (Accessible *obj)
244 long retval = (long) Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
245 cspi_check_ev (cspi_ev (), "getIndexInParent");
250 * Accessible_getRelationSet:
251 * @obj: a pointer to the #Accessible object on which to operate.
253 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
254 * relationships with other #Accessible objects.
256 * Returns: an array of #AccessibleRelation pointers.
259 AccessibleRelation **
260 Accessible_getRelationSet (Accessible *obj)
262 AccessibleRelation **relations;
265 Accessibility_RelationSet *relation_set =
266 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
268 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
269 n_relations = relation_set->_length;
270 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
272 for (i=0; i<n_relations; ++i)
274 relations[i] = cspi_object_add (CORBA_Object_duplicate (relation_set->_buffer[i], cspi_ev ()));
276 relations[i] = CORBA_OBJECT_NIL;
278 CORBA_free (relation_set);
284 * Accessible_getRole:
285 * @obj: a pointer to the #Accessible object on which to operate.
287 * Get the UI role of an #Accessible object.
289 * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
293 Accessible_getRole (Accessible *obj)
295 const char *retval = AccessibleRole_getName (
296 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
297 cspi_check_ev (cspi_ev (), "getRole");
302 * Accessible_getStateSet:
303 * @obj: a pointer to the #Accessible object on which to operate.
305 * Not Yet Implemented.
307 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
310 Accessible_getStateSet (Accessible *obj)
315 /* Interface query methods */
318 * Accessible_isAction:
319 * @obj: a pointer to the #Accessible instance to query.
321 * Query whether the specified #Accessible implements #AccessibleAction.
323 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
327 Accessible_isAction (Accessible *obj)
329 return cspi_accessible_is_a (obj,
330 "IDL:Accessibility/Action:1.0");
334 * Accessible_isApplication:
335 * @obj: a pointer to the #Accessible instance to query.
337 * Query whether the specified #Accessible implements #AccessibleApplication.
339 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
343 Accessible_isApplication (Accessible *obj)
345 return cspi_accessible_is_a (obj,
346 "IDL:Accessibility/Application:1.0");
350 * Accessible_isComponent:
351 * @obj: a pointer to the #Accessible instance to query.
353 * Query whether the specified #Accessible implements #AccessibleComponent.
355 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
359 Accessible_isComponent (Accessible *obj)
361 return cspi_accessible_is_a (obj,
362 "IDL:Accessibility/Component:1.0");
366 * Accessible_isEditableText:
367 * @obj: a pointer to the #Accessible instance to query.
369 * Query whether the specified #Accessible implements #AccessibleEditableText.
371 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
375 Accessible_isEditableText (Accessible *obj)
377 return cspi_accessible_is_a (obj,
378 "IDL:Accessibility/EditableText:1.0");
382 * Accessible_isHypertext:
383 * @obj: a pointer to the #Accessible instance to query.
385 * Query whether the specified #Accessible implements #AccessibleHypertext.
387 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
391 Accessible_isHypertext (Accessible *obj)
393 return cspi_accessible_is_a (obj,
394 "IDL:Accessibility/Hypertext:1.0");
398 * Accessible_isImage:
399 * @obj: a pointer to the #Accessible instance to query.
401 * Query whether the specified #Accessible implements #AccessibleImage.
403 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
407 Accessible_isImage (Accessible *obj)
409 return cspi_accessible_is_a (obj,
410 "IDL:Accessibility/Image:1.0");
414 * Accessible_isSelection:
415 * @obj: a pointer to the #Accessible instance to query.
417 * Query whether the specified #Accessible implements #AccessibleSelection.
419 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
423 Accessible_isSelection (Accessible *obj)
425 return cspi_accessible_is_a (obj,
426 "IDL:Accessibility/Selection:1.0");
430 * Accessible_isTable:
431 * @obj: a pointer to the #Accessible instance to query.
433 * Query whether the specified #Accessible implements #AccessibleTable.
435 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
439 Accessible_isTable (Accessible *obj)
441 return cspi_accessible_is_a (obj,
442 "IDL:Accessibility/Table:1.0");
447 * @obj: a pointer to the #Accessible instance to query.
449 * Query whether the specified #Accessible implements #AccessibleText.
451 * Returns: #TRUE if @obj implements the #AccessibleText interface,
455 Accessible_isText (Accessible *obj)
457 return cspi_accessible_is_a (obj,
458 "IDL:Accessibility/Text:1.0");
462 * Accessible_isValue:
463 * @obj: a pointer to the #Accessible instance to query.
465 * Query whether the specified #Accessible implements #AccessibleValue.
467 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
471 Accessible_isValue (Accessible *obj)
473 return cspi_accessible_is_a (obj,
474 "IDL:Accessibility/Value:1.0");
478 * Accessible_getApplication:
479 * @obj: a pointer to the #Accessible instance to query.
481 * Get the #AccessibleApplication interface for an #Accessible.
483 * Returns: a pointer to an #AccessibleApplication interface instance, or
484 * NULL if @obj does not implement #AccessibleApplication.
486 AccessibleApplication *
487 Accessible_getApplication (Accessible *obj)
489 return (AccessibleApplication *) Accessible_queryInterface (
490 obj, "IDL:Accessibility/Application:1.0");
494 * Accessible_getAction:
495 * @obj: a pointer to the #Accessible instance to query.
497 * Get the #AccessibleAction interface for an #Accessible.
499 * Returns: a pointer to an #AccessibleAction interface instance, or
500 * NULL if @obj does not implement #AccessibleAction.
503 Accessible_getAction (Accessible *obj)
505 return (AccessibleAction *) Accessible_queryInterface (
506 obj, "IDL:Accessibility/Action:1.0");
510 * Accessible_getComponent:
511 * @obj: a pointer to the #Accessible instance to query.
513 * Get the #AccessibleComponent interface for an #Accessible.
515 * Returns: a pointer to an #AccessibleComponent interface instance, or
516 * NULL if @obj does not implement #AccessibleComponent.
518 AccessibleComponent *
519 Accessible_getComponent (Accessible *obj)
521 return (AccessibleComponent *) Accessible_queryInterface (
522 obj, "IDL:Accessibility/Component:1.0");
526 * Accessible_getEditableText:
527 * @obj: a pointer to the #Accessible instance to query.
529 * Get the #AccessibleEditableText interface for an #Accessible.
531 * Returns: a pointer to an #AccessibleEditableText interface instance, or
532 * NULL if @obj does not implement #AccessibleEditableText.
534 AccessibleEditableText *
535 Accessible_getEditableText (Accessible *obj)
537 return (AccessibleEditableText *) Accessible_queryInterface (
538 obj, "IDL:Accessibility/EditableText:1.0");
544 * Accessible_getHypertext:
545 * @obj: a pointer to the #Accessible instance to query.
547 * Get the #AccessibleHypertext interface for an #Accessible.
549 * Returns: a pointer to an #AccessibleHypertext interface instance, or
550 * NULL if @obj does not implement #AccessibleHypertext.
552 AccessibleHypertext *
553 Accessible_getHypertext (Accessible *obj)
555 return (AccessibleHypertext *) Accessible_queryInterface (
556 obj, "IDL:Accessibility/Hypertext:1.0");
562 * Accessible_getImage:
563 * @obj: a pointer to the #Accessible instance to query.
565 * Get the #AccessibleImage interface for an #Accessible.
567 * Returns: a pointer to an #AccessibleImage interface instance, or
568 * NULL if @obj does not implement #AccessibleImage.
571 Accessible_getImage (Accessible *obj)
573 return (AccessibleImage *) Accessible_queryInterface (
574 obj, "IDL:Accessibility/Image:1.0");
580 * Accessible_getSelection:
581 * @obj: a pointer to the #Accessible instance to query.
583 * Get the #AccessibleSelection interface for an #Accessible.
585 * Returns: a pointer to an #AccessibleSelection interface instance, or
586 * NULL if @obj does not implement #AccessibleSelection.
588 AccessibleSelection *
589 Accessible_getSelection (Accessible *obj)
591 return (AccessibleSelection *) Accessible_queryInterface (
592 obj, "IDL:Accessibility/Selection:1.0");
598 * Accessible_getTable:
599 * @obj: a pointer to the #Accessible instance to query.
601 * Get the #AccessibleTable interface for an #Accessible.
603 * Returns: a pointer to an #AccessibleTable interface instance, or
604 * NULL if @obj does not implement #AccessibleTable.
607 Accessible_getTable (Accessible *obj)
609 return (AccessibleTable *) Accessible_queryInterface (
610 obj, "IDL:Accessibility/Table:1.0");
614 * Accessible_getText:
615 * @obj: a pointer to the #Accessible instance to query.
617 * Get the #AccessibleText interface for an #Accessible.
619 * Returns: a pointer to an #AccessibleText interface instance, or
620 * NULL if @obj does not implement #AccessibleText.
623 Accessible_getText (Accessible *obj)
625 return (AccessibleText *) Accessible_queryInterface (
626 obj, "IDL:Accessibility/Text:1.0");
632 * Accessible_getValue:
633 * @obj: a pointer to the #Accessible instance to query.
635 * Get the #AccessibleValue interface for an #Accessible.
637 * Returns: a pointer to an #AccessibleValue interface instance, or
638 * NULL if @obj does not implement #AccessibleValue.
641 Accessible_getValue (Accessible *obj)
643 return (AccessibleValue *) Accessible_queryInterface (
644 obj, "IDL:Accessibility/Value:1.0");
650 * Accessible_queryInterface:
651 * @obj: a pointer to the #Accessible instance to query.
652 * @interface_name: a UTF-8 character string specifiying the requested interface.
654 * Query an #Accessible object to for a named interface.
656 * Returns: an instance of the named interface object, if it is implemented
657 * by @obj, or NULL otherwise.
661 Accessible_queryInterface (Accessible *obj, char *interface_name)
663 Bonobo_Unknown iface;
670 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
675 * FIXME: we need to be fairly sure that references are going
676 * to mach up if we are going to expose QueryInterface, ie. we
677 * can't allow people to do:
678 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
679 * this should be no real problem though for this level of API
683 return cspi_object_add (iface);
688 * AccessibleRelation_ref:
689 * @obj: a pointer to the #AccessibleRelation object on which to operate.
691 * Increment the reference count for an #AccessibleRelation object.
693 * Returns: (no return code implemented yet).
697 AccessibleRelation_ref (AccessibleRelation *obj)
699 cspi_object_ref (obj);
704 * AccessibleRelation_unref:
705 * @obj: a pointer to the #AccessibleRelation object on which to operate.
707 * Decrement the reference count for an #AccessibleRelation object.
709 * Returns: (no return code implemented yet).
713 AccessibleRelation_unref (AccessibleRelation *obj)
715 cspi_object_unref (obj);
720 * AccessibleRelation_getRelationType:
721 * @obj: a pointer to the #AccessibleRelation object to query.
723 * Get the type of relationship represented by an #AccessibleRelation.
725 * Returns: an #AccessibleRelationType indicating the type of relation
726 * encapsulated in this #AccessibleRelation object.
729 AccessibleRelationType
730 AccessibleRelation_getRelationType (AccessibleRelation *obj)
736 * AccessibleRelation_getNTargets:
737 * @obj: a pointer to the #AccessibleRelation object to query.
739 * Get the number of objects which this relationship has as its
740 * target objects (the subject is the #Accessible from which this
741 * #AccessibleRelation originated).
743 * Returns: a short integer indicating how many target objects which the
744 * originating #Accessible object has the #AccessibleRelation
748 AccessibleRelation_getNTargets (AccessibleRelation *obj)
754 * AccessibleRelation_getTarget:
755 * @obj: a pointer to the #AccessibleRelation object to query.
756 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
758 * Get the @i-th target of a specified #AccessibleRelation relationship.
760 * Returns: an #Accessible which is the @i-th object with which the
761 * originating #Accessible has relationship specified in the
762 * #AccessibleRelation object.
766 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
772 * AccessibleStateSet_ref:
773 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
775 * Increment the reference count for an #AccessibleStateSet object.
777 * Returns: (no return code implemented yet).
781 AccessibleStateSet_ref (AccessibleStateSet *obj)
783 cspi_object_ref (obj);
788 * AccessibleStateSet_unref:
789 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
791 * Decrement the reference count for an #AccessibleStateSet object.
793 * Returns: (no return code implemented yet).
797 AccessibleStateSet_unref (AccessibleStateSet *obj)
799 cspi_object_unref (obj);
805 * AccessibleStateSet_contains:
806 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
807 * @state: an #AccessibleState for which the specified #AccessibleStateSet
810 * Determine whether a given #AccessibleStateSet includes a given state; that is,
811 * whether @state is true for the stateset in question.
813 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
818 AccessibleStateSet_contains (AccessibleStateSet *obj,
819 AccessibleState state)
821 CORBA_boolean retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj), state, cspi_ev ());
822 cspi_check_ev (cspi_ev (), "contains");
823 return (SPIBoolean) retval;
827 * AccessibleStateSet_add:
828 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
829 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
831 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
832 * given state to #TRUE in the stateset.
836 AccessibleStateSet_add (AccessibleStateSet *obj,
837 AccessibleState state)
839 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
840 cspi_check_ev (cspi_ev (), "contains");
845 * AccessibleStateSet_remove:
846 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
847 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
849 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
850 * given state to #FALSE in the stateset.)
854 AccessibleStateSet_remove (AccessibleStateSet *obj,
855 AccessibleState state)
857 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
858 cspi_check_ev (cspi_ev (), "contains");
862 * AccessibleStateSet_equals:
863 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
864 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
866 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
867 * consist of the same #AccessibleStates). Useful for checking multiple
868 * state variables at once; construct the target state then compare against it.
870 * @see AccessibleStateSet_compare().
872 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
877 AccessibleStateSet_equals (AccessibleStateSet *obj,
878 AccessibleStateSet *obj2)
880 return Accessibility_StateSet_equals (CSPI_OBJREF (obj), CSPI_OBJREF (obj2), cspi_ev ());
884 * AccessibleStateSet_compare:
885 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
886 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
887 * @differenceSet: a pointer to an array of #AccessibleStates, which is set when the
888 * fuction returns to point to an array of states representing the states which
889 * the two state sets do not have in common.
891 * Determine the differences between two instances of #AccessibleStateSet.
893 * @see AccessibleStateSet_equals().
895 * Returns: an #AccessibleStateSet object containing all states contained on one of
896 * the two sets but not the other.
900 AccessibleStateSet_compare (AccessibleStateSet *obj,
901 AccessibleStateSet *obj2,
902 AccessibleStateSet **differenceSet);
906 * AccessibleStateSet_isEmpty:
907 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
909 * Determine whether a given #AccessibleStateSet is the empty set.
911 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
916 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
919 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/