コード例 #1
0
    def _generatePageSummary(self, obj, **args):
        """Returns an array of strings (and possibly voice and audio
        specifications) that summarize the objects found on the page
        containing obj.
        """
        result = []
        acss = self.voice(speech_generator.DEFAULT)
        headings, forms, tables, vlinks, uvlinks, percent = \
            self._script.getPageSummary(obj)
        if headings:
            # Translators: Announces the number of headings in the
            # web page that is currently being displayed.
            #
            result.append(ngettext \
                ('%d heading', '%d headings', headings) % headings)
        if forms:
            # Translators: Announces the number of forms in the
            # web page that is currently being displayed.
            #
            result.append(ngettext('%d form', '%d forms', forms) % forms)
        if tables:
            # Translators: Announces the number of non-layout tables in the
            # web page that is currently being displayed.
            #
            result.append(ngettext('%d table', '%d tables', tables) % tables)
        if vlinks:
            # Translators: Announces the number of visited links in the
            # web page that is currently being displayed.
            #
            result.append(ngettext \
                ('%d visited link', '%d visited links', vlinks) % vlinks)
        if uvlinks:
            # Translators: Announces the number of unvisited links in the
            # web page that is currently being displayed.
            #
            result.append(ngettext \
                ('%d unvisited link', '%d unvisited links', uvlinks) % uvlinks)
        if percent is not None:
            # Translators: Announces the percentage of the document that has
            # been read.  This is calculated by knowing the index of the
            # current position divided by the total number of objects on the
            # page.
            #
            result.append(ngettext \
                ('%d percent of document read',
                 '%d percent of document read',
                 percent) % percent)

        if result:
            result.extend(acss)
        return result
コード例 #2
0
ファイル: script.py プロジェクト: Alberto-Beralix/Beralix
    def getItemCount(self, frame):
        """Return a string containing the number of items in the current
        folder.

        Arguments:
        - frame: the top-level frame for this Nautilus window.

        Return a string containing the number of items in the current
        folder.
        """

        itemCount = -1
        itemCountString = " "
        allScrollPanes = self.utilities.descendantsWithRole(
            frame, pyatspi.ROLE_SCROLL_PANE)
        rolesList = [pyatspi.ROLE_SCROLL_PANE,
                     pyatspi.ROLE_FILLER,
                     pyatspi.ROLE_FILLER,
                     pyatspi.ROLE_SPLIT_PANE,
                     pyatspi.ROLE_PANEL,
                     pyatspi.ROLE_FRAME,
                     pyatspi.ROLE_APPLICATION]

        # Look for the scroll pane containing the folder items. If this
        # window is showing an icon view, then the child will be a layered
        # pane. If it's showing a list view, then the child will be a table.
        # Create a string of the number of items in the folder.
        #
        for pane in allScrollPanes:
            if self.utilities.hasMatchingHierarchy(pane, rolesList):
                for i in range(0, pane.childCount):
                    child = pane.getChildAtIndex(i)
                    if child.getRole() == pyatspi.ROLE_LAYERED_PANE:
                        itemCount = child.childCount
                    elif child.getRole() == pyatspi.ROLE_TABLE:
                        try:
                            itemCount = child.queryTable().nRows
                        except NotImplementedError:
                            itemCount = -1
                    if itemCount != -1:
                        itemCountString = " " + ngettext("%d item",
                                                         "%d items",
                                                         itemCount) % itemCount
                    break

        return itemCountString
コード例 #3
0
    def _generateNumberOfChildren(self, obj, **args):
        if _settingsManager.getSetting('onlySpeakDisplayedText'):
            return []

        result = []
        acss = self.voice(speech_generator.SYSTEM)
        role = args.get('role', obj.getRole())
        if role == pyatspi.ROLE_LIST:
            # Translators: this represents a list in HTML.
            #
            result.append(ngettext("List with %d item",
                                   "List with %d items",
                                   obj.childCount) % obj.childCount)
            result.extend(acss)
        else:
            result.extend(
                speech_generator.SpeechGenerator._generateNumberOfChildren(
                    self, obj, **args))
        return result
