[glib] GSettings: complete support for enum binding
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GSettings: complete support for enum binding
- Date: Sat, 19 Jun 2010 20:14:16 +0000 (UTC)
commit ea6470e31a6884a7243e9cd4df9734f1dc4828b9
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Jun 19 16:13:58 2010 -0400
GSettings: complete support for enum binding
gio/gsettings-mapping.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gio/gsettings-mapping.c b/gio/gsettings-mapping.c
index cf1ac11..bbca56f 100644
--- a/gio/gsettings-mapping.c
+++ b/gio/gsettings-mapping.c
@@ -446,6 +446,28 @@ g_settings_get_mapping (GValue *value,
g_value_set_string (value, g_variant_get_string (variant, NULL));
return TRUE;
}
+
+ else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING) &&
+ G_VALUE_HOLDS_ENUM (value))
+ {
+ GEnumClass *eclass;
+ GEnumValue *evalue;
+ const gchar *nick;
+
+ eclass = g_type_class_ref (G_VALUE_TYPE (value));
+ nick = g_variant_get_string (variant, NULL);
+ evalue = g_enum_get_value_by_nick (eclass, nick);
+ g_type_class_unref (eclass);
+
+ if (evalue)
+ {
+ g_value_set_enum (value, evalue->value);
+ return TRUE;
+ }
+
+ g_warning ("Unable to lookup enum nick '%s' via GType\n", nick);
+ return FALSE;
+ }
}
else if (g_variant_is_of_type (variant, G_VARIANT_TYPE ("ay")))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]