summaryrefslogtreecommitdiff
path: root/Bustle.hs
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-11-04 13:52:31 -0400
committerWill Thompson <will.thompson@collabora.co.uk>2011-06-25 14:53:33 +0100
commitaecb004b3025b85b8d833d788c1bd44eb25a1db5 (patch)
treeac2ca45e46e9bd888789aaab2019f7182c60aa1c /Bustle.hs
parent18582f7ee95881cdf7cd2cec9cf92b1219724b49 (diff)
Show relative frequencies using progress bars
Diffstat (limited to 'Bustle.hs')
-rw-r--r--Bustle.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/Bustle.hs b/Bustle.hs
index 2d361ac..fd39230 100644
--- a/Bustle.hs
+++ b/Bustle.hs
@@ -22,6 +22,7 @@ where
import Prelude hiding (log, catch)
+import Control.Applicative ((<$>))
import Control.Arrow ((&&&))
import Control.Exception
import Control.Monad (when, forM)
@@ -237,12 +238,19 @@ newCountView method signal = do
treeViewAppendColumn countView nameColumn
- countRenderer <- cellRendererTextNew
countColumn <- treeViewColumnNew
treeViewColumnSetTitle countColumn "Frequency"
- cellLayoutPackStart countColumn countRenderer True
- cellLayoutSetAttributes countColumn countRenderer countStore $
- \(count, (_type, _name)) -> [ cellText := show count ]
+
+ -- Using a progress bar here is not really ideal, but I CBA to do anything
+ -- more auspicious right now. :)
+ countBar <- cellRendererProgressNew
+ cellLayoutPackStart countColumn countBar True
+ cellLayoutSetAttributes countColumn countBar countStore $ \(count, _) ->
+ [ cellProgressValue :=> do
+ upperBound <- maximum . map fst <$> listStoreToList countStore
+ return (count * 100 `div` upperBound)
+ , cellProgressText := Just $ show count
+ ]
treeViewAppendColumn countView countColumn