コード例 #4
0
    def getItemCount(self, frame):
        """Return a string containing the number of items in the current 
        folder.

        Arguments:
        - frame: the top-level frame for this Nautilus window.

        Return a string containing the number of items in the current 
        folder.
        """

        itemCount = -1
        itemCountString = " "
        allScrollPanes = self.findByRole(frame, rolenames.ROLE_SCROLL_PANE)
        rolesList = [rolenames.ROLE_SCROLL_PANE, \
                     rolenames.ROLE_FILLER, \
                     rolenames.ROLE_FILLER, \
                     rolenames.ROLE_SPLIT_PANE, \
                     rolenames.ROLE_PANEL, \
                     rolenames.ROLE_FRAME, \
                     rolenames.ROLE_APPLICATION]

        # Look for the scroll pane containing the folder items. If this
        # window is showing an icon view, then the child will be a layered
        # pane. If it's showing a list view, then the child will be a table.
        # Create a string of the number of items in the folder.
        #
        for pane in allScrollPanes:
            if self.isDesiredFocusedItem(pane, rolesList):
                for i in range(0, pane.childCount):
                    child = pane.child(i)
                    if child.role == rolenames.ROLE_LAYERED_PANE:
                        itemCount = child.childCount
                    elif child.role == rolenames.ROLE_TABLE:
                        itemCount = child.table.nRows
                    if itemCount != -1:
                        itemCountString = " " + ngettext(
                            "%d item", "%d items", itemCount) % itemCount
                    break

        return itemCountString
コード例 #5
0
    def _generateTooLong(self, obj, **args):
        """If there is text in this spread sheet cell, compare the size of
        the text within the table cell with the size of the actual table
        cell and report back to the user if it is larger.

        Returns an indication of how many characters are greater than the size
        of the spread sheet cell, or None if the message fits.
        """
        if _settingsManager.getSetting('onlySpeakDisplayedText'):
            return []

        result = []
        acss = self.voice(speech_generator.SYSTEM)
        try:
            text = obj.queryText()
            objectText = \
                self._script.utilities.substring(obj, 0, -1).decode("UTF-8")
            extents = obj.queryComponent().getExtents(pyatspi.DESKTOP_COORDS)
        except NotImplementedError:
            pass
        else:
            tooLongCount = 0
            for i in range(0, len(objectText)):
                [x, y, width, height] = text.getRangeExtents(i, i + 1, 0)
                if x < extents.x:
                    tooLongCount += 1
                elif (x + width) > extents.x + extents.width:
                    tooLongCount += len(objectText) - i
                    break
            if tooLongCount > 0:
                # Translators: people can enter a string of text that is
                # too wide for a spreadsheet cell.  This string will be
                # spoken if such a cell is encountered.
                #
                result = [ngettext("%d character too long",
                                   "%d characters too long",
                                   tooLongCount) % tooLongCount]
        if result:
            result.extend(acss)
        return result
コード例 #6
0
    def _generateNumberOfChildren(self, obj, **args):
        """Returns an array of strings (and possibly voice and audio
        specifications) that represents the number of children the
        object has."""

        if _settingsManager.getSetting('onlySpeakDisplayedText'):
            return []

        result = []
        acss = self.voice(speech_generator.SYSTEM)
        if obj and obj.getState().contains(pyatspi.STATE_EXPANDED) \
           and obj.getRole() == pyatspi.ROLE_LABEL and obj.childCount:
            children = obj.childCount
            # Translators: this is the number of items in a layered
            # pane or table.
            #
            items = ngettext("%d item", "%d items", children) % children
            result.append(items)
            result.extend(acss)
        else:
            result.extend(speech_generator.SpeechGenerator.\
                          _generateNumberOfChildren(self, obj, **args))

        return result
