Add spi-role-types.h
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_selection.c
index 1b98704..d369070 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,16 @@ AccessibleSelection_unref (AccessibleSelection *obj)
 long
 AccessibleSelection_getNSelectedChildren (AccessibleSelection *obj)
 {
-  return (long)
-    Accessibility_Selection__get_nSelectedChildren (CSPI_OBJREF (obj), cspi_ev ());
-}
+  dbus_int32_t retval;
+
+  cspi_return_val_if_fail (obj != NULL, -1);
 
+  cspi_dbus_get_property (obj, spi_interface_selection, "nSelectedChildren", NULL, "i", &retval);
+
+  cspi_return_val_if_ev ("getNSelectedChildren", -1);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_getSelectedChild:
@@ -75,12 +95,16 @@ 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");
+  dbus_int32_t d_selectedChildIndex = selectedChildIndex;
+  char *path;
+  Accessible *child;
 
-  return (Accessible *) cspi_object_add (child);
+  cspi_return_val_if_fail (obj != NULL, NULL);
+  
+  cspi_dbus_call (obj, spi_interface_selection, "getSelectedChild", NULL, "i=>o", &d_selectedChildIndex, &path);
+  child = cspi_ref_related_accessible (obj, path);
+  g_free (path);
+  return child;
 }
 
 /**
@@ -95,17 +119,22 @@ AccessibleSelection_getSelectedChild (AccessibleSelection *obj,
  *         selection.
  *
  * Returns: #TRUE if the child was successfully selected, #FALSE otherwise.
- *
  **/
-boolean
+SPIBoolean
 AccessibleSelection_selectChild (AccessibleSelection *obj,
                                  long int childIndex)
 {
-  return (boolean)
-    Accessibility_Selection_selectChild (CSPI_OBJREF (obj),
-                                        (CORBA_long) childIndex, cspi_ev ());
-}
+  dbus_int32_t d_childIndex = childIndex;
+  dbus_bool_t retval;
+
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  cspi_dbus_call (obj, spi_interface_selection, "selectChild", NULL, "i=>b", &d_childIndex, &retval);
 
+  cspi_return_val_if_ev ("selectChild", FALSE);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_deselectSelectedChild:
@@ -120,17 +149,54 @@ AccessibleSelection_selectChild (AccessibleSelection *obj,
  *          are asymmettric.
  *
  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
- *
  **/
-boolean
+SPIBoolean
 AccessibleSelection_deselectSelectedChild (AccessibleSelection *obj,
                                            long int selectedChildIndex)
 {
-  return Accessibility_Selection_deselectSelectedChild (
-         CSPI_OBJREF (obj), (CORBA_long) selectedChildIndex, cspi_ev ());
+  dbus_int32_t d_selectedChildIndex = selectedChildIndex;
+  dbus_bool_t retval;
+
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  cspi_dbus_call (obj, spi_interface_selection, "deselectSelectedChild", NULL, "i=>b", &d_selectedChildIndex, &retval);
+
+  cspi_return_val_if_ev ("deselectSelectedChild", FALSE);
+
+  return retval;
 }
 
+/**
+ * AccessibleSelection_deselectChild:
+ * @obj: a pointer to the #AccessibleSelection on which to operate.
+ * @childIndex: a #long indicating which of the children
+ *              of the #Accessible is to be de-selected.
+ *
+ * Deselect a specific child of an #AccessibleSelection.
+ *          Note that @childIndex is the index of the child
+ *          in the parent container.
+ * 
+ * See #AccessibleSelection_deselectSelectedChild
+ *
+ * Since AT-SPI 1.8.0
+ * 
+ * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
+ **/
+SPIBoolean
+AccessibleSelection_deselectChild (AccessibleSelection *obj,
+                                  long int childIndex)
+{
+  dbus_int32_t d_childIndex = childIndex;
+  dbus_bool_t retval;
+
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  cspi_dbus_call (obj, spi_interface_selection, "deselectChild", NULL, "i=>b", &d_childIndex, &retval);
 
+  cspi_return_val_if_ev ("deselectChild", FALSE);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_isChildSelected:
@@ -143,18 +209,22 @@ AccessibleSelection_deselectSelectedChild (AccessibleSelection *obj,
  *
  * Returns: #TRUE if the specified child is currently selected,
  *          #FALSE otherwise.
- *
  **/
-boolean
+SPIBoolean
 AccessibleSelection_isChildSelected (AccessibleSelection *obj,
                                      long int childIndex)
 {
-  return (boolean)
-    Accessibility_Selection_isChildSelected (CSPI_OBJREF (obj),
-                                            (CORBA_long) childIndex, cspi_ev ());
-}
+  dbus_int32_t d_childIndex = childIndex;
+  dbus_bool_t retval;
+
+  cspi_return_val_if_fail (obj != NULL, FALSE);
 
+  cspi_dbus_call (obj, spi_interface_selection, "isChildSelected", NULL, "i=>b", &d_childIndex, &retval);
 
+  cspi_return_val_if_ev ("isChildSelected", FALSE);
+
+  return retval;
+}
 
 /**
  * AccessibleSelection_selectAll:
@@ -166,14 +236,19 @@ AccessibleSelection_isChildSelected (AccessibleSelection *obj,
  * Returns: #TRUE if successful, #FALSE otherwise.
  *
  **/
-boolean
+SPIBoolean
 AccessibleSelection_selectAll (AccessibleSelection *obj)
 {
-  Accessibility_Selection_selectAll (CSPI_OBJREF (obj), cspi_ev ());
-  return TRUE; /* TODO: change the bonobo method to return boolean */
-}
+  dbus_bool_t retval;
+  
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  cspi_dbus_call (obj, spi_interface_selection, "selectAll", NULL, "=>b", &retval);
 
+  cspi_return_val_if_ev ("selectAll", FALSE);
 
+  return retval;
+}
 
 /**
  * AccessibleSelection_clearSelection:
@@ -182,11 +257,18 @@ 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 ());
-}
+  dbus_bool_t retval;
+  
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  cspi_dbus_call (obj, spi_interface_selection, "clearSelection", NULL, "=>b", &retval);
 
+  return retval;
+}