GNOME Bugzilla – Bug 679044
Wrap all interfaces
Last modified: 2015-02-27 16:40:34 UTC
Looking at a File menu in Accerciser's iPython console: In [1]: acc.name Out[1]: 'File' In [1]: acc.get_name() Out[2]: 'File' In [2]: acc.getName(0) Out[3]: 'click' At best this is confusing. The problem is that in the introspected world, we are seeing queryIfaceName() returning the accessible object for which the interface is being sought, rather than the interface like we used to get prior to introspection: In [3]: acc.queryAction() == acc Out[4]: True This is not the case for all interfaces; just most of them. From IRC: ~~~~ <mgorse> joanie: pygobject doesn't return a separate kind of object for an interface, and the methods for all of the object's interfaces are available from the object. I asked in #introspection once if this was intentional, and walters said that he thought that it was <mgorse> but it leads to naming conflicts sometimes (ie, AtspiAccessible, AtspiText, and AtspiDocument all have get_attributes functions), so I ended up wrapping text and document into their own objects in python, but I only did this where it was needed [...] <mgorse> Mostly I just didn't wrap the other classes because I didn't see a reason to take the time to do it, although doing that would move pyatspi further away from what is being returned by introspection. I don't know why interfaces are returned as their objects; would need to find whoever wrote that code and ask. <@joanie> mgorse: I'm not sure you should change anything yourself. But I am in favor of inquiring why interfaces are returned as their objects. ~~~~ I have subsequently chatted with Piñeiro about this to see what he thinks we should do: <API> short term: that wrapping thing, for coherence <API> medium-long term: kill it and start to use purely object-introspected stuff (It == pyatspi2)
Committed: 22ca2e Although I've done some testing, this is close to a complete rewrite of pyatspi, so something may well be broken.
(In reply to comment #1) > Committed: 22ca2e > > Although I've done some testing, this is close to a complete rewrite of > pyatspi, so something may well be broken. So first of all: Thank you thank you thank you! (And sorry about the complete rewrite thing) Secondly, while many things seem to be working perfectly, I am finding a few bugs directly resulting from the changes here. If you can wrap for me, I can certainly debug and propose patches for you. <smiles> And I have to put them somewhere, so I'm going to re-open and attach here. Hope that's ok.
Created attachment 218013 [details] [review] getExtents() should return a bounding box rather than a tuple Patch to put the return value of getExtents() back to what you had before. We're expecting a bounding box. node.py:127:highlight:AttributeError: 'tuple' object has no attribute 'width' Traceback (most recent call last):
+ Trace 230469
self.node.update(new_acc)
self.highlight()
0 in (self.extents.width, self.extents.height) or \
Created attachment 218015 [details] [review] Fix Hypertext.getNLinks() You had some lines of code you forgot to remove. Results in this traceback: Traceback (most recent call last):
+ Trace 230470
linkCount = hypertext.getNLinks()
func = self.get_dbus_method("GetNLinks", dbus_interface=ATSPI_HYPERTEXT)
Aha, I think I see now why you had getExtents() return a tuple. Seems that Orca sometimes uses that. My bad. Having said that, I much prefer the bounding box. And the pre-wrapped code made it possible to get x, y, width, and height as if it were a bounding box. So rather than break that by returning a tuple in the wrapped code, I would rather fix the bogus code that is in Orca. So I'll do that.
Comment on attachment 218013 [details] [review] getExtents() should return a bounding box rather than a tuple >From 047f9ae404191626bffb89022332521d33d37d22 Mon Sep 17 00:00:00 2001 >From: Joanmarie Diggs <jdiggs@igalia.com> >Date: Wed, 4 Jul 2012 10:50:13 -0400 >Subject: [PATCH] getExtents() should return a bounding box rather than a > tuple > >--- > pyatspi/component.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/pyatspi/component.py b/pyatspi/component.py >index 0ad69ef..7657f70 100644 >--- a/pyatspi/component.py >+++ b/pyatspi/component.py >@@ -117,7 +117,7 @@ class Component(interface): > @return a BoundingBox which entirely contains the object's onscreen > visual representation. > """ >- return rectToList(Atspi.Component.get_extents(self.obj, coord_type)) >+ return Atspi.Component.get_extents(self.obj, coord_type) > > def getLayer(self): > """ >-- >1.7.10.4 >
Comment on attachment 218015 [details] [review] Fix Hypertext.getNLinks() >From a54dee492a17a64566609b3dbd2f8ec53e30406f Mon Sep 17 00:00:00 2001 >From: Joanmarie Diggs <jdiggs@igalia.com> >Date: Wed, 4 Jul 2012 11:18:58 -0400 >Subject: [PATCH 2/2] Fix Hypertext.getNLinks() > >--- > pyatspi/hypertext.py | 2 -- > 1 file changed, 2 deletions(-) > >diff --git a/pyatspi/hypertext.py b/pyatspi/hypertext.py >index 44b5498..9a7aac7 100644 >--- a/pyatspi/hypertext.py >+++ b/pyatspi/hypertext.py >@@ -61,8 +61,6 @@ class Hypertext(interface): > @return the number of Hyperlinks associated with this Hypertext > object, as a long integer. > """ >- func = self.get_dbus_method("GetNLinks", dbus_interface=ATSPI_HYPERTEXT) >- return func() > return Atspi.Hypertext.get_n_links(self.obj) > > #END---------------------------------------------------------------------------- >-- >1.7.10.4 >
Comment on attachment 218013 [details] [review] getExtents() should return a bounding box rather than a tuple http://git.gnome.org/browse/pyatspi2/commit/?id=394e7aea5db3df94077fbde7f4019bb24c77e9e8
Comment on attachment 218015 [details] [review] Fix Hypertext.getNLinks() http://git.gnome.org/browse/pyatspi2/commit/?id=567831b0d80f48b3ac7a87f64786fa28e51590df
Created attachment 218044 [details] [review] Fix some Collection-related issues
Comment on attachment 218044 [details] [review] Fix some Collection-related issues >From afc87e91128106a773c171c5e9441c08b6589020 Mon Sep 17 00:00:00 2001 >From: Joanmarie Diggs <jdiggs@igalia.com> >Date: Wed, 4 Jul 2012 15:15:10 -0400 >Subject: [PATCH] Fix some Collection-related issues > >--- > pyatspi/Accessibility.py | 11 +---------- > pyatspi/collection.py | 5 ++--- > pyatspi/utils.py | 14 +++++++++++++- > 3 files changed, 16 insertions(+), 14 deletions(-) > >diff --git a/pyatspi/Accessibility.py b/pyatspi/Accessibility.py >index f7bb8de..435f8a6 100644 >--- a/pyatspi/Accessibility.py >+++ b/pyatspi/Accessibility.py >@@ -26,6 +26,7 @@ from pyatspi.document import * > from pyatspi.utils import * > from pyatspi.action import * > from pyatspi.component import * >+from pyatspi.collection import * > from pyatspi.hypertext import * > from pyatspi.image import * > from pyatspi.selection import * >@@ -94,22 +95,12 @@ class BoundingBox(list): > def getBoundingBox(rect): > return BoundingBox (rect.x, rect.y, rect.width, rect.height) > >-def attributeListToHash(list): >- ret = dict() >- for item in list: >- [key, val] = item.split(":") >- ret[key] = val >- return ret >- > def getInterface(func, obj): > ret = func(obj) > if ret: > return ret > raise NotImplementedError > >-def hashToAttributeList(h): >- return [x + ":" + h[x] for x in h.keys()] >- > def getEventType(event): > try: > return event.pyType >diff --git a/pyatspi/collection.py b/pyatspi/collection.py >index a6166bb..aab41e1 100644 >--- a/pyatspi/collection.py >+++ b/pyatspi/collection.py >@@ -19,7 +19,6 @@ from pyatspi.utils import * > > __all__ = [ > "Collection", >- "MatchRule", > "SortOrder", > "MatchType", > "TreeTraversalType", >@@ -97,10 +96,10 @@ class Collection: > return Atspi.Collection.get_matches(self.obj, rule, sortby, count, traverse) > > def getMatchesTo(self, current_object, rule, sortby, tree, recurse, count, traverse): >- return Atspi.Collection.get_matches_to(self.obj, current_object._acc_path, rule, sortby, tree, recurse, count, traverse) >+ return Atspi.Collection.get_matches_to(self.obj, current_object, rule, sortby, tree, recurse, count, traverse) > > def getMatchesFrom(self, current_object, rule, sortby, tree, count, traverse): >- return Atspi.Collection.get_matches_from(self.obj, current_object._acc_path, rule, sortby, tree, count, traverse) >+ return Atspi.Collection.get_matches_from(self.obj, current_object, rule, sortby, tree, count, traverse) > > def getActiveDescendant(self): > return Atspi.Collection.get_active_descendant(self.obj) >diff --git a/pyatspi/utils.py b/pyatspi/utils.py >index 6d3e8bf..7e8e73d 100644 >--- a/pyatspi/utils.py >+++ b/pyatspi/utils.py >@@ -43,7 +43,9 @@ __all__ = [ > "findAncestor", > "getPath", > "pointToList", >- "rectToList" >+ "rectToList", >+ "attributeListToHash", >+ "hashToAttributeList" > ] > > def setCacheLevel(level): >@@ -331,3 +333,13 @@ def pointToList(point): > > def rectToList(rect): > return (rect.x, rect.y, rect.width, rect.height) >+ >+def attributeListToHash(list): >+ ret = dict() >+ for item in list: >+ [key, val] = item.split(":") >+ ret[key] = val >+ return ret >+ >+def hashToAttributeList(h): >+ return [x + ":" + h[x] for x in h.keys()] >-- >1.7.10.4 >
Comment on attachment 218044 [details] [review] Fix some Collection-related issues http://git.gnome.org/browse/pyatspi2/commit/?id=b78810b8f0b101cdd8ea77c4b60dfd3b4fde9357
I've beaten on this quite a bit now. Mike fixed some additional issues. I think we're good. Reclosing as FIXED. Thanks again Mike!!
[Moving at-spi/pyatspi2 bugs to separate product. See bug 740075]