1 #include <stdlib.h> /* for malloc */
2 #include <cspi/spi-private.h>
6 static char *role_names [MAX_ROLES] =
64 "table column header",
78 * AccessibleRole_getName:
79 * @role: an #AccessibleRole object to query.
81 * Get a localizeable string that indicates the name of an #AccessibleRole.
83 * Returns: a localizable string name for an #AccessibleRole enumerated type.
86 AccessibleRole_getName (AccessibleRole role)
88 if (role < MAX_ROLES) return role_names [(int) role];
96 * @obj: a pointer to the #Accessible object on which to operate.
98 * Increment the reference count for an #Accessible object.
100 * Returns: (no return code implemented yet).
104 Accessible_ref (Accessible *obj)
106 cspi_object_ref (obj);
113 * @obj: a pointer to the #Accessible object on which to operate.
115 * Decrement the reference count for an #Accessible object.
117 * Returns: (no return code implemented yet).
121 Accessible_unref (Accessible *obj)
123 cspi_object_unref (obj);
128 * Accessible_getName:
129 * @obj: a pointer to the #Accessible object on which to operate.
131 * Get the name of an #Accessible object.
133 * Returns: a UTF-8 string indicating the name of the #Accessible object.
137 Accessible_getName (Accessible *obj)
141 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
142 cspi_check_ev (cspi_ev (), "getName");
147 * Accessible_getDescription:
148 * @obj: a pointer to the #Accessible object on which to operate.
150 * Get the description of an #Accessible object.
152 * Returns: a UTF-8 string describing the #Accessible object.
156 Accessible_getDescription (Accessible *obj)
158 char *retval = (char *)
159 Accessibility_Accessible__get_description (CSPI_OBJREF (obj), cspi_ev ());
160 cspi_check_ev (cspi_ev (), "getDescription");
165 * Accessible_getParent:
166 * @obj: a pointer to the #Accessible object to query.
168 * Get an #Accessible object's parent container.
170 * Returns: a pointer tothe #Accessible object which contains the given
171 * #Accessible instance, or NULL if the @obj has no parent container.
175 Accessible_getParent (Accessible *obj)
178 cspi_object_add (Accessibility_Accessible__get_parent (CSPI_OBJREF (obj), cspi_ev ()));
179 cspi_check_ev (cspi_ev (), "getParent");
184 * Accessible_getChildCount:
185 * @obj: a pointer to the #Accessible object on which to operate.
187 * Get the number of children contained by an #Accessible object.
189 * Returns: a #long indicating the number of #Accessible children
190 * contained by an #Accessible object.
194 Accessible_getChildCount (Accessible *obj)
196 long retval = (long) Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj), cspi_ev ());
197 cspi_check_ev (cspi_ev (), "getChildCount");
202 * Accessible_getChildAtIndex:
203 * @obj: a pointer to the #Accessible object on which to operate.
204 * @childIndex: a #long indicating which child is specified.
206 * Get the #Accessible child of an #Accessible object at a given index.
208 * Returns: a pointer to the #Accessible child object at index
213 Accessible_getChildAtIndex (Accessible *obj,
216 Accessible *retval = cspi_object_add (Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj), childIndex, cspi_ev ()));
217 cspi_check_ev (cspi_ev (), "getChildAtIndex");
222 * Accessible_getIndexInParent:
223 * @obj: a pointer to the #Accessible object on which to operate.
225 * Get the index of an #Accessible object in its containing #Accessible.
227 * Returns: a #long indicating the index of the #Accessible object
228 * in its parent (i.e. containing) #Accessible instance,
229 * or -1 if @obj has no containing parent.
233 Accessible_getIndexInParent (Accessible *obj)
235 long retval = (long) Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
236 cspi_check_ev (cspi_ev (), "getIndexInParent");
241 * Accessible_getRelationSet:
242 * @obj: a pointer to the #Accessible object on which to operate.
244 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
245 * relationships with other #Accessible objects.
247 * Returns: an array of #AccessibleRelation pointers.
250 AccessibleRelation **
251 Accessible_getRelationSet (Accessible *obj)
253 AccessibleRelation **relations;
256 Accessibility_RelationSet *relation_set =
257 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
259 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
260 n_relations = relation_set->_length;
261 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
263 for (i=0; i<n_relations; ++i)
265 relations[i] = cspi_object_add (relation_set->_buffer[i]);
267 relations[i] = CORBA_OBJECT_NIL;
273 * Accessible_getRole:
274 * @obj: a pointer to the #Accessible object on which to operate.
276 * Get the UI role of an #Accessible object.
278 * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
282 Accessible_getRole (Accessible *obj)
284 char *retval = AccessibleRole_getName (
285 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
286 cspi_check_ev (cspi_ev (), "getRole");
291 * Accessible_getStateSet:
292 * @obj: a pointer to the #Accessible object on which to operate.
294 * Not Yet Implemented.
296 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
299 Accessible_getStateSet (Accessible *obj)
304 /* Interface query methods */
307 cspi_accessible_is_a (Accessible *obj,
308 const char *interface_name)
311 Bonobo_Unknown unknown;
313 unknown = Bonobo_Unknown_queryInterface (CSPI_OBJREF (obj),
314 interface_name, cspi_ev ());
316 if (BONOBO_EX (cspi_ev ()))
318 g_error ("Exception '%s' checking if is '%s'",
319 bonobo_exception_get_text (cspi_ev ()),
323 if (unknown != CORBA_OBJECT_NIL)
326 bonobo_object_release_unref (unknown, NULL);
337 * Accessible_isAction:
338 * @obj: a pointer to the #Accessible instance to query.
340 * Query whether the specified #Accessible implements #AccessibleAction.
342 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
346 Accessible_isAction (Accessible *obj)
348 return cspi_accessible_is_a (obj,
349 "IDL:Accessibility/Action:1.0");
353 * Accessible_isComponent:
354 * @obj: a pointer to the #Accessible instance to query.
356 * Query whether the specified #Accessible implements #AccessibleComponent.
358 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
362 Accessible_isComponent (Accessible *obj)
364 return cspi_accessible_is_a (obj,
365 "IDL:Accessibility/Component:1.0");
369 * Accessible_isEditableText:
370 * @obj: a pointer to the #Accessible instance to query.
372 * Query whether the specified #Accessible implements #AccessibleEditableText.
374 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
378 Accessible_isEditableText (Accessible *obj)
380 return cspi_accessible_is_a (obj,
381 "IDL:Accessibility/EditableText:1.0");
385 * Accessible_isHypertext:
386 * @obj: a pointer to the #Accessible instance to query.
388 * Query whether the specified #Accessible implements #AccessibleHypertext.
390 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
394 Accessible_isHypertext (Accessible *obj)
396 return cspi_accessible_is_a (obj,
397 "IDL:Accessibility/Hypertext:1.0");
401 * Accessible_isImage:
402 * @obj: a pointer to the #Accessible instance to query.
404 * Query whether the specified #Accessible implements #AccessibleImage.
406 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
410 Accessible_isImage (Accessible *obj)
412 return cspi_accessible_is_a (obj,
413 "IDL:Accessibility/Image:1.0");
417 * Accessible_isSelection:
418 * @obj: a pointer to the #Accessible instance to query.
420 * Query whether the specified #Accessible implements #AccessibleSelection.
422 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
426 Accessible_isSelection (Accessible *obj)
428 return cspi_accessible_is_a (obj,
429 "IDL:Accessibility/Selection:1.0");
433 * Accessible_isTable:
434 * @obj: a pointer to the #Accessible instance to query.
436 * Query whether the specified #Accessible implements #AccessibleTable.
438 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
442 Accessible_isTable (Accessible *obj)
444 return cspi_accessible_is_a (obj,
445 "IDL:Accessibility/Table:1.0");
450 * @obj: a pointer to the #Accessible instance to query.
452 * Query whether the specified #Accessible implements #AccessibleText.
454 * Returns: #TRUE if @obj implements the #AccessibleText interface,
458 Accessible_isText (Accessible *obj)
460 return cspi_accessible_is_a (obj,
461 "IDL:Accessibility/Text:1.0");
465 * Accessible_isValue:
466 * @obj: a pointer to the #Accessible instance to query.
468 * Query whether the specified #Accessible implements #AccessibleValue.
470 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
474 Accessible_isValue (Accessible *obj)
476 return cspi_accessible_is_a (obj,
477 "IDL:Accessibility/Value:1.0");
481 * Accessible_getAction:
482 * @obj: a pointer to the #Accessible instance to query.
484 * Get the #AccessibleAction interface for an #Accessible.
486 * Returns: a pointer to an #AccessibleAction interface instance, or
487 * NULL if @obj does not implement #AccessibleAction.
490 Accessible_getAction (Accessible *obj)
492 return (AccessibleAction *) Accessible_queryInterface (
493 obj, "IDL:Accessibility/Action:1.0");
497 * Accessible_getComponent:
498 * @obj: a pointer to the #Accessible instance to query.
500 * Get the #AccessibleComponent interface for an #Accessible.
502 * Returns: a pointer to an #AccessibleComponent interface instance, or
503 * NULL if @obj does not implement #AccessibleComponent.
505 AccessibleComponent *
506 Accessible_getComponent (Accessible *obj)
508 return (AccessibleComponent *) Accessible_queryInterface (
509 obj, "IDL:Accessibility/Component:1.0");
513 * Accessible_getEditableText:
514 * @obj: a pointer to the #Accessible instance to query.
516 * Get the #AccessibleEditableText interface for an #Accessible.
518 * Returns: a pointer to an #AccessibleEditableText interface instance, or
519 * NULL if @obj does not implement #AccessibleEditableText.
521 AccessibleEditableText *
522 Accessible_getEditableText (Accessible *obj)
524 return (AccessibleEditableText *) Accessible_queryInterface (
525 obj, "IDL:Accessibility/EditableText:1.0");
531 * Accessible_getHypertext:
532 * @obj: a pointer to the #Accessible instance to query.
534 * Get the #AccessibleHypertext interface for an #Accessible.
536 * Returns: a pointer to an #AccessibleHypertext interface instance, or
537 * NULL if @obj does not implement #AccessibleHypertext.
539 AccessibleHypertext *
540 Accessible_getHypertext (Accessible *obj)
542 return (AccessibleHypertext *) Accessible_queryInterface (
543 obj, "IDL:Accessibility/Hypertext:1.0");
549 * Accessible_getImage:
550 * @obj: a pointer to the #Accessible instance to query.
552 * Get the #AccessibleImage interface for an #Accessible.
554 * Returns: a pointer to an #AccessibleImage interface instance, or
555 * NULL if @obj does not implement #AccessibleImage.
558 Accessible_getImage (Accessible *obj)
560 return (AccessibleImage *) Accessible_queryInterface (
561 obj, "IDL:Accessibility/Image:1.0");
567 * Accessible_getSelection:
568 * @obj: a pointer to the #Accessible instance to query.
570 * Get the #AccessibleSelection interface for an #Accessible.
572 * Returns: a pointer to an #AccessibleSelection interface instance, or
573 * NULL if @obj does not implement #AccessibleSelection.
575 AccessibleSelection *
576 Accessible_getSelection (Accessible *obj)
578 return (AccessibleSelection *) Accessible_queryInterface (
579 obj, "IDL:Accessibility/Selection:1.0");
585 * Accessible_getTable:
586 * @obj: a pointer to the #Accessible instance to query.
588 * Get the #AccessibleTable interface for an #Accessible.
590 * Returns: a pointer to an #AccessibleTable interface instance, or
591 * NULL if @obj does not implement #AccessibleTable.
594 Accessible_getTable (Accessible *obj)
596 return (AccessibleTable *) Accessible_queryInterface (
597 obj, "IDL:Accessibility/Table:1.0");
601 * Accessible_getText:
602 * @obj: a pointer to the #Accessible instance to query.
604 * Get the #AccessibleText interface for an #Accessible.
606 * Returns: a pointer to an #AccessibleText interface instance, or
607 * NULL if @obj does not implement #AccessibleText.
610 Accessible_getText (Accessible *obj)
612 return (AccessibleText *) Accessible_queryInterface (
613 obj, "IDL:Accessibility/Text:1.0");
619 * Accessible_getValue:
620 * @obj: a pointer to the #Accessible instance to query.
622 * Get the #AccessibleValue interface for an #Accessible.
624 * Returns: a pointer to an #AccessibleValue interface instance, or
625 * NULL if @obj does not implement #AccessibleValue.
628 Accessible_getValue (Accessible *obj)
630 return (AccessibleValue *) Accessible_queryInterface (
631 obj, "IDL:Accessibility/Value:1.0");
637 * Accessible_queryInterface:
638 * @obj: a pointer to the #Accessible instance to query.
639 * @interface_name: a UTF-8 character string specifiying the requested interface.
641 * Query an #Accessible object to for a named interface.
643 * Returns: an instance of the named interface object, if it is implemented
644 * by @obj, or NULL otherwise.
648 Accessible_queryInterface (Accessible *obj, char *interface_name)
650 Bonobo_Unknown iface;
652 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
657 * FIXME: we need to be fairly sure that references are going
658 * to mach up if we are going to expose QueryInterface, ie. we
659 * can't allow people to do:
660 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
661 * this should be no real problem though for this level of API
665 return cspi_object_add (iface);
670 * AccessibleRelation_ref:
671 * @obj: a pointer to the #AccessibleRelation object on which to operate.
673 * Increment the reference count for an #AccessibleRelation object.
675 * Returns: (no return code implemented yet).
679 AccessibleRelation_ref (AccessibleRelation *obj)
681 cspi_object_ref (obj);
686 * AccessibleRelation_unref:
687 * @obj: a pointer to the #AccessibleRelation object on which to operate.
689 * Decrement the reference count for an #AccessibleRelation object.
691 * Returns: (no return code implemented yet).
695 AccessibleRelation_unref (AccessibleRelation *obj)
697 cspi_object_unref (obj);
702 * AccessibleRelation_getRelationType:
703 * @obj: a pointer to the #AccessibleRelation object to query.
705 * Get the type of relationship represented by an #AccessibleRelation.
707 * Returns: an #AccessibleRelationType indicating the type of relation
708 * encapsulated in this #AccessibleRelation object.
711 AccessibleRelationType
712 AccessibleRelation_getRelationType (AccessibleRelation *obj)
718 * AccessibleRelation_getNTargets:
719 * @obj: a pointer to the #AccessibleRelation object to query.
721 * Get the number of objects which this relationship has as its
722 * target objects (the subject is the #Accessible from which this
723 * #AccessibleRelation originated).
725 * Returns: a short integer indicating how many target objects which the
726 * originating #Accessible object has the #AccessibleRelation
730 AccessibleRelation_getNTargets (AccessibleRelation *obj)
736 * AccessibleRelation_getTarget:
737 * @obj: a pointer to the #AccessibleRelation object to query.
738 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
740 * Get the @i-th target of a specified #AccessibleRelation relationship.
742 * Returns: an #Accessible which is the @i-th object with which the
743 * originating #Accessible has relationship specified in the
744 * #AccessibleRelation object.
748 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
754 * AccessibleStateSet_ref:
755 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
757 * Increment the reference count for an #AccessibleStateSet object.
759 * Returns: (no return code implemented yet).
763 AccessibleStateSet_ref (AccessibleStateSet *obj)
765 cspi_object_ref (obj);
770 * AccessibleStateSet_unref:
771 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
773 * Decrement the reference count for an #AccessibleStateSet object.
775 * Returns: (no return code implemented yet).
779 AccessibleStateSet_unref (AccessibleStateSet *obj)
781 cspi_object_unref (obj);
787 * AccessibleStateSet_contains:
788 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
789 * @state: an #AccessibleState for which the specified #AccessibleStateSet
792 * Determine whether a given #AccessibleStateSet includes a given state; that is,
793 * whether @state is true for the stateset in question.
795 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
800 AccessibleStateSet_contains (AccessibleStateSet *obj,
801 AccessibleState state)
803 CORBA_boolean retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj), state, cspi_ev ());
804 cspi_check_ev (cspi_ev (), "contains");
805 return (boolean) retval;
809 * AccessibleStateSet_add:
810 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
811 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
813 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
814 * given state to #TRUE in the stateset.
818 AccessibleStateSet_add (AccessibleStateSet *obj,
819 AccessibleState state)
821 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
822 cspi_check_ev (cspi_ev (), "contains");
827 * AccessibleStateSet_remove:
828 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
829 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
831 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
832 * given state to #FALSE in the stateset.)
836 AccessibleStateSet_remove (AccessibleStateSet *obj,
837 AccessibleState state)
839 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
840 cspi_check_ev (cspi_ev (), "contains");
844 * AccessibleStateSet_equals:
845 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
846 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
848 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
849 * consist of the same #AccessibleStates). Useful for checking multiple
850 * state variables at once; construct the target state then compare against it.
852 * @see AccessibleStateSet_compare().
854 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
859 AccessibleStateSet_equals (AccessibleStateSet *obj,
860 AccessibleStateSet *obj2)
862 return Accessibility_StateSet_equals (CSPI_OBJREF (obj), CSPI_OBJREF (obj2), cspi_ev ());
866 * AccessibleStateSet_compare:
867 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
868 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
869 * @differenceSet: a pointer to an array of #AccessibleStates, which is set when the
870 * fuction returns to point to an array of states representing the states which
871 * the two state sets do not have in common.
873 * Determine the differences between two instances of #AccessibleStateSet.
875 * @see AccessibleStateSet_equals().
877 * Returns: an #AccessibleStateSet object containing all states contained on one of
878 * the two sets but not the other.
882 AccessibleStateSet_compare (AccessibleStateSet *obj,
883 AccessibleStateSet *obj2,
884 AccessibleStateSet **differenceSet);
888 * AccessibleStateSet_isEmpty:
889 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
891 * Determine whether a given #AccessibleStateSet is the empty set.
893 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
898 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
901 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/