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