From cd3800287297bdcd9fb8c90ee01a2414be3b9312 Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Mon, 2 Jan 2012 14:14:41 +0000 Subject: change units to the IEC standard (and the Ubuntu units policy) for base2 (/1024) - KiB/GiB etc. this is instead of KB/s etc which Windows and many other apps use for base2. I've tried to fix up the translations as best as I can. --- src/json.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/json.c') diff --git a/src/json.c b/src/json.c index 0ffc2fa..38bcf76 100644 --- a/src/json.c +++ b/src/json.c @@ -92,3 +92,23 @@ JsonObject *get_arguments(JsonObject * req) { return json_object_get_object_member(req, PARAM_ARGUMENTS); } + +gdouble json_double_to_progress(JsonNode * n) +{ + return json_node_really_get_double(n) * 100.0; +} + +gdouble json_node_really_get_double(JsonNode * node) +{ + GValue a = { 0 }; + + json_node_get_value(node, &a); + switch (G_VALUE_TYPE(&a)) { + case G_TYPE_INT64: + return (gdouble) g_value_get_int64(&a); + case G_TYPE_DOUBLE: + return g_value_get_double(&a); + default: + return 0.0; + } +} -- cgit v1.2.3