Changeset 2505

Show
Ignore:
Timestamp:
11/17/08 13:24:42 (7 weeks ago)
Author:
bzr
Message:

Changes to support position information in IAccessible2, and to improve management of position information in speech.
*Removed the positionString and level properties on NVDAObjects, and replaced them with a 'positionInfo' property. This property is a dictionary containing 'level', 'indexInGroup', and 'similarItemsInGroup'.
*Implemented support for IAccessible2's groupPosition property, which maps back to NVDA's positionInfo property.
*As we now support IAccessible2 groupPosition, there is no need to grab this info from the description property on Gecko IAccessible objects. This change though does mean that Gecko 1.8 applications (no IAccessible2) will no longer hard their positionInfo read -- I can add it back in for those if people truely want that.
*speech.speakObjectProperties, speech.getSpeechTextForProperties, deal with positionInfo, but as three separate properties: positionInfo_level, positionInfo_indexInGroup and positionInfo_similarItemsInGroup. Splitting these means that they can then be cached/enabled/disabled separately.
*speech.getSpeechTextForProperties no longer generates text for unknown properties. This seems to not be needed anymore. Even if it was, the names wouldn't have been translatable.

Location:
trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk

    • Property bzr:revision-info
      •  

        old new  
        1 timestamp: 2008-11-16 14:03:55.767999887 +1100 
         1timestamp: 2008-11-18 00:21:47.572999954 +1100 
        22committer: Michael Curran <mick@kulgan.net> 
        33properties:  
        44        branch-nick: main 
        5         rebase-of: mick@kulgan.net-20081116030355-hlgvawwkchs8f3kw 
    • Property bzr:revision-id:v3-list-QlpoOTFBWSZTWbrL2vUAAB1VgAAQABCAQDrrnqAgAFCgaaGRkxBoTIJ6mmaNRwhndFAoNhZjh_YY4a01fOg1ulgNNC2UrzPdXXEnDpX8XckU4UJC6y9r1A..
      •  

        old new  
        2742742302 peter.v@datagate.sk-20081115151536-i58km19q3qvzcef6 
        2752752303 mick@kulgan.net-20081116030355-7lzsm5jf7pzpebal 
         2762304 mick@kulgan.net-20081117132147-0s0gw63lue1v5xar 
    • Property bzr:file-ids
      •  

        old new  
        1 source/IAccessibleHandler.py    267@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FIAccessibleHandler.py 
        2 source/NVDAObjects/IAccessible/akelEdit.py      2320@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FIAccessible%2FakelEdit.py 
        3 source/NVDAObjects/IAccessible/edit.py  885@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FIAccessible%2Fedit.py 
        4 source/NVDAObjects/IAccessible/scintilla.py     829@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FIAccessible%2Fscintilla.py 
         1source/NVDAObjects/IAccessible/__init__.py      683@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FIAccessible%2F__init__.py 
        52source/NVDAObjects/IAccessible/sysListView32.py 683@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FIAccessible%2FsysListView32.py 
        6 source/appModules/miranda32.py  1236@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FappModules%2Fmiranda32.py 
        7 source/appModules/winamp.py     1059@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FappModules%2Fwinamp.py 
         3source/NVDAObjects/IAccessible/sysTreeView32.py 834@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FIAccessible%2FsysTreeView32.py 
         4source/NVDAObjects/JAB/__init__.py      683@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FJAB%2F__init__.py 
         5source/NVDAObjects/__init__.py  683@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2F__init__.py 
         6source/braille.py       braille.py-20080908070240-tjwqjsv7drp1kt8c-1 
         7source/speech.py        503@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2Fspeech.py 
  • trunk/source/NVDAObjects/IAccessible/__init__.py

    r2468 r2505  
    6767        if rawDescription.startswith('Description: '): 
    6868                obj.description=rawDescription[13:] 
    69                 return 
    70         m=re_gecko_level.match(rawDescription) 
    71         groups=m.groups() if m else [] 
    72         if len(groups)>=1: 
    73                 level=_("level %s")%groups[0] 
    7469        else: 
    75                 level=None 
    76         m=re_gecko_position.match(rawDescription) 
    77         groups=m.groups() if m else [] 
    78         if len(groups)==2: 
    79                 positionString=_("%s of %s")%(groups[0],groups[1]) 
    80         else: 
    81                 positionString=None 
    82         m=re_gecko_contains.match(rawDescription) 
    83         groups=m.groups() if m else [] 
    84         if len(groups)>=1: 
    85                 contains=_("contains %s items")%groups[0] 
    86         else: 
    87                 contains=None 
    88                 obj.positionString=" ".join([x for x in level,positionString,contains if x]) 
    89         obj.description="" 
     70                obj.description="" 
    9071 
    9172class IA2TextTextInfo(NVDAObjectTextInfo): 
     
    700681                                log.debugWarning("IAccessible2::scrollTo failed", exc_info=True) 
    701682 
    702         def _get_positionString(self): 
    703                 position="" 
    704                 childID=self.IAccessibleChildID 
    705                 if childID>0: 
     683        def _get_positionInfo(self): 
     684                info={} 
     685                try: 
     686                        groupPosition=list(self.IAccessibleObject.groupPosition) 
     687                except: 
     688                        groupPosition=[0,0,0] 
     689                if groupPosition[2]==0 and self.IAccessibleChildID>0: 
     690                        groupPosition[2]=self.IAccessibleChildID 
     691                if groupPosition[1]==0: 
    706692                        parent=self.parent 
    707693                        if parent: 
    708                                 parentChildCount=parent.childCount 
    709                                 if parentChildCount>=childID: 
    710                                         position=_("%s of %s")%(childID,parentChildCount) 
    711                 return position 
     694                                groupPosition[1]=parent.childCount 
     695                if groupPosition[0]: 
     696                        info['level']=groupPosition[0] 
     697                if groupPosition[1]: 
     698                        info['similarItemsInGroup']=groupPosition[1] 
     699                if groupPosition[2]: 
     700                        info['indexInGroup']=groupPosition[2] 
     701                return info 
    712702 
    713703        def event_valueChange(self): 
  • trunk/source/NVDAObjects/IAccessible/sysListView32.py

    r2504 r2505  
    221221                return super(ListItem,self)._get_description() 
    222222 
    223         def _get_positionString(self): 
     223        def _get_positionInfo(self): 
     224                info=super(ListItem,self)._get_positionInfo() 
    224225                totalCount=winUser.sendMessage(self.windowHandle,LVM_GETITEMCOUNT,0,0) 
    225                 return _("%s of %s")%(self.IAccessibleChildID,totalCount) 
     226                info['similarItemsInGroup']=totalCount 
     227                return info 
    226228 
    227229        def event_stateChange(self): 
  • trunk/source/NVDAObjects/IAccessible/sysTreeView32.py

    r2411 r2505  
    132132                return len(self.children) 
    133133 
    134         def _get_positionString(self): 
    135                 if self.IAccessibleChildID==0: 
    136                         return super(self.__class__,self)._get_positionString() 
    137                 hItem=winUser.sendMessage(self.windowHandle,TVM_MAPACCIDTOHTREEITEM,self.IAccessibleChildID,0) 
    138                 if not hItem: 
    139                         return None 
    140                 newItem=hItem 
    141                 index=0 
    142                 while newItem>0: 
    143                         index+=1 
    144                         newItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_PREVIOUS,newItem) 
    145                 newItem=hItem 
    146                 numItems=index-1 
    147                 while newItem>0: 
    148                         numItems+=1 
    149                         newItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_NEXT,newItem) 
    150                 return _("%d of %d")%(index,numItems) 
     134        def _get_positionInfo(self): 
     135                info=super(TreeViewItem,self)._get_positionInfo() 
     136                if self.IAccessibleChildID>0: 
     137                        hItem=winUser.sendMessage(self.windowHandle,TVM_MAPACCIDTOHTREEITEM,self.IAccessibleChildID,0) 
     138                        if not hItem: 
     139                                return info 
     140                        newItem=hItem 
     141                        index=0 
     142                        while newItem>0: 
     143                                index+=1 
     144                                newItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_PREVIOUS,newItem) 
     145                        newItem=hItem 
     146                        numItems=index-1 
     147                        while newItem>0: 
     148                                numItems+=1 
     149                                newItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_NEXT,newItem) 
     150                        info['indexInGroup']=index 
     151                        info['similarItemsInGroup']=numItems 
     152                return info 
     153 
    151154 
    152155        def event_stateChange(self): 
  • trunk/source/NVDAObjects/JAB/__init__.py

    r2423 r2505  
    250250                        return False 
    251251 
    252         def _get_positionString(self): 
     252        def _get_positionInfo(self): 
    253253                if self._JABAccContextInfo.childrenCount: 
    254                         return None 
     254                        return {} 
    255255                parent=self.parent 
    256256                if not isinstance(parent,JAB) or (self.role!=controlTypes.ROLE_RADIOBUTTON and parent.role not in [controlTypes.ROLE_TREEVIEW,controlTypes.ROLE_LIST]): 
    257                         return None 
     257                        return {} 
    258258                index=self._JABAccContextInfo.indexInParent+1 
    259259                childCount=parent._JABAccContextInfo.childrenCount 
    260                 return _("%d of %d")%(index,childCount) 
    261  
     260                return {'indexInGroup':index,'similarItemsInGroup':childCount} 
    262261 
    263262 
  • trunk/source/NVDAObjects/__init__.py

    r2487 r2505  
    349349@ivar description: The object's description. (e.g. Further info to describe the button's action to go with the label)  
    350350@type description: string 
    351 @ivar positionString: a description of where the object is in relation to other objects around it. (e.g. a list item might say 2 of 5). 
    352 @type positionString: string 
     351@ivar positionInfo: A dict of 'indexInGroup', 'similarItemsInGroup', and 'level', describing the object's position. 
     352@type positionInfo: dict 
    353353@ivar location: The object's location. (A tuple of left, top, width, depth). 
    354354@type location: 4-tuple (int) 
     
    586586                return None 
    587587 
    588         def _get_positionString(self): 
    589                 return None 
     588        def _get_positionInfo(self): 
     589                return {} 
    590590 
    591591        def _get_isProtected(self): 
  • trunk/source/braille.py

    r2489 r2505  
    213213        if keyboardShortcut: 
    214214                textList.append(keyboardShortcut) 
    215         positionString = propertyValues["positionString"] 
    216         if positionString: 
    217                 textList.append(positionString) 
    218         level = propertyValues.get("level") 
    219         if level: 
    220                 textList.append(_("lvl %s") % level) 
     215        positionInfo = propertyValues["positionInfo"] 
     216        if positionInfo: 
     217                if 'indexInGroup' in positionInfo and 'similarItemsInGroup' in positionInfo: 
     218                        textList.append(_("%s of %s")%(positionInfo['indexInGroup'],positionInfo['similarItemsInGroup'])) 
     219                if 'level' in positionInfo: 
     220                        textList.append(_('level %s')%positionInfo['level']) 
    221221        return " ".join([x for x in textList if x]) 
    222222 
     
    240240        def update(self): 
    241241                obj = self.obj 
    242                 text = getBrailleTextForProperties(name=obj.name, role=obj.role, value=obj.value, states=obj.states, description=obj.description, keyboardShortcut=obj.keyboardShortcut, positionString=obj.positionString) 
     242                text = getBrailleTextForProperties(name=obj.name, role=obj.role, value=obj.value, states=obj.states, description=obj.description, keyboardShortcut=obj.keyboardShortcut, positionInfo=obj.positionInfo) 
    243243                self.rawText = text + self.appendText 
    244244                super(NVDAObjectRegion, self).update() 
  • trunk/source/speech.py

    r2420 r2505  
    194194        #Fetch the values for all wanted properties 
    195195        newPropertyValues={} 
     196        positionInfo=None 
    196197        for name,value in allowedProperties.iteritems(): 
    197                 if value: 
     198                if name.startswith('positionInfo_') and value: 
     199                        if positionInfo is None: 
     200                                positionInfo=obj.positionInfo 
     201                elif value: 
    198202                        newPropertyValues[name]=getattr(obj,name) 
     203        if positionInfo: 
     204                if allowedProperties.get('positionInfo_level',False) and 'level' in positionInfo: 
     205                        newPropertyValues['positionInfo_level']=positionInfo['level'] 
     206                if allowedProperties.get('positionInfo_indexInGroup',False) and 'indexInGroup' in positionInfo: 
     207                        newPropertyValues['positionInfo_indexInGroup']=positionInfo['indexInGroup'] 
     208                if allowedProperties.get('positionInfo_similarItemsInGroup',False) and 'similarItemsInGroup' in positionInfo: 
     209                        newPropertyValues['positionInfo_similarItemsInGroup']=positionInfo['similarItemsInGroup'] 
    199210        #Fetched the cached properties and update them with the new ones 
    200211        oldCachedPropertyValues=getattr(obj,'_speakObjectPropertiesCache',{}).copy() 
     
    226237def speakObject(obj,reason=REASON_QUERY,index=None): 
    227238        isEditable=bool(obj.role==controlTypes.ROLE_EDITABLETEXT or controlTypes.STATE_EDITABLE in obj.states) 
    228         allowProperties={'name':True,'role':True,'states':True,'value':True,'description':True,'keyboardShortcut':True,'positionString':True} 
     239        allowProperties={'name':True,'role':True,'states':True,'value':True,'description':True,'keyboardShortcut':True,'positionInfo_level':True,'positionInfo_indexInGroup':True,'positionInfo_similarItemsInGroup':True} 
    229240        if not config.conf["presentation"]["reportObjectDescriptions"]: 
    230241                allowProperties["description"]=False 
     
    232243                allowProperties["keyboardShortcut"]=False 
    233244        if not config.conf["presentation"]["reportObjectPositionInformation"]: 
    234                 allowProperties["positionString"]=False 
     245                allowProperties["positionInfo_level"]=False 
     246                allowProperties["positionInfo_indexInGroup"]=False 
     247                allowProperties["positionInfo_similarItemsInGroup"]=False 
    235248        if isEditable: 
    236249                allowProperties['value']=False 
     
    542555        if 'name' in propertyValues: 
    543556                textList.append(propertyValues['name']) 
    544                 del propertyValues['name'] 
    545557        if 'role' in propertyValues: 
    546558                role=propertyValues['role'] 
    547559                if reason not in (REASON_SAYALL,REASON_CARET,REASON_FOCUS) or role not in silentRolesOnFocus: 
    548560                        textList.append(controlTypes.speechRoleLabels[role]) 
    549                 del propertyValues['role'] 
    550561        elif '_role' in propertyValues: 
    551562                role=propertyValues['_role'] 
     
    555566                if not role in silentValuesForRoles: 
    556567                        textList.append(propertyValues['value']) 
    557                 del propertyValues['value'] 
    558568        states=propertyValues.get('states') 
    559569        realStates=propertyValues.get('_states',states) 
     
    561571                positiveStates=processPositiveStates(role,realStates,reason,states) 
    562572                textList.extend([controlTypes.speechStateLabels[x] for x in positiveStates]) 
    563                 del propertyValues['states'] 
    564573        if 'negativeStates' in propertyValues: 
    565574                negativeStates=propertyValues['negativeStates'] 
    566                 del propertyValues['negativeStates'] 
    567575        else: 
    568576                negativeStates=None 
     
    572580        if 'description' in propertyValues: 
    573581                textList.append(propertyValues['description']) 
    574                 del propertyValues['description'] 
    575582        if 'keyboardShortcut' in propertyValues: 
    576583                textList.append(propertyValues['keyboardShortcut']) 
    577                 del propertyValues['keyboardShortcut'] 
    578         if 'positionString' in propertyValues: 
    579                 textList.append(propertyValues['positionString']) 
    580                 del propertyValues['positionString'] 
    581         if 'level' in propertyValues: 
    582                 levelNo=propertyValues['level'] 
    583                 del propertyValues['level'] 
    584                 if levelNo is not None or reason not in (REASON_SAYALL,REASON_CARET,REASON_FOCUS): 
    585                         textList.append(_("level %s")%levelNo) 
    586         for name,value in propertyValues.items(): 
    587                 if not name.startswith('_') and value is not None and value is not "": 
    588                         textList.append(name) 
    589                         textList.append(unicode(value)) 
     584        if 'positionInfo_indexInGroup' in propertyValues and 'positionInfo_similarItemsInGroup' in propertyValues: 
     585                textList.append(_("%s of %s")%(propertyValues['positionInfo_indexInGroup'],propertyValues['positionInfo_similarItemsInGroup'])) 
     586        if 'positionInfo_level' in propertyValues: 
     587                textList.append(_('level %s')%propertyValues['positionInfo_level']) 
    590588        return " ".join([x for x in textList if x]) 
    591589 
     
    616614        keyboardShortcutText=getSpeechTextForProperties(reason=reason,keyboardShortcut=keyboardShortcut) 
    617615        nameText=getSpeechTextForProperties(reason=reason,name=name) 
    618         levelText=getSpeechTextForProperties(reason=reason,level=level) 
     616        levelText=getSpeechTextForProperties(reason=reason,positionInfo_level=level) 
    619617        if not extraDetail and ((reason==REASON_FOCUS and fieldType in ("end_relative","end_inControlFieldStack")) or (reason in (REASON_CARET,REASON_SAYALL) and fieldType in ("start_inControlFieldStack","start_addedToControlFieldStack","start_relative"))) and role in (controlTypes.ROLE_LINK,controlTypes.ROLE_HEADING,controlTypes.ROLE_BUTTON,controlTypes.ROLE_RADIOBUTTON,controlTypes.ROLE_CHECKBOX,controlTypes.ROLE_GRAPHIC,controlTypes.ROLE_SEPARATOR,controlTypes.ROLE_MENUITEM): 
    620618                if role==controlTypes.ROLE_LINK: