app: Add gimp_enum_get_value_name() utility function

This commit is contained in:
Martin Nordholts 2010-10-26 13:45:17 +02:00
parent 3d82d40f5b
commit ee81f23f0a
2 changed files with 28 additions and 0 deletions

View File

@ -685,6 +685,32 @@ gimp_markup_extract_text (const gchar *markup)
return g_string_free (string, FALSE); return g_string_free (string, FALSE);
} }
/**
* gimp_enum_get_value_name:
* @enum_type: Enum type
* @value: Enum value
*
* Returns the value name for a given value of a given enum
* type. Useful to have inline in GIMP_LOG() messages for example.
*
* Returns: The value name.
**/
const gchar *
gimp_enum_get_value_name (GType enum_type,
gint value)
{
const gchar *value_name = NULL;
gimp_enum_get_value (enum_type,
value,
&value_name,
NULL /*value_nick*/,
NULL /*value_desc*/,
NULL /*value_help*/);
return value_name;
}
/** /**
* gimp_utils_point_to_line_distance: * gimp_utils_point_to_line_distance:
* @point: The point to calculate the distance for. * @point: The point to calculate the distance for.

View File

@ -78,6 +78,8 @@ GimpObject * gimp_container_get_neighbor_of_active (GimpContainer *container,
gchar * gimp_markup_extract_text (const gchar *markup); gchar * gimp_markup_extract_text (const gchar *markup);
const gchar* gimp_enum_get_value_name (GType enum_type,
gint value);
/* Common values for the n_snap_lines parameter of /* Common values for the n_snap_lines parameter of
* gimp_constrain_line. * gimp_constrain_line.