[glib/wip/plist] Remove object path, signature support
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/plist] Remove object path, signature support
- Date: Sat, 31 Dec 2011 17:01:31 +0000 (UTC)
commit 4f1c0c8d5622cfcc64c73e46803910686356f56d
Author: William Hua <william attente ca>
Date: Sat Dec 31 11:56:50 2011 -0500
Remove object path, signature support
gio/gnextstepsettingsbackend.c | 84 +++++++++++----------------------------
1 files changed, 24 insertions(+), 60 deletions(-)
---
diff --git a/gio/gnextstepsettingsbackend.c b/gio/gnextstepsettingsbackend.c
index 4431016..876493c 100644
--- a/gio/gnextstepsettingsbackend.c
+++ b/gio/gnextstepsettingsbackend.c
@@ -342,8 +342,6 @@ g_nextstep_settings_backend_get_g_variant (id object,
return g_variant_new_handle ([object longValue]);
else if (g_variant_type_equal (type, G_VARIANT_TYPE_DOUBLE))
return g_variant_new_double ([object doubleValue]);
- else
- return NULL;
}
else if ([object isKindOfClass:[NSString class]])
{
@@ -359,75 +357,43 @@ g_nextstep_settings_backend_get_g_variant (id object,
else if (g_variant_type_equal (type, G_VARIANT_TYPE_SIGNATURE))
return g_variant_is_signature (string) ?
g_variant_new_signature (string) : NULL;
- else
- return NULL;
}
else if ([object isKindOfClass:[NSDictionary class]])
{
- if (g_variant_type_is_subtype_of (type, G_VARIANT_TYPE_DICTIONARY))
+ if (g_variant_type_is_subtype_of (type, G_VARIANT_TYPE ("a{s*}")))
{
- const GVariantType *element_type;
- const GVariantType *key_type;
const GVariantType *value_type;
+ GVariantBuilder builder;
+ NSString *key;
+
+ value_type = g_variant_type_value (g_variant_type_element (type));
- element_type = g_variant_type_element (type);
- key_type = g_variant_type_first (element_type);
- value_type = g_variant_type_next (key_type);
+ g_variant_builder_init (&builder, type);
- if (g_variant_type_equal (key_type, G_VARIANT_TYPE_STRING) ||
- g_variant_type_equal (key_type, G_VARIANT_TYPE_OBJECT_PATH) ||
- g_variant_type_equal (key_type, G_VARIANT_TYPE_SIGNATURE))
+ for (key in object)
{
- GVariantBuilder builder;
- NSString *key;
+ GVariant *name;
+ id value;
+ GVariant *variant;
+ GVariant *entry;
- g_variant_builder_init (&builder, type);
+ name = g_variant_new_string ([key UTF8String]);
+ value = [object objectForKey:key];
+ variant = g_nextstep_settings_backend_get_g_variant (value, value_type);
- for (key in object)
+ if (variant == NULL)
{
- id value;
- GVariant *name;
- GVariant *variant;
- GVariant *entry;
-
- if ((g_variant_type_equal (key_type, G_VARIANT_TYPE_OBJECT_PATH) &&
- !g_variant_is_object_path ([key UTF8String])) ||
- (g_variant_type_equal (key_type, G_VARIANT_TYPE_SIGNATURE) &&
- !g_variant_is_signature ([key UTF8String])))
- {
- g_variant_builder_clear (&builder);
-
- return NULL;
- }
-
- value = [object objectForKey:key];
- variant = g_nextstep_settings_backend_get_g_variant (value, value_type);
-
- if (variant == NULL)
- {
- g_variant_builder_clear (&builder);
-
- return NULL;
- }
-
- if (g_variant_type_equal (key_type, G_VARIANT_TYPE_STRING))
- name = g_variant_new_string ([key UTF8String]);
- else if (g_variant_type_equal (key_type, G_VARIANT_TYPE_OBJECT_PATH))
- name = g_variant_new_object_path ([key UTF8String]);
- else if (g_variant_type_equal (key_type, G_VARIANT_TYPE_SIGNATURE))
- name = g_variant_new_signature ([key UTF8String]);
-
- entry = g_variant_new_dict_entry (name, variant);
- g_variant_builder_add_value (&builder, entry);
+ g_variant_builder_clear (&builder);
+
+ return NULL;
}
- return g_variant_builder_end (&builder);
+ entry = g_variant_new_dict_entry (name, variant);
+ g_variant_builder_add_value (&builder, entry);
}
- else
- return NULL;
+
+ return g_variant_builder_end (&builder);
}
- else
- return NULL;
}
else if ([object isKindOfClass:[NSArray class]])
{
@@ -456,11 +422,9 @@ g_nextstep_settings_backend_get_g_variant (id object,
return g_variant_builder_end (&builder);
}
- else
- return NULL;
}
- else
- return NULL;
+
+ return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]