1 '''
2 Defines a GTK dialog for buffering C{pyatspi} events.
3
4 @author: Peter Parente
5 @author: Brett Clippingdale
6 @organization: IBM Corporation
7 @copyright: Copyright (c) 2005, 2007 IBM Corporation
8 @license: The BSD License
9
10 @author: Frank Zenker
11 @organization: IT Science Center Ruegen gGmbH, Germany
12 @copyright: Copyright (c) 2007, 2008 ITSC Ruegen
13 @license: The BSD License
14
15 All rights reserved. This program and the accompanying materials are made
16 available under the terms of the BSD license which accompanies
17 this distribution, and is available at
18 U{http://www.opensource.org/licenses/bsd-license.php}
19 '''
20
21 import pyatspi
22 from GTKEventDialog import GTKEventDialog
23 from Tools.i18n import _
24
25 __uie__ = dict(kind='monitor', profiles=['developer'])
26
28 '''
29 Logs information about platform accessibility events to a GUI window.
30 '''
32 '''
33 Gets the localized name of this monitor.
34
35 @return: Monitor name
36 @rtype: string
37 '''
38 return _('Event monitor')
39
41 '''
42 Gets the event categories to be displayed in the View menu for filtering.
43
44 @return: Event categories
45 @rtype: list of string
46 '''
47
48 all_types = ['window', 'focus', 'mouse', 'keyboard']
49 all_types.extend(pyatspi.EVENT_TREE['object'])
50 names = all_types
51 names.sort()
52 return names
53
55 '''
56 Gets the default event categories to check in the View menu.
57
58 @return: Event categories
59 @rtype: list of string
60 '''
61
62 default_types = ['window', 'focus', 'object:active-descendant-changed']
63 return default_types
64
66 '''
67 Gets the C{pyatspi.event.Event} base class to indicate the type of events
68 this monitor wants to buffer.
69
70 @return: Base type of the event this monitor should buffer
71 @rtype: C{pyatspi.event.Event} class
72 '''
73 return pyatspi.event.Event
74
76 '''
77 Gets if the given event name is in the L{shown} list and if L{logging} is
78 enabled.
79
80 @param event_name: Name of the event
81 @type event_name: string
82 @return: Is the event to be shown?
83 @rtype: boolean
84 '''
85 if not self.logging:
86 return False
87 for n in self.shown:
88 if event_name.startswith(n):
89 return True
90 return False
91
92 - def show(self, event, **kwargs):
93 '''
94 Renders an event as text into the gtk.TextBuffer. The context has no effect
95 on rendering in this monitor and so it defaults to None.
96
97 @param event: Event to buffer
98 @type event: C{pyatspi.event.Event}
99 '''
100 if not self.isInitialized():
101 raise IOError
102 try:
103 app = event.source.getApplication()
104 except Exception:
105 return
106 if (self._isShown(event.type.name) and not
107 app.name.lower().startswith('sue')):
108 self._queueText(str(event)+'\n')
109