GNOME Bugzilla – Bug 344985
New IAccessibleInfo methods
Last modified: 2006-07-10 18:52:06 UTC
Add the following IAccessibleInfo methods to the appropriate adapters. The items in the square brackets indicate what AT-SPI methods can be used to implement the methods. getAccDoubleValueExtents(self) # returns a 3-tuple of (min, max, step) # can use Value interface and minimumValue, maximumValue, minimumIncrement properties # should be added to default info adapter # raise NotImplementedError if Value not supported getAccDoubleValue(self) # returns a double # can use Value interface and currentValue property # should be added to default info adapter # raise NotImplementedError if Value not supported getAccDefTextAttrs(self) # returns a list of name:value default text attribute pairs as strings # if no attributes, returns an empty list # can use Text interface and getDefaultAttributes method # should be added to default info adapter # raise NotImplementedError if Text not supported getAccTextSelection(self, n=None) # returns a list of all selections if n is None, or the nth selection if specified # returns an empty list if no selections # can use Text interface and getNSelections, getSelection methods # should be added to default info adapter # raise NotImplementedError if Text not supported getAccText(self, start=None, end=None) # returns all text between the start and end offsets as a string # if start is None, defaults to the beginning of the text # if end is None, defaults to the end of the text # can use Text interface and getText method # should be added to default info adapter # raise NotImplementedError if Text not supported getAccTableExtents(self) # returns the number of rows and columns in a table as a 2-tuple of integers # can use the Table interface and nRows, nColumns properties # should be added to the table info adapter # raise NotImplementedError in the default info adapter getAccAppLocale(self) # returns the POSIX locale of an application as a string # can use the Application interface and the getLocale method # should be added to the default info adapter # raise NotImplementedError if Application not supported getAccAttrs(self) # returns a list of name:value object attribute pairs as strings # if no attributes, returns an empty list # should be added to the default info adapter Method signatures should be added to LSRInterfaces.py for documentation purposes.
Rename getAccDoubleValueExtents and getAccDoubleValue to getAccFloatValueExtents and getAccFloatValue to be Pythonic.
I still haven't found a GTK app that returns any getAccText or shows anything in AT-Poke that indicates that it should have some. Need help here. Post patch containing these routines soon.
getAccAppLocale(self) # returns the POSIX locale of an application as a string # can use the Application interface and the getLocale method # should be added to the default info adapter # raise NotImplementedError if Application not supported This is not that simple. ATSPI's Application.getLocale(LOCAL_TYPE) requires an input parameter which specifies which locale attribute is being requested. ATSPI: string Accessibility::Application::getLocale(in LOCALE_TYPE lctype) Gets the locale in which the application is currently operating. For the current message locale, use lctype LOCALE_TYPE_MESSAGES. Parameters: lctype The LocaleType for which the locale is queried. ------------- Okay, so, we need an input parameter, which is a constant equal to one of: enum Accessibility::LOCALE_TYPE used by Text and Document: these correspond to the POSIX setlocale() enum values. Enumerator: LOCALE_TYPE_MESSAGES LOCALE_TYPE_COLLATE LOCALE_TYPE_CTYPE LOCALE_TYPE_MONETARY LOCALE_TYPE_NUMERIC LOCALE_TYPE_TIME ------------ But, I ask, which one are we interested in here? Conceivably we could support all of them.
In DefaultInfo.py calling self.acessible.getAttributes() raises an exception CORBA_UNKNOWN I don't know what to do about this. I think perhaps this is not implemented in the ATSPI implementation that CORBA is talking to, but I really don't know. I will comment this out and simply return None from my routine in DefaultInfo.py'
Erirur, I assume comment #4 refers to implementing getAccAttrs(self) ? 1. typo on 'accessible' ? 'self.acessible.getAttributes()' -- it's not in the code like that, I'm guessing. 2. you tried self.getAttributes()? 3. you looked at how we get text attributes in DefaultInfo.py, ie. getAccAllTextAttrs() ?
Brett, in re. comment 5, self doesn't have a getAttributes() method, either. Self is an instance of DefaultAccInfoAdapter. It's not related to the POR. Such methods basically call other methods in the same instance. Look at hasAccState(self). It calls self.accessible.getState(). I'm pretty sure that getAttributes() should be in the accessiblity object.
Eirikur, getAttributes has been deprecated. See: http://gnome.org/%7Ebillh/at-spi-new-idl/html/html/classAccessibility_1_1Text.html
Created attachment 67905 [details] [review] The remaining routines in this chunk of work. Haven't updated LSRInterfaces yet. This is a cvs diff.
Re. comment 8. I was using an older version of the spec at: http://gnome.org/~billh/at-spi-new-idl/html/html/index.html
Re: getAccAppLocale Hardwire it to MESSAGES for the time being. Re: getAccAttrs Eirikur, you are right about trying to use the Accessible:getAttributes method, not the one in the text interface. The CORBA exception means the method hasn't been implemented yet for the accessible widget on which you are calling the method at present.
Re: getAccAttrs (comment 11) Code now looks like this. Might start working when this is implemented on the other side, but then again, might not. In the meantime, I think it is okay like this, behaving as if getAttributes() is unimplemented on all accessible objects. This required importing CORBA at the top of the module as I didn't want to do it in the routine for performance reasons. Python won't repeatedly import a module, but it has to check. try: attrs = self.accessible.getAttributes() except CORBA.UNKNOWN: raise NotImplementedError return attrs
Re: getAccAttrs (comment 12) Dang, spoke too soon. In actuality, we can get a Bonobo.BadArgs exception here, as well as CORBA.UNKNOWN. There seems to be no Bonobo module to import to define this. Ideas?
Oooh, long sigh. The bonobo module has no BadArg in it. Actually, the exception is Bonobo.BadArg, capital B on the Bonobo. This is probably something in the CORBA world, which I don't know how to search or import. Importing CORBA did work for resolving CORBA.UNKNOWN. I could resolve this by trapping all exceptions (while s previous clause for specifically dealing with CORBA.UNKNOWN. I could really use some help here, or an endorsement of trapping all exceptions from (accessiblilty object).getAttributes()
Let the exception be raised without catching it. Just remove the try/except block from your method. The pyLinAcc.ErrorToLookupError decorator on your method should do the right thing. If not, the decorator needs tweaking.
Solved by sheepishly adding the omitted decorators. That solves another problem, that of minimumIncrement not being implemented for some objects.
Solved by sheepishly adding the omitted decorators. That solves another similar problem (which just cropped up), that of minimumIncrement not being implemented for some objects.
Created attachment 68146 [details] [review] Patch with all IAccessibleInfo methods (tested), All IAccessibleAction methods (untested) Patch with all IAccessibleInfo methods. I've done SOME testing. I can't find widgets that implement some of these types of gets, so we always get None via the Unimplemented error. All IAccessibleAction methods from Bug 345341 – New IAccessibleAction methods. These are untested because I haven't figured out how to test them via a Perk. I know I should add a new class to my test perk, but I don't know what to name it or what to subclass it from, or who is going to call it. The action methods aren't in LSRInterfaces.py yet and LSRInterfaces.py hasn't had a patch-release cleanup. This is an interim patch so you can see what I'm doing. The LSRInterfaces.py finalization and cleanup will appear in a patch tomorrow.
Eirikur, is the latest patch the final patch for the IAccessibleInfo work? I don't care if IAccessibleAction isn't done yet, I just need the IAccessibleInfo methods. I don't see IAccAppLocale in the patch so I'm holding off in applying it. Please post the patch today.
You wouldn't be able to search for IAccAppLocale, but the following was in that patch. Full patch for all the IAccssibleInfo work coming TODAY. All that needs doing is the accTable extents and checking the LSRInterfaces.py documentation. @pyLinAcc.errorToLookupError def getAccAppLocale(self): """ Gets the POSIX locale of an application as a string. At the present time this routine returns only the locale set for messages. @return: POSIX locale as string @rtype: string @raise LookupError: When the accessible or any parent accessible up to the application is dead """ app = self.accessible.getApplication() try: return app.getLocale(Constants.LOCALE_TYPE_MESSAGES) except AttributeError: return None
Ha. Wrong method name. Sorry about that. Looking forward to your patch.
Created attachment 68420 [details] [review] All methods. Complete doc in LSRInterfaces.py This patch contains the IAccessibleAction stuff which is not yet tested. All the IaccessibleInfo stuff is tested and the next attachment is the test perk.
Created attachment 68422 [details] Tests the methods added to resolve this bug. This is a very simple test of the getAccFoo methods, but it shows that they work. Some have never returned something other than None for me, but their code is nearly the same as those that do return values, so I assume that I haven't found a GTK object that supports them. There have been no problems caused by this patch as tested by this perk.
Eirikur, The patch needs some work. Here's where: 1) getAccDefTextAttrs in DefaultInfo.py has doc that says it returns a dict. According to the code, it returns one long string. It's fine if you want to return a dict, but you have to split the string yourself to create it. See getAccTextAttr for an example of a method that does something similar. 2) getAccAttrs should behave just like getAccDefTextAttrs in terms of how it splits the string it gets back from at-spi into a dictionary. I know you can't test it yet because getAttributes isn't implemented, but go ahead and write the code at least. We'll test it when it becomes available. 3) getAccText in DefaultInfo.py is missing epydoc for the start and end params. 4) The LSRInterfaces shell methods are wrong in a number of places. Some have parameters that they shouldn't. None of them should have a self parameter (they're not callable, and something that doesn't have an explicit self might implement the interface like a module). Some of the methods are missing doc for parameters that do indeed exist. 5) All of the Task.Tools.View methods are missing epydoc for at least their POR parameters. Some are missing the epydoc for the other parameters too like start, end, etc. 6) None of the methods you wrote in Task/Tools/View.py should be using Interfaces.IText. In fact, nothing in View.py should ever touch anything from pyLinAcc. That method should be using the IAccessibleInfo adapter gotten by doing IAccessibleInfo(por) just like all the other Task/Tools/View.py methods you've ever written. Please make cleaning up this patch priority over the other tasks I've assigned you.
Most of the fixes are in place. Expecting to issue revised patch Friday noonish. Question/comment on getAccDefTextAttrs: The story is that getDefaultAttributes is deprecated in favor of a new method: getDefaultAttributeSet, but that doesn't seem to be implemented yet in the Python IAccessibleText interface. attribute_string = tex.getDefaultAttributeSet() AttributeError: 'Text' object has no attribute 'getDefaultAttributeSet' I wrote a little routine to dict-ize the string returned from getAttributes() in order to return a dict as I had said in the doc and originally intended. I've added a test in my testing perk. There was a fair amount of debugging required to analyse the real format of the returned string, which is a bit funky, but I was able to keep the routine simple in the end. The issue is using the deprecated routine. I suppose we have to for now. It does seem to work, and I've given it a fair amount of testing.
> Question/comment on getAccDefTextAttrs: The story is that getDefaultAttributes > is deprecated in favor of a new method: getDefaultAttributeSet. Leave it using getDefaultAttributes for now as the new method appears to be both missing from the at-spi IDL doc and not implemented.
Created attachment 68586 [details] [review] Revised patch with fixes as per Pete Parented Gak. I submitted this on time but to the wrong bug. Defaultinfo.py: Removed unused includes in DefaultInfo.py Re-wrote getAccDefAttrs routine entirely to properly return a dict. Re-wrote getAccAttrs using the code I wrote for getAccDefTextAttrs. Now returns a dict. Code was tested in getAccDefTextAttrs(). Fixed epydoc to include input params in getAccText. LSRInterfaces.py: Fixed LSRInterfaces.py Removed inappropriate self input params, added epydoc for all input params. Task/Tools/View.py: Added epydoc for all input params, including POR. Re-wrote routines to remove refs to Interfaces.IText and use calls appropriate to this module.
Created attachment 68588 [details] [review] Revised patch with fixes as per Pete Parente Gak. I submitted this on time but to the wrong bug. Defaultinfo.py: Removed unused includes in DefaultInfo.py Re-wrote getAccDefAttrs routine entirely to properly return a dict. Re-wrote getAccAttrs using the code I wrote for getAccDefTextAttrs. Now returns a dict. Code was tested in getAccDefTextAttrs(). Fixed epydoc to include input params in getAccText. LSRInterfaces.py: Fixed LSRInterfaces.py Removed inappropriate self input params, added epydoc for all input params. Task/Tools/View.py: Added epydoc for all input params, including POR. Re-wrote routines to remove refs to Interfaces.IText and use calls appropriate to this module.
Created attachment 68589 [details] Latest test perk. Includes new tests for dict returns.
Accepting patch. Needs work. Will clean up when integrating.
Fixed in the development version. The fix will be available in the next major release. Thank you for your bug report.