strongwind r20 - in trunk: . strongwind



Author: jtai
Date: Fri Jul 18 18:27:01 2008
New Revision: 20
URL: http://svn.gnome.org/viewvc/strongwind?rev=20&view=rev

Log:
2008-07-18  Jonathan Tai  <jon tgpsolutions com>

	* strongwind/accessibles.py: Add support labelledBy param in generated
	  search functions.  (#543511, CÃsar Octavio LÃpez NatarÃn)


Modified:
   trunk/ChangeLog
   trunk/strongwind/accessibles.py
   trunk/strongwind/utils.py

Modified: trunk/strongwind/accessibles.py
==============================================================================
--- trunk/strongwind/accessibles.py	(original)
+++ trunk/strongwind/accessibles.py	Fri Jul 18 18:27:01 2008
@@ -119,6 +119,10 @@
             return self._accessible.queryText().caretOffset
         elif attr == 'characterCount':
             return self._accessible.queryText().characterCount
+        elif attr == 'getRelationSet':
+            # Never change this line to: self._accessible.queryAccessible().getRelationSet
+            # unexpected problems result from that.
+            return self._accessible.getRelationSet
         elif attr == 'app':
             try:
                 return cache.getApplicationById(self._accessible.getApplication().id)
@@ -174,9 +178,10 @@
                 v = vars(pyatspi)
                 if v.has_key(a):
                     # generate a function on-the-fly and return it
-                    def findMethod(name, logName=None, checkShowing=True, retry=True, recursive=True, breadthFirst=True, raiseException=True, setReference=False):
+                    def findMethod(name, logName=None, checkShowing=True, retry=True, recursive=True, breadthFirst=True, raiseException=True, setReference=False, labelledBy=None):
                         dontCheckShowing = not checkShowing
-                        y = utils.findDescendant(self, lambda x: x.role == v[a] and utils.equalsOrMatches(x.name, name) and (dontCheckShowing or x.showing), \
+                        y = utils.findDescendant(self, lambda x: x.role == v[a] and utils.equalsOrMatches(x.name, name) and (dontCheckShowing or x.showing) \
+                                                     and utils.labelledBy(x, labelledBy),
                             retry=retry, recursive=recursive, breadthFirst=breadthFirst, raiseException=raiseException)
 
                         # don't try promoting y if it's None

Modified: trunk/strongwind/utils.py
==============================================================================
--- trunk/strongwind/utils.py	(original)
+++ trunk/strongwind/utils.py	Fri Jul 18 18:27:01 2008
@@ -181,3 +181,16 @@
 
     assert os.path.exists(path)
 
+def labelledBy(acc, label):
+    if label is None:
+        return True
+
+    for relation in acc.getRelationSet():
+        if relation.getRelationType() == pyatspi.RELATION_LABELLED_BY:
+            for i in range(relation.getNTargets()):
+                target = relation.getTarget(i)
+
+                if target.name == label:
+                    return True
+
+    return False



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]