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)
89 * TODO: replace with implementation linked to ATK, which
90 * now supports Role/Name mapping
93 if (role < MAX_ROLES) return role_names [(int) role];
99 * @obj: a pointer to the #Accessible object on which to operate.
101 * Increment the reference count for an #Accessible object.
103 * Returns: (no return code implemented yet).
107 Accessible_ref (Accessible *obj)
109 cspi_object_ref (obj);
115 * @obj: a pointer to the #Accessible object on which to operate.
117 * Decrement the reference count for an #Accessible object.
119 * Returns: (no return code implemented yet).
123 Accessible_unref (Accessible *obj)
125 cspi_object_unref (obj);
130 * Accessible_getName:
131 * @obj: a pointer to the #Accessible object on which to operate.
133 * Get the name of an #Accessible object.
135 * Returns: a UTF-8 string indicating the name of the #Accessible object.
139 Accessible_getName (Accessible *obj)
143 Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
144 cspi_check_ev (cspi_ev (), "getName");
149 * Accessible_getDescription:
150 * @obj: a pointer to the #Accessible object on which to operate.
152 * Get the description of an #Accessible object.
154 * Returns: a UTF-8 string describing the #Accessible object.
158 Accessible_getDescription (Accessible *obj)
160 char *retval = (char *)
161 Accessibility_Accessible__get_description (CSPI_OBJREF (obj), cspi_ev ());
162 cspi_check_ev (cspi_ev (), "getDescription");
167 * Accessible_getParent:
168 * @obj: a pointer to the #Accessible object to query.
170 * Get an #Accessible object's parent container.
172 * Returns: a pointer tothe #Accessible object which contains the given
173 * #Accessible instance, or NULL if the @obj has no parent container.
177 Accessible_getParent (Accessible *obj)
180 cspi_object_add (Accessibility_Accessible__get_parent (CSPI_OBJREF (obj), cspi_ev ()));
181 cspi_check_ev (cspi_ev (), "getParent");
186 * Accessible_getChildCount:
187 * @obj: a pointer to the #Accessible object on which to operate.
189 * Get the number of children contained by an #Accessible object.
191 * Returns: a #long indicating the number of #Accessible children
192 * contained by an #Accessible object.
196 Accessible_getChildCount (Accessible *obj)
198 long retval = (long) Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj), cspi_ev ());
199 cspi_check_ev (cspi_ev (), "getChildCount");
204 * Accessible_getChildAtIndex:
205 * @obj: a pointer to the #Accessible object on which to operate.
206 * @childIndex: a #long indicating which child is specified.
208 * Get the #Accessible child of an #Accessible object at a given index.
210 * Returns: a pointer to the #Accessible child object at index
215 Accessible_getChildAtIndex (Accessible *obj,
218 Accessible *retval = cspi_object_add (Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj), childIndex, cspi_ev ()));
219 cspi_check_ev (cspi_ev (), "getChildAtIndex");
224 * Accessible_getIndexInParent:
225 * @obj: a pointer to the #Accessible object on which to operate.
227 * Get the index of an #Accessible object in its containing #Accessible.
229 * Returns: a #long indicating the index of the #Accessible object
230 * in its parent (i.e. containing) #Accessible instance,
231 * or -1 if @obj has no containing parent.
235 Accessible_getIndexInParent (Accessible *obj)
237 long retval = (long) Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
238 cspi_check_ev (cspi_ev (), "getIndexInParent");
243 * Accessible_getRelationSet:
244 * @obj: a pointer to the #Accessible object on which to operate.
246 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
247 * relationships with other #Accessible objects.
249 * Returns: an array of #AccessibleRelation pointers.
252 AccessibleRelation **
253 Accessible_getRelationSet (Accessible *obj)
255 AccessibleRelation **relations;
258 Accessibility_RelationSet *relation_set =
259 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
261 /* this looks hack-ish, but it's based on the CORBA C bindings spec */
262 n_relations = relation_set->_length;
263 relations = malloc (sizeof (AccessibleRelation *) * n_relations);
265 for (i=0; i<n_relations; ++i)
267 relations[i] = cspi_object_add (relation_set->_buffer[i]);
269 relations[i] = CORBA_OBJECT_NIL;
275 * Accessible_getRole:
276 * @obj: a pointer to the #Accessible object on which to operate.
278 * Get the UI role of an #Accessible object.
280 * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
284 Accessible_getRole (Accessible *obj)
286 char *retval = AccessibleRole_getName (
287 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
288 cspi_check_ev (cspi_ev (), "getRole");
293 * Accessible_getStateSet:
294 * @obj: a pointer to the #Accessible object on which to operate.
296 * Not Yet Implemented.
298 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
301 Accessible_getStateSet (Accessible *obj)
306 /* Interface query methods */
309 cspi_accessible_is_a (Accessible *obj,
310 const char *interface_name)
313 Bonobo_Unknown unknown;
315 unknown = Bonobo_Unknown_queryInterface (CSPI_OBJREF (obj),
316 interface_name, cspi_ev ());
318 if (BONOBO_EX (cspi_ev ()))
320 g_error ("Exception '%s' checking if is '%s'",
321 bonobo_exception_get_text (cspi_ev ()),
325 if (unknown != CORBA_OBJECT_NIL)
328 bonobo_object_release_unref (unknown, NULL);
339 * Accessible_isAction:
340 * @obj: a pointer to the #Accessible instance to query.
342 * Query whether the specified #Accessible implements #AccessibleAction.
344 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
348 Accessible_isAction (Accessible *obj)
350 return cspi_accessible_is_a (obj,
351 "IDL:Accessibility/Action:1.0");
355 * Accessible_isComponent:
356 * @obj: a pointer to the #Accessible instance to query.
358 * Query whether the specified #Accessible implements #AccessibleComponent.
360 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
364 Accessible_isComponent (Accessible *obj)
366 return cspi_accessible_is_a (obj,
367 "IDL:Accessibility/Component:1.0");
371 * Accessible_isEditableText:
372 * @obj: a pointer to the #Accessible instance to query.
374 * Query whether the specified #Accessible implements #AccessibleEditableText.
376 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
380 Accessible_isEditableText (Accessible *obj)
382 return cspi_accessible_is_a (obj,
383 "IDL:Accessibility/EditableText:1.0");
387 * Accessible_isHypertext:
388 * @obj: a pointer to the #Accessible instance to query.
390 * Query whether the specified #Accessible implements #AccessibleHypertext.
392 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
396 Accessible_isHypertext (Accessible *obj)
398 return cspi_accessible_is_a (obj,
399 "IDL:Accessibility/Hypertext:1.0");
403 * Accessible_isImage:
404 * @obj: a pointer to the #Accessible instance to query.
406 * Query whether the specified #Accessible implements #AccessibleImage.
408 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
412 Accessible_isImage (Accessible *obj)
414 return cspi_accessible_is_a (obj,
415 "IDL:Accessibility/Image:1.0");
419 * Accessible_isSelection:
420 * @obj: a pointer to the #Accessible instance to query.
422 * Query whether the specified #Accessible implements #AccessibleSelection.
424 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
428 Accessible_isSelection (Accessible *obj)
430 return cspi_accessible_is_a (obj,
431 "IDL:Accessibility/Selection:1.0");
435 * Accessible_isTable:
436 * @obj: a pointer to the #Accessible instance to query.
438 * Query whether the specified #Accessible implements #AccessibleTable.
440 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
444 Accessible_isTable (Accessible *obj)
446 return cspi_accessible_is_a (obj,
447 "IDL:Accessibility/Table:1.0");
452 * @obj: a pointer to the #Accessible instance to query.
454 * Query whether the specified #Accessible implements #AccessibleText.
456 * Returns: #TRUE if @obj implements the #AccessibleText interface,
460 Accessible_isText (Accessible *obj)
462 return cspi_accessible_is_a (obj,
463 "IDL:Accessibility/Text:1.0");
467 * Accessible_isValue:
468 * @obj: a pointer to the #Accessible instance to query.
470 * Query whether the specified #Accessible implements #AccessibleValue.
472 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
476 Accessible_isValue (Accessible *obj)
478 return cspi_accessible_is_a (obj,
479 "IDL:Accessibility/Value:1.0");
483 * Accessible_getAction:
484 * @obj: a pointer to the #Accessible instance to query.
486 * Get the #AccessibleAction interface for an #Accessible.
488 * Returns: a pointer to an #AccessibleAction interface instance, or
489 * NULL if @obj does not implement #AccessibleAction.
492 Accessible_getAction (Accessible *obj)
494 return (AccessibleAction *) Accessible_queryInterface (
495 obj, "IDL:Accessibility/Action:1.0");
499 * Accessible_getComponent:
500 * @obj: a pointer to the #Accessible instance to query.
502 * Get the #AccessibleComponent interface for an #Accessible.
504 * Returns: a pointer to an #AccessibleComponent interface instance, or
505 * NULL if @obj does not implement #AccessibleComponent.
507 AccessibleComponent *
508 Accessible_getComponent (Accessible *obj)
510 return (AccessibleComponent *) Accessible_queryInterface (
511 obj, "IDL:Accessibility/Component:1.0");
515 * Accessible_getEditableText:
516 * @obj: a pointer to the #Accessible instance to query.
518 * Get the #AccessibleEditableText interface for an #Accessible.
520 * Returns: a pointer to an #AccessibleEditableText interface instance, or
521 * NULL if @obj does not implement #AccessibleEditableText.
523 AccessibleEditableText *
524 Accessible_getEditableText (Accessible *obj)
526 return (AccessibleEditableText *) Accessible_queryInterface (
527 obj, "IDL:Accessibility/EditableText:1.0");
533 * Accessible_getHypertext:
534 * @obj: a pointer to the #Accessible instance to query.
536 * Get the #AccessibleHypertext interface for an #Accessible.
538 * Returns: a pointer to an #AccessibleHypertext interface instance, or
539 * NULL if @obj does not implement #AccessibleHypertext.
541 AccessibleHypertext *
542 Accessible_getHypertext (Accessible *obj)
544 return (AccessibleHypertext *) Accessible_queryInterface (
545 obj, "IDL:Accessibility/Hypertext:1.0");
551 * Accessible_getImage:
552 * @obj: a pointer to the #Accessible instance to query.
554 * Get the #AccessibleImage interface for an #Accessible.
556 * Returns: a pointer to an #AccessibleImage interface instance, or
557 * NULL if @obj does not implement #AccessibleImage.
560 Accessible_getImage (Accessible *obj)
562 return (AccessibleImage *) Accessible_queryInterface (
563 obj, "IDL:Accessibility/Image:1.0");
569 * Accessible_getSelection:
570 * @obj: a pointer to the #Accessible instance to query.
572 * Get the #AccessibleSelection interface for an #Accessible.
574 * Returns: a pointer to an #AccessibleSelection interface instance, or
575 * NULL if @obj does not implement #AccessibleSelection.
577 AccessibleSelection *
578 Accessible_getSelection (Accessible *obj)
580 return (AccessibleSelection *) Accessible_queryInterface (
581 obj, "IDL:Accessibility/Selection:1.0");
587 * Accessible_getTable:
588 * @obj: a pointer to the #Accessible instance to query.
590 * Get the #AccessibleTable interface for an #Accessible.
592 * Returns: a pointer to an #AccessibleTable interface instance, or
593 * NULL if @obj does not implement #AccessibleTable.
596 Accessible_getTable (Accessible *obj)
598 return (AccessibleTable *) Accessible_queryInterface (
599 obj, "IDL:Accessibility/Table:1.0");
603 * Accessible_getText:
604 * @obj: a pointer to the #Accessible instance to query.
606 * Get the #AccessibleText interface for an #Accessible.
608 * Returns: a pointer to an #AccessibleText interface instance, or
609 * NULL if @obj does not implement #AccessibleText.
612 Accessible_getText (Accessible *obj)
614 return (AccessibleText *) Accessible_queryInterface (
615 obj, "IDL:Accessibility/Text:1.0");
621 * Accessible_getValue:
622 * @obj: a pointer to the #Accessible instance to query.
624 * Get the #AccessibleValue interface for an #Accessible.
626 * Returns: a pointer to an #AccessibleValue interface instance, or
627 * NULL if @obj does not implement #AccessibleValue.
630 Accessible_getValue (Accessible *obj)
632 return (AccessibleValue *) Accessible_queryInterface (
633 obj, "IDL:Accessibility/Value:1.0");
639 * Accessible_queryInterface:
640 * @obj: a pointer to the #Accessible instance to query.
641 * @interface_name: a UTF-8 character string specifiying the requested interface.
643 * Query an #Accessible object to for a named interface.
645 * Returns: an instance of the named interface object, if it is implemented
646 * by @obj, or NULL otherwise.
650 Accessible_queryInterface (Accessible *obj, char *interface_name)
652 Bonobo_Unknown iface;
654 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
659 * FIXME: we need to be fairly sure that references are going
660 * to mach up if we are going to expose QueryInterface, ie. we
661 * can't allow people to do:
662 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
663 * this should be no real problem though for this level of API
667 return cspi_object_add (iface);
672 * AccessibleRelation_ref:
673 * @obj: a pointer to the #AccessibleRelation object on which to operate.
675 * Increment the reference count for an #AccessibleRelation object.
677 * Returns: (no return code implemented yet).
681 AccessibleRelation_ref (AccessibleRelation *obj)
683 cspi_object_ref (obj);
688 * AccessibleRelation_unref:
689 * @obj: a pointer to the #AccessibleRelation object on which to operate.
691 * Decrement the reference count for an #AccessibleRelation object.
693 * Returns: (no return code implemented yet).
697 AccessibleRelation_unref (AccessibleRelation *obj)
699 cspi_object_unref (obj);
704 * AccessibleRelation_getRelationType:
705 * @obj: a pointer to the #AccessibleRelation object to query.
707 * Get the type of relationship represented by an #AccessibleRelation.
709 * Returns: an #AccessibleRelationType indicating the type of relation
710 * encapsulated in this #AccessibleRelation object.
713 AccessibleRelationType
714 AccessibleRelation_getRelationType (AccessibleRelation *obj)
720 * AccessibleRelation_getNTargets:
721 * @obj: a pointer to the #AccessibleRelation object to query.
723 * Get the number of objects which this relationship has as its
724 * target objects (the subject is the #Accessible from which this
725 * #AccessibleRelation originated).
727 * Returns: a short integer indicating how many target objects which the
728 * originating #Accessible object has the #AccessibleRelation
732 AccessibleRelation_getNTargets (AccessibleRelation *obj)
738 * AccessibleRelation_getTarget:
739 * @obj: a pointer to the #AccessibleRelation object to query.
740 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
742 * Get the @i-th target of a specified #AccessibleRelation relationship.
744 * Returns: an #Accessible which is the @i-th object with which the
745 * originating #Accessible has relationship specified in the
746 * #AccessibleRelation object.
750 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
756 * AccessibleStateSet_ref:
757 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
759 * Increment the reference count for an #AccessibleStateSet object.
761 * Returns: (no return code implemented yet).
765 AccessibleStateSet_ref (AccessibleStateSet *obj)
767 cspi_object_ref (obj);
772 * AccessibleStateSet_unref:
773 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
775 * Decrement the reference count for an #AccessibleStateSet object.
777 * Returns: (no return code implemented yet).
781 AccessibleStateSet_unref (AccessibleStateSet *obj)
783 cspi_object_unref (obj);
789 * AccessibleStateSet_contains:
790 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
791 * @state: an #AccessibleState for which the specified #AccessibleStateSet
794 * Determine whether a given #AccessibleStateSet includes a given state; that is,
795 * whether @state is true for the stateset in question.
797 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
802 AccessibleStateSet_contains (AccessibleStateSet *obj,
803 AccessibleState state)
805 CORBA_boolean retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj), state, cspi_ev ());
806 cspi_check_ev (cspi_ev (), "contains");
807 return (SPIBoolean) retval;
811 * AccessibleStateSet_add:
812 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
813 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
815 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
816 * given state to #TRUE in the stateset.
820 AccessibleStateSet_add (AccessibleStateSet *obj,
821 AccessibleState state)
823 Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
824 cspi_check_ev (cspi_ev (), "contains");
829 * AccessibleStateSet_remove:
830 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
831 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
833 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
834 * given state to #FALSE in the stateset.)
838 AccessibleStateSet_remove (AccessibleStateSet *obj,
839 AccessibleState state)
841 Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
842 cspi_check_ev (cspi_ev (), "contains");
846 * AccessibleStateSet_equals:
847 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
848 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
850 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
851 * consist of the same #AccessibleStates). Useful for checking multiple
852 * state variables at once; construct the target state then compare against it.
854 * @see AccessibleStateSet_compare().
856 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
861 AccessibleStateSet_equals (AccessibleStateSet *obj,
862 AccessibleStateSet *obj2)
864 return Accessibility_StateSet_equals (CSPI_OBJREF (obj), CSPI_OBJREF (obj2), cspi_ev ());
868 * AccessibleStateSet_compare:
869 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
870 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
871 * @differenceSet: a pointer to an array of #AccessibleStates, which is set when the
872 * fuction returns to point to an array of states representing the states which
873 * the two state sets do not have in common.
875 * Determine the differences between two instances of #AccessibleStateSet.
877 * @see AccessibleStateSet_equals().
879 * Returns: an #AccessibleStateSet object containing all states contained on one of
880 * the two sets but not the other.
884 AccessibleStateSet_compare (AccessibleStateSet *obj,
885 AccessibleStateSet *obj2,
886 AccessibleStateSet **differenceSet);
890 * AccessibleStateSet_isEmpty:
891 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
893 * Determine whether a given #AccessibleStateSet is the empty set.
895 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
900 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
903 /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/