예제 #1
0
    def onStateChanged(self, event):
        """Called whenever an object's state changes.

        Arguments:
        - event: the Event
        """

        if event.type.startswith("object:state-changed:checked") and \
           event.source.role == rolenames.ROLE_RADIO_BUTTON:
            # Radio buttons in the Search panel are not automatically
            # selected when you arrow to them.  You have to press Space
            # to select the current radio button.  Watch for this.
            #
            orca.visualAppearanceChanged(event, event.source)
            return

        elif event.type.startswith("object:state-changed:focused") and \
             event.detail1 == 1:
            if event.source.role == rolenames.ROLE_PUSH_BUTTON:
                # Try to minimize chattiness in the Search panel
                #
                utterances = \
                     self.speechGenerator.getSpeech(event.source, False)
                speech.speakUtterances(utterances)
                brailleRegions = \
                     self.brailleGenerator.getBrailleRegions(event.source)
                braille.displayRegions(brailleRegions)
                orca.setLocusOfFocus(event, event.source, False)
                return

            elif event.source.role == rolenames.ROLE_TEXT:
                # There's an excellent chance that the Find toolbar just
                # gained focus.  Check.
                #
                if self.isInFindToolbar(event.source):
                    self.findToolbarActive = True

        default.Script.onStateChanged(self, event)
예제 #2
0
    def onStateChanged(self, event):
        """Called whenever an object's state changes.

        Arguments:
        - event: the Event
        """

        if event.type.startswith("object:state-changed:checked") and \
           event.source.role == rolenames.ROLE_RADIO_BUTTON:
            # Radio buttons in the Search panel are not automatically
            # selected when you arrow to them.  You have to press Space
            # to select the current radio button.  Watch for this.
            #
            orca.visualAppearanceChanged(event, event.source)
            return

        elif event.type.startswith("object:state-changed:focused") and \
             event.detail1 == 1:
            if event.source.role == rolenames.ROLE_PUSH_BUTTON:
                # Try to minimize chattiness in the Search panel
                #
                utterances = \
                     self.speechGenerator.getSpeech(event.source, False)
                speech.speakUtterances(utterances)
                brailleRegions = \
                     self.brailleGenerator.getBrailleRegions(event.source)
                braille.displayRegions(brailleRegions)
                orca.setLocusOfFocus(event, event.source, False)
                return

            elif event.source.role == rolenames.ROLE_TEXT:
                # There's an excellent chance that the Find toolbar just
                # gained focus.  Check.
                #
                if self.isInFindToolbar(event.source):
                    self.findToolbarActive = True

        default.Script.onStateChanged(self, event)
예제 #3
0
    def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
        """Called when the visual object with focus changes. Overridden
        in this script to minimize the repetition of text along with
        the unnecessary speaking of object types.

        Arguments:
        - event: if not None, the Event that caused the change
        - oldLocusOfFocus: Accessible that is the old locus of focus
        - newLocusOfFocus: Accessible that is the new locus of focus
        """

        if not newLocusOfFocus or (oldLocusOfFocus == newLocusOfFocus):
            return

        # Eliminate unnecessary chattiness related to the Find toolbar.
        #
        if self.findToolbarActive:
            if newLocusOfFocus.role == rolenames.ROLE_TEXT:
                newText = self.getTextLineAtCaret(newLocusOfFocus)
                if newText == self.preFindLine:
                    orca.setLocusOfFocus(event, oldLocusOfFocus, False)
                    return
            if newLocusOfFocus.role == rolenames.ROLE_DRAWING_AREA:
                orca.setLocusOfFocus(event, oldLocusOfFocus, False)
                return

            utterances = \
                 self.speechGenerator.getSpeech(newLocusOfFocus, False)
            speech.speakUtterances(utterances)
            brailleRegions = \
                 self.brailleGenerator.getBrailleRegions(newLocusOfFocus)
            braille.displayRegions(brailleRegions)
            orca.setLocusOfFocus(event, newLocusOfFocus, False)
            return

        # Eliminate unnecessary chattiness in the Search panel.
        #
        if newLocusOfFocus.role == rolenames.ROLE_PUSH_BUTTON and \
           oldLocusOfFocus and oldLocusOfFocus.role == self.ROLE_LINK and \
           newLocusOfFocus.name == oldLocusOfFocus.name:
            return

        # Eliminate general document chattiness.
        #
        if newLocusOfFocus.role == self.ROLE_DOCUMENT or \
           newLocusOfFocus.role == rolenames.ROLE_DRAWING_AREA:
            orca.setLocusOfFocus(event, newLocusOfFocus, False)
            return

        elif newLocusOfFocus.role == self.ROLE_LINK:
            # It seems that this will be the only event we will get.  But
            # the default script's onFocus will result in unnecessary
            # verboseness: reporting the drawing area(s) in which this link
            # is contained, speaking the periods in a table of contents, etc.
            #
            utterances = self.speechGenerator.getSpeech(newLocusOfFocus, False)
            adjustedUtterances = []
            for utterance in utterances:
                adjustedUtterances.append(self.adjustForRepeats(utterance))
            speech.speakUtterances(adjustedUtterances)
            brailleRegions = \
                     self.brailleGenerator.getBrailleRegions(newLocusOfFocus)
            braille.displayRegions(brailleRegions)
            orca.setLocusOfFocus(event, newLocusOfFocus, False)
            return

        default.Script.locusOfFocusChanged(self, event,
                                           oldLocusOfFocus, newLocusOfFocus)
