~stomato463/+junk/nvdajp

« back to all changes in this revision

Viewing changes to source/appModules/utorrent.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:
7
7
u"""App module for µTorrent
8
8
"""
9
9
 
10
 
import _default
 
10
import appModuleHandler
11
11
import api
12
12
import controlTypes
 
13
import displayModel
 
14
from logHandler import log
13
15
from NVDAObjects.IAccessible import IAccessible
 
16
from NVDAObjects.window import Window
14
17
 
15
18
class DuplicateFocusListView(IAccessible):
16
19
        """A list view which annoyingly fires focus events every second, even when a menu is open.
28
31
                        return False
29
32
                return super(DuplicateFocusListView, self).shouldAllowIAccessibleFocusEvent
30
33
 
31
 
class AppModule(_default.AppModule):
 
34
class TorrentContentsListItem(IAccessible):
 
35
        """Items of the Torrent Contents list in the Add Torrent dialog.
 
36
        The file names aren't exposed to MSAA, though the other column (size) is.
 
37
        """
 
38
 
 
39
        def _get_name(self):
 
40
                superName = super(TorrentContentsListItem, self).name
 
41
                if superName:
 
42
                        return superName
 
43
 
 
44
                # We need to use the display model to retrieve the Name column.
 
45
                try:
 
46
                        # We don't want to just use displayText because it also contains the size, which is exposed correctly in the value property.
 
47
                        # Therefore, use the left and right of the Name column as obtained from the column header.
 
48
                        nameHdrLoc = Window._get_firstChild(self).firstChild.firstChild.location
 
49
                        left = nameHdrLoc[0]
 
50
                        right = left + nameHdrLoc[2]
 
51
                        # Use the top and bottom of the list item.
 
52
                        selfLoc = self.location
 
53
                        top = selfLoc[1]
 
54
                        bottom = top + selfLoc[3]
 
55
                        return displayModel.getWindowTextInRect(self.appModule.helperLocalBindingHandle, self.windowHandle,
 
56
                                left, top, right, bottom,
 
57
                                displayModel.DisplayModelTextInfo.minHorizontalWhitespace, displayModel.DisplayModelTextInfo.minVerticalWhitespace)[0]
 
58
                except:
 
59
                        log.debugWarning("Error retrieving name using display model", exc_info=True)
 
60
                        return superName
 
61
 
 
62
class AppModule(appModuleHandler.AppModule):
32
63
 
33
64
        def chooseNVDAObjectOverlayClasses(self, obj, clsList):
 
65
                role = obj.role
 
66
                if role == controlTypes.ROLE_WINDOW:
 
67
                        return
 
68
 
34
69
                if obj.windowClassName == "SysListView32":
35
 
                        clsList.insert(0, DuplicateFocusListView)
 
70
                        if obj.windowControlID == 1206 and role == controlTypes.ROLE_LISTITEM:
 
71
                                clsList.insert(0, TorrentContentsListItem)
 
72
                        else:
 
73
                                clsList.insert(0, DuplicateFocusListView)