aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/reference/shell/eshell-sections.txt2
-rw-r--r--doc/reference/shell/tmpl/e-util.sgml24
-rw-r--r--e-util/e-util.c74
-rw-r--r--e-util/e-util.h10
4 files changed, 110 insertions, 0 deletions
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt
index fce9efe715..9634551c5c 100644
--- a/doc/reference/shell/eshell-sections.txt
+++ b/doc/reference/shell/eshell-sections.txt
@@ -1165,6 +1165,8 @@ e_util_guess_mime_type
e_util_get_category_filter_options
e_binding_transform_color_to_string
e_binding_transform_string_to_color
+e_binding_transform_enum_nick_to_value
+e_binding_transform_enum_value_to_nick
e_binding_transform_source_to_uid
e_binding_transform_uid_to_source
e_charset_add_radio_actions
diff --git a/doc/reference/shell/tmpl/e-util.sgml b/doc/reference/shell/tmpl/e-util.sgml
index edc49fb2ae..060ec3f322 100644
--- a/doc/reference/shell/tmpl/e-util.sgml
+++ b/doc/reference/shell/tmpl/e-util.sgml
@@ -359,6 +359,30 @@ Miscellaneous Utilities
@Returns:
+<!-- ##### FUNCTION e_binding_transform_enum_nick_to_value ##### -->
+<para>
+
+</para>
+
+@binding:
+@source_value:
+@target_value:
+@not_used:
+@Returns:
+
+
+<!-- ##### FUNCTION e_binding_transform_enum_value_to_nick ##### -->
+<para>
+
+</para>
+
+@binding:
+@source_value:
+@target_value:
+@not_used:
+@Returns:
+
+
<!-- ##### FUNCTION e_binding_transform_source_to_uid ##### -->
<para>
diff --git a/e-util/e-util.c b/e-util/e-util.c
index abc6ccc377..4c2764de4b 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1565,6 +1565,80 @@ e_binding_transform_string_to_color (GBinding *binding,
}
/**
+ * e_binding_transform_enum_value_to_nick:
+ * @binding: a #GBinding
+ * @source_value: a #GValue whose type is derived from #G_TYPE_ENUM
+ * @target_value: a #GValue of type #G_TYPE_STRING
+ * @not_used: not used
+ *
+ * Transforms an enumeration value to its corresponding nickname.
+ *
+ * Returns: %TRUE if the enum value has a corresponding nickname
+ **/
+gboolean
+e_binding_transform_enum_value_to_nick (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer not_used)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+ gint value;
+ gboolean success = FALSE;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+
+ enum_class = g_type_class_peek (G_VALUE_TYPE (source_value));
+ g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), FALSE);
+
+ value = g_value_get_enum (source_value);
+ enum_value = g_enum_get_value (enum_class, value);
+ if (enum_value != NULL) {
+ g_value_set_string (target_value, enum_value->value_nick);
+ success = TRUE;
+ }
+
+ return success;
+}
+
+/**
+ * e_binding_transform_enum_nick_to_value:
+ * @binding: a #GBinding
+ * @source_value: a #GValue of type #G_TYPE_STRING
+ * @target_value: a #GValue whose type is derived from #G_TYPE_ENUM
+ * @not_used: not_used
+ *
+ * Transforms an enumeration nickname to its corresponding value.
+ *
+ * Returns: %TRUE if the enum nickname has a corresponding value
+ **/
+gboolean
+e_binding_transform_enum_nick_to_value (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer not_used)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+ const gchar *string;
+ gboolean success = FALSE;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+
+ enum_class = g_type_class_peek (G_VALUE_TYPE (target_value));
+ g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), FALSE);
+
+ string = g_value_get_string (source_value);
+ enum_value = g_enum_get_value_by_nick (enum_class, string);
+ if (enum_value != NULL) {
+ g_value_set_enum (target_value, enum_value->value);
+ success = TRUE;
+ }
+
+ return success;
+}
+
+/**
* e_binding_transform_source_to_uid:
* @binding: a #GBinding
* @source_value: a #GValue of type #E_TYPE_SOURCE
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 4e982bf248..6560481f06 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -156,6 +156,16 @@ gboolean e_binding_transform_string_to_color
const GValue *source_value,
GValue *target_value,
gpointer not_used);
+gboolean e_binding_transform_enum_value_to_nick
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer not_used);
+gboolean e_binding_transform_enum_nick_to_value
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer not_used);
gboolean e_binding_transform_source_to_uid
(GBinding *binding,
const GValue *source_value,