2008-12-17 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / pyatspi / application.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 factory import accessible_factory
17 from accessible import Accessible
18
19 __all__ = [
20                   "Application",
21           ]
22
23 #------------------------------------------------------------------------------
24
25 class Application(Accessible):
26         """
27         An interface identifying an object which is the root of the user
28         interface Accessible hierarchy associated with a running application.
29         Children of Application are typically, but not exclusively, top-level
30         windows.
31         """
32
33         def getLocale(self, *args, **kwargs):
34                 """
35                 Gets the locale in which the application is currently operating.
36                 For the current message locale, use lctype LOCALE_TYPE_MESSAGES.
37                 @param : lctype
38                 The LocaleType for which the locale is queried. 
39                 @return a string compliant with the POSIX standard for locale
40                 description.
41                 """
42                 func = self.get_dbus_method("getLocale", dbus_interface=ATSPI_APPLICATION)
43                 return func(*args, **kwargs)
44
45         def pause(self, *args, **kwargs):
46                 """
47                 Request that the application temporarily stop sending events.
48                 In most cases this should pause the application's main event
49                 loop.
50                 @return : true if the request succeeded, false otherwise.
51                 """
52                 func = self.get_dbus_method("pause", dbus_interface=ATSPI_APPLICATION)
53                 return func(*args, **kwargs)
54
55         def registerObjectEventListener(self, *args, **kwargs):
56                 """
57                 registerObjectEventListener: 
58                 @param : listener
59                 an EventListener object which will receive the requested events
60                 @param : eventName
61                 a UTF-8 string indicating the type of (toolkit-specific) event
62                 being requested. Register with this application toolkit for "Accessibility::Accessible"
63                 event notifications.
64                 """
65                 func = self.get_dbus_method("registerObjectEventListener", dbus_interface=ATSPI_APPLICATION)
66                 return func(*args, **kwargs)
67
68         def registerToolkitEventListener(self, *args, **kwargs):
69                 """
70                 @param : listener
71                 an EventListener object which will receive the requested events
72                 from the application's toolkits via toolit 'bridges' 
73                 @param : eventName
74                 a UTF-8 string indicating the type of (toolkit-specific) event
75                 being requested. Not all applications can generate toolkit events
76                 of a given type.
77                 Register with this application's toolkit for "toolkit-specific"
78                 event notifications.
79                 """
80                 func = self.get_dbus_method("registerToolkitEventListener", dbus_interface=ATSPI_APPLICATION)
81                 return func(*args, **kwargs)
82
83         def resume(self, *args, **kwargs):
84                 """
85                 Request that the application resume sending events.
86                 @return : True if the request succeeded, False otherwise.
87                 """
88                 func = self.get_dbus_method("resume", dbus_interface=ATSPI_APPLICATION)
89                 return func(*args, **kwargs)
90
91         def get_id(self):
92                 return self._pgetter(self._dbus_interface, "id")
93         def set_id(self, value):
94                 self._psetter(self._dbus_interface, "id", value)
95         _idDoc = \
96                 """
97                 The application instance's unique ID as assigned by the registry.
98                 """
99         id = property(fget=get_id, fset=set_id, doc=_idDoc)
100
101         def get_toolkitName(self):
102                 return self._pgetter(self._dbus_interface, "toolkitName")
103         def set_toolkitName(self, value):
104                 self._psetter(self._dbus_interface, "toolkitName", value)
105         _toolkitNameDoc = \
106                 """
107                 A string indicating the type of user interface toolkit which
108                 is used by the application.
109                 """
110         toolkitName = property(fget=get_toolkitName, fset=set_toolkitName, doc=_toolkitNameDoc)
111
112         def get_version(self):
113                 return self._pgetter(self._dbus_interface, "version")
114         def set_version(self, value):
115                 self._psetter(self._dbus_interface, "version", value)
116         _versionDoc = \
117                 """
118                 A string indicating the version number of the application's accessibility
119                 bridge implementation.
120                 """
121         version = property(fget=get_version, fset=set_version, doc=_versionDoc)
122
123 # Register the accessible class with the factory.
124 accessible_factory.register_accessible_class(ATSPI_APPLICATION, Application)
125
126 #END----------------------------------------------------------------------------