Make sure that we always return an Accessible when we're supposed to, and be
[platform/core/uifw/at-spi2-atk.git] / pyatspi / hyperlink.py
index 10b8b36..de7a6db 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
-from factory import add_accessible_class
+from interfaces import *
+from accessible import Accessible
+from factory import accessible_factory
+
+import dbus
 
 __all__ = [
            "Hyperlink",
@@ -22,7 +24,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Hyperlink(BaseProxy):
+class Hyperlink(Accessible):
         """
         Instances of Hyperlink are returned by Hypertext objects, and
         are the means by which end users and clients interact with linked,
@@ -35,7 +37,7 @@ class Hyperlink(BaseProxy):
         interface.
         """
 
-        def getObject(self, *args, **kwargs):
+        def getObject(self, index):
                 """
                 Gets the i'th object, (where i is an integer between 0 and Hyperlink::numAnchors
                 - 1, inclusive) associated with a Hyperlink. The objects returned
@@ -48,20 +50,21 @@ class Hyperlink(BaseProxy):
                 ith anchor, or through which the content associated with the
                 ith anchor can be accessed.
                 """
-                func = self.get_dbus_method("getObject")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("getObject", dbus_interface=ATSPI_HYPERLINK)
+                return self._cache.create_accessible(self._app_name, func(index),
+                                                     interfaces.ATSPI_HYPERLINK)
 
-        def getURI(self, *args, **kwargs):
+        def getURI(self, index):
                 """
                 Obtain a resource locator ('URI') which can be used to access
                 the content to which this link "points" or is connected. 
                 @return a string corresponding to the URI of the Hyperlink's
                 'ith' anchor, if one exists, or a NIL string otherwise.
                 """
-                func = self.get_dbus_method("getURI")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("getURI", dbus_interface=ATSPI_HYPERLINK)
+                return func(index)
 
-        def isValid(self, *args, **kwargs):
+        def isValid(self):
                 """
                 Check the hyperlink to see if a connection to its backing content
                 can be established, or if its URI is valid. 
@@ -69,13 +72,11 @@ class Hyperlink(BaseProxy):
                 the hyperlink's URI is invalid, or a connection to the resource
                 can not be established.
                 """
-                func = self.get_dbus_method("isValid")
-                return func(*args, **kwargs)
+                func = self.get_dbus_method("isValid", dbus_interface=ATSPI_HYPERLINK)
+                return func()
 
         def get_endIndex(self):
-                return self._pgetter(self._dbus_interface, "endIndex")
-        def set_endIndex(self, value):
-                self._psetter(self._dbus_interface, "endIndex", value)
+                return dbus.Int32(self._pgetter(self._dbus_interface, "endIndex"))
         _endIndexDoc = \
                 """
                 the ending offset within the containing Hypertext content with
@@ -83,30 +84,26 @@ class Hyperlink(BaseProxy):
                 first element past the range within the Hypertext associated
                 with this Hyperlink.
                 """
-        endIndex = property(fget=get_endIndex, fset=set_endIndex, doc=_endIndexDoc)
+        endIndex = property(fget=get_endIndex, doc=_endIndexDoc)
 
         def get_nAnchors(self):
-                return self._pgetter(self._dbus_interface, "nAnchors")
-        def set_nAnchors(self, value):
-                self._psetter(self._dbus_interface, "nAnchors", value)
+                return dbus.Int16(self._pgetter(self._dbus_interface, "nAnchors"))
         _nAnchorsDoc = \
                 """
                 the number of separate anchors associated with this Hyperlink
                 """
-        nAnchors = property(fget=get_nAnchors, fset=set_nAnchors, doc=_nAnchorsDoc)
+        nAnchors = property(fget=get_nAnchors, doc=_nAnchorsDoc)
 
         def get_startIndex(self):
-                return self._pgetter(self._dbus_interface, "startIndex")
-        def set_startIndex(self, value):
-                self._psetter(self._dbus_interface, "startIndex", value)
+                return dbus.Int32(self._pgetter(self._dbus_interface, "startIndex"))
         _startIndexDoc = \
                 """
                 the starting offset within the containing Hypertext content with
                 which this Hyperlink is associated
                 """
-        startIndex = property(fget=get_startIndex, fset=set_startIndex, doc=_startIndexDoc)
+        startIndex = property(fget=get_startIndex, doc=_startIndexDoc)
 
-# ATTENTION - Register the Application class with the accessible factory.
-add_accessible_class(interfaces.ATSPI_HYPERLINK, Hyperlink)
+# Register the accessible class with the factory.
+accessible_factory.register_accessible_class(ATSPI_HYPERLINK, Hyperlink)
 
 #END----------------------------------------------------------------------------