[evolution-data-server/openismus-work] Fixup e_enum_to_string()
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work] Fixup e_enum_to_string()
- Date: Mon, 19 Nov 2012 11:47:26 +0000 (UTC)
commit 1d15117ac3501213629abb31aad158829188eb92
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Mon Nov 19 19:49:03 2012 +0900
Fixup e_enum_to_string()
libedataserver/e-data-server-util.c | 94 ++++++++++++++++++-----------------
1 files changed, 49 insertions(+), 45 deletions(-)
---
diff --git a/libedataserver/e-data-server-util.c b/libedataserver/e-data-server-util.c
index ebd45a1..cf330fa 100644
--- a/libedataserver/e-data-server-util.c
+++ b/libedataserver/e-data-server-util.c
@@ -1276,40 +1276,41 @@ e_binding_transform_enum_nick_to_value (GBinding *binding,
*
* Returns: %TRUE if the string was a valid name or nick
* for the given @type, %FALSE if the conversion failed.
+ *
+ * Since: 3.8
*/
gboolean
e_enum_from_string (GType type,
const gchar *string,
gint *enum_value)
{
- GEnumClass *eclass;
- GEnumValue *ev;
- gchar *endptr;
- gint value;
- gboolean retval = TRUE;
-
- g_return_val_if_fail (G_TYPE_IS_ENUM (type), 0);
- g_return_val_if_fail (string != NULL, 0);
-
- value = g_ascii_strtoull (string, &endptr, 0);
- if (endptr != string) /* parsed a number */
- *enum_value = value;
- else
- {
- eclass = g_type_class_ref (type);
- ev = g_enum_get_value_by_name (eclass, string);
- if (!ev)
- ev = g_enum_get_value_by_nick (eclass, string);
-
- if (ev)
- *enum_value = ev->value;
- else
- retval = FALSE;
-
- g_type_class_unref (eclass);
- }
-
- return retval;
+ GEnumClass *eclass;
+ GEnumValue *ev;
+ gchar *endptr;
+ gint value;
+ gboolean retval = TRUE;
+
+ g_return_val_if_fail (G_TYPE_IS_ENUM (type), FALSE);
+ g_return_val_if_fail (string != NULL, FALSE);
+
+ value = g_ascii_strtoull (string, &endptr, 0);
+ if (endptr != string) /* parsed a number */
+ *enum_value = value;
+ else {
+ eclass = g_type_class_ref (type);
+ ev = g_enum_get_value_by_name (eclass, string);
+ if (!ev)
+ ev = g_enum_get_value_by_nick (eclass, string);
+
+ if (ev)
+ *enum_value = ev->value;
+ else
+ retval = FALSE;
+
+ g_type_class_unref (eclass);
+ }
+
+ return retval;
}
/**
@@ -1319,29 +1320,32 @@ e_enum_from_string (GType type,
*
* Converts an enum value to a string using strings from the GType system.
*
- * Returns: the string representing @eval
+ * Returns: the string representing @eval
+ *
+ * Since: 3.8
*/
const gchar *
e_enum_to_string (GType etype,
gint eval)
{
- GEnumClass *eclass;
- const gchar *string = NULL;
- guint i;
+ GEnumClass *eclass;
+ const gchar *string = NULL;
+ guint i;
- eclass = g_type_class_ref (etype);
-
- g_return_val_if_fail (eclass != NULL, NULL);
- for (i = 0; i < eclass->n_values; i++)
- {
- if (eval == eclass->values[i].value)
- {
- string = eclass->values[i].value_nick;
- break;
- }
- }
- g_type_class_unref (eclass);
- return string;
+ eclass = g_type_class_ref (etype);
+
+ g_return_val_if_fail (eclass != NULL, NULL);
+
+ for (i = 0; i < eclass->n_values; i++) {
+
+ if (eval == eclass->values[i].value) {
+ string = eclass->values[i].value_nick;
+ break;
+ }
+ }
+
+ g_type_class_unref (eclass);
+ return string;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]