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