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,
662 const char *interface_name)
664 Bonobo_Unknown iface;
671 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
676 * FIXME: we need to be fairly sure that references are going
677 * to mach up if we are going to expose QueryInterface, ie. we
678 * can't allow people to do:
679 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
680 * this should be no real problem though for this level of API
684 return cspi_object_add (iface);
689 * AccessibleRelation_ref:
690 * @obj: a pointer to the #AccessibleRelation object on which to operate.
692 * Increment the reference count for an #AccessibleRelation object.
694 * Returns: (no return code implemented yet).
698 AccessibleRelation_ref (AccessibleRelation *obj)
700 cspi_object_ref (obj);
705 * AccessibleRelation_unref:
706 * @obj: a pointer to the #AccessibleRelation object on which to operate.
708 * Decrement the reference count for an #AccessibleRelation object.
710 * Returns: (no return code implemented yet).
714 AccessibleRelation_unref (AccessibleRelation *obj)
716 cspi_object_unref (obj);
721 * AccessibleRelation_getRelationType:
722 * @obj: a pointer to the #AccessibleRelation object to query.
724 * Get the type of relationship represented by an #AccessibleRelation.
726 * Returns: an #AccessibleRelationType indicating the type of relation
727 * encapsulated in this #AccessibleRelation object.
730 AccessibleRelationType
731 AccessibleRelation_getRelationType (AccessibleRelation *obj)
737 * AccessibleRelation_getNTargets:
738 * @obj: a pointer to the #AccessibleRelation object to query.
740 * Get the number of objects which this relationship has as its
741 * target objects (the subject is the #Accessible from which this
742 * #AccessibleRelation originated).
744 * Returns: a short integer indicating how many target objects which the
745 * originating #Accessible object has the #AccessibleRelation
749 AccessibleRelation_getNTargets (AccessibleRelation *obj)
755 * AccessibleRelation_getTarget:
756 * @obj: a pointer to the #AccessibleRelation object to query.
757 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
759 * Get the @i-th target of a specified #AccessibleRelation relationship.
761 * Returns: an #Accessible which is the @i-th object with which the
762 * originating #Accessible has relationship specified in the
763 * #AccessibleRelation object.
767 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
773 * AccessibleStateSet_ref:
774 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
776 * Increment the reference count for an #AccessibleStateSet object.
778 * Returns: (no return code implemented yet).
782 AccessibleStateSet_ref (AccessibleStateSet *obj)
784 cspi_object_ref (obj);
789 * AccessibleStateSet_unref:
790 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
792 * Decrement the reference count for an #AccessibleStateSet object.
794 * Returns: (no return code implemented yet).
798 AccessibleStateSet_unref (AccessibleStateSet *obj)
800 cspi_object_unref (obj);
806 * AccessibleStateSet_contains:
807 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
808 * @state: an #AccessibleState for which the specified #AccessibleStateSet
811 * Determine whether a given #AccessibleStateSet includes a given state; that is,
812 * whether @state is true for the stateset in question.
814 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
819 AccessibleStateSet_contains (AccessibleStateSet *obj,
820 AccessibleState state)
822 CORBA_boolean retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj), state, cspi_ev ());
823 cspi_check_ev (cspi_ev (), "contains");
824 return (SPIBoolean) retval;
828 * AccessibleStateSet_add:
829 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
830 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
832 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
833 * given state to #TRUE in the stateset.
837 AccessibleStateSet_add (AccessibleStateSet *obj,
838 AccessibleState state)
840 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
841 cspi_check_ev (cspi_ev (), "contains");
846 * AccessibleStateSet_remove:
847 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
848 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
850 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
851 * given state to #FALSE in the stateset.)
855 AccessibleStateSet_remove (AccessibleStateSet *obj,
856 AccessibleState state)
858 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
859 cspi_check_ev (cspi_ev (), "contains");
863 * AccessibleStateSet_equals:
864 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
865 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
867 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
868 * consist of the same #AccessibleStates). Useful for checking multiple
869 * state variables at once; construct the target state then compare against it.
871 * @see AccessibleStateSet_compare().
873 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
878 AccessibleStateSet_equals (AccessibleStateSet *obj,
879 AccessibleStateSet *obj2)
881 return Accessibility_StateSet_equals (CSPI_OBJREF (obj), CSPI_OBJREF (obj2), cspi_ev ());
885 * AccessibleStateSet_compare:
886 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
887 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
888 * @differenceSet: a pointer to an array of #AccessibleStates, which is set when the
889 * fuction returns to point to an array of states representing the states which
890 * the two state sets do not have in common.
892 * Determine the differences between two instances of #AccessibleStateSet.
894 * @see AccessibleStateSet_equals().
896 * Returns: an #AccessibleStateSet object containing all states contained on one of
897 * the two sets but not the other.
901 AccessibleStateSet_compare (AccessibleStateSet *obj,
902 AccessibleStateSet *obj2,
903 AccessibleStateSet **differenceSet);
907 * AccessibleStateSet_isEmpty:
908 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
910 * Determine whether a given #AccessibleStateSet is the empty set.
912 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
917 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
920 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/