예제 #4
0
    def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
        """Called when the visual object with focus changes.

        Arguments:
        - event: if not None, the Event that caused the change
        - oldLocusOfFocus: Accessible that is the old locus of focus
        - newLocusOfFocus: Accessible that is the new locus of focus
        """

        brailleGen = self.brailleGenerator
        speechGen = self.speechGenerator

        debug.printObjectEvent(self.debugLevel,
                               event,
                               event.source.toString())

        # Here we handle the case when focus is in the "Work online/offline" 
        # button near the status bar that has an image without a description.
        # We speak and braille "Online/Offline button" here, until the 
        # developer of the application adds a description to the images 
        # associated with the button, which shows the online or offline 
        # work mode.
        #
        rolesList = [rolenames.ROLE_PUSH_BUTTON,
                     rolenames.ROLE_FILLER,
                     rolenames.ROLE_FILLER,
                     rolenames.ROLE_FRAME]

        # We are checking if the button with the focus is the button to 
        # turn on/off the work mode in liferea. This push button is
        # hierarchically located in the main window of the application 
        # (frame), inside a filler and inside another filler.
        #
        if self.isDesiredFocusedItem(event.source, rolesList):
             # If we are focusing this button we construct a utterance and 
             # a braille region to speak/braille "online/offline button".
             # Here we declare utterances and add the localized string 
             # "online/offline".
             #
             utterances = []
             utterances.append(_("Work online / offline")) 

             # Here we extend the utterances with the speech generator for 
             # the object with focus (the push button).
             #
             utterances.extend(speechGen.getSpeech(event.source,False))

             # Finally we speak/braille the utterances/regions.
             #
             speech.speakUtterances(utterances)
           
             regions = brailleGen.getBrailleRegions(event.source)
             regions[0].insert(0, braille.Region(utterances[0] + " "))
             braille.displayRegions(regions)
           
             return

        # Here we handle the case when the focus is in the headlines table.
        # See comment #3 of bug #350233.
        # http://bugzilla.gnome.org/show_bug.cgi?id=350233
        #
        if orca_state.locusOfFocus.role == rolenames.ROLE_TABLE_COLUMN_HEADER:
             table = event.source.parent
             cells = self.findByRole(table, rolenames.ROLE_TABLE_CELL)
             eventsynthesizer.clickObject(cells[1], 1)
        
        default.Script.locusOfFocusChanged(self, event, 
                                           oldLocusOfFocus, newLocusOfFocus)
