diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-03-30 23:57:44 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-06-25 14:53:34 +0100 |
commit | d07c661cb0b5f94aafbfb7de5316862ed2278073 (patch) | |
tree | 475dd9a078e06e35a38af344820f50c0d1aa7456 /Bustle/StatisticsPane.hs | |
parent | ee2960d0c2e31e6039ac4aac197f8fff32657aaf (diff) |
Move more stats UI to StatisticsPane
Diffstat (limited to 'Bustle/StatisticsPane.hs')
-rw-r--r-- | Bustle/StatisticsPane.hs | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/Bustle/StatisticsPane.hs b/Bustle/StatisticsPane.hs index e59946e..43d896b 100644 --- a/Bustle/StatisticsPane.hs +++ b/Bustle/StatisticsPane.hs @@ -17,18 +17,54 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -} module Bustle.StatisticsPane - ( newCountView - , newTimeView + ( StatsPane + , statsPaneNew + , statsPaneSetMessages ) where +import Control.Applicative ((<$>)) +import Control.Monad (forM_) import Text.Printf +import Graphics.UI.Gtk +import Graphics.UI.Gtk.Glade +import Bustle.Stats +import Bustle.Types (Log) -import Control.Applicative ((<$>)) +data StatsPane = + StatsPane { spCountStore :: ListStore FrequencyInfo + , spTimeStore :: ListStore TimeInfo + } -import Bustle.Stats +statsPaneNew :: GladeXML + -> Maybe Pixbuf + -> Maybe Pixbuf + -> IO StatsPane +statsPaneNew xml methodIcon signalIcon = do + [frequencySW, durationSW] <- mapM (xmlGetWidget xml castToScrolledWindow) + ["frequencySW", "durationSW"] -import Graphics.UI.Gtk + (countStore, countView) <- newCountView methodIcon signalIcon + containerAdd frequencySW countView + + (timeStore, timeView) <- newTimeView + containerAdd durationSW timeView + + return $ StatsPane countStore timeStore + +statsPaneSetMessages :: StatsPane + -> Log -- ^ session bus messages + -> Log -- ^ system bus messages + -> IO () +statsPaneSetMessages sp sessionMessages systemMessages = do + -- This conflates messages on the system bus and on the session bus, + -- but I think that's okay for now. + let allMessages = sessionMessages ++ systemMessages + freqs = frequencies allMessages + times = methodTimes allMessages + + forM_ (frequencies allMessages) $ listStoreAppend (spCountStore sp) + forM_ (methodTimes allMessages) $ listStoreAppend (spTimeStore sp) addTextRenderer :: TreeViewColumn -> ListStore a @@ -148,4 +184,3 @@ newTimeView = do (printf "%.3f" . tiMeanCallTime) return (timeStore, timeView) - |