1 #Copyright (C) 2008 Codethink Ltd
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 from interfaces import *
16 from accessible import Accessible
17 from factory import accessible_factory
25 #------------------------------------------------------------------------------
27 class Hyperlink(Accessible):
29 Instances of Hyperlink are returned by Hypertext objects, and
30 are the means by which end users and clients interact with linked,
31 and in some cases embedded, content. Hyperlinks may have multiple
32 "anchors", where an anchor corresponds to a reference to a particular
33 resource with a corresponding resource identified (URI). Hyperlinks
34 may be queried for their URIs, or queried for the objects corresponding
35 to their anchors. The objects thus obtained are instances of
36 Accessible, and may be queried, and manipulated via the Action
40 def getObject(self, index):
42 Gets the i'th object, (where i is an integer between 0 and Hyperlink::numAnchors
43 - 1, inclusive) associated with a Hyperlink. The objects returned
44 are usually actionable (i.e. they should implement Accessibility::Action),
45 and the available actions often include "open", "bookmark", "save
46 link as", etc. They may also implement Accessibility::StreamableContent,
47 although clients can normally use getURI to obtain a resource
48 locator via which the object's data may be accessed.
49 @return an Accessible object instance representing the Hyperlink's
50 ith anchor, or through which the content associated with the
51 ith anchor can be accessed.
53 func = self.get_dbus_method("getObject", dbus_interface=ATSPI_HYPERLINK)
54 return self._cache.create_accessible(self._app_name, func(index),
55 interfaces.ATSPI_HYPERLINK)
57 def getURI(self, index):
59 Obtain a resource locator ('URI') which can be used to access
60 the content to which this link "points" or is connected.
61 @return a string corresponding to the URI of the Hyperlink's
62 'ith' anchor, if one exists, or a NIL string otherwise.
64 func = self.get_dbus_method("getURI", dbus_interface=ATSPI_HYPERLINK)
69 Check the hyperlink to see if a connection to its backing content
70 can be established, or if its URI is valid.
71 @return True if the object's content is available, or False if
72 the hyperlink's URI is invalid, or a connection to the resource
73 can not be established.
75 func = self.get_dbus_method("isValid", dbus_interface=ATSPI_HYPERLINK)
78 def get_endIndex(self):
79 return dbus.Int32(self._pgetter(self._dbus_interface, "endIndex"))
82 the ending offset within the containing Hypertext content with
83 which this Hyperlink is associated; that is, the offset of the
84 first element past the range within the Hypertext associated
87 endIndex = property(fget=get_endIndex, doc=_endIndexDoc)
89 def get_nAnchors(self):
90 return dbus.Int16(self._pgetter(self._dbus_interface, "nAnchors"))
93 the number of separate anchors associated with this Hyperlink
95 nAnchors = property(fget=get_nAnchors, doc=_nAnchorsDoc)
97 def get_startIndex(self):
98 return dbus.Int32(self._pgetter(self._dbus_interface, "startIndex"))
101 the starting offset within the containing Hypertext content with
102 which this Hyperlink is associated
104 startIndex = property(fget=get_startIndex, doc=_startIndexDoc)
106 # Register the accessible class with the factory.
107 accessible_factory.register_accessible_class(ATSPI_HYPERLINK, Hyperlink)
109 #END----------------------------------------------------------------------------