Merge branch 'mdoff' of ssh://git.codethink.co.uk/git/atspi-dbus
[platform/core/uifw/at-spi2-atk.git] / pyatspi / action.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 import interfaces
16 from base import BaseProxy
17 from factory import create_accessible, add_accessible_class
18
19 __all__ = [
20            "Action",
21           ]
22
23 #------------------------------------------------------------------------------
24
25 class Action(BaseProxy):
26     """
27     An interface through which a user-actionable user interface component
28     can be manipulated. Components which react to mouse or keyboard
29     input from the user, (with the exception of pure text entry fields
30     with no other function), should implement this interface. Typical
31     actions include "click", "press", "release" (for instance for
32     buttons), "menu" (for objects which have context menus invokable
33     from mouse or keyboard), "open" for icons representing files
34     folders, and others.
35     """
36     
37     def doAction(self, index):
38         """
39         doAction: 
40         @param : index
41         the 0-based index of the action to perform.
42         Causes the object to perform the specified action.
43         @return : a boolean indicating success or failure.
44         """
45         func = self.get_dbus_method("doAction")
46         return func(index)
47     
48     def getDescription(self, index):
49         """
50         getDescription: 
51         @param : index
52         the index of the action for which a description is desired.
53         Get the description of the specified action. The description
54         of an action may provide information about the result of action
55         invocation, unlike the action name. 
56         @return : a string containing the description of the specified
57         action.
58         """
59         func = self.get_dbus_method("getDescription")
60         return func(index)
61     
62     def getKeyBinding(self, index):
63         """
64         getKeyBinding: 
65         @param : index
66         the 0-based index of the action for which a key binding is requested.
67         Get the key binding associated with a specific action.
68         @return : a string containing the key binding for the specified
69         action, or an empty string ("") if none exists.
70         """
71         func = self.get_dbus_method("getKeyBinding")
72         return func(index)
73     
74     def getName(self, index):
75         """
76         getName: 
77         @param : index
78         the index of the action whose name is requested.
79         Get the name of the specified action. Action names generally
80         describe the user action, i.e. "click" or "press", rather then
81         the result of invoking the action.
82         @return : a string containing the name of the specified action.
83         """
84         func = self.get_dbus_method("getName")
85         return func(index)
86     
87     def get_nActions(self):
88         return self._pgetter(self._dbus_interface, "nActions")
89     def set_nActions(self, value):
90         self._psetter(self._dbus_interface, "nActions", value)
91     _nActionsDoc = \
92         """
93         nActions: a long containing the number of actions this object
94         supports.
95         """
96     nActions = property(fget=get_nActions, fset=set_nActions, doc=_nActionsDoc)
97
98 # Register the Accessible class with the accessible factory.
99 add_accessible_class(interfaces.ATSPI_ACTION, Action)
100
101 #END----------------------------------------------------------------------------