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 516120 - Present labels and objects in the order they appear on the screen
Present labels and objects in the order they appear on the screen
Status: RESOLVED OBSOLETE
Product: orca
Classification: Applications
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Orca Maintainers
Orca Maintainers
post-3.0
Depends on:
Blocks:
 
 
Reported: 2008-02-12 21:35 UTC by Willie Walker
Modified: 2018-02-08 12:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Orca Preference dialog in Arabic. (64.92 KB, image/png)
2008-06-19 16:48 UTC, Rich Burridge
Details

Description Willie Walker 2008-02-12 21:35:09 UTC
We run into situations where an object is labeled by multiple labels and the object might be visually in the middle of these labels.  Examples include that discussed in bug 133275 as well as the "Scrolling" tab of the gnome-terminal preferences dialog.

For example, consider the following, where "some_label:" is a label, "_______" is a text area, and "another_label" is a label, where each label is a LABEL_FOR the text area and the text area has a LABEL_BY relation for each of the labels:

some_label: _________ another_label

Right now, I believe Orca will present both labels before the text area.  It would be better if Orca presented the labels and text area in the natural reading order as presented in the dialog.
Comment 1 Willie Walker 2008-03-11 14:06:45 UTC
First coarse pass at GNOME 2.24 planning.
Comment 2 Rich Burridge 2008-06-19 00:46:36 UTC
I don't see an easy way to do this. 

There is a method in default.py called findDisplayedLabel 
(sic) that returns a list of the objects that are 
labelling the given object.

That in turn is used by getDisplayedLabel in default.py
to append all the strings together, returning a single 
string.

getDisplayedLabel is used in multiple (20) places in     
braillegenerator.py, once in default.py to determine
if an object is for layout purposes only and once in 
liveregions.py. It is used in three places in 
speechgenerator.py and once in where_am_I.py.

In speechgenerator.py, the three places are:

1/ The _getSpeechForObjectLabel() method.
2/ The _getSpeechForTerminal() method.
3/ In a while loop in the getSpeechContext() method.

The _getSpeechForObjectLabel() method is called in
14 places in speechgenerator.py, for various types
of object.

I cannot think of a straight forward way to adjust 
this code, so that if there are two or more labels
labelling the given object, speaking/brailling
them will take into account the labels extents and
therefore be before or after the speaking/brailling 
of the given object.

I'd gladly be proven wrong.

Anybody have any ideas?
Comment 3 Willie Walker 2008-06-19 15:05:33 UTC
(In reply to comment #2)
> I don't see an easy way to do this. 

I'm not sure it will be easy.  :-(

> There is a method in default.py called findDisplayedLabel 
> (sic) that returns a list of the objects that are 
> labelling the given object.

As a thought, perhaps this could be modified to return two lists of objects: one for the labels to the left of the object and one for the labels to the right of the object?  While doing this, you could change the name to findDisplayedLabels so it won't sic'en you anymore.  :-)

> That in turn is used by getDisplayedLabel in default.py
> to append all the strings together, returning a single 
> string.

With the above change, this could be modified to return two strings - one for the left and one for the right.

I realize this would touch a lot of code, but I think this is a very useful feature to have.

Thoughts?  Should we also try to consider labels above/below as well?
Comment 4 Rich Burridge 2008-06-19 15:30:20 UTC
Oh, I realize it could be done. It just won't be 
easy and straight forward. The above was just an
attempt to evaluate it to see if it was going to
be a quick fix.

Your approach above is certainly feasible.

My thoughts are that this is a potentially risky 
change at this stage of the development cycle, for 
a small benefit, and as this is currently marked 
as Normal/Enhancement, perhaps we should concentrate
on more important bugs.

Thanks for looking at it.

Comment 5 Joanmarie Diggs (IRC: joanie) 2008-06-19 15:43:45 UTC
> As a thought, perhaps this could be modified to return two lists of objects:
> one for the labels to the left of the object and one for the labels to the
> right of the object? 

I like this idea.  And it might buy us something else -- or it might introduce something else we need to work out -- though I'm not sure, so....

Consider the following example:

   Margin: <spin button> pixels

Where "Margin:" and "pixels" are each labels for the text object <spin button>.

Right now for English, we say something like "Margin: pixels 10 spin button."  But what happens in rtl languages like Arabic and Hebrew?  Does some miracle of localization cause the dialog for those users to display (essentially)

    pixels <spin button> Margin:

