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 353088 - gtk_expander_get_label should return the full label text
gtk_expander_get_label should return the full label text
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 352176
 
 
Reported: 2006-08-27 11:20 UTC by Mattias Karlsson
Modified: 2009-04-07 16:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Trivial patch. (472 bytes, patch)
2007-04-29 19:41 UTC, Xan Lopez
committed Details | Review
Fix to make gailexpander.c not use gtk_expander_get_label (2.43 KB, patch)
2008-11-03 19:54 UTC, Peter Johanson
none Details | Review
Cleaner fix for gailexpander.c (2.28 KB, patch)
2008-11-03 22:59 UTC, Peter Johanson
committed Details | Review
Note change in docs (646 bytes, patch)
2008-11-28 11:01 UTC, Björn Lindqvist
needs-work Details | Review
Better note in docs (1.17 KB, patch)
2008-12-02 20:45 UTC, Björn Lindqvist
committed Details | Review

Description Mattias Karlsson 2006-08-27 11:20:24 UTC
gtk_expander_get_label should return the label set by gtk_expander_set_label but currently it retuns the label text stripped of any Pango markup or underscore character.

The problem is that gtk_expander_get_label uses gtk_label_get_text instead of gtk_label_get_label.
Comment 1 Xan Lopez 2007-04-29 19:41:59 UTC
Created attachment 87247 [details] [review]
Trivial patch.

Not sure if this counts as API change though (someone might already depend on the current behavior)
Comment 2 Behdad Esfahbod 2007-08-08 22:21:02 UTC
Looks right to me.
Comment 3 Björn Lindqvist 2008-03-22 01:29:01 UTC
committed to trunk.

2008-03-22  Björn Lindqvist  <bjourne@gmail.com>

	* gtk/gtkexpander.c (gtk_expander_get_label):
	gtk_label_get_label() should be used instead of
	gtk_label_get_text(). (#353088, Xan Lopez)
Comment 4 Peter Johanson 2008-11-03 18:19:55 UTC
Unfortunately, I've got to re-open this one. Xan's comment on "someone might already depend on the current behavior" turns out to have been true.

From modules/other/gail/gailexpander.c:gail_expander_get_name it ends up calling gtk_expander_get_label. This previously use to return the label text, with the underscore's stripped. With this change to gtkexpander.c, the accessible layer is seeing underscores in expander names (accersicer, orca, etc).

I see two potential fixes:

1) Introduce a gtk_expander_get_text function, which would ultimately end up calling gtk_label_get_text. This of course introduces new API just to fix a bug. Not sure the policy on this.

2) Enhance gailexpander.c to use gtk_expander_get_label_widget, and then just doing a gtk_label_get_text on that. This would restore the previous functionality without new API.

Personally, I'd say #2 is probably the better bet, but I'm certainly not the exper on this.

Thoughts?

Comment 5 Behdad Esfahbod 2008-11-03 18:26:44 UTC
I say lets:

  - Revert the patch,

  - Do #2,

  - Deprecate gtk_expander_get_label

How does that sound?
Comment 6 Peter Johanson 2008-11-03 18:34:30 UTC
Behdad, that would go beyond fixing the bug introduced. I can't really comment on the deprecation issue, but I just cooked a patch to make gailexpander.c use gtk_expander_get_label_widget instead, and am compiling now to test it.
Comment 7 Peter Johanson 2008-11-03 19:54:41 UTC
Created attachment 121908 [details] [review]
Fix to make gailexpander.c not use gtk_expander_get_label

This implements "Option #2" and seems to work as expected. Accersicer now shows the text as it did with gtk+ 2.12 in all places.

Would probably be good to have a "gail person" look at this, as I'm ceratinly not well versed in the gail code.
Comment 8 Xan Lopez 2008-11-03 19:59:47 UTC
Unless there's some reason for the differences in behavior of the additions (basically using g_return_if_fail sometimes and not others) I think I'd make a small function to get the label text from the expander, as you are repeating it 4 times.

Other than that looks good to me.
Comment 9 Peter Johanson 2008-11-03 21:30:28 UTC
In one of the cases, it's sufficient to return NULL, but the others have further logic I was scared to bypass, so I attempted to continue, but using NULL for the label text. I certainly could make a small function for returning the text, and use it in all 4 spots though.
Comment 10 Peter Johanson 2008-11-03 22:59:34 UTC
Created attachment 121922 [details] [review]
Cleaner fix for gailexpander.c

Ok, this is a cleaner (IMHO) patch, that also prevents a Gtk-CRITICAL from being printed, by avoiding using g_return_val_if_fail.
Comment 11 Behdad Esfahbod 2008-11-04 11:35:34 UTC
Well, we now have a gtk_expander_get_label symbol that has one semantic in most releases and another in the latest one.  Granted, it seems like no one is using it (quick Google Code check), but if we're not ok adding a _get_text equivalent on the basis that it can be done equivalently already, then the least-confusion approach may be to simply deprecate the current problematic _get_label symbol too.
Comment 12 Björn Lindqvist 2008-11-04 14:14:10 UTC
If get_label is deprecated, then set_label should too be deprecated... In fact, why not deprecate the other label-setter attributes too, use_underline and use_markup?  They are just convenience functions for C programmers.

I also think that gail is the one being bad here. The gtk_expander_get_label documentation clearly states "Fetches the text from a label widget including any embedded underlines indicating mnemonics and Pango markup." So if we go with the old get_text behaviour, then the docs should be updated too.
Comment 13 Peter Johanson 2008-11-11 21:12:18 UTC
Regardless of this API debate, can we at least get the attached fix commited, which works as expected?
Comment 14 Matthias Clasen 2008-11-27 06:15:55 UTC
The gail patch looks fine. Please commit. To both branches, if you don't mind.

Wrt. to the api debate, I'm not sure deprecating it all is a good idea. 

Reverting to the old behaviour doesn't strike me as very convincing either, since the old behaviour _was_ wrong, and we've only found a single user, which we are fixing with the above patch. I'd propose to leave the behaviour as it is now, and add a note to the docs pointing out that the function behaved differently in versions < 2.14.
Comment 15 Björn Lindqvist 2008-11-28 11:01:46 UTC
Created attachment 123601 [details] [review]
Note change in docs
Comment 16 Matthias Clasen 2008-11-28 19:17:16 UTC
Might want to add that this problem can be avoided by getting the label widget and using its api.
Comment 17 Björn Lindqvist 2008-12-02 20:45:21 UTC
Created attachment 123824 [details] [review]
Better note in docs
Comment 18 Cody Russell 2009-04-07 16:16:16 UTC
What's the status of this?  Can we commit the documentation improvements and close this bug?