summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2012-01-02 14:14:41 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2012-01-02 14:14:41 +0000
commitcd3800287297bdcd9fb8c90ee01a2414be3b9312 (patch)
tree93c4718a5f8dab79f9fd3c0af22c7ab1fc892a26 /src/json.c
parent8259ceddd02f76a337bb7037cdf5b86872ad09c6 (diff)
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.
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c20
1 files changed, 20 insertions, 0 deletions
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;
+ }
+}