2009-27-09 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / pyatspi / document.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 __all__ = [
20            "Document",
21           ]
22
23 #------------------------------------------------------------------------------
24
25 class Document(Accessible):
26         """
27         Primarily a 'tagging' interface which indicates the start of
28         document content in the Accessibility hierarchy. Accessible objects
29         below the node implementing Document are normally assumed to
30         be part of the document content. Attributes of Document are those
31         attributes associated with the document as a whole. Objects that
32         implement Document are normally expected to implement Collection
33         as well.
34         """
35
36         def getAttributeValue(self, key):
37                 """
38                 Gets the value of a single attribute, if specified for the document
39                 as a whole.
40                 @param : attributename
41                 a string indicating the name of a specific attribute (name-value
42                 pair) being queried.
43                 @return a string corresponding to the value of the specified
44                 attribute, or an empty string if the attribute is unspecified
45                 for the object.
46                 """
47                 func = self.get_dbus_method("getAttributeValue", dbus_interface=ATSPI_DOCUMENT)
48                 return func(key)
49
50         def getAttributes(self):
51                 """
52                 Gets all attributes specified for a document as a whole. For
53                 attributes which change within the document content, see Accessibility::Text::getAttributes
54                 instead.
55                 @return an AttributeSet containing the attributes of the document,
56                 as name-value pairs.
57                 """
58                 func = self.get_dbus_method("getAttributes", dbus_interface=ATSPI_DOCUMENT)
59                 return [key + ':' + value for key, value in func().values()]
60
61         def getLocale(self):
62                 """
63                 Gets the locale associated with the document's content. e.g.
64                 the locale for LOCALE_TYPE_MESSAGES.
65                 @return a string compliant with the POSIX standard for locale
66                 description.
67                 """
68                 func = self.get_dbus_method("getLocale", dbus_interface=ATSPI_DOCUMENT)
69                 return func()
70
71 # Register the accessible class with the factory.
72 accessible_factory.register_accessible_class(ATSPI_DOCUMENT, Document)
73
74 #END----------------------------------------------------------------------------