GNOME Bugzilla – Bug 78903
Does not escape underscores in profile names used for menu items
Last modified: 2004-12-22 21:47:04 UTC
So we end up with funky mnemonics.
Created attachment 8393 [details] [review] Here's a straight-forward fix (written and tested May 11 2002)
Is there an easier way to do this using some glib utility function or something?
To my knowledge there isn't any substantially "easier" way using glib. I remember checking for just that when doing it. But then again, I didn't think the 20-line or so function the patch uses to do it now is all that "hard" anyway. If you find a more elegant way, then by all means attach it.
I'm going to guess that the "proper" way to do this would probably be to use pango markup or something.
Created attachment 11839 [details] [review] 78903.patch
this patch fixes it properly. a few comments: - I'm not 100% sure how gtk_label_set_pattern() works, so it might be possible to cheat by just using "_" instead of creating a pattern buffer and filling it with spaces and such. - I suppose, even though we will only ever g_alloca() up to a max of 36 pattern buffers, we might have problems with not having enough space on the stack? possibly should change the patch to use g_malloc() and g_free (pattern) when we g_free (str) the patch is against gnome-2-0 branch, but I realise this patch will also have to go into HEAD so I can do that too.
set_pattern() is visual-only, it doesn't actually set up a mnemonic, would just make it look like there was one. I think the first fix is more how I would go about it (and yes I'm a loser for not processing this bug earlier). The main things I'd change in the first patch are just stylistic: - while loop not for - braces on their own line - name the function escape_underscores() not get_name_formatted_... - spaces before parentheses But basically an escape_underscores() function is how I'd go about this. Thanks to everybody for their help.
A couple of things. I looked at updating the patch to meet your wishes, but I need to know: - which for loop should be a while loop? Both? - there are already spaces before parentheses and the braces are on their own lines, wassup? :)
yeah both for loops should be while also, s/gchar/char/ and in "char * foo" should be "char *foo"
The original patch also allocated not enough memory - didn't take into account the terminating \0.
The following patch does the same thing, using GLib's GString.
Created attachment 17885 [details] [review] fix the bug, using GStrings
Patch looks good to commit to me.
Commited