+ if (G_VALUE_HOLDS_STRING (value))
+ {
+ g_value_set_string (value, g_variant_get_string (variant, NULL));
+ return TRUE;
+ }
+
+ else if (G_VALUE_HOLDS_ENUM (value))
+ {
+ GEnumClass *eclass;
+ GEnumValue *evalue;
+ const gchar *nick;
+
+ /* GParamSpecEnum holds a ref on the class so we just peek... */
+ eclass = g_type_class_peek (G_VALUE_TYPE (value));
+ nick = g_variant_get_string (variant, NULL);
+ evalue = g_enum_get_value_by_nick (eclass, nick);
+
+ 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 ("as")))
+ {
+ if (G_VALUE_HOLDS (value, G_TYPE_STRV))
+ {
+ g_value_take_boxed (value, g_variant_dup_strv (variant, NULL));
+ return TRUE;
+ }
+
+ else if (G_VALUE_HOLDS_FLAGS (value))
+ {
+ GFlagsClass *fclass;
+ GFlagsValue *fvalue;
+ const gchar *nick;
+ GVariantIter iter;
+ guint flags = 0;
+
+ fclass = g_type_class_peek (G_VALUE_TYPE (value));
+
+ g_variant_iter_init (&iter, variant);
+ while (g_variant_iter_next (&iter, "&s", &nick))
+ {
+ fvalue = g_flags_get_value_by_nick (fclass, nick);
+
+ if (fvalue)
+ flags |= fvalue->value;
+
+ else
+ {
+ g_warning ("Unable to lookup flags nick '%s' via GType\n",
+ nick);
+ return FALSE;
+ }
+ }
+
+ g_value_set_flags (value, flags);
+ return TRUE;
+ }