Make sure that we always return an Accessible when we're supposed to, and be
[platform/core/uifw/at-spi2-atk.git] / pyatspi / component.py
index ff39600..335b30a 100644 (file)
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy, Enum
-from factory import create_accessible, add_accessible_class
-from accessible import BoundingBox
+from interfaces import *
+from base import Enum
+from factory import accessible_factory
+from accessible import BoundingBox, Accessible
 
-from dbus.types import Int16
+from dbus.types import UInt32
 
 __all__ = [
            "CoordType",
@@ -74,7 +74,7 @@ LAYER_WINDOW = ComponentLayer(7)
 
 #------------------------------------------------------------------------------
 
-class Component(BaseProxy):
+class Component(Accessible):
         """
         The Component interface is implemented by objects which occupy
         on-screen space, e.g. objects which have onscreen visual representations.
@@ -87,39 +87,33 @@ class Component(BaseProxy):
         purposes of this interface.
         """
 
-        def contains(self, *args, **kwargs):
+        def contains(self, x, y, coord_type):
                 """
                 @return True if the specified point lies within the Component's
                 bounding box, False otherwise.
                 """
-                func = self.get_dbus_method("contains")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("contains", dbus_interface=ATSPI_COMPONENT)
+                return func(x, y, coord_type)
 
-        def deregisterFocusHandler(self, *args, **kwargs):
-                """
-                Request that an EventListener registered via registerFocusHandler
-                no longer be notified when this object receives keyboard focus.
-                """
-                func = self.get_dbus_method("deregisterFocusHandler")
-                return func(*args, **kwargs)
-
-        def getAccessibleAtPoint(self, *args, **kwargs):
+        def getAccessibleAtPoint(self, x, y, coord_type):
                 """
                 @return the Accessible child whose bounding box contains the
                 specified point.
                 """
-                func = self.get_dbus_method("getAccessibleAtPoint")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("getAccessibleAtPoint", dbus_interface=ATSPI_COMPONENT)
+                return self._cache.create_accessible(self._app_name,
+                                                     func(x, y, coord_type),
+                                                     interfaces.ATSPI_COMPONENT)
 
-        def getAlpha(self, *args, **kwargs):
+        def getAlpha(self):
                 """
                 Obtain the alpha value of the component. An alpha value of 1.0
                 or greater indicates that the object is fully opaque, and an
                 alpha value of 0.0 indicates that the object is fully transparent.
                 Negative alpha values have no defined meaning at this time.
                 """
-                func = self.get_dbus_method("getAlpha")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("getAlpha", dbus_interface=ATSPI_COMPONENT)
+                return func()
 
         def getExtents(self, coord_type):
                 """
@@ -129,16 +123,16 @@ class Component(BaseProxy):
                 @return a BoundingBox which entirely contains the object's onscreen
                 visual representation.
                 """
-                func = self.get_dbus_method("getExtents")
-                extents = func(Int16(coord_type))
+                func = self.get_dbus_method("getExtents", dbus_interface=ATSPI_COMPONENT)
+                extents = func(UInt32(coord_type))
                 return BoundingBox(*extents)
 
-        def getLayer(self, *args, **kwargs):
+        def getLayer(self):
                 """
                 @return the ComponentLayer in which this object resides.
                 """
-                func = self.get_dbus_method("getLayer")
-                return ComponentLayer(func(*args, **kwargs))
+                func = self.get_dbus_method("getLayer", dbus_interface=ATSPI_COMPONENT)
+                return ComponentLayer(func())
 
         def getMDIZOrder(self):
                 """
@@ -149,7 +143,7 @@ class Component(BaseProxy):
                 @return an integer indicating the object's place in the stacking
                 order.
                 """
-                func = self.get_dbus_method("getMDIZOrder")
+                func = self.get_dbus_method("getMDIZOrder", dbus_interface=ATSPI_COMPONENT)
                 return func()
 
         def getPosition(self, coord_type):
@@ -164,10 +158,10 @@ class Component(BaseProxy):
                 an out parameter which will be back-filled with the returned
                 y coordinate.
                 """
-                func = self.get_dbus_method("getPosition")
-                return func(Int16(coord_type))
+                func = self.get_dbus_method("getPosition", dbus_interface=ATSPI_COMPONENT)
+                return func(UInt32(coord_type))
 
-        def getSize(self, *args, **kwargs):
+        def getSize(self):
                 """
                 Obtain the size, in the coordinate system specified by coord_type,
                 of the rectangular area which fully contains the object's visual
@@ -177,27 +171,19 @@ class Component(BaseProxy):
                 @param : height
                 the object's vertical extents in the specified coordinate system.
                 """
-                func = self.get_dbus_method("getSize")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("getSize", dbus_interface=ATSPI_COMPONENT)
+                return func()
 
-        def grabFocus(self, *args, **kwargs):
+        def grabFocus(self):
                 """
                 Request that the object obtain keyboard focus.
                 @return True if keyboard focus was successfully transferred to
                 the Component.
                 """
-                func = self.get_dbus_method("grabFocus")
-                return func(*args, **kwargs)
-
-        def registerFocusHandler(self, *args, **kwargs):
-                """
-                Register an EventListener for notification when this object receives
-                keyboard focus.
-                """
-                func = self.get_dbus_method("registerFocusHandler")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("grabFocus", dbus_interface=ATSPI_COMPONENT)
+                return func()
 
-# Register the Accessible class with the accessible factory.
-add_accessible_class(interfaces.ATSPI_COMPONENT, Component)
+# Register the accessible class with the factory.
+accessible_factory.register_accessible_class(ATSPI_COMPONENT, Component)
 
 #END----------------------------------------------------------------------------