summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 05c28ee..07a6440 100644
--- a/src/util.c
+++ b/src/util.c
@@ -367,3 +367,17 @@ void trg_widget_set_visible(GtkWidget * w, gboolean visible) {
else
gtk_widget_hide(w);
}
+
+gdouble json_int_or_double_to_double(JsonNode *n)
+{
+ GValue a = { 0 };
+ json_node_get_value(n, &a);
+ switch (G_VALUE_TYPE(&a)) {
+ case G_TYPE_INT64:
+ return (gdouble) g_value_get_int64(&a) * 100.0;
+ case G_TYPE_DOUBLE:
+ return g_value_get_double(&a) * 100.0;
+ default:
+ return 0.0;
+ }
+}