aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-06-28 16:19:57 -0500
committerTed Gould <ted@gould.cx>2010-06-28 16:19:57 -0500
commitfc3ce0689dacf6396b54e51f6a9c9f24a4a6b9ef (patch)
treee3943a560aa69f5349312df2c3d4d914dd9b35ce
parentfa34ff87fd2149d3c89c8b00fa8713b8a2b9b563 (diff)
downloadlibdbusmenu-fc3ce0689dacf6396b54e51f6a9c9f24a4a6b9ef.tar.gz
libdbusmenu-fc3ce0689dacf6396b54e51f6a9c9f24a4a6b9ef.tar.bz2
libdbusmenu-fc3ce0689dacf6396b54e51f6a9c9f24a4a6b9ef.zip
Restructuring a bit to make it more reusable.
-rw-r--r--tests/json-loader.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/tests/json-loader.c b/tests/json-loader.c
index 94df096..aa11aa5 100644
--- a/tests/json-loader.c
+++ b/tests/json-loader.c
@@ -2,9 +2,27 @@
#include "json-loader.h"
static GValue *
-handle_complex_types (JsonNode * node)
+node2value (JsonNode * node)
{
+ if (node == NULL) {
+ return NULL;
+ }
+
+ GValue * value = g_new0(GValue, 1);
+ if (JSON_NODE_TYPE(node) == JSON_NODE_VALUE) {
+ json_node_get_value(node, value);
+ return value;
+ }
+
+ if (JSON_NODE_TYPE(node) == JSON_NODE_ARRAY) {
+ }
+
+
+ if (JSON_NODE_TYPE(node) == JSON_NODE_OBJECT) {
+ }
+
+ g_free(value);
return NULL;
}
@@ -21,19 +39,12 @@ set_props (DbusmenuMenuitem * mi, JsonObject * node)
if (!g_strcmp0(member, "submenu")) { continue; }
JsonNode * lnode = json_object_get_member(node, member);
+ GValue * value = node2value(lnode);
- if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) {
- GValue * value = handle_complex_types(lnode);
- if (value != NULL) {
- dbusmenu_menuitem_property_set_value(mi, member, value);
- g_value_unset(value);
- g_free(value);
- }
- } else {
- GValue value = {0};
- json_node_get_value(lnode, &value);
- dbusmenu_menuitem_property_set_value(mi, member, &value);
- g_value_unset(&value);
+ if (value != NULL) {
+ dbusmenu_menuitem_property_set_value(mi, member, value);
+ g_value_unset(value);
+ g_free(value);
}
}