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 base import BaseProxy, Enum
17 from accessible import Accessible
18 from factory import accessible_factory
26 #------------------------------------------------------------------------------
29 def __new__(cls, name, id):
30 list.__new__(cls, (name, id))
31 def __init__(self, name, id):
32 list.__init__(self, (name, id))
36 def _set_name(self, val):
38 name = property(fget=_get_name, fset=_set_name)
41 def _set_id(self, val):
43 id = property(fget=_get_id, fset=_set_id)
45 #------------------------------------------------------------------------------
47 class CommandListener(BaseProxy):
49 An interface which should be implemented by assistive technologies
50 or other clients of the Selector interface, over which notifications
51 to the list of available commands is made. The notifyCommands()
52 method of the client is then called by the Selector instance.
54 def notifyCommands(self, *args, **kwargs):
56 Notify the CommandListener instance of changes to the currently
57 available commands, by sending the current CommandList.
59 The newly-available list of Command objects which may be invoked
62 func = self.get_dbus_method("notifyCommands", dbus_interface=ATSPI_COMMAND_LISTENER)
63 return func(*args, **kwargs)
65 #------------------------------------------------------------------------------
67 class Selector(Accessible):
69 This interface is intended for use by assistive technologies
70 and related user-agents. Via this interface, an assistive technology
71 or user agent may expose a series of choices or selections in
72 textual form, which can be activated on demand by a client of
73 the Selector interface.
74 Examples of the use of this interface include voice-command and
75 remote-control applications, in which the user interaction is
76 wholly or partly delegated by the implementor to an external
80 def activateCommand(self, *args, **kwargs):
82 Request that the Selector invoke the specified Command.
84 the Command to activate/invoke.
85 @return a CommandResult indicating whether the request was honored,
86 and the reason for failure if the Command could not be activated
89 func = self.get_dbus_method("activateCommand", dbus_interface=ATSPI_SELECTOR)
90 return func(*args, **kwargs)
92 def deregisterChangeListener(self, *args, **kwargs):
94 Tell the Selector instance to cease notifying the specified CommandListener
95 of changes to the command list.
97 the CommandListener to remove from the notification list.
99 func = self.get_dbus_method("deregisterChangeListener", dbus_interface=ATSPI_SELECTOR)
100 return func(*args, **kwargs)
102 def getCommands(self, *args, **kwargs):
104 Query the Selector for the current CommandList.
105 @return the currently available CommandList
107 func = self.get_dbus_method("getCommands", dbus_interface=ATSPI_SELECTOR)
108 return func(*args, **kwargs)
110 def refreshCommands(self, *args, **kwargs):
112 Ask the Selector to re-calculate its CommandList.
113 @return TRUE if the CommandList changed.
115 func = self.get_dbus_method("refreshCommands", dbus_interface=ATSPI_SELECTOR)
116 return func(*args, **kwargs)
118 def registerChangeListener(self, *args, **kwargs):
120 Register a :CommandListener instance for notification of changes
123 the CommandListener to be notified of changes.
125 func = self.get_dbus_method("registerChangeListener", dbus_interface=ATSPI_SELECTOR)
126 return func(*args, **kwargs)
128 def replaceCommands(self, *args, **kwargs):
130 @return TRUE if the replacement request was successful, FALSE
131 if the request could not be honored.
133 func = self.get_dbus_method("replaceCommands", dbus_interface=ATSPI_SELECTOR)
134 return func(*args, **kwargs)
136 def get_supportsReplace(self):
137 return self._pgetter(self._dbus_interface, "supportsReplace")
138 def set_supportsReplace(self, value):
139 self._psetter(self._dbus_interface, "supportsReplace", value)
140 _supportsReplaceDoc = \
142 This attribute is TRUE if this Selector allows its CommandList
143 to be specified by the client
145 supportsReplace = property(fget=get_supportsReplace, fset=set_supportsReplace, doc=_supportsReplaceDoc)
147 class CommandResult(Enum):
149 A code returned by a call to activateCommand, indicating the
150 result of the activation request.
153 0:'COMMAND_RESULT_INVALID',
154 1:'COMMAND_RESULT_SUCCESS',
155 2:'COMMAND_RESULT_FAILED',
156 3:'COMMAND_RESULT_OBSOLETE',
157 4:'COMMAND_RESULT_LAST_DEFINED',
160 COMMAND_RESULT_FAILED = CommandResult(2)
161 COMMAND_RESULT_INVALID = CommandResult(0)
162 COMMAND_RESULT_LAST_DEFINED = CommandResult(4)
163 COMMAND_RESULT_OBSOLETE = CommandResult(3)
164 COMMAND_RESULT_SUCCESS = CommandResult(1)
166 # Register the accessible class with the factory.
167 accessible_factory.register_accessible_class(ATSPI_SELECTOR, Selector)
169 #END----------------------------------------------------------------------------