OSDN Git Service

explorer: If UIA isn't available (e.g. on XP/Vista), don't try to import UIA NVDAObjects.
authorJames Teh <jamie@jantrid.net>
Mon, 15 Oct 2012 00:23:13 +0000 (10:23 +1000)
committerJames Teh <jamie@jantrid.net>
Mon, 15 Oct 2012 00:23:13 +0000 (10:23 +1000)
Fixes #2718.

source/appModules/explorer.py

index 84aca37..ebb3eb6 100644 (file)
@@ -13,7 +13,9 @@ import eventHandler
 import mouseHandler\r
 from NVDAObjects.window import Window\r
 from NVDAObjects.IAccessible import sysListView32, IAccessible\r
-from NVDAObjects.UIA import UIA\r
+import UIAHandler\r
+if UIAHandler.isUIAAvailable:\r
+       from NVDAObjects.UIA import UIA\r
 \r
 #win8hack: Class to disable incorrect focus on windows 8 search box (containing the already correctly focused edit field)\r
 class SearchBoxClient(IAccessible):\r
@@ -75,23 +77,24 @@ class NotificationArea(IAccessible):
                        return\r
                super(NotificationArea, self).event_gainFocus()\r
 \r
-class GridTileElement(UIA):\r
+if UIAHandler.isUIAAvailable:\r
+       class GridTileElement(UIA):\r
 \r
-       role=controlTypes.ROLE_TABLECELL\r
+               role=controlTypes.ROLE_TABLECELL\r
 \r
-       def _get_description(self):\r
-               name=self.name\r
-               descriptionStrings=[]\r
-               for child in self.children:\r
-                       description=child.basicText\r
-                       if not description or description==name: continue\r
-                       descriptionStrings.append(description)\r
-               return " ".join(descriptionStrings)\r
-               return description\r
+               def _get_description(self):\r
+                       name=self.name\r
+                       descriptionStrings=[]\r
+                       for child in self.children:\r
+                               description=child.basicText\r
+                               if not description or description==name: continue\r
+                               descriptionStrings.append(description)\r
+                       return " ".join(descriptionStrings)\r
+                       return description\r
 \r
-class GridListTileElement(UIA):\r
-       role=controlTypes.ROLE_TABLECELL\r
-       description=None\r
+       class GridListTileElement(UIA):\r
+               role=controlTypes.ROLE_TABLECELL\r
+               description=None\r
 \r
 class AppModule(appModuleHandler.AppModule):\r
 \r
@@ -129,7 +132,7 @@ class AppModule(appModuleHandler.AppModule):
                                clsList.insert(0, NotificationArea)\r
                                return\r
 \r
-               if isinstance(obj, UIA):\r
+               if UIAHandler.isUIAAvailable and isinstance(obj, UIA):\r
                        uiaClassName = obj.UIAElement.cachedClassName\r
                        if uiaClassName == "GridTileElement":\r
                                clsList.insert(0, GridTileElement)\r