コード例 #7
0
ファイル: script.py プロジェクト: Alberto-Beralix/Beralix
    def onStateChanged(self, event):
        """Called whenever an object's state changes.

        Arguments:
        - event: the Event
        """

        details = debug.getAccessibleDetails(self.debugLevel, event.source)
        debug.printObjectEvent(self.debugLevel, event, details)

        # self.printAncestry(event.source)

        rolesList = [pyatspi.ROLE_PUSH_BUTTON, \
                    pyatspi.ROLE_FILLER, \
                    pyatspi.ROLE_FILLER, \
                    pyatspi.ROLE_FILLER, \
                    pyatspi.ROLE_FRAME, \
                    pyatspi.ROLE_APPLICATION]
        visible = event.source.getState().contains(pyatspi.STATE_VISIBLE)

        # Check to see if we have just had an "object:state-changed:showing"
        # event for the Stop button. If the name is "Stop", and one of its
        # states is VISIBLE, that means we have started a search. As the
        # search progresses, regularly inform the user of this by speaking
        # "Searching" (assuming the search tool has focus).
        #
        # Translators: the "Stop" string must match what gnome-search-tool
        # is using.  We hate keying off stuff like this, but we're forced
        # to do so in this case.
        #
        if self.utilities.hasMatchingHierarchy(event.source, rolesList) and \
           event.source.name == _("Stop") and visible:
            debug.println(self.debugLevel,
                          "gnome-search-tool.onNameChanged - " \
                          + "search started.")

            self.searching = True

            # If we don't already have a handle to the table containing the
            # list of files found, then get it now.
            #
            if not self.fileTable:
                frame = self.utilities.topLevelObject(event.source)
                allTables = self.utilities.descendantsWithRole(
                    frame, pyatspi.ROLE_TABLE)
                self.fileTable = allTables[0]

            GObject.idle_add(self._speakSearching)

        # Check to see if we have just had an "object:state-changed:showing"
        # event for the Find button. If the name is "Find", and one of its
        # states is VISIBLE and we are currently searching, that means we
        # have just stopped a search. Inform the user that the search is
        # complete and tell them how many files were found.
        #
        # Translators: the "Find" string must match what gnome-search-tool
        # is using.  We hate keying off stuff like this, but we're forced
        # to do so in this case.
        #
        if self.utilities.hasMatchingHierarchy(event.source, rolesList) \
           and event.source.name == _("Find") and visible and self.searching:
            debug.println(self.debugLevel,
                          "gnome-search-tool.onNameChanged - " \
                          + "search completed.")

            self.searching = False
            self.presentMessage(_("Search complete."))
            sensitive = self.fileTable.getState().contains( \
                                                pyatspi.STATE_SENSITIVE)
            if sensitive:
                try:
                    fileCount = self.fileTable.queryTable().nRows
                except NotImplementedError:
                    fileCount = 0
                noFilesString = ngettext("%d file found",
                                         "%d files found",
                                         fileCount) % fileCount
                self.presentMessage(noFilesString)
            else:
                self.presentMessage(_("No files found."))

        # Pass the event onto the parent class to be handled in the default way.
        #
        default.Script.onStateChanged(self, event)
