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.
85 * Currently broken, do not use.
87 * Returns: a localizable string name for an #AccessibleRole enumerated type.
90 AccessibleRole_getName (AccessibleRole role)
94 return g_strdup (role_names [(int) role]);
104 * @obj: a pointer to the #Accessible object on which to operate.
106 * Increment the reference count for an #Accessible object.
109 Accessible_ref (Accessible *obj)
111 cspi_object_ref (obj);
116 * @obj: a pointer to the #Accessible object on which to operate.
118 * Decrement the reference count for an #Accessible object.
121 Accessible_unref (Accessible *obj)
123 cspi_object_unref (obj);
127 * Accessible_getName:
128 * @obj: a pointer to the #Accessible object on which to operate.
130 * Get the name of an #Accessible object.
132 * Returns: a UTF-8 string indicating the name of the #Accessible object.
133 * or NULL on exception
136 Accessible_getName (Accessible *obj)
140 cspi_return_val_if_fail (obj != NULL, NULL);
143 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
145 cspi_return_val_if_ev ("getName", NULL);
151 * Accessible_getDescription:
152 * @obj: a pointer to the #Accessible object on which to operate.
154 * Get the description of an #Accessible object.
156 * Returns: a UTF-8 string describing the #Accessible object.
157 * or NULL on exception
160 Accessible_getDescription (Accessible *obj)
164 cspi_return_val_if_fail (obj != NULL, NULL);
167 Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
170 cspi_return_val_if_ev ("getDescription", NULL);
176 * Accessible_getParent:
177 * @obj: a pointer to the #Accessible object to query.
179 * Get an #Accessible object's parent container.
181 * Returns: a pointer tothe #Accessible object which contains the given
182 * #Accessible instance, or NULL if the @obj has no parent container.
186 Accessible_getParent (Accessible *obj)
190 cspi_return_val_if_fail (obj != NULL, NULL);
192 retval = cspi_object_add (
193 Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
196 cspi_return_val_if_ev ("getParent", NULL);
202 * Accessible_getChildCount:
203 * @obj: a pointer to the #Accessible object on which to operate.
205 * Get the number of children contained by an #Accessible object.
207 * Returns: a #long indicating the number of #Accessible children
208 * contained by an #Accessible object. or -1 on exception
212 Accessible_getChildCount (Accessible *obj)
216 cspi_return_val_if_fail (obj != NULL, -1);
219 Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
222 cspi_return_val_if_ev ("getChildCount", -1);
228 * Accessible_getChildAtIndex:
229 * @obj: a pointer to the #Accessible object on which to operate.
230 * @childIndex: a #long indicating which child is specified.
232 * Get the #Accessible child of an #Accessible object at a given index.
234 * Returns: a pointer to the #Accessible child object at index
235 * @childIndex. or NULL on exception
238 Accessible_getChildAtIndex (Accessible *obj,
243 cspi_return_val_if_fail (obj != NULL, NULL);
245 retval = cspi_object_add (
246 Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
247 childIndex, cspi_ev ()));
253 * Accessible_getIndexInParent:
254 * @obj: a pointer to the #Accessible object on which to operate.
256 * Get the index of an #Accessible object in its containing #Accessible.
258 * Returns: a #long indicating the index of the #Accessible object
259 * in its parent (i.e. containing) #Accessible instance,
260 * or -1 if @obj has no containing parent or on exception.
263 Accessible_getIndexInParent (Accessible *obj)
267 cspi_return_val_if_fail (obj != NULL, -1);
270 Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
272 cspi_return_val_if_ev ("getIndexInparent", -1);
277 * Accessible_getRelationSet:
278 * @obj: a pointer to the #Accessible object on which to operate.
280 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
281 * relationships with other #Accessible objects.
283 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
285 AccessibleRelation **
286 Accessible_getRelationSet (Accessible *obj)
290 AccessibleRelation **relations;
291 Accessibility_RelationSet *relation_set;
293 cspi_return_val_if_fail (obj != NULL, NULL);
296 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
298 cspi_return_val_if_ev ("getRelationSet", NULL);
300 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
301 n_relations = relation_set->_length;
302 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
304 for (i = 0; i < n_relations; ++i)
306 relations[i] = cspi_object_add (CORBA_Object_duplicate (
307 relation_set->_buffer[i], cspi_ev ()));
309 relations[i] = CORBA_OBJECT_NIL;
311 CORBA_free (relation_set);
317 * Accessible_getRole:
318 * @obj: a pointer to the #Accessible object on which to operate.
320 * Get the UI role of an #Accessible object.
321 * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
323 * Returns: the #AccessibleRole of the object.
327 Accessible_getRole (Accessible *obj)
329 AccessibleRole retval;
331 cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
334 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
336 cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID);
342 * Accessible_getRoleName:
343 * @obj: a pointer to the #Accessible object on which to operate.
345 * Get a UTF-8 string describing the role this object plays in the UI.
346 * This method will return useful values for roles that fall outside the
347 * enumeration used in Accessible_getRole ().
349 * Returns: a UTF-8 string specifying the role of this #Accessible object.
353 Accessible_getRoleName (Accessible *obj)
357 cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
360 Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
362 cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid"));
368 * Accessible_getStateSet:
369 * @obj: a pointer to the #Accessible object on which to operate.
371 * Not Yet Implemented.
373 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
376 Accessible_getStateSet (Accessible *obj)
381 /* Interface query methods */
384 * Accessible_isAction:
385 * @obj: a pointer to the #Accessible instance to query.
387 * Query whether the specified #Accessible implements #AccessibleAction.
389 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
393 Accessible_isAction (Accessible *obj)
395 return cspi_accessible_is_a (obj,
396 "IDL:Accessibility/Action:1.0");
400 * Accessible_isApplication:
401 * @obj: a pointer to the #Accessible instance to query.
403 * Query whether the specified #Accessible implements #AccessibleApplication.
405 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
409 Accessible_isApplication (Accessible *obj)
411 return cspi_accessible_is_a (obj,
412 "IDL:Accessibility/Application:1.0");
416 * Accessible_isComponent:
417 * @obj: a pointer to the #Accessible instance to query.
419 * Query whether the specified #Accessible implements #AccessibleComponent.
421 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
425 Accessible_isComponent (Accessible *obj)
427 return cspi_accessible_is_a (obj,
428 "IDL:Accessibility/Component:1.0");
432 * Accessible_isEditableText:
433 * @obj: a pointer to the #Accessible instance to query.
435 * Query whether the specified #Accessible implements #AccessibleEditableText.
437 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
441 Accessible_isEditableText (Accessible *obj)
443 return cspi_accessible_is_a (obj,
444 "IDL:Accessibility/EditableText:1.0");
448 * Accessible_isHypertext:
449 * @obj: a pointer to the #Accessible instance to query.
451 * Query whether the specified #Accessible implements #AccessibleHypertext.
453 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
457 Accessible_isHypertext (Accessible *obj)
459 return cspi_accessible_is_a (obj,
460 "IDL:Accessibility/Hypertext:1.0");
464 * Accessible_isImage:
465 * @obj: a pointer to the #Accessible instance to query.
467 * Query whether the specified #Accessible implements #AccessibleImage.
469 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
473 Accessible_isImage (Accessible *obj)
475 return cspi_accessible_is_a (obj,
476 "IDL:Accessibility/Image:1.0");
480 * Accessible_isSelection:
481 * @obj: a pointer to the #Accessible instance to query.
483 * Query whether the specified #Accessible implements #AccessibleSelection.
485 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
489 Accessible_isSelection (Accessible *obj)
491 return cspi_accessible_is_a (obj,
492 "IDL:Accessibility/Selection:1.0");
496 * Accessible_isTable:
497 * @obj: a pointer to the #Accessible instance to query.
499 * Query whether the specified #Accessible implements #AccessibleTable.
501 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
505 Accessible_isTable (Accessible *obj)
507 return cspi_accessible_is_a (obj,
508 "IDL:Accessibility/Table:1.0");
513 * @obj: a pointer to the #Accessible instance to query.
515 * Query whether the specified #Accessible implements #AccessibleText.
517 * Returns: #TRUE if @obj implements the #AccessibleText interface,
521 Accessible_isText (Accessible *obj)
523 return cspi_accessible_is_a (obj,
524 "IDL:Accessibility/Text:1.0");
528 * Accessible_isValue:
529 * @obj: a pointer to the #Accessible instance to query.
531 * Query whether the specified #Accessible implements #AccessibleValue.
533 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
537 Accessible_isValue (Accessible *obj)
539 return cspi_accessible_is_a (obj,
540 "IDL:Accessibility/Value:1.0");
544 * Accessible_getApplication:
545 * @obj: a pointer to the #Accessible instance to query.
547 * Get the #AccessibleApplication interface for an #Accessible.
549 * Returns: a pointer to an #AccessibleApplication interface instance, or
550 * NULL if @obj does not implement #AccessibleApplication.
552 AccessibleApplication *
553 Accessible_getApplication (Accessible *obj)
555 return (AccessibleApplication *) Accessible_queryInterface (
556 obj, "IDL:Accessibility/Application:1.0");
560 * Accessible_getAction:
561 * @obj: a pointer to the #Accessible instance to query.
563 * Get the #AccessibleAction interface for an #Accessible.
565 * Returns: a pointer to an #AccessibleAction interface instance, or
566 * NULL if @obj does not implement #AccessibleAction.
569 Accessible_getAction (Accessible *obj)
571 return (AccessibleAction *) Accessible_queryInterface (
572 obj, "IDL:Accessibility/Action:1.0");
576 * Accessible_getComponent:
577 * @obj: a pointer to the #Accessible instance to query.
579 * Get the #AccessibleComponent interface for an #Accessible.
581 * Returns: a pointer to an #AccessibleComponent interface instance, or
582 * NULL if @obj does not implement #AccessibleComponent.
584 AccessibleComponent *
585 Accessible_getComponent (Accessible *obj)
587 return (AccessibleComponent *) Accessible_queryInterface (
588 obj, "IDL:Accessibility/Component:1.0");
592 * Accessible_getEditableText:
593 * @obj: a pointer to the #Accessible instance to query.
595 * Get the #AccessibleEditableText interface for an #Accessible.
597 * Returns: a pointer to an #AccessibleEditableText interface instance, or
598 * NULL if @obj does not implement #AccessibleEditableText.
600 AccessibleEditableText *
601 Accessible_getEditableText (Accessible *obj)
603 return (AccessibleEditableText *) Accessible_queryInterface (
604 obj, "IDL:Accessibility/EditableText:1.0");
610 * Accessible_getHypertext:
611 * @obj: a pointer to the #Accessible instance to query.
613 * Get the #AccessibleHypertext interface for an #Accessible.
615 * Returns: a pointer to an #AccessibleHypertext interface instance, or
616 * NULL if @obj does not implement #AccessibleHypertext.
618 AccessibleHypertext *
619 Accessible_getHypertext (Accessible *obj)
621 return (AccessibleHypertext *) Accessible_queryInterface (
622 obj, "IDL:Accessibility/Hypertext:1.0");
628 * Accessible_getImage:
629 * @obj: a pointer to the #Accessible instance to query.
631 * Get the #AccessibleImage interface for an #Accessible.
633 * Returns: a pointer to an #AccessibleImage interface instance, or
634 * NULL if @obj does not implement #AccessibleImage.
637 Accessible_getImage (Accessible *obj)
639 return (AccessibleImage *) Accessible_queryInterface (
640 obj, "IDL:Accessibility/Image:1.0");
646 * Accessible_getSelection:
647 * @obj: a pointer to the #Accessible instance to query.
649 * Get the #AccessibleSelection interface for an #Accessible.
651 * Returns: a pointer to an #AccessibleSelection interface instance, or
652 * NULL if @obj does not implement #AccessibleSelection.
654 AccessibleSelection *
655 Accessible_getSelection (Accessible *obj)
657 return (AccessibleSelection *) Accessible_queryInterface (
658 obj, "IDL:Accessibility/Selection:1.0");
664 * Accessible_getTable:
665 * @obj: a pointer to the #Accessible instance to query.
667 * Get the #AccessibleTable interface for an #Accessible.
669 * Returns: a pointer to an #AccessibleTable interface instance, or
670 * NULL if @obj does not implement #AccessibleTable.
673 Accessible_getTable (Accessible *obj)
675 return (AccessibleTable *) Accessible_queryInterface (
676 obj, "IDL:Accessibility/Table:1.0");
680 * Accessible_getText:
681 * @obj: a pointer to the #Accessible instance to query.
683 * Get the #AccessibleText interface for an #Accessible.
685 * Returns: a pointer to an #AccessibleText interface instance, or
686 * NULL if @obj does not implement #AccessibleText.
689 Accessible_getText (Accessible *obj)
691 return (AccessibleText *) Accessible_queryInterface (
692 obj, "IDL:Accessibility/Text:1.0");
698 * Accessible_getValue:
699 * @obj: a pointer to the #Accessible instance to query.
701 * Get the #AccessibleValue interface for an #Accessible.
703 * Returns: a pointer to an #AccessibleValue interface instance, or
704 * NULL if @obj does not implement #AccessibleValue.
707 Accessible_getValue (Accessible *obj)
709 return (AccessibleValue *) Accessible_queryInterface (
710 obj, "IDL:Accessibility/Value:1.0");
716 * Accessible_queryInterface:
717 * @obj: a pointer to the #Accessible instance to query.
718 * @interface_name: a UTF-8 character string specifiying the requested interface.
720 * Query an #Accessible object to for a named interface.
722 * Returns: an instance of the named interface object, if it is implemented
723 * by @obj, or NULL otherwise.
727 Accessible_queryInterface (Accessible *obj,
728 const char *interface_name)
730 Bonobo_Unknown iface;
737 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
742 cspi_return_val_if_ev ("queryInterface", NULL);
745 * FIXME: we need to be fairly sure that references are going
746 * to mach up if we are going to expose QueryInterface, ie. we
747 * can't allow people to do:
748 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
749 * this should be no real problem though for this level of API
753 return cspi_object_add (iface);
758 * AccessibleRelation_ref:
759 * @obj: a pointer to the #AccessibleRelation object on which to operate.
761 * Increment the reference count for an #AccessibleRelation object.
765 AccessibleRelation_ref (AccessibleRelation *obj)
767 cspi_object_ref (obj);
771 * AccessibleRelation_unref:
772 * @obj: a pointer to the #AccessibleRelation object on which to operate.
774 * Decrement the reference count for an #AccessibleRelation object.
778 AccessibleRelation_unref (AccessibleRelation *obj)
780 cspi_object_unref (obj);
784 * AccessibleRelation_getRelationType:
785 * @obj: a pointer to the #AccessibleRelation object to query.
787 * Get the type of relationship represented by an #AccessibleRelation.
789 * Returns: an #AccessibleRelationType indicating the type of relation
790 * encapsulated in this #AccessibleRelation object.
793 AccessibleRelationType
794 AccessibleRelation_getRelationType (AccessibleRelation *obj)
796 cspi_return_val_if_fail (obj != NULL, -1);
801 * AccessibleRelation_getNTargets:
802 * @obj: a pointer to the #AccessibleRelation object to query.
804 * Get the number of objects which this relationship has as its
805 * target objects (the subject is the #Accessible from which this
806 * #AccessibleRelation originated).
808 * Returns: a short integer indicating how many target objects which the
809 * originating #Accessible object has the #AccessibleRelation
813 AccessibleRelation_getNTargets (AccessibleRelation *obj)
815 cspi_return_val_if_fail (obj != NULL, -1);
820 * AccessibleRelation_getTarget:
821 * @obj: a pointer to the #AccessibleRelation object to query.
822 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
824 * Get the @i-th target of a specified #AccessibleRelation relationship.
826 * Returns: an #Accessible which is the @i-th object with which the
827 * originating #Accessible has relationship specified in the
828 * #AccessibleRelation object.
832 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
834 cspi_return_val_if_fail (obj != NULL, NULL);
839 * AccessibleStateSet_ref:
840 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
842 * Increment the reference count for an #AccessibleStateSet object.
846 AccessibleStateSet_ref (AccessibleStateSet *obj)
848 cspi_object_ref (obj);
852 * AccessibleStateSet_unref:
853 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
855 * Decrement the reference count for an #AccessibleStateSet object.
859 AccessibleStateSet_unref (AccessibleStateSet *obj)
861 cspi_object_unref (obj);
865 * AccessibleStateSet_contains:
866 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
867 * @state: an #AccessibleState for which the specified #AccessibleStateSet
870 * Determine whether a given #AccessibleStateSet includes a given state; that is,
871 * whether @state is true for the stateset in question.
873 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
878 AccessibleStateSet_contains (AccessibleStateSet *obj,
879 AccessibleState state)
881 CORBA_boolean retval;
883 cspi_return_val_if_fail (obj != NULL, FALSE);
885 retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
888 cspi_return_val_if_ev ("contains", FALSE);
890 return (SPIBoolean) retval;
894 * AccessibleStateSet_add:
895 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
896 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
898 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
899 * given state to #TRUE in the stateset.
903 AccessibleStateSet_add (AccessibleStateSet *obj,
904 AccessibleState state)
906 cspi_return_if_fail (obj != NULL);
908 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
909 cspi_check_ev ("add");
913 * AccessibleStateSet_remove:
914 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
915 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
917 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
918 * given state to #FALSE in the stateset.)
922 AccessibleStateSet_remove (AccessibleStateSet *obj,
923 AccessibleState state)
925 cspi_return_if_fail (obj != NULL);
927 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
928 cspi_check_ev ("remove");
932 * AccessibleStateSet_equals:
933 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
934 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
936 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
937 * consist of the same #AccessibleStates). Useful for checking multiple
938 * state variables at once; construct the target state then compare against it.
940 * @see AccessibleStateSet_compare().
942 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
947 AccessibleStateSet_equals (AccessibleStateSet *obj,
948 AccessibleStateSet *obj2)
955 cspi_return_val_if_fail (obj != NULL, FALSE);
956 cspi_return_val_if_fail (obj2 != NULL, FALSE);
958 return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
959 CSPI_OBJREF (obj2), cspi_ev ());
963 * AccessibleStateSet_compare:
964 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
965 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
967 * Determine the differences between two instances of #AccessibleStateSet.
968 * Not Yet Implemented.
970 * @see AccessibleStateSet_equals().
972 * Returns: an #AccessibleStateSet object containing all states contained on one of
973 * the two sets but not the other.
977 AccessibleStateSet_compare (AccessibleStateSet *obj,
978 AccessibleStateSet *obj2)
980 cspi_return_val_if_fail (obj != NULL, NULL);
981 cspi_return_val_if_fail (obj2 != NULL, NULL);
986 * AccessibleStateSet_isEmpty:
987 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
989 * Determine whether a given #AccessibleStateSet is the empty set.
991 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
996 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
998 cspi_return_val_if_fail (obj != NULL, FALSE);
1000 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/