? And, if so, are we then saying (essentially) "pixels <spin button> Margin" to users of those languages?

Knowing the answer to the above would help me sort out my next question, but I'll ask it now anyway:  If we build up speech context to present:

1. Label on the left
2. Object being labeled
3. Label on the right

What happens to the aforementioned users?

If right now some localization miracle is solving the direction problem, I would want to be sure we're not screwing it up by this change.  On the other hand, if right now the way in which we're speaking labels and the objects being labeled is backwards for those users, maybe there's something clever we can do to get things in the right order as we look at the labels' locations spatially??

(Am I making any sense?)

> Thoughts?  Should we also try to consider labels above/below as well?

If we're currently grabbing labels which are above/below (which I assume we are), then I would think we'd also want to consider their locations.

Comment 6 Rich Burridge 2008-06-19 16:48:10 UTC
Created attachment 113055 [details]
Orca Preference dialog in Arabic.

The Speech pane of the Orca Preferences dialog, showing how the
spin button with two labels (near the bottom of the pane) is
rendered.
Comment 7 Willie Walker 2008-06-19 18:52:42 UTC
In discussion with Mike, we decided that this problem is not encountered enough to justify the significant change for 2.24.  So, marking this for FUTURE and we probably should get to it early in the 2.26 cycle.

For future reference:

> If right now some localization miracle is solving the direction problem, I
> would want to be sure we're not screwing it up by this change.  

Just a reminder that what we're doing now isn't the greatest -- we're just concatenating things in the order we find them in list of relations.  It's kind of a crap shoot if they come out in the right order or not.  The probability, however, is that the ordering will be correct.

> hand, if right now the way in which we're speaking labels and the objects being
> labeled is backwards for those users, maybe there's something clever we can do
> to get things in the right order as we look at the labels' locations
> spatially??

LTR and RTL concerns are definitely valid (thanks for thinking of this!).  So, instead of left/right lists, maybe we think of the values as before/after lists, where the before/after represent the logical reading order.  This could still be done in findDisplayedLabels, thought it would need some magic in it to determine what before and after meant.  That magic might be spacial layout coupled with knowledge about the layout direction for the window (if we can get it).

There's some algorithm here that could be used to use the text of the label to predict LTR vs. RTL: http://osdir.com/ml/gnome.gtk+.internationalization/2005-08/msg00033.html.  Though, it might be better to try to use something else such as app.getLocale(pyatspi.LOCALE_TYPE_MESSAGES) to get the LANG of the app.  From here, we might be able to infer the layout direction for the window.
Comment 8 Willie Walker 2008-06-19 19:22:10 UTC
For more future reference:

The decision about defaulting to RTL instead of LTR seems to be a human one, and it is done by the translators.  In do_post_parse_initialization of gtkmain.c, it looks for the translated value of "default:LTR":

  /* Translate to default:RTL if you want your widgets
   * to be RTL, otherwise translate to default:LTR.
   * Do *not* translate it to "predefinito:LTR", if it
   * it isn't default:LTR or default:RTL it will not work 
   */
    char *e = _("default:LTR");
    if (strcmp (e, "default:RTL")==0) 
      gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
    else if (strcmp (e, "default:LTR"))
      g_warning ("Whoever translated default:LTR did so wrongly.\n");
  }

I'm not sure of the best way for us to find this.  It might be that we should request that 'direction' be exposed via an attribute to obtain via acc.getAttributes() and acc.queryText().getAttributes() (the first for how the widget wants to layout its children, the second for what the actual text is doing at a particular offset).

Comment 9 Willie Walker 2009-03-17 23:51:41 UTC
See also bug #568611, which discusses the DESCRIBED_BY relation we have yet to include.
Comment 10 Willie Walker 2009-05-08 16:23:28 UTC
As an alternative to two lists, we could still return a single list, but have a "None" item that represents a placeholder for the object being labeled.
Comment 11 Mesar Hameed 2009-06-10 00:24:31 UTC
With work on 570658 and 584529  being done, it might be better to have before, after, above and below, as separate entities, enabling us to put them as elements of the formatting strings.
Comment 12 Joanmarie Diggs (IRC: joanie) 2010-07-05 02:45:19 UTC
(3.0 Planning Spam-o-rama. Sorry!)
Comment 13 Joanmarie Diggs (IRC: joanie) 2010-07-05 21:20:21 UTC
Note that I am planning (hoping) to have bug 622515 fixed for 3.0.