Merge branch 'master' of git+ssh://doffm@git.freedesktop.org/git/at-spi2/at-spi2...
[platform/core/uifw/at-spi2-atk.git] / pyatspi / hyperlink.py
1 #Copyright (C) 2008 Codethink Ltd
2
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.
6
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.
14
15 from interfaces import *
16 from accessible import Accessible
17 from factory import accessible_factory
18
19 import dbus
20
21 __all__ = [
22            "Hyperlink",
23           ]
24
25 #------------------------------------------------------------------------------
26
27 class Hyperlink(Accessible):
28         """
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
37         interface.
38         """
39
40         def getObject(self, index):
41                 """
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.
52                 """
53                 func = self.get_dbus_method("getObject", dbus_interface=ATSPI_HYPERLINK)
54                 return func(index)
55
56         def getURI(self, index):
57                 """
58                 Obtain a resource locator ('URI') which can be used to access
59                 the content to which this link "points" or is connected. 
60                 @return a string corresponding to the URI of the Hyperlink's
61                 'ith' anchor, if one exists, or a NIL string otherwise.
62                 """
63                 func = self.get_dbus_method("getURI", dbus_interface=ATSPI_HYPERLINK)
64                 return func(index)
65
66         def isValid(self):
67                 """
68                 Check the hyperlink to see if a connection to its backing content
69                 can be established, or if its URI is valid. 
70                 @return True if the object's content is available, or False if
71                 the hyperlink's URI is invalid, or a connection to the resource
72                 can not be established.
73                 """
74                 func = self.get_dbus_method("isValid", dbus_interface=ATSPI_HYPERLINK)
75                 return func()
76
77         def get_endIndex(self):
78                 return dbus.Int32(self._pgetter(self._dbus_interface, "endIndex"))
79         _endIndexDoc = \
80                 """
81                 the ending offset within the containing Hypertext content with
82                 which this Hyperlink is associated; that is, the offset of the
83                 first element past the range within the Hypertext associated
84                 with this Hyperlink.
85                 """
86         endIndex = property(fget=get_endIndex, doc=_endIndexDoc)
87
88         def get_nAnchors(self):
89                 return dbus.Int16(self._pgetter(self._dbus_interface, "nAnchors"))
90         _nAnchorsDoc = \
91                 """
92                 the number of separate anchors associated with this Hyperlink
93                 """
94         nAnchors = property(fget=get_nAnchors, doc=_nAnchorsDoc)
95
96         def get_startIndex(self):
97                 return dbus.Int32(self._pgetter(self._dbus_interface, "startIndex"))
98         _startIndexDoc = \
99                 """
100                 the starting offset within the containing Hypertext content with
101                 which this Hyperlink is associated
102                 """
103         startIndex = property(fget=get_startIndex, doc=_startIndexDoc)
104
105 # Register the accessible class with the factory.
106 accessible_factory.register_accessible_class(ATSPI_HYPERLINK, Hyperlink)
107
108 #END----------------------------------------------------------------------------