예제 #1
0
    def _generateRealTableCell(self, obj, **args):
        """Get the speech for a table cell. If this isn't inside a
        spread sheet, just return the utterances returned by the default
        table cell speech handler.

        Arguments:
        - obj: the table cell

        Returns a list of utterances to be spoken for the object.
        """
        result = []
        if self._script.utilities.isSpreadSheetCell(obj):
            result.extend(self._generateSpreadSheetCell(obj, **args))
        else:
            # Check to see how many children this table cell has. If it's
            # just one (or none), then pass it on to the superclass to be
            # processed.
            #
            # If it's more than one, then get the speech for each child,
            # and call this method again.
            #
            if obj.childCount <= 1:
                result.extend(braille_generator.BrailleGenerator.\
                              _generateRealTableCell(self, obj, **args))
            else:
                for child in obj:
                    cellResult = self._generateRealTableCell(child, **args)
                    if cellResult and result and self._mode == 'braille':
                        result.append(
                            braille.Region(object_properties.
                                           TABLE_CELL_DELIMITER_BRAILLE))
                    result.extend(cellResult)
        return result
예제 #2
0
    def _generateTableCellRow(self, obj, **args):
        """Get the speech for a table row or cell depending on settings.

        Arguments:
        - obj: the table cell

        Returns a list of utterances to be spoken for the object.
        """
        result = []
        if self._script.utilities.isSpreadSheetCell(obj):
            # Adding in a check here to make sure that the parent is a
            # valid table. It's possible that the parent could be a
            # table cell too (see bug #351501).
            #
            parent = obj.parent
            parentTable = parent.queryTable()
            readFullRow = self._script.utilities.shouldReadFullRow(obj)
            if readFullRow and parentTable:
                index = self._script.utilities.cellIndex(obj)
                row = parentTable.getRowAtIndex(index)
                column = parentTable.getColumnAtIndex(index)
                # This is an indication of whether we should present all the
                # table cells (the user has moved focus up or down a row),
                # or just the current one (focus has moved left or right in
                # the same row).
                #
                presentAll = True
                if "lastRow" in self._script.pointOfReference and \
                    "lastColumn" in self._script.pointOfReference:
                    pointOfReference = self._script.pointOfReference
                    presentAll = \
                        (self._mode == 'braille') \
                        or ((pointOfReference["lastRow"] != row) \
                            or ((row == 0 or row == parentTable.nRows-1) \
                                and pointOfReference["lastColumn"] == column))
                if presentAll:
                    [startIndex, endIndex] = \
                        self._script.utilities.getTableRowRange(obj)
                    for i in range(startIndex, endIndex):
                        cell = parentTable.getAccessibleAt(row, i)
                        showing = cell.getState().contains( \
                                      pyatspi.STATE_SHOWING)
                        if showing:
                            cellResult = self._generateRealTableCell(cell,
                                                                     **args)
                            if cellResult and result \
                               and self._mode == 'braille':
                                result.append(braille.Region(
                                    object_properties.TABLE_CELL_DELIMITER_BRAILLE))
                            result.extend(cellResult)
                else:
                    result.extend(self._generateRealTableCell(obj, **args))
            else:
                result.extend(self._generateRealTableCell(obj, **args))
        else:
            result.extend(
                braille_generator.BrailleGenerator._generateTableCellRow(
                    self, obj, **args))
        return result
예제 #3
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
        """

        # First pass the event onto the parent class to be handled in
        # the default way.
        #
        default.Script.locusOfFocusChanged(self, event, oldLocusOfFocus,
                                           newLocusOfFocus)

        # Correctly handle the "System" tab (see Orca bug #433818).
        # If the locus of focus is on a page tab in the main GNOME
        # System Monitor window, then get a list of all the panels
        # on that page. For all of the panels that have a name, find
        # all the unrelated labels and speak them.
        #
        rolesList = [rolenames.ROLE_PAGE_TAB, \
                     rolenames.ROLE_PAGE_TAB_LIST, \
                     rolenames.ROLE_FILLER, \
                     rolenames.ROLE_FRAME]
        if self.isDesiredFocusedItem(event.source, rolesList):
            debug.println(
                self.debugLevel,
                "GNOME System Monitor.locusOfFocusChanged - page tab.")
            line = braille.getShowingLine()
            utterances = []
            panels = self.findByRole(newLocusOfFocus, rolenames.ROLE_PANEL)
            for panel in panels:
                if panel.name and len(panel.name) > 0:
                    line.addRegion(braille.Region(" " + panel.name))
                    utterances.append(panel.name)
                    labels = self.findUnrelatedLabels(panel)
                    for label in labels:
                        line.addRegion(braille.Region(" " + label.name))
                        utterances.append(label.name)

            speech.speakUtterances(utterances)
            braille.refresh()
예제 #4
0
    def generateContents(self, contents, **args):
        if not len(contents):
            return []

        result = []
        contents = self._script.utilities.filterContentsForPresentation(
            contents, False)

        obj, offset = self._script.utilities.getCaretContext(
            documentFrame=None)
        index = self._script.utilities.findObjectInContents(
            obj, offset, contents)

        lastRegion = None
        focusedRegion = None
        for i, content in enumerate(contents):
            acc, start, end, string = content
            regions, fRegion = self.generateBraille(acc,
                                                    startOffset=start,
                                                    endOffset=end,
                                                    string=string,
                                                    index=i,
                                                    total=len(contents))
            if not regions:
                continue

            if i == index:
                focusedRegion = fRegion

            if lastRegion and regions:
                if lastRegion.string:
                    lastChar = lastRegion.string[-1]
                else:
                    lastChar = ""
                if regions[0].string:
                    nextChar = regions[0].string[0]
                else:
                    nextChar = ""
                if self._script.utilities.needsSeparator(lastChar, nextChar):
                    regions.insert(0, braille.Region(" "))

            lastRegion = regions[-1]
            result.append(regions)

        return result, focusedRegion
예제 #5
0
 def _generateTableCellDelimiter(self, obj, **args):
     return braille.Region(object_properties.TABLE_CELL_DELIMITER_BRAILLE)
예제 #6
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)