GNOME Bugzilla – Bug 452861
gtk_label_set_pattern() is not working anymore
Last modified: 2007-07-09 20:54:42 UTC
I believe this is the cause of bug 443776 (panel has needless mnemonic on the first char of menu). With the addition of gtk-enable-mnemonics, a call to gtk_label_set_pattern() is overridden by the signal handler of "screen-changed". We should probably remember that gtk_label_set_pattern() was called and that the pattern shouldn't be overridden. Here's a stack trace showing why gtk_label_set_pattern_internal() is called:
+ Trace 145064
Created attachment 90971 [details] [review] Proof-of-concept patch Wit this patch, everything works fine. I'm not sure it's 100% right, though. Maybe gtk_label_set_uline_text_internal() should be changed to look at pattern_set.
That patch looks wrong to me. Shouldn't set_pattern() rather unset use_underline ?
Putting "gtk_label_set_use_underline_internal (label, FALSE);" in set_pattern() results in this: "_Places" (with the underscore being a separated character). Hrm. I'm not familiar at all with the code there, but something better than my first patch might be to not change effective_attrs when the pattern has been set. It's also not clear to me what has the higher priority between the pattern property and the use-underline/use-markup properties. I'm assuming it's the pattern one, but I don't know if it's right.
Actually, looking at this mess and what the panel does some more, the best way to support this may be to just make mnemonic-keyval a writable property - we still need to do the extra work to ensure that recalculating the label contents will not overwrite the custom mnemonic-keyval, but that should be doable.
But maybe the approach in Vincents patch is good enough. Two things: 1) I believe the gtk_label_set_pattern (label, NULL) should reset pattern_set to FALSE 2) GtkLabel is the most common widget, therefore I'd hate to grow it. Can we use one of the few remaining bits in the public struct instead ?
Created attachment 91188 [details] [review] Update for comments from Matthias It probably makes sense to call gtk_label_recalculate() when unsetting the pattern with gtk_label_set_pattern (label, NULL), so I added this too.
2007-07-09 Matthias Clasen <mclasen@redhat.com> * gtklabel.[ch]: Use a bit of the GtkLabel structure to remember that a pattern has been set. (gtk_label_set_pattern_internal): Don't do anything if a specific pattern has been set. (gtk_label_set_pattern): set the new bit to TRUE when setting a pattern, and recalculate everything if the pattern is unset. Fix gtk_label_set_pattern() not working anymore. (#452861, Vincent Untz)