added new function gimp_get_mod_string() which takes a GdkModifierType and

2004-06-29  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpwidgets-utils.[ch]: added new function
	gimp_get_mod_string() which takes a GdkModifierType and returns
	correctly formated strings for all shift,control,alt combinations.

	* app/tools/gimpbucketfilloptions.c
	* app/tools/gimpcolorpickeroptions.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpcropoptions.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimperasertool.c
	* app/tools/gimpflipoptions.c
	* app/tools/gimpmagnifyoptions.c
	* app/tools/gimpmoveoptions.c
	* app/tools/gimptransformoptions.c
	* app/tools/gimpvectoroptions.c
	* app/widgets/gimpchanneltreeview.c
	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimpdocumentview.c
	* app/widgets/gimperrorconsole.c
	* app/widgets/gimpgradienteditor.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimppaletteeditor.c
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimpthumbbox.c
	* app/widgets/gimptooloptionseditor.c
	* app/widgets/gimpvectorstreeview.c: use the new function instead
	of gimp_get_mod_name_shift(),control(),alt(),separator(). This
	kindof addresses the issue of configurable modifier keys but is
	actually indended to ease translation of format strings ("%s" is
	easier to get right than "%s%s%s").
This commit is contained in:
Michael Natterer
2004-06-28 23:30:57 +00:00
committed by Michael Natterer
parent 6a5e68c9e2
commit 6cd5737257
25 changed files with 170 additions and 64 deletions

View File

@ -600,6 +600,67 @@ gimp_get_mod_separator (void)
return (const gchar *) mod_separator;
}
const gchar *
gimp_get_mod_string (GdkModifierType modifiers)
{
static struct
{
GdkModifierType modifiers;
gchar *name;
}
modifier_strings[] =
{
{ GDK_SHIFT_MASK, NULL },
{ GDK_CONTROL_MASK, NULL },
{ GDK_MOD1_MASK, NULL },
{ GDK_SHIFT_MASK | GDK_CONTROL_MASK, NULL },
{ GDK_SHIFT_MASK | GDK_MOD1_MASK, NULL },
{ GDK_CONTROL_MASK | GDK_MOD1_MASK, NULL },
{ GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK, NULL }
};
gint i;
for (i = 0; i < G_N_ELEMENTS (modifier_strings); i++)
{
if (modifiers == modifier_strings[i].modifiers)
{
if (! modifier_strings[i].name)
{
GString *str = g_string_new ("");
if (modifiers & GDK_SHIFT_MASK)
{
g_string_append (str, gimp_get_mod_name_shift ());
}
if (modifiers & GDK_CONTROL_MASK)
{
if (str->len)
g_string_append (str, gimp_get_mod_separator ());
g_string_append (str, gimp_get_mod_name_control ());
}
if (modifiers & GDK_MOD1_MASK)
{
if (str->len)
g_string_append (str, gimp_get_mod_separator ());
g_string_append (str, gimp_get_mod_name_alt ());
}
modifier_strings[i].name = g_string_free (str, FALSE);
}
return modifier_strings[i].name;
}
}
return "<BUG: unsupported modifiers>";
}
/**
* gimp_get_screen_resolution:
* @screen: a #GdkScreen or %NULL