? atspi.c
? build
Index: cspi.pxd
===================================================================
RCS file: /cvs/gnome/pyspi/cspi.pxd,v
retrieving revision 1.5
diff -a -u -r1.5 cspi.pxd
--- cspi.pxd	10 Mar 2006 21:03:02 -0000	1.5
+++ cspi.pxd	30 Mar 2006 01:25:19 -0000
@@ -7,6 +7,7 @@
 	ctypedef Accessible AccessibleHypertext
 	ctypedef Accessible AccessibleHyperlink
 	ctypedef Accessible AccessibleImage
+	ctypedef Accessible AccessibleSelection
 	ctypedef Accessible AccessibleTable
 	ctypedef Accessible AccessibleComponent
 
@@ -459,6 +460,24 @@
 												 long int *width,
 												 long int *height,
 												 AccessibleCoordType ctype)
+
+	# Accessible Objects
+	SPIBoolean Accessible_isSelection            (Accessible *obj)
+	AccessibleSelection *Accessible_getSelection     (Accessible *obj)
+	# Subinterface Methods - AccessibleSelection Interface
+	void AccessibleSelection_ref                 (AccessibleSelection *obj)
+	void AccessibleSelection_unref               (AccessibleSelection *obj)
+	int         AccessibleSelection_getNSelectedChildren (AccessibleSelection *obj)
+	Accessible*  AccessibleSelection_getSelectedChild (AccessibleSelection *obj,
+													  int i)
+	SPIBoolean  AccessibleSelection_selectChild (AccessibleSelection *obj,
+												  int i)
+	SPIBoolean  AccessibleSelection_deselectSelectedChild (AccessibleSelection *obj,
+														   int i)
+	SPIBoolean  AccessibleSelection_isChildSelected (AccessibleSelection *obj,
+												     int i)
+	SPIBoolean  AccessibleSelection_selectAll (AccessibleSelection *obj)
+	SPIBoolean  AccessibleSelection_clearSelection (AccessibleSelection *obj)
 
 	# Accessible Objects
 	SPIBoolean Accessible_isTable            (Accessible *obj)
Index: pyspi.pyx
===================================================================
RCS file: /cvs/gnome/pyspi/pyspi.pyx,v
retrieving revision 1.14
diff -a -u -r1.14 pyspi.pyx
--- pyspi.pyx	28 Mar 2006 21:46:56 -0000	1.14
+++ pyspi.pyx	30 Mar 2006 01:25:19 -0000
@@ -20,6 +20,7 @@
 cdef class Hypertext (Text)
 cdef class Hyperlink (Base)
 cdef class Image (Base)
+cdef class Selection (Base)
 cdef class Table (Base)
 cdef class Event (EventBase)
 cdef class DeviceEvent (DeviceEventBase)
@@ -562,6 +563,18 @@
 		if image.__item != NULL:
 			return image
 
+	def getSelection (self):
+		"""
+		Wrapper around cspi.Accessible_getSelection, returning an
+		atspi.Selection or None
+		"""
+		self.__checkSelf ()
+		cdef Selection selection
+		selection = Selection ()
+		selection.__setItem (cspi.Accessible_getSelection (self.__item))
+		if selection.__item != NULL:
+			return selection 
+
 	def getComponent (self):
 		"""
 		Wrapper around cspi.Accessible_getComponent, returning an
@@ -968,6 +981,81 @@
 		cspi.AccessibleImage_getImageExtents(self.__item, &x, &y, &w, &h, type)
 		return [x, y, w, h]
 
+cdef class Selection (Base):
+	"""
+	Wrapper around the low-level cspi.AccessibleSelection_ functions,
+	giving an OO-style API.
+	"""
+
+	def getNSelectedChildren (self):
+		"""
+		Wraps cspi.AccessibleSelection_getNSelectedChildren
+		"""
+		self.__checkSelf ()
+		return cspi.AccessibleSelection_getNSelectedChildren (self.__item)
+
+	def getSelectedChild (self, index):
+		"""
+		Wraps cspi.AccessibleSelection_getSelectedChild
+		"""
+		self.__checkSelf ()
+
+		cdef cspi.Accessible* spiChild
+		spiChild = cspi.AccessibleSelection_getSelectedChild (self.__item, index)
+
+		assert spiChild != NULL
+		
+		cdef object child
+		cdef Application app
+		cdef Accessible acc
+		cdef Text text
+		
+		if cspi.Accessible_isApplication (spiChild):
+			app = Application ()
+			app.__setItem (spiChild)
+			child = app
+		else:
+			acc = Accessible ()
+			acc.__setItem (spiChild)
+			child = acc
+
+		return child
+
+	def selectChild (self, index):
+		"""
+		Wraps cspi.AccessibleSelection_selectChild
+		"""
+		self.__checkSelf ()
+		return cspi.AccessibleSelection_selectChild (self.__item, index)
+	
+	def deselectSelectedChild (self, index):
+		"""
+		Wraps cspi.AccessibleSelection_deselectSelectedChild
+		"""
+		self.__checkSelf ()
+		return cspi.AccessibleSelection_deselectSelectedChild (self.__item, index)
+	
+	def isChildSelected (self, index):
+		"""
+		Wraps cspi.AccessibleSelection_isChildSelected
+		"""
+		self.__checkSelf ()
+		return cspi.AccessibleSelection_isChildSelected (self.__item, index)
+
+	def selectAll (self):
+		"""
+		Wraps cspi.AccessibleSelection_selectAll
+		"""
+		self.__checkSelf ()
+		return cspi.AccessibleSelection_selectAll( self.__item)
+
+	def clearSelection (self):
+		"""
+		Wraps cspi.AccessibleSelection_clearSelection
+		"""
+		self.__checkSelf ()
+		return cspi.AccessibleSelection_clearSelection (self.__item)
+	
 cdef class Table (Base):
 	"""
 	Wrapper around the low-level cspi.AccessibleTable_ functions,
