summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Bustle/Diagram.hs18
-rw-r--r--Bustle/Marquee.hs (renamed from Bustle/Markup.hs)52
-rw-r--r--Bustle/StatisticsPane.hs34
-rw-r--r--Bustle/UI.hs3
-rw-r--r--Bustle/UI/DetailsView.hs10
-rw-r--r--Bustle/UI/Recorder.hs3
-rw-r--r--bustle.cabal2
7 files changed, 63 insertions, 59 deletions
diff --git a/Bustle/Diagram.hs b/Bustle/Diagram.hs
index bc6a794..f9a96b7 100644
--- a/Bustle/Diagram.hs
+++ b/Bustle/Diagram.hs
@@ -58,8 +58,8 @@ import Graphics.UI.Gtk.Cairo (cairoCreateContext, showLayout)
import Graphics.Rendering.Pango.Layout
import Graphics.Rendering.Pango.Font
-import qualified Bustle.Markup as Markup
-import Bustle.Markup (Markup)
+import qualified Bustle.Marquee as Marquee
+import Bustle.Marquee (Marquee)
import Bustle.Util
import Bustle.Types (ObjectPath, InterfaceName, MemberName)
@@ -430,7 +430,7 @@ drawArc cx cy dx dy x1 y1 x2 y2 cap = saved $ do
stroke
setSourceRGB 0 0 0
- l <- mkLayout (Markup.escape cap) EllipsizeNone AlignLeft
+ l <- mkLayout (Marquee.escape cap) EllipsizeNone AlignLeft
(PangoRectangle _ _ textWidth _, _) <- liftIO $ layoutGetExtents l
let tx = min x2 dx + abs (x2 - dx) / 2
moveTo (if x1 > cx then tx - textWidth else tx) (y2 - 5)
@@ -445,7 +445,7 @@ font = unsafePerformIO $ do
{-# NOINLINE font #-}
mkLayout :: (MonadIO m)
- => Markup -> EllipsizeMode -> LayoutAlignment
+ => Marquee -> EllipsizeMode -> LayoutAlignment
-> m PangoLayout
mkLayout s e a = liftIO $ do
ctx <- cairoCreateContext Nothing
@@ -456,7 +456,7 @@ mkLayout s e a = liftIO $ do
-- which we need to disambiguate between Text and String. Old versions were
-- .. -> IO String
-- so go with that.
- layoutSetMarkup layout (Markup.unMarkup s) :: IO String
+ layoutSetMarkup layout (Marquee.toPangoMarkup s) :: IO String
layoutSetFontDescription layout (Just font)
layoutSetEllipsize layout e
layoutSetAlignment layout a
@@ -470,7 +470,7 @@ withWidth m w = do
drawHeader :: [String] -> Double -> Double -> Render ()
drawHeader names x y = forM_ (zip [0..] names) $ \(i, name) -> do
- l <- mkLayout (Markup.escape name) EllipsizeEnd AlignCenter `withWidth` columnWidth
+ l <- mkLayout (Marquee.escape name) EllipsizeEnd AlignCenter `withWidth` columnWidth
moveTo (x - (columnWidth / 2)) (y + i * h)
showLayout l
where h = 10
@@ -491,14 +491,14 @@ drawMember p i m isReturn x y = do
moveTo (x - memberWidth / 2) y'
showLayout l
- path = (if isReturn then id else Markup.b) $ Markup.escape p
+ path = (if isReturn then id else Marquee.b) $ Marquee.escape p
fullMethod =
- (if isReturn then Markup.i else id) $ Markup.formatMember i m
+ (if isReturn then Marquee.i else id) $ Marquee.formatMember i m
drawTimestamp :: String -> Double -> Double -> Render ()
drawTimestamp ts x y = do
moveTo (x - timestampWidth / 2) (y - 10)
- showLayout =<< mkLayout (Markup.escape ts) EllipsizeNone AlignLeft `withWidth` timestampWidth
+ showLayout =<< mkLayout (Marquee.escape ts) EllipsizeNone AlignLeft `withWidth` timestampWidth
drawClientLines :: NonEmpty Double -> Double -> Double -> Render ()
drawClientLines xs y1 y2 = saved $ do
diff --git a/Bustle/Markup.hs b/Bustle/Marquee.hs
index 5c31552..46c2b4c 100644
--- a/Bustle/Markup.hs
+++ b/Bustle/Marquee.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
{-
-Bustle.Diagram: My First Type-Safe Markup Library
+Bustle.Marquee: My First Type-Safe Markup Library With A Cutesy Name To Not Collide With Pango's 'Markup' Which Is A Synonym For String
Copyright © 2011 Will Thompson
This library is free software; you can redistribute it and/or
@@ -17,9 +17,9 @@ You should have received a copy of the GNU Lesser General Public
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.Markup
- ( Markup
- , unMarkup
+module Bustle.Marquee
+ ( Marquee
+ , toPangoMarkup
, tag
, b
, i
@@ -29,6 +29,8 @@ module Bustle.Markup
, escape
, formatMember
+
+ , toString
)
where
@@ -42,44 +44,44 @@ import Graphics.Rendering.Pango.Markup (markSpan, SpanAttribute(..))
import Bustle.Types (ObjectPath, formatObjectPath, InterfaceName, formatInterfaceName, MemberName, formatMemberName)
-newtype Markup = Markup { unMarkup :: String }
+newtype Marquee = Marquee { unMarquee :: String }
deriving (Show, Read, Ord, Eq)
-instance Monoid Markup where
- mempty = Markup ""
- mappend x y = Markup (unMarkup x `mappend` unMarkup y)
- mconcat = Markup . mconcat . map unMarkup
+toPangoMarkup :: Marquee -> String
+toPangoMarkup = unMarquee
---raw :: String -> Markup
---raw = Markup
+instance Monoid Marquee where
+ mempty = Marquee ""
+ mappend x y = Marquee (unMarquee x `mappend` unMarquee y)
+ mconcat = Marquee . mconcat . map unMarquee
-tag :: String -> Markup -> Markup
+tag :: String -> Marquee -> Marquee
tag name contents =
- Markup $ concat [ "<", name, ">"
- , unMarkup contents
+ Marquee $ concat [ "<", name, ">"
+ , unMarquee contents
, "</", name, ">"
]
-b, i :: Markup -> Markup
+b, i :: Marquee -> Marquee
b = tag "b"
i = tag "i"
a :: String
-> String
- -> Markup
+ -> Marquee
a href contents =
- Markup $ concat [ "<a href=\"", escapeMarkup href, "\">"
+ Marquee $ concat [ "<a href=\"", escapeMarkup href, "\">"
, escapeMarkup contents
, "</a>"
]
-span_ :: [SpanAttribute] -> Markup -> Markup
-span_ attrs = Markup . markSpan attrs . unMarkup
+span_ :: [SpanAttribute] -> Marquee -> Marquee
+span_ attrs = Marquee . markSpan attrs . unMarquee
-light :: Markup -> Markup
+light :: Marquee -> Marquee
light = span_ [FontWeight WeightLight]
-red :: Markup -> Markup
+red :: Marquee -> Marquee
red = span_ [FontForeground "#ff0000"]
-- Kind of a transitional measure because some strings are Strings, and some are Text.
@@ -101,12 +103,12 @@ instance Unescaped ObjectPath where
instance Unescaped MemberName where
toString = formatMemberName
-escape :: Unescaped s => s -> Markup
-escape = Markup . escapeMarkup . toString
+escape :: Unescaped s => s -> Marquee
+escape = Marquee . escapeMarkup . toString
-formatMember :: Maybe InterfaceName -> MemberName -> Markup
+formatMember :: Maybe InterfaceName -> MemberName -> Marquee
formatMember iface member = iface' `mappend` b (escape member)
where
iface' = case iface of
- Just ifaceName -> escape ifaceName `mappend` Markup "."
+ Just ifaceName -> escape ifaceName `mappend` Marquee "."
Nothing -> light (escape "(no interface) ")
diff --git a/Bustle/StatisticsPane.hs b/Bustle/StatisticsPane.hs
index 8e895a8..1faead4 100644
--- a/Bustle/StatisticsPane.hs
+++ b/Bustle/StatisticsPane.hs
@@ -26,12 +26,12 @@ where
import Control.Applicative ((<$>))
import Control.Monad (forM_)
import Text.Printf
-import Graphics.UI.Gtk hiding (Markup)
+import Graphics.UI.Gtk
import Bustle.Stats
import Bustle.Translation (__)
import Bustle.Types (Log)
-import qualified Bustle.Markup as Markup
-import Bustle.Markup (Markup)
+import qualified Bustle.Marquee as Marquee
+import Bustle.Marquee (Marquee)
import Data.Monoid
data StatsPane =
@@ -83,20 +83,20 @@ statsPaneSetMessages sp sessionMessages systemMessages = do
addTextRenderer :: TreeViewColumn
-> ListStore a
-> Bool
- -> (a -> Markup)
+ -> (a -> Marquee)
-> IO CellRendererText
addTextRenderer col store expand f = do
renderer <- cellRendererTextNew
cellLayoutPackStart col renderer expand
set renderer [ cellTextSizePoints := 7 ]
cellLayoutSetAttributes col renderer store $ \x ->
- [ cellTextMarkup := (Just . Markup.unMarkup) $ f x ]
+ [ cellTextMarkup := (Just . Marquee.toPangoMarkup) $ f x ]
return renderer
addMemberRenderer :: TreeViewColumn
-> ListStore a
-> Bool
- -> (a -> Markup)
+ -> (a -> Marquee)
-> IO CellRendererText
addMemberRenderer col store expand f = do
renderer <- addTextRenderer col store expand f
@@ -110,7 +110,7 @@ addMemberRenderer col store expand f = do
addStatColumn :: TreeView
-> ListStore a
-> String
- -> (a -> Markup)
+ -> (a -> Marquee)
-> IO ()
addStatColumn view store title f = do
col <- treeViewColumnNew
@@ -126,7 +126,7 @@ addTextStatColumn :: TreeView
-> (a -> String)
-> IO ()
addTextStatColumn view store title f =
- addStatColumn view store title (Markup.escape . f)
+ addStatColumn view store title (Marquee.escape . f)
-- If we managed to load the method and signal icons...
maybeAddTypeIconColumn :: CellLayoutClass layout
@@ -164,7 +164,7 @@ newCountView method signal = do
TallySignal -> False
addMemberRenderer nameColumn countStore True $ \fi ->
- Markup.formatMember (fiInterface fi) (fiMember fi)
+ Marquee.formatMember (fiInterface fi) (fiMember fi)
treeViewAppendColumn countView nameColumn
countColumn <- treeViewColumnNew
@@ -203,7 +203,7 @@ newTimeView = do
]
addMemberRenderer nameColumn timeStore True $ \ti ->
- Markup.formatMember (tiInterface ti) (tiMethodName ti)
+ Marquee.formatMember (tiInterface ti) (tiMethodName ti)
treeViewAppendColumn timeView nameColumn
addTextStatColumn timeView timeStore (__ "Total")
@@ -214,16 +214,16 @@ newTimeView = do
return (timeStore, timeView)
-formatSizeInfoMember :: SizeInfo -> Markup
+formatSizeInfoMember :: SizeInfo -> Marquee
formatSizeInfoMember si =
- f (Markup.formatMember (siInterface si) (siName si))
+ f (Marquee.formatMember (siInterface si) (siName si))
where
f = case siType si of
- SizeReturn -> Markup.i
- SizeError -> Markup.red
+ SizeReturn -> Marquee.i
+ SizeError -> Marquee.red
_ -> id
-formatSize :: Int -> Markup
+formatSize :: Int -> Marquee
formatSize s
| s < maxB = value 1 `mappend` units (__ "B")
| s < maxKB = value 1024 `mappend` units (__ "KB")
@@ -232,9 +232,9 @@ formatSize s
maxB = 10000
maxKB = 10000 * 1024
- units = Markup.escape . (' ':)
+ units = Marquee.escape . (' ':)
- value factor = Markup.escape (show (s `div` factor))
+ value factor = Marquee.escape (show (s `div` factor))
newSizeView :: Maybe Pixbuf
-> Maybe Pixbuf
diff --git a/Bustle/UI.hs b/Bustle/UI.hs
index 9fa340d..733dd08 100644
--- a/Bustle/UI.hs
+++ b/Bustle/UI.hs
@@ -38,6 +38,7 @@ import Bustle.Application.Monad
import Bustle.Renderer
import Bustle.Types
import Bustle.Diagram
+import Bustle.Marquee (toString)
import Bustle.Util
import Bustle.UI.AboutDialog
import Bustle.UI.Canvas
@@ -526,7 +527,7 @@ loadPixbuf :: FilePath -> IO (Maybe Pixbuf)
loadPixbuf filename = do
iconName <- getDataFileName $ "data/" ++ filename
C.catch (fmap Just (pixbufNewFromFile iconName))
- (\(GError _ _ msg) -> warn (show msg) >> return Nothing)
+ (\(GError _ _ msg) -> warn (toString msg) >> return Nothing)
openDialogue :: Window -> B ()
openDialogue window = embedIO $ \r -> do
diff --git a/Bustle/UI/DetailsView.hs b/Bustle/UI/DetailsView.hs
index d1b9d96..c347bbd 100644
--- a/Bustle/UI/DetailsView.hs
+++ b/Bustle/UI/DetailsView.hs
@@ -25,13 +25,13 @@ module Bustle.UI.DetailsView
where
import Data.List (intercalate)
-import Graphics.UI.Gtk hiding (Signal, Markup)
+import Graphics.UI.Gtk hiding (Signal)
import qualified DBus as D
import Bustle.Translation (__)
import Bustle.Types
-import Bustle.Markup
+import Bustle.Marquee
import Bustle.VariantFormatter
data DetailsView =
@@ -99,7 +99,7 @@ detailsViewNew = do
widgetShowAll table
return $ DetailsView table title pathLabel memberLabel view
-pickTitle :: Detailed Message -> Markup
+pickTitle :: Detailed Message -> Marquee
pickTitle (Detailed _ m _) = case m of
MethodCall {} -> b (escape (__ "Method call"))
MethodReturn {} -> b (escape (__ "Method return"))
@@ -111,7 +111,7 @@ pickTitle (Detailed _ m _) = case m of
getMemberMarkup :: Member -> String
getMemberMarkup m =
- unMarkup $ formatMember (iface m) (membername m)
+ toPangoMarkup $ formatMember (iface m) (membername m)
getMember :: Detailed Message -> Maybe Member
getMember (Detailed _ m _) = case m of
@@ -140,7 +140,7 @@ detailsViewUpdate :: DetailsView
detailsViewUpdate d m = do
buf <- textViewGetBuffer $ detailsBodyView d
let member_ = getMember m
- labelSetMarkup (detailsTitle d) (unMarkup $ pickTitle m)
+ labelSetMarkup (detailsTitle d) (toPangoMarkup $ pickTitle m)
labelSetText (detailsPath d) (maybe unknown (D.formatObjectPath . path) member_)
labelSetMarkup (detailsMember d) (maybe unknown getMemberMarkup member_)
textBufferSetText buf $ formatMessage m
diff --git a/Bustle/UI/Recorder.hs b/Bustle/UI/Recorder.hs
index 0e40a23..d0546bd 100644
--- a/Bustle/UI/Recorder.hs
+++ b/Bustle/UI/Recorder.hs
@@ -36,6 +36,7 @@ import Graphics.UI.Gtk
import Bustle.Loader.Pcap (convert)
import Bustle.Loader (isRelevant)
+import Bustle.Marquee (toString)
import Bustle.Monitor
import Bustle.Renderer
import Bustle.Translation (__)
@@ -143,7 +144,7 @@ recorderRun filename mwindow incoming finished = C.handle newFailed $ do
widgetShowAll dialog
where
newFailed (GError _ _ message) = do
- displayError mwindow (show message) Nothing
+ displayError mwindow (toString message) Nothing
recorderChooseFile :: FilePath
-> Maybe Window
diff --git a/bustle.cabal b/bustle.cabal
index 1f5ad25..d416fa2 100644
--- a/bustle.cabal
+++ b/bustle.cabal
@@ -71,7 +71,7 @@ Executable bustle
, Bustle.Loader
, Bustle.Loader.OldSkool
, Bustle.Loader.Pcap
- , Bustle.Markup
+ , Bustle.Marquee
, Bustle.Monitor
, Bustle.Noninteractive
, Bustle.Regions