[gimp] app: Add gimp_enum_get_value_name() utility function
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Add gimp_enum_get_value_name() utility function
- Date: Tue, 26 Oct 2010 12:15:35 +0000 (UTC)
commit ee81f23f0a08fa0f9676b865d8409ca4ffba5d45
Author: Martin Nordholts <martinn src gnome org>
Date: Tue Oct 26 13:45:17 2010 +0200
app: Add gimp_enum_get_value_name() utility function
app/core/gimp-utils.c | 26 ++++++++++++++++++++++++++
app/core/gimp-utils.h | 2 ++
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimp-utils.c b/app/core/gimp-utils.c
index a9d1189..5b2ad6c 100644
--- a/app/core/gimp-utils.c
+++ b/app/core/gimp-utils.c
@@ -686,6 +686,32 @@ gimp_markup_extract_text (const gchar *markup)
}
/**
+ * 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:
* @point: The point to calculate the distance for.
* @point_on_line: A point on the line.
diff --git a/app/core/gimp-utils.h b/app/core/gimp-utils.h
index 6c77140..96043fc 100644
--- a/app/core/gimp-utils.h
+++ b/app/core/gimp-utils.h
@@ -78,6 +78,8 @@ GimpObject * gimp_container_get_neighbor_of_active (GimpContainer *container,
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
* gimp_constrain_line.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]