20
20
"""Custom script for metacity."""
22
__id__ = "$Id: metacity.py 1584 2006-10-19 18:16:54Z richb $"
23
__version__ = "$Revision: 1584 $"
24
__date__ = "$Date: 2006-10-19 14:16:54 -0400 (Thu, 19 Oct 2006) $"
25
__copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc."
22
__id__ = "$Id: metacity.py 2268 2007-04-09 22:35:42Z wwalker $"
23
__version__ = "$Revision: 2268 $"
24
__date__ = "$Date: 2007-04-09 18:35:42 -0400 (Mon, 09 Apr 2007) $"
25
__copyright__ = "Copyright (c) 2005-2007 Sun Microsystems Inc."
26
26
__license__ = "LGPL"
28
28
import orca.braille as braille
52
51
default.Script.__init__(self, app)
54
def onNameChanged(self, event):
55
"""The status bar in metacity tells us what toplevel window will be
56
activated when tab is released. We will key off the name changed
57
event to determine when to say something, as it seems to be the
61
- event: the name changed Event
64
# Do the default thing if this is not the status bar.
66
if event.source.role != rolenames.ROLE_STATUSBAR:
67
default.Script.onNameChanged(self, event)
69
def onStateChanged(self, event):
70
"""The status bar in metacity tells us what toplevel window will be
71
activated when tab is released.
74
- event: the object:state-changed: Event
77
# Ignore changes on the status bar. We handle them in onNameChanged.
79
if event.source.role != rolenames.ROLE_STATUSBAR:
80
default.Script.onStateChanged(self, event)
82
def onTextInserted(self, event):
83
"""Called whenever text is inserted into an object.
89
# Ignore changes on the status bar. We handle them in onNameChanged.
91
if event.source.role != rolenames.ROLE_STATUSBAR:
92
default.Script.onTextInserted(self, event)
53
def presentStatusBar(self, obj):
54
"""Presents information about the metacity status bar."""
94
56
# We have to stop speech, as Metacity has a key grab and we're not
105
for app in util.getKnownApplications():
67
for app in self.getKnownApplications():
107
69
while i < app.childCount:
108
70
win = app.child(i)
110
72
print "app error " + app.name
111
elif win.name == event.source.name:
73
elif win.name == obj.name:
115
text = event.source.name
117
# Note to translators: the "Workspace " and "Desk " strings
118
# are the prefix of what metacity shows when you press
119
# Ctrl+Alt and the left or right arrow keys to switch between
120
# workspaces. The goal here is to find a match with that
79
# Translators: the "Workspace " and "Desk " strings are
80
# the prefix of what metacity shows when you press
81
# Ctrl+Alt and the left or right arrow keys to switch
82
# between workspaces. The goal here is to find a match
123
85
if text.startswith(_("Workspace ")) or text.startswith(_("Desk ")):
88
# Translators: inaccessible means that the application cannot
89
# be read by Orca. This usually means the application is not
90
# friendly to the assistive technology infrastructure.
126
92
text += ". " + _("inaccessible")
128
94
braille.displayMessage(text)
129
95
speech.speak(text)
97
def onNameChanged(self, event):
98
"""The status bar in metacity tells us what toplevel window
99
will be activated when tab is released. We will key off the
100
text inserted event to determine when to say something, as it
101
seems to be the more reliable event.
104
- event: the name changed Event
107
# Ignore changes on the status bar. We handle them in onTextInserted.
109
if event.source.role != rolenames.ROLE_STATUSBAR:
110
default.Script.onNameChanged(self, event)
112
def onStateChanged(self, event):
113
"""The status bar in metacity tells us what toplevel window
114
will be activated when tab is released. We will key off the
115
text inserted event to determine when to say something, as it
116
seems to be the more reliable event.
119
- event: the object:state-changed: Event
122
# Ignore changes on the status bar. We handle them in
123
# onTextInserted. The only exception is if the status bar is
124
# suddenly showing. Then, we want to present it because we
125
# typically do not get onTextInserted events at that time.
127
if event.source.role != rolenames.ROLE_STATUSBAR:
128
default.Script.onStateChanged(self, event)
129
elif (event.type == "object:state-changed:showing") \
131
self.presentStatusBar(event.source)
133
def onTextInserted(self, event):
134
"""Called whenever text is inserted into an object. This seems to
135
be the most reliable event to let us know something is changing.
141
if event.source.role != rolenames.ROLE_STATUSBAR:
142
default.Script.onTextInserted(self, event)
144
self.presentStatusBar(event.source)
131
146
def onTextDeleted(self, event):
132
147
"""Called whenever text is deleted from an object.