summaryrefslogtreecommitdiff
path: root/src/egg-discrete.c
diff options
context:
space:
mode:
authorPedro Martinez-Julia <[email protected]>2011-03-07 22:31:40 +0000
committerBenjamin Valentin <[email protected]>2012-03-17 15:45:40 +0100
commit3b3bddfeea90ce4d33aa137d6b64b066e81324f3 (patch)
tree95857e5b2339c9d0b0be810684d15df4b2a29b37 /src/egg-discrete.c
parent285e040fd7ba4bedc25054790b4de9eb0fcb6410 (diff)
downloadmate-power-manager-3b3bddfeea90ce4d33aa137d6b64b066e81324f3.tar.bz2
mate-power-manager-3b3bddfeea90ce4d33aa137d6b64b066e81324f3.tar.xz
Fixed #644143, how to convert from percentage to discrete and vice-versa.
Signed-off-by: Richard Hughes <[email protected]>
Diffstat (limited to 'src/egg-discrete.c')
-rw-r--r--src/egg-discrete.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/egg-discrete.c b/src/egg-discrete.c
index a051282..fe910cc 100644
--- a/src/egg-discrete.c
+++ b/src/egg-discrete.c
@@ -47,7 +47,7 @@ egg_discrete_from_percent (guint percentage, guint levels)
egg_warning ("levels is 0!");
return 0;
}
- return ((gfloat) percentage * (gfloat) (levels - 1)) / 100.0f;
+ return (guint) ((((gfloat) percentage * (gfloat) (levels - 1)) / 100.0f) + 0.5f);
}
/**
@@ -69,7 +69,7 @@ egg_discrete_to_percent (guint discrete, guint levels)
egg_warning ("levels is 0!");
return 0;
}
- return (guint) ((gfloat) discrete * (100.0f / (gfloat) (levels - 1)));
+ return (guint) (((gfloat) discrete * (100.0f / (gfloat) (levels - 1))) + 0.5f);
}
/**