コード例 #8
0
ファイル: script.py プロジェクト: thnguyn2/ECE_527_MP
    def checkForTableBoundary (self, oldFocus, newFocus):
        """Check to see if we've crossed any table boundaries,
        speaking the appropriate details when we have.

        Arguments:
        - oldFocus: Accessible that is the old locus of focus
        - newFocus: Accessible that is the new locus of focus
        """

        if oldFocus == None or newFocus == None:
            return

        [oldFocusIsTable, oldFocusRows, oldFocusColumns] = \
                   self.getTableAndDimensions(oldFocus)
        [newFocusIsTable, newFocusRows, newFocusColumns] = \
                   self.getTableAndDimensions(newFocus)

        # [[[TODO: JD - It is possible to move focus into the object
        # that contains the object that contains the text object. We
        # need to detect this and adjust accordingly.]]]

        if not oldFocusIsTable and newFocusIsTable:
            # Translators: this represents the number of rows in a table.
            #
            rowString = ngettext("table with %d row",
                                 "table with %d rows",
                                 newFocusRows) % newFocusRows
            # Translators: this represents the number of columns in a table.
            #
            colString = ngettext("%d column",
                                 "%d columns",
                                 newFocusColumns) % newFocusColumns

            line = rowString + " " + colString
            self.presentMessage(line)

        elif oldFocusIsTable and not newFocusIsTable:
            # We've left a table.  Announce this fact.
            #
            self.presentMessage(_("leaving table."))

        elif oldFocusIsTable and newFocusIsTable:
            # See if we've crossed a cell boundary.  If so, speak
            # what has changed (per Mike).
            #
            [oldRow, oldCol] = \
                   self.getCellCoordinates(oldFocusIsTable, oldFocus)
            [newRow, newCol] = \
                   self.getCellCoordinates(newFocusIsTable, newFocus)
            # We can't count on being in the first/last cell
            # of the new row -- only the first/last cell of
            # the new row that contains data.
            #
            if newRow != oldRow:
                # Translators: this represents the row and column we're
                # on in a table.
                #
                line = _("row %(row)d, column %(column)d") \
                       % {"row": newRow, "column": newCol}
                self.presentMessage(line)
            elif newCol != oldCol:
                # Translators: this represents the column we're
                # on in a table.
                #
                line = _("column %d") % newCol
                self.presentMessage(line)
コード例 #9
0
    def onStateChanged(self, event):
        """Called whenever an object's state changes.

        Arguments:
        - event: the Event
        """

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

        # self.printAncestry(event.source)

        rolesList = [rolenames.ROLE_PUSH_BUTTON, \
                    rolenames.ROLE_FILLER, \
                    rolenames.ROLE_FILLER, \
                    rolenames.ROLE_FILLER, \
                    rolenames.ROLE_FRAME, \
                    rolenames.ROLE_APPLICATION]
        visible = event.source.state.count( \
                               atspi.Accessibility.STATE_VISIBLE)

        # Check to see if we have just had an "object:state-changed:showing"
        # event for the Stop button. If the name is "Stop", and one of its
        # states is VISIBLE, that means we have started a search. As the
        # search progresses, regularly inform the user of this by speaking
        # "Searching" (assuming the search tool has focus).
        #
        # Translators: the "Stop" string must match what gnome-search-tool
        # is using.  We hate keying off stuff like this, but we're forced
        # to do so in this case.
        #
        if self.isDesiredFocusedItem(event.source, rolesList) and \
           event.source.name == _("Stop") and visible:
            debug.println(self.debugLevel,
                          "gnome-search-tool.onNameChanged - " \
                          + "search started.")

            self.searching = True

            # If we don't already have a handle to the table containing the
            # list of files found, then get it now.
            #
            if not self.fileTable:
                frame = self.getTopLevel(event.source)
                allTables = self.findByRole(frame, rolenames.ROLE_TABLE)
                self.fileTable = allTables[0]

            gobject.idle_add(self._speakSearching)

        # Check to see if we have just had an "object:state-changed:showing"
        # event for the Find button. If the name is "Find", and one of its
        # states is VISIBLE and we are currently searching, that means we
        # have just stopped a search. Inform the user that the search is
        # complete and tell them how many files were found.
        #
        # Translators: the "Find" string must match what gnome-search-tool
        # is using.  We hate keying off stuff like this, but we're forced
        # to do so in this case.
        #
        if self.isDesiredFocusedItem(event.source, rolesList) and \
           event.source.name == _("Find") and visible and self.searching:
            debug.println(self.debugLevel,
                          "gnome-search-tool.onNameChanged - " \
                          + "search completed.")

            self.searching = False
            speech.speak(_("Search complete."))
            sensitive = self.fileTable.state.count( \
                               atspi.Accessibility.STATE_SENSITIVE)
            if sensitive:
                fileCount = self.fileTable.table.nRows
                noFilesString = ngettext("%d file found", "%d files found",
                                         fileCount) % fileCount
                speech.speak(noFilesString)
            else:
                speech.speak(_("No files found."))

        # Pass the event onto the parent class to be handled in the default way.
        #
        default.Script.onStateChanged(self, event)