1 #include <stdlib.h> /* for malloc */
2 #include <cspi/spi-private.h>
4 static const char *role_names [] =
60 "table column header",
74 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
77 cspi_role_from_spi_role (Accessibility_Role role)
79 return role; /* FIXME: need to compare, equivalence not guaranteed */
83 * AccessibleRole_getName:
84 * @role: an #AccessibleRole object to query.
86 * Get a localizeable string that indicates the name of an #AccessibleRole.
87 * Currently broken, do not use.
89 * Returns: a localizable string name for an #AccessibleRole enumerated type.
92 AccessibleRole_getName (AccessibleRole role)
96 return g_strdup (role_names [(int) role]);
100 return g_strdup ("");
106 * @obj: a pointer to the #Accessible object on which to operate.
108 * Increment the reference count for an #Accessible object.
111 Accessible_ref (Accessible *obj)
113 cspi_object_ref (obj);
118 * @obj: a pointer to the #Accessible object on which to operate.
120 * Decrement the reference count for an #Accessible object.
123 Accessible_unref (Accessible *obj)
125 cspi_object_unref (obj);
129 * Accessible_getName:
130 * @obj: a pointer to the #Accessible object on which to operate.
132 * Get the name of an #Accessible object.
134 * Returns: a UTF-8 string indicating the name of the #Accessible object.
135 * or NULL on exception
138 Accessible_getName (Accessible *obj)
142 cspi_return_val_if_fail (obj != NULL, NULL);
145 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
147 cspi_return_val_if_ev ("getName", NULL);
153 * Accessible_getDescription:
154 * @obj: a pointer to the #Accessible object on which to operate.
156 * Get the description of an #Accessible object.
158 * Returns: a UTF-8 string describing the #Accessible object.
159 * or NULL on exception
162 Accessible_getDescription (Accessible *obj)
166 cspi_return_val_if_fail (obj != NULL, NULL);
169 Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
172 cspi_return_val_if_ev ("getDescription", NULL);
178 * Accessible_getParent:
179 * @obj: a pointer to the #Accessible object to query.
181 * Get an #Accessible object's parent container.
183 * Returns: a pointer tothe #Accessible object which contains the given
184 * #Accessible instance, or NULL if the @obj has no parent container.
188 Accessible_getParent (Accessible *obj)
192 cspi_return_val_if_fail (obj != NULL, NULL);
194 retval = cspi_object_add (
195 Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
198 cspi_return_val_if_ev ("getParent", NULL);
204 * Accessible_getChildCount:
205 * @obj: a pointer to the #Accessible object on which to operate.
207 * Get the number of children contained by an #Accessible object.
209 * Returns: a #long indicating the number of #Accessible children
210 * contained by an #Accessible object. or -1 on exception
214 Accessible_getChildCount (Accessible *obj)
218 cspi_return_val_if_fail (obj != NULL, -1);
221 Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
224 cspi_return_val_if_ev ("getChildCount", -1);
230 * Accessible_getChildAtIndex:
231 * @obj: a pointer to the #Accessible object on which to operate.
232 * @childIndex: a #long indicating which child is specified.
234 * Get the #Accessible child of an #Accessible object at a given index.
236 * Returns: a pointer to the #Accessible child object at index
237 * @childIndex. or NULL on exception
240 Accessible_getChildAtIndex (Accessible *obj,
245 cspi_return_val_if_fail (obj != NULL, NULL);
247 retval = cspi_object_add (
248 Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
249 childIndex, cspi_ev ()));
255 * Accessible_getIndexInParent:
256 * @obj: a pointer to the #Accessible object on which to operate.
258 * Get the index of an #Accessible object in its containing #Accessible.
260 * Returns: a #long indicating the index of the #Accessible object
261 * in its parent (i.e. containing) #Accessible instance,
262 * or -1 if @obj has no containing parent or on exception.
265 Accessible_getIndexInParent (Accessible *obj)
269 cspi_return_val_if_fail (obj != NULL, -1);
272 Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
274 cspi_return_val_if_ev ("getIndexInparent", -1);
279 * Accessible_getRelationSet:
280 * @obj: a pointer to the #Accessible object on which to operate.
282 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
283 * relationships with other #Accessible objects.
285 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
287 AccessibleRelation **
288 Accessible_getRelationSet (Accessible *obj)
292 AccessibleRelation **relations;
293 Accessibility_RelationSet *relation_set;
295 cspi_return_val_if_fail (obj != NULL, NULL);
298 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
300 cspi_return_val_if_ev ("getRelationSet", NULL);
302 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
303 n_relations = relation_set->_length;
304 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
306 for (i = 0; i < n_relations; ++i)
308 relations[i] = cspi_object_add (CORBA_Object_duplicate (
309 relation_set->_buffer[i], cspi_ev ()));
311 relations[i] = CORBA_OBJECT_NIL;
313 CORBA_free (relation_set);
319 * Accessible_getRole:
320 * @obj: a pointer to the #Accessible object on which to operate.
322 * Get the UI role of an #Accessible object.
323 * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
325 * Returns: the #AccessibleRole of the object.
329 Accessible_getRole (Accessible *obj)
331 AccessibleRole retval;
333 cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
336 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
338 cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID);
340 return cspi_role_from_spi_role (retval);
344 * Accessible_getRoleName:
345 * @obj: a pointer to the #Accessible object on which to operate.
347 * Get a UTF-8 string describing the role this object plays in the UI.
348 * This method will return useful values for roles that fall outside the
349 * enumeration used in Accessible_getRole ().
351 * Returns: a UTF-8 string specifying the role of this #Accessible object.
355 Accessible_getRoleName (Accessible *obj)
359 cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
362 Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
364 cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid"));
370 * Accessible_getStateSet:
371 * @obj: a pointer to the #Accessible object on which to operate.
373 * Not Yet Implemented.
375 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
378 Accessible_getStateSet (Accessible *obj)
383 /* Interface query methods */
386 * Accessible_isAction:
387 * @obj: a pointer to the #Accessible instance to query.
389 * Query whether the specified #Accessible implements #AccessibleAction.
391 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
395 Accessible_isAction (Accessible *obj)
397 return cspi_accessible_is_a (obj,
398 "IDL:Accessibility/Action:1.0");
402 * Accessible_isApplication:
403 * @obj: a pointer to the #Accessible instance to query.
405 * Query whether the specified #Accessible implements #AccessibleApplication.
407 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
411 Accessible_isApplication (Accessible *obj)
413 return cspi_accessible_is_a (obj,
414 "IDL:Accessibility/Application:1.0");
418 * Accessible_isComponent:
419 * @obj: a pointer to the #Accessible instance to query.
421 * Query whether the specified #Accessible implements #AccessibleComponent.
423 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
427 Accessible_isComponent (Accessible *obj)
429 return cspi_accessible_is_a (obj,
430 "IDL:Accessibility/Component:1.0");
434 * Accessible_isEditableText:
435 * @obj: a pointer to the #Accessible instance to query.
437 * Query whether the specified #Accessible implements #AccessibleEditableText.
439 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
443 Accessible_isEditableText (Accessible *obj)
445 return cspi_accessible_is_a (obj,
446 "IDL:Accessibility/EditableText:1.0");
450 * Accessible_isHypertext:
451 * @obj: a pointer to the #Accessible instance to query.
453 * Query whether the specified #Accessible implements #AccessibleHypertext.
455 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
459 Accessible_isHypertext (Accessible *obj)
461 return cspi_accessible_is_a (obj,
462 "IDL:Accessibility/Hypertext:1.0");
466 * Accessible_isImage:
467 * @obj: a pointer to the #Accessible instance to query.
469 * Query whether the specified #Accessible implements #AccessibleImage.
471 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
475 Accessible_isImage (Accessible *obj)
477 return cspi_accessible_is_a (obj,
478 "IDL:Accessibility/Image:1.0");
482 * Accessible_isSelection:
483 * @obj: a pointer to the #Accessible instance to query.
485 * Query whether the specified #Accessible implements #AccessibleSelection.
487 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
491 Accessible_isSelection (Accessible *obj)
493 return cspi_accessible_is_a (obj,
494 "IDL:Accessibility/Selection:1.0");
498 * Accessible_isTable:
499 * @obj: a pointer to the #Accessible instance to query.
501 * Query whether the specified #Accessible implements #AccessibleTable.
503 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
507 Accessible_isTable (Accessible *obj)
509 return cspi_accessible_is_a (obj,
510 "IDL:Accessibility/Table:1.0");
515 * @obj: a pointer to the #Accessible instance to query.
517 * Query whether the specified #Accessible implements #AccessibleText.
519 * Returns: #TRUE if @obj implements the #AccessibleText interface,
523 Accessible_isText (Accessible *obj)
525 return cspi_accessible_is_a (obj,
526 "IDL:Accessibility/Text:1.0");
530 * Accessible_isValue:
531 * @obj: a pointer to the #Accessible instance to query.
533 * Query whether the specified #Accessible implements #AccessibleValue.
535 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
539 Accessible_isValue (Accessible *obj)
541 return cspi_accessible_is_a (obj,
542 "IDL:Accessibility/Value:1.0");
546 * Accessible_getApplication:
547 * @obj: a pointer to the #Accessible instance to query.
549 * Get the #AccessibleApplication interface for an #Accessible.
551 * Returns: a pointer to an #AccessibleApplication interface instance, or
552 * NULL if @obj does not implement #AccessibleApplication.
554 AccessibleApplication *
555 Accessible_getApplication (Accessible *obj)
557 return (AccessibleApplication *) Accessible_queryInterface (
558 obj, "IDL:Accessibility/Application:1.0");
562 * Accessible_getAction:
563 * @obj: a pointer to the #Accessible instance to query.
565 * Get the #AccessibleAction interface for an #Accessible.
567 * Returns: a pointer to an #AccessibleAction interface instance, or
568 * NULL if @obj does not implement #AccessibleAction.
571 Accessible_getAction (Accessible *obj)
573 return (AccessibleAction *) Accessible_queryInterface (
574 obj, "IDL:Accessibility/Action:1.0");
578 * Accessible_getComponent:
579 * @obj: a pointer to the #Accessible instance to query.
581 * Get the #AccessibleComponent interface for an #Accessible.
583 * Returns: a pointer to an #AccessibleComponent interface instance, or
584 * NULL if @obj does not implement #AccessibleComponent.
586 AccessibleComponent *
587 Accessible_getComponent (Accessible *obj)
589 return (AccessibleComponent *) Accessible_queryInterface (
590 obj, "IDL:Accessibility/Component:1.0");
594 * Accessible_getEditableText:
595 * @obj: a pointer to the #Accessible instance to query.
597 * Get the #AccessibleEditableText interface for an #Accessible.
599 * Returns: a pointer to an #AccessibleEditableText interface instance, or
600 * NULL if @obj does not implement #AccessibleEditableText.
602 AccessibleEditableText *
603 Accessible_getEditableText (Accessible *obj)
605 return (AccessibleEditableText *) Accessible_queryInterface (
606 obj, "IDL:Accessibility/EditableText:1.0");
612 * Accessible_getHypertext:
613 * @obj: a pointer to the #Accessible instance to query.
615 * Get the #AccessibleHypertext interface for an #Accessible.
617 * Returns: a pointer to an #AccessibleHypertext interface instance, or
618 * NULL if @obj does not implement #AccessibleHypertext.
620 AccessibleHypertext *
621 Accessible_getHypertext (Accessible *obj)
623 return (AccessibleHypertext *) Accessible_queryInterface (
624 obj, "IDL:Accessibility/Hypertext:1.0");
630 * Accessible_getImage:
631 * @obj: a pointer to the #Accessible instance to query.
633 * Get the #AccessibleImage interface for an #Accessible.
635 * Returns: a pointer to an #AccessibleImage interface instance, or
636 * NULL if @obj does not implement #AccessibleImage.
639 Accessible_getImage (Accessible *obj)
641 return (AccessibleImage *) Accessible_queryInterface (
642 obj, "IDL:Accessibility/Image:1.0");
648 * Accessible_getSelection:
649 * @obj: a pointer to the #Accessible instance to query.
651 * Get the #AccessibleSelection interface for an #Accessible.
653 * Returns: a pointer to an #AccessibleSelection interface instance, or
654 * NULL if @obj does not implement #AccessibleSelection.
656 AccessibleSelection *
657 Accessible_getSelection (Accessible *obj)
659 return (AccessibleSelection *) Accessible_queryInterface (
660 obj, "IDL:Accessibility/Selection:1.0");
666 * Accessible_getTable:
667 * @obj: a pointer to the #Accessible instance to query.
669 * Get the #AccessibleTable interface for an #Accessible.
671 * Returns: a pointer to an #AccessibleTable interface instance, or
672 * NULL if @obj does not implement #AccessibleTable.
675 Accessible_getTable (Accessible *obj)
677 return (AccessibleTable *) Accessible_queryInterface (
678 obj, "IDL:Accessibility/Table:1.0");
682 * Accessible_getText:
683 * @obj: a pointer to the #Accessible instance to query.
685 * Get the #AccessibleText interface for an #Accessible.
687 * Returns: a pointer to an #AccessibleText interface instance, or
688 * NULL if @obj does not implement #AccessibleText.
691 Accessible_getText (Accessible *obj)
693 return (AccessibleText *) Accessible_queryInterface (
694 obj, "IDL:Accessibility/Text:1.0");
700 * Accessible_getValue:
701 * @obj: a pointer to the #Accessible instance to query.
703 * Get the #AccessibleValue interface for an #Accessible.
705 * Returns: a pointer to an #AccessibleValue interface instance, or
706 * NULL if @obj does not implement #AccessibleValue.
709 Accessible_getValue (Accessible *obj)
711 return (AccessibleValue *) Accessible_queryInterface (
712 obj, "IDL:Accessibility/Value:1.0");
718 * Accessible_queryInterface:
719 * @obj: a pointer to the #Accessible instance to query.
720 * @interface_name: a UTF-8 character string specifiying the requested interface.
722 * Query an #Accessible object to for a named interface.
724 * Returns: an instance of the named interface object, if it is implemented
725 * by @obj, or NULL otherwise.
729 Accessible_queryInterface (Accessible *obj,
730 const char *interface_name)
732 Bonobo_Unknown iface;
739 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
744 cspi_return_val_if_ev ("queryInterface", NULL);
747 * FIXME: we need to be fairly sure that references are going
748 * to mach up if we are going to expose QueryInterface, ie. we
749 * can't allow people to do:
750 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
751 * this should be no real problem though for this level of API
755 return cspi_object_add (iface);
760 * AccessibleRelation_ref:
761 * @obj: a pointer to the #AccessibleRelation object on which to operate.
763 * Increment the reference count for an #AccessibleRelation object.
767 AccessibleRelation_ref (AccessibleRelation *obj)
769 cspi_object_ref (obj);
773 * AccessibleRelation_unref:
774 * @obj: a pointer to the #AccessibleRelation object on which to operate.
776 * Decrement the reference count for an #AccessibleRelation object.
780 AccessibleRelation_unref (AccessibleRelation *obj)
782 cspi_object_unref (obj);
786 * AccessibleRelation_getRelationType:
787 * @obj: a pointer to the #AccessibleRelation object to query.
789 * Get the type of relationship represented by an #AccessibleRelation.
791 * Returns: an #AccessibleRelationType indicating the type of relation
792 * encapsulated in this #AccessibleRelation object.
795 AccessibleRelationType
796 AccessibleRelation_getRelationType (AccessibleRelation *obj)
798 cspi_return_val_if_fail (obj != NULL, -1);
803 * AccessibleRelation_getNTargets:
804 * @obj: a pointer to the #AccessibleRelation object to query.
806 * Get the number of objects which this relationship has as its
807 * target objects (the subject is the #Accessible from which this
808 * #AccessibleRelation originated).
810 * Returns: a short integer indicating how many target objects which the
811 * originating #Accessible object has the #AccessibleRelation
815 AccessibleRelation_getNTargets (AccessibleRelation *obj)
817 cspi_return_val_if_fail (obj != NULL, -1);
822 * AccessibleRelation_getTarget:
823 * @obj: a pointer to the #AccessibleRelation object to query.
824 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
826 * Get the @i-th target of a specified #AccessibleRelation relationship.
828 * Returns: an #Accessible which is the @i-th object with which the
829 * originating #Accessible has relationship specified in the
830 * #AccessibleRelation object.
834 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
836 cspi_return_val_if_fail (obj != NULL, NULL);
841 * AccessibleStateSet_ref:
842 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
844 * Increment the reference count for an #AccessibleStateSet object.
848 AccessibleStateSet_ref (AccessibleStateSet *obj)
850 cspi_object_ref (obj);
854 * AccessibleStateSet_unref:
855 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
857 * Decrement the reference count for an #AccessibleStateSet object.
861 AccessibleStateSet_unref (AccessibleStateSet *obj)
863 cspi_object_unref (obj);
867 * AccessibleStateSet_contains:
868 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
869 * @state: an #AccessibleState for which the specified #AccessibleStateSet
872 * Determine whether a given #AccessibleStateSet includes a given state; that is,
873 * whether @state is true for the stateset in question.
875 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
880 AccessibleStateSet_contains (AccessibleStateSet *obj,
881 AccessibleState state)
883 CORBA_boolean retval;
885 cspi_return_val_if_fail (obj != NULL, FALSE);
887 retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
890 cspi_return_val_if_ev ("contains", FALSE);
892 return (SPIBoolean) retval;
896 * AccessibleStateSet_add:
897 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
898 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
900 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
901 * given state to #TRUE in the stateset.
905 AccessibleStateSet_add (AccessibleStateSet *obj,
906 AccessibleState state)
908 cspi_return_if_fail (obj != NULL);
910 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
911 cspi_check_ev ("add");
915 * AccessibleStateSet_remove:
916 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
917 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
919 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
920 * given state to #FALSE in the stateset.)
924 AccessibleStateSet_remove (AccessibleStateSet *obj,
925 AccessibleState state)
927 cspi_return_if_fail (obj != NULL);
929 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
930 cspi_check_ev ("remove");
934 * AccessibleStateSet_equals:
935 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
936 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
938 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
939 * consist of the same #AccessibleStates). Useful for checking multiple
940 * state variables at once; construct the target state then compare against it.
942 * @see AccessibleStateSet_compare().
944 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
949 AccessibleStateSet_equals (AccessibleStateSet *obj,
950 AccessibleStateSet *obj2)
957 cspi_return_val_if_fail (obj != NULL, FALSE);
958 cspi_return_val_if_fail (obj2 != NULL, FALSE);
960 return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
961 CSPI_OBJREF (obj2), cspi_ev ());
965 * AccessibleStateSet_compare:
966 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
967 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
969 * Determine the differences between two instances of #AccessibleStateSet.
970 * Not Yet Implemented.
972 * @see AccessibleStateSet_equals().
974 * Returns: an #AccessibleStateSet object containing all states contained on one of
975 * the two sets but not the other.
979 AccessibleStateSet_compare (AccessibleStateSet *obj,
980 AccessibleStateSet *obj2)
982 cspi_return_val_if_fail (obj != NULL, NULL);
983 cspi_return_val_if_fail (obj2 != NULL, NULL);
988 * AccessibleStateSet_isEmpty:
989 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
991 * Determine whether a given #AccessibleStateSet is the empty set.
993 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
998 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1000 cspi_return_val_if_fail (obj != NULL, FALSE);
1002 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/