updated
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_selection.c
index dd663ee..5268ff4 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
 #include <cspi/spi-private.h>
 
 /**
  *
  * Increment the reference count for an #AccessibleSelection object.
  *
- * Returns: (no return code implemented yet).
- *
  **/
-int
+void
 AccessibleSelection_ref (AccessibleSelection *obj)
 {
   cspi_object_ref (obj);
-  return 0;
 }
 
-
 /**
  * AccessibleSelection_unref:
  * @obj: a pointer to the #AccessibleSelection implementor on which to operate. 
  *
  * Decrement the reference count for an #Accessible object.
  *
- * Returns: (no return code implemented yet).
- *
  **/
-int
+void
 AccessibleSelection_unref (AccessibleSelection *obj)
 {
   cspi_object_unref (obj);
-  return 0;
 }
 
-
-
 /**
  * AccessibleSelection_getNSelectedChildren:
  * @obj: a pointer to the #AccessibleSelection implementor on which to operate.
@@ -49,10 +63,18 @@ AccessibleSelection_unref (AccessibleSelection *obj)
 long
 AccessibleSelection_getNSelectedChildren (AccessibleSelection *obj)
 {
-  return (long)
-    Accessibility_Selection__get_nSelectedChildren (CSPI_OBJREF (obj), cspi_ev ());
-}
+  long retval;
+
+  cspi_return_val_if_fail (obj != NULL, -1);
 
+  retval =
+    Accessibility_Selection__get_nSelectedChildren (CSPI_OBJREF (obj),
+                                                   cspi_ev ());
+
+  cspi_return_val_if_ev ("getNSelectedChildren", -1);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_getSelectedChild:
@@ -75,12 +97,15 @@ Accessible *
 AccessibleSelection_getSelectedChild (AccessibleSelection *obj,
                                       long int selectedChildIndex)
 {
-  Accessibility_Accessible child = 
-    Accessibility_Selection_getSelectedChild (CSPI_OBJREF (obj),
-                                             (CORBA_long) selectedChildIndex, cspi_ev ());
-  cspi_warn_ev (cspi_ev (), "getSelectedChild");
+  Accessibility_Accessible child;
 
-  return (Accessible *) cspi_object_add (child);
+  cspi_return_val_if_fail (obj != NULL, NULL);
+  
+  child = Accessibility_Selection_getSelectedChild (
+    CSPI_OBJREF (obj),
+    selectedChildIndex, cspi_ev ());
+
+  return  cspi_object_add (child);
 }
 
 /**
@@ -95,17 +120,23 @@ AccessibleSelection_getSelectedChild (AccessibleSelection *obj,
  *         selection.
  *
  * Returns: #TRUE if the child was successfully selected, #FALSE otherwise.
- *
  **/
 SPIBoolean
 AccessibleSelection_selectChild (AccessibleSelection *obj,
                                  long int childIndex)
 {
-  return (SPIBoolean)
+  SPIBoolean retval;
+
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  retval =
     Accessibility_Selection_selectChild (CSPI_OBJREF (obj),
-                                        (CORBA_long) childIndex, cspi_ev ());
-}
+                                        childIndex, cspi_ev ());
 
+  cspi_return_val_if_ev ("selectChild", FALSE);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_deselectSelectedChild:
@@ -120,17 +151,22 @@ AccessibleSelection_selectChild (AccessibleSelection *obj,
  *          are asymmettric.
  *
  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
- *
  **/
 SPIBoolean
 AccessibleSelection_deselectSelectedChild (AccessibleSelection *obj,
                                            long int selectedChildIndex)
 {
-  return Accessibility_Selection_deselectSelectedChild (
-         CSPI_OBJREF (obj), (CORBA_long) selectedChildIndex, cspi_ev ());
-}
+  SPIBoolean retval;
+
+  cspi_return_val_if_fail (obj != NULL, FALSE);
 
+  retval = Accessibility_Selection_deselectSelectedChild (
+    CSPI_OBJREF (obj), selectedChildIndex, cspi_ev ());
 
+  cspi_return_val_if_ev ("deselectSelectedChild", FALSE);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_isChildSelected:
@@ -143,18 +179,23 @@ AccessibleSelection_deselectSelectedChild (AccessibleSelection *obj,
  *
  * Returns: #TRUE if the specified child is currently selected,
  *          #FALSE otherwise.
- *
  **/
 SPIBoolean
 AccessibleSelection_isChildSelected (AccessibleSelection *obj,
                                      long int childIndex)
 {
-  return (SPIBoolean)
-    Accessibility_Selection_isChildSelected (CSPI_OBJREF (obj),
-                                            (CORBA_long) childIndex, cspi_ev ());
-}
+  SPIBoolean retval;
 
+  cspi_return_val_if_fail (obj != NULL, FALSE);
 
+  retval = Accessibility_Selection_isChildSelected (
+    CSPI_OBJREF (obj),
+    childIndex, cspi_ev ());
+
+  cspi_return_val_if_ev ("isChildSelected", FALSE);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_selectAll:
@@ -169,11 +210,16 @@ AccessibleSelection_isChildSelected (AccessibleSelection *obj,
 SPIBoolean
 AccessibleSelection_selectAll (AccessibleSelection *obj)
 {
-  Accessibility_Selection_selectAll (CSPI_OBJREF (obj), cspi_ev ());
-  return TRUE; /* TODO: change the bonobo method to return boolean */
-}
+  SPIBoolean retval;
+  
+  cspi_return_val_if_fail (obj != NULL, FALSE);
 
+  retval = Accessibility_Selection_selectAll (CSPI_OBJREF (obj), cspi_ev ());
 
+  cspi_return_val_if_ev ("selectAll", FALSE);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_clearSelection:
@@ -182,11 +228,20 @@ AccessibleSelection_selectAll (AccessibleSelection *obj)
  * Clear the current selection, removing all selected children from the
  *       specified #AccessibleSelection implementor's selection list.
  *
+ * Returns: #TRUE if successful, #FALSE otherwise.
+ *
  **/
-void
+SPIBoolean
 AccessibleSelection_clearSelection (AccessibleSelection *obj)
 {
-  Accessibility_Selection_clearSelection (CSPI_OBJREF (obj), cspi_ev ());
+  SPIBoolean retval;
+  
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  retval = Accessibility_Selection_clearSelection (CSPI_OBJREF (obj), cspi_ev ());
+  cspi_return_val_if_ev ("clearSelection", FALSE);
+
+  return retval;
 }