~stomato463/+junk/nvdajp

« back to all changes in this revision

Viewing changes to source/appModules/msimn.py

  • Committer: Masataka Shinke
  • Date: 2011-10-25 12:35:26 UTC
  • mfrom: (4185 jpmain)
  • mto: This revision was merged to the branch mainline in revision 4211.
  • Revision ID: mshinke@users.sourceforge.jp-20111025123526-ze527a2rl3z0g2ky
lp:~nishimotz/nvdajp/main : 4185 をマージ

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
import winUser
8
8
import controlTypes
 
9
import displayModel
9
10
import textInfos
10
11
import api
11
 
import _default
 
12
import appModuleHandler
12
13
import speech
13
 
from keyUtils import key, sendKey
 
14
from keyboardHandler import KeyboardInputGesture
 
15
from NVDAObjects.IAccessible import sysListView32
 
16
import watchdog
14
17
 
15
18
#Labels for the header fields of an email, by control ID
16
19
envelopeNames={
30
33
        1037:_("From:"),
31
34
}
32
35
 
33
 
class AppModule(_default.AppModule):
 
36
class AppModule(appModuleHandler.AppModule):
34
37
 
35
38
        def event_NVDAObject_init(self,obj):
36
39
                controlID=obj.windowControlID
44
47
                        obj.useITextDocumentSupport=True
45
48
                        obj.editValueUnit=textInfos.UNIT_STORY
46
49
 
 
50
        def chooseNVDAObjectOverlayClasses(self,obj,clsList):
 
51
                if obj.windowClassName=="SysListView32" and obj.windowControlID in (128,129,130) and obj.role==controlTypes.ROLE_LISTITEM:
 
52
                        clsList.insert(0,MessageRuleListItem)
 
53
                elif "SysListView32" in obj.windowClassName and obj.role==controlTypes.ROLE_LISTITEM and obj.parent.name=="Outlook Express Message List":
 
54
                        clsList.insert(0,MessageListItem)
 
55
 
47
56
        def event_gainFocus(self,obj,nextHandler):
48
57
                nextHandler()
49
58
                #Force focus to move to something sane when landing on an outlook express message window
50
59
                if obj.windowClassName=="ATH_Note" and obj.event_objectID==winUser.OBJID_CLIENT and obj.IAccessibleChildID==0:
51
60
                        api.processPendingEvents()
52
61
                        if obj==api.getFocusObject() and controlTypes.STATE_FOCUSED in obj.states:
53
 
                                return sendKey(key("SHIFT+TAB"))
54
 
 
 
62
                                return KeyboardInputGesture.fromName("shift+tab").send()
 
63
 
 
64
class MessageRuleListItem(sysListView32.ListItem):
 
65
        """Used for the checkbox list items used to select message rule types in in message filters"""
 
66
 
 
67
        role=controlTypes.ROLE_CHECKBOX
 
68
 
 
69
        def _get_states(self):
 
70
                states=super(MessageRuleListItem,self).states
 
71
                if (watchdog.cancellableSendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12)==8:
 
72
                        states.add(controlTypes.STATE_CHECKED)
 
73
                return states
 
74
 
 
75
class MessageListItem(sysListView32.ListItem):
 
76
 
 
77
        def _get_isUnread(self):
 
78
                info=displayModel.DisplayModelTextInfo(self,textInfos.POSITION_FIRST)
 
79
                info.expand(textInfos.UNIT_CHARACTER)
 
80
                fields=info.getTextWithFields()
 
81
                try:
 
82
                        isUnread=fields[1].field['bold']
 
83
                except:
 
84
                        isUnread=False
 
85
                return isUnread
 
86
 
 
87
        def _get_name(self):
 
88
                nameList=[]
 
89
                imageState=watchdog.cancellableSendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12
 
90
                if imageState==5:
 
91
                        nameList.append(controlTypes.speechStateLabels[controlTypes.STATE_COLLAPSED])
 
92
                elif imageState==6:
 
93
                        nameList.append(controlTypes.speechStateLabels[controlTypes.STATE_EXPANDED])
 
94
                if self.isUnread:
 
95
                        nameList.append(_("unread"))
 
96
                name=super(MessageListItem,self).name
 
97
                if name:
 
98
                        nameList.append(name)
 
99
                return " ".join(nameList)