After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 344985 - New IAccessibleInfo methods
New IAccessibleInfo methods
Status: RESOLVED FIXED
Product: lsr
Classification: Deprecated
Component: core
0.2.x
Other Linux
: Normal enhancement
: 0.3.0
Assigned To: Eirikur Hallgrimsson
LSR maintainers
Depends on:
Blocks: 344989
 
 
Reported: 2006-06-15 12:45 UTC by Peter Parente
Modified: 2006-07-10 18:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The remaining routines in this chunk of work. (18.34 KB, patch)
2006-06-23 20:03 UTC, Eirikur Hallgrimsson
none Details | Review
Patch with all IAccessibleInfo methods (tested), All IAccessibleAction methods (untested) (34.51 KB, patch)
2006-06-29 05:52 UTC, Eirikur Hallgrimsson
none Details | Review
All methods. Complete doc in LSRInterfaces.py (31.93 KB, patch)
2006-07-05 17:50 UTC, Eirikur Hallgrimsson
rejected Details | Review
Tests the methods added to resolve this bug. (993 bytes, text/plain)
2006-07-05 18:04 UTC, Eirikur Hallgrimsson
  Details
Revised patch with fixes as per Pete Parented (39.62 KB, patch)
2006-07-07 19:11 UTC, Eirikur Hallgrimsson
none Details | Review
Revised patch with fixes as per Pete Parente (39.62 KB, patch)
2006-07-07 19:13 UTC, Eirikur Hallgrimsson
needs-work Details | Review
Latest test perk. (1.27 KB, text/plain)
2006-07-07 19:15 UTC, Eirikur Hallgrimsson
  Details

Description Peter Parente 2006-06-15 12:45:40 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.
Comment 1 Peter Parente 2006-06-15 18:36:56 UTC
Rename getAccDoubleValueExtents and getAccDoubleValue to getAccFloatValueExtents and getAccFloatValue to be Pythonic.
Comment 2 Eirikur Hallgrimsson 2006-06-23 01:35:04 UTC
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.

Comment 3 Eirikur Hallgrimsson 2006-06-23 06:08:34 UTC
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.





Comment 4 Eirikur Hallgrimsson 2006-06-23 16:57:12 UTC
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'

Comment 5 Brett Clippingdale 2006-06-23 17:48:23 UTC
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() ? 
Comment 6 Eirikur Hallgrimsson 2006-06-23 19:45:19 UTC
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.

Comment 7 Eirikur Hallgrimsson 2006-06-23 20:00:47 UTC
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.

Comment 8 Brett Clippingdale 2006-06-23 20:02:58 UTC
Eirikur, getAttributes has been deprecated.

See: http://gnome.org/%7Ebillh/at-spi-new-idl/html/html/classAccessibility_1_1Text.html
Comment 9 Eirikur Hallgrimsson 2006-06-23 20:03:23 UTC
Created attachment 67905 [details] [review]
The remaining routines in this chunk of work.

Haven't updated LSRInterfaces yet.  This is a cvs diff.
Comment 10 Eirikur Hallgrimsson 2006-06-26 15:35:55 UTC
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
Comment 11 Peter Parente 2006-06-27 20:37:59 UTC
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.
Comment 12 Eirikur Hallgrimsson 2006-06-28 05:50:24 UTC
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

Comment 13 Eirikur Hallgrimsson 2006-06-28 06:04:02 UTC
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?
Comment 14 Eirikur Hallgrimsson 2006-06-28 20:45:21 UTC
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()

Comment 15 Peter Parente 2006-06-28 22:36:10 UTC
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.
Comment 16 Eirikur Hallgrimsson 2006-06-29 02:23:07 UTC
Solved by sheepishly adding the omitted decorators.
That solves another problem, that of minimumIncrement not being implemented for some objects.

Comment 17 Eirikur Hallgrimsson 2006-06-29 02:43:48 UTC
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.
Comment 18 Eirikur Hallgrimsson 2006-06-29 05:52:24 UTC
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.
Comment 19 Peter Parente 2006-07-05 13:23:05 UTC
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.
Comment 20 Eirikur Hallgrimsson 2006-07-05 15:22:00 UTC
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
Comment 21 Peter Parente 2006-07-05 15:37:47 UTC
Ha. Wrong method name. Sorry about that. Looking forward to your patch.
Comment 22 Eirikur Hallgrimsson 2006-07-05 17:50:14 UTC
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.
Comment 23 Eirikur Hallgrimsson 2006-07-05 18:04:48 UTC
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.
Comment 24 Peter Parente 2006-07-06 18:43:05 UTC
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.
Comment 25 Eirikur Hallgrimsson 2006-07-07 04:23:38 UTC
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.

Comment 26 Peter Parente 2006-07-07 10:51:18 UTC
> 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.
Comment 27 Eirikur Hallgrimsson 2006-07-07 19:11:54 UTC
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.
Comment 28 Eirikur Hallgrimsson 2006-07-07 19:13:21 UTC
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.
Comment 29 Eirikur Hallgrimsson 2006-07-07 19:15:56 UTC
Created attachment 68589 [details]
Latest test perk.

Includes new tests for dict returns.
Comment 30 Peter Parente 2006-07-10 17:37:27 UTC
Accepting patch. Needs work. Will clean up when integrating.
Comment 31 Peter Parente 2006-07-10 18:52:06 UTC
Fixed in the development version. The fix will be available in the next major release. Thank you for your bug report.