예제 #5
0
    def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
        """Called when the visual object with focus changes.

        Arguments:
        - event: if not None, the Event that caused the change
        - oldLocusOfFocus: Accessible that is the old locus of focus
        - newLocusOfFocus: Accessible that is the new locus of focus
        """

        brailleGen = self.brailleGenerator
        speechGen = self.speechGenerator

        debug.printObjectEvent(self.debugLevel, event, event.source.toString())

        # Here we handle the case when focus is in the "Work online/offline"
        # button near the status bar that has an image without a description.
        # We speak and braille "Online/Offline button" here, until the
        # developer of the application adds a description to the images
        # associated with the button, which shows the online or offline
        # work mode.
        #
        rolesList = [
            rolenames.ROLE_PUSH_BUTTON, rolenames.ROLE_FILLER,
            rolenames.ROLE_FILLER, rolenames.ROLE_FRAME
        ]

        # We are checking if the button with the focus is the button to
        # turn on/off the work mode in liferea. This push button is
        # hierarchically located in the main window of the application
        # (frame), inside a filler and inside another filler.
        #
        if self.isDesiredFocusedItem(event.source, rolesList):
            # If we are focusing this button we construct a utterance and
            # a braille region to speak/braille "online/offline button".
            # Here we declare utterances and add the localized string
            # "online/offline".
            #
            utterances = []
            utterances.append(_("Work online / offline"))

            # Here we extend the utterances with the speech generator for
            # the object with focus (the push button).
            #
            utterances.extend(speechGen.getSpeech(event.source, False))

            # Finally we speak/braille the utterances/regions.
            #
            speech.speakUtterances(utterances)

            regions = brailleGen.getBrailleRegions(event.source)
            regions[0].insert(0, braille.Region(utterances[0] + " "))
            braille.displayRegions(regions)

            return

        # Here we handle the case when the focus is in the headlines table.
        # See comment #3 of bug #350233.
        # http://bugzilla.gnome.org/show_bug.cgi?id=350233
        #
        if orca_state.locusOfFocus.role == rolenames.ROLE_TABLE_COLUMN_HEADER:
            table = event.source.parent
            cells = self.findByRole(table, rolenames.ROLE_TABLE_CELL)
            eventsynthesizer.clickObject(cells[1], 1)

        default.Script.locusOfFocusChanged(self, event, oldLocusOfFocus,
                                           newLocusOfFocus)
예제 #6
0
    def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
        """Called when the visual object with focus changes. Overridden
        in this script to minimize the repetition of text along with
        the unnecessary speaking of object types.

        Arguments:
        - event: if not None, the Event that caused the change
        - oldLocusOfFocus: Accessible that is the old locus of focus
        - newLocusOfFocus: Accessible that is the new locus of focus
        """

        if not newLocusOfFocus or (oldLocusOfFocus == newLocusOfFocus):
            return

        # Eliminate unnecessary chattiness related to the Find toolbar.
        #
        if self.findToolbarActive:
            if newLocusOfFocus.role == rolenames.ROLE_TEXT:
                newText = self.getTextLineAtCaret(newLocusOfFocus)
                if newText == self.preFindLine:
                    orca.setLocusOfFocus(event, oldLocusOfFocus, False)
                    return
            if newLocusOfFocus.role == rolenames.ROLE_DRAWING_AREA:
                orca.setLocusOfFocus(event, oldLocusOfFocus, False)
                return

            utterances = \
                 self.speechGenerator.getSpeech(newLocusOfFocus, False)
            speech.speakUtterances(utterances)
            brailleRegions = \
                 self.brailleGenerator.getBrailleRegions(newLocusOfFocus)
            braille.displayRegions(brailleRegions)
            orca.setLocusOfFocus(event, newLocusOfFocus, False)
            return

        # Eliminate unnecessary chattiness in the Search panel.
        #
        if newLocusOfFocus.role == rolenames.ROLE_PUSH_BUTTON and \
           oldLocusOfFocus and oldLocusOfFocus.role == self.ROLE_LINK and \
           newLocusOfFocus.name == oldLocusOfFocus.name:
            return

        # Eliminate general document chattiness.
        #
        if newLocusOfFocus.role == self.ROLE_DOCUMENT or \
           newLocusOfFocus.role == rolenames.ROLE_DRAWING_AREA:
            orca.setLocusOfFocus(event, newLocusOfFocus, False)
            return

        elif newLocusOfFocus.role == self.ROLE_LINK:
            # It seems that this will be the only event we will get.  But
            # the default script's onFocus will result in unnecessary
            # verboseness: reporting the drawing area(s) in which this link
            # is contained, speaking the periods in a table of contents, etc.
            #
            utterances = self.speechGenerator.getSpeech(newLocusOfFocus, False)
            adjustedUtterances = []
            for utterance in utterances:
                adjustedUtterances.append(self.adjustForRepeats(utterance))
            speech.speakUtterances(adjustedUtterances)
            brailleRegions = \
                     self.brailleGenerator.getBrailleRegions(newLocusOfFocus)
            braille.displayRegions(brailleRegions)
            orca.setLocusOfFocus(event, newLocusOfFocus, False)
            return

        default.Script.locusOfFocusChanged(self, event, oldLocusOfFocus,
                                           newLocusOfFocus)