~ubuntu-branches/ubuntu/hardy/gnome-orca/hardy

« back to all changes in this revision

Viewing changes to src/orca/scripts/metacity.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-04-26 11:06:56 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20070426110656-uwpmlvdkave5jwrg
Tags: 2.19.1-0ubuntu1
* Synchronized with Debian, remaining Ubuntu changes:
  - debian/control:
    - newer Depends/Build-Depends, add Packages python-orca-brlapi and
      python-orca-brlapi-dbg.
  - debian/patches/01_add_ubiquity-script.dpatch,
    debian/patches/01_libbrlapi_fix.dpatch,
    debian/patches/01_link_libbrlapi.dpatch,
    debian/patches/01_no_default_desktop_item.dpatch,
    debian/patches/02_libbrlapi_fix.dpatch: added patches.
  - debian/rules, debian/control:
    - use pycentral, build python packages.
  - debian/copyright, debian/README.Debian: give credit to Luke Yelavich.
  - debian/install: python2.4 -> python*, install *.so files to different
    package.
  - debian/watch: added.
* New upstream release.
* debian/control:
  - added python-gconf as Build-Depends and Depends.
  - set Maintainer: Ubuntu Accessibility Developers
    <ubuntu-accessibility-devel@lists.ubuntu.com>
* debian/patches/01_add_ubiquity-script.dpatch:
  - updated.
* debian/patches/01_no_default_desktop_item.dpatch:
  - removed .rej file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Orca
2
2
#
3
 
# Copyright 2005-2006 Sun Microsystems Inc.
 
3
# Copyright 2005-2007 Sun Microsystems Inc.
4
4
#
5
5
# This library is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU Library General Public
19
19
 
20
20
"""Custom script for metacity."""
21
21
 
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"
27
27
 
28
28
import orca.braille as braille
30
30
import orca.rolenames as rolenames
31
31
import orca.orca as orca
32
32
import orca.speech as speech
33
 
import orca.util as util
34
33
 
35
34
from orca.orca_i18n import _
36
35
 
51
50
 
52
51
        default.Script.__init__(self, app)
53
52
 
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
58
 
        more reliable event.
59
 
 
60
 
        Arguments:
61
 
        - event: the name changed Event
62
 
        """
63
 
 
64
 
        # Do the default thing if this is not the status bar.
65
 
        #
66
 
        if event.source.role != rolenames.ROLE_STATUSBAR:
67
 
            default.Script.onNameChanged(self, event)
68
 
 
69
 
    def onStateChanged(self, event):
70
 
        """The status bar in metacity tells us what toplevel window will be
71
 
        activated when tab is released.
72
 
 
73
 
        Arguments:
74
 
        - event: the object:state-changed: Event
75
 
        """
76
 
 
77
 
        # Ignore changes on the status bar.  We handle them in onNameChanged.
78
 
        #
79
 
        if event.source.role != rolenames.ROLE_STATUSBAR:
80
 
            default.Script.onStateChanged(self, event)
81
 
 
82
 
    def onTextInserted(self, event):
83
 
        """Called whenever text is inserted into an object.
84
 
 
85
 
        Arguments:
86
 
        - event: the Event
87
 
        """
88
 
 
89
 
        # Ignore changes on the status bar.  We handle them in onNameChanged.
90
 
        #
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."""
93
55
 
94
56
        # We have to stop speech, as Metacity has a key grab and we're not
95
57
        # getting keys
102
64
        # not.
103
65
        #
104
66
        found = False
105
 
        for app in util.getKnownApplications():
 
67
        for app in self.getKnownApplications():
106
68
            i = 0
107
69
            while i < app.childCount:
108
70
                win = app.child(i)
109
71
                if win is None:
110
72
                    print "app error " + app.name
111
 
                elif win.name == event.source.name:
 
73
                elif win.name == obj.name:
112
74
                    found = True
113
75
                i = i + 1
114
76
 
115
 
        text = event.source.name
 
77
        text = obj.name
116
78
 
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
121
 
        # prefix.
 
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
 
83
        # with that prefix.
122
84
        #
123
85
        if text.startswith(_("Workspace ")) or text.startswith(_("Desk ")):
124
86
            pass
125
87
        elif not found:
 
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.
 
91
            #
126
92
            text += ". " + _("inaccessible")
127
93
 
128
94
        braille.displayMessage(text)
129
95
        speech.speak(text)
130
96
 
 
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.
 
102
 
 
103
        Arguments:
 
104
        - event: the name changed Event
 
105
        """
 
106
 
 
107
        # Ignore changes on the status bar.  We handle them in onTextInserted.
 
108
        #
 
109
        if event.source.role != rolenames.ROLE_STATUSBAR:
 
110
            default.Script.onNameChanged(self, event)
 
111
 
 
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.
 
117
 
 
118
        Arguments:
 
119
        - event: the object:state-changed: Event
 
120
        """
 
121
 
 
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.
 
126
        #
 
127
        if event.source.role != rolenames.ROLE_STATUSBAR:
 
128
            default.Script.onStateChanged(self, event)
 
129
        elif (event.type == "object:state-changed:showing") \
 
130
            and event.detail1:
 
131
            self.presentStatusBar(event.source)
 
132
 
 
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.
 
136
 
 
137
        Arguments:
 
138
        - event: the Event
 
139
        """
 
140
 
 
141
        if event.source.role != rolenames.ROLE_STATUSBAR:
 
142
            default.Script.onTextInserted(self, event)
 
143
 
 
144
        self.presentStatusBar(event.source)
 
145
 
131
146
    def onTextDeleted(self, event):
132
147
        """Called whenever text is deleted from an object.
133
148
 
135
150
        - event: the Event
136
151
        """
137
152
 
138
 
        # Ignore changes on the status bar.  We handle them in onNameChanged.
 
153
        # Ignore changes on the status bar.  We handle them in onTextInserted.
139
154
        #
140
155
        if event.source.role != rolenames.ROLE_STATUSBAR:
141
156
            default.Script.onTextDeleted(self, event)
147
162
        - event: the Event
148
163
        """
149
164
 
150
 
        # Ignore changes on the status bar.  We handle them in onNameChanged.
 
165
        # Ignore changes on the status bar.  We handle them in onTextInserted.
151
166
        #
152
167
        if event.source.role != rolenames.ROLE_STATUSBAR:
153
168
            default.Script.onCaretMoved(self, event)