From d07c661cb0b5f94aafbfb7de5316862ed2278073 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 30 Mar 2011 23:57:44 +0100 Subject: Move more stats UI to StatisticsPane --- Bustle/StatisticsPane.hs | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'Bustle/StatisticsPane.hs') 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) - -- cgit v1.2.3