changed based on a patch by Joao S. O. Bueno to remove mnemonics as used

2004-11-13  Sven Neumann  <sven@gimp.org>

	* libgimpbase/gimputils.c (gimp_strip_uline): changed based on a
	patch by Joao S. O. Bueno to remove mnemonics as used in languages
	like Chinese. Fixes bug #157561.
This commit is contained in:
Sven Neumann 2004-11-13 12:32:01 +00:00 committed by Sven Neumann
parent 4cbef9ff1b
commit 4cc6564a0e
2 changed files with 32 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2004-11-13 Sven Neumann <sven@gimp.org>
* libgimpbase/gimputils.c (gimp_strip_uline): changed based on a
patch by Joao S. O. Bueno to remove mnemonics as used in languages
like Chinese. Fixes bug #157561.
2004-11-13 Sven Neumann <sven@gimp.org>
* plug-ins/ifscompose/README.ifscompose: updated link to the

View File

@ -220,20 +220,26 @@ gimp_filename_to_utf8 (const gchar *filename)
/**
* gimp_strip_uline:
* @str: Underline infested string (or %NULL)
* @str: underline infested string (or %NULL)
*
* This function returns a copy of @str stripped of underline
* characters. This comes in handy when needing to strip mnemonics
* from menu paths etc.
*
* In some languages, mnemonics are handled by adding the mnemonic
* character in brackets (like "File (_F)"). This function recognizes
* this construct and removes the whole bracket construction to get
* rid of the mnemonic (see bug #157561).
*
* Return value: A (possibly stripped) copy of @str which should be
* freed using g_free() when it is not needed any longer.
* freed using g_free() when it is not needed any longer.
**/
gchar *
gimp_strip_uline (const gchar *str)
{
gchar *escaped;
gchar *p;
gchar *escaped;
gchar *p;
gboolean past_bracket = FALSE;
if (! str)
return NULL;
@ -246,12 +252,26 @@ gimp_strip_uline (const gchar *str)
{
/* "__" means a literal "_" in the menu path */
if (str[1] == '_')
*p++ = *str++;
{
*p++ = *str++;
*p++ = *str++;
}
str++;
/* find the "(_X)" construct and remove it entirely */
if (past_bracket && str[1] && *(g_utf8_next_char (str + 1)) == ')')
{
str = g_utf8_next_char (str + 1) + 1;
p--;
}
else
{
str++;
}
}
else
{
past_bracket = (*str == '(');
*p++ = *str++;
}
}