summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar.hs
diff options
context:
space:
mode:
authorEdward O'Callaghan <victoredwardocallaghan@gmail.com>2013-01-21 06:19:26 +1100
committerAlexander Polakov <plhk@sdf.org>2013-01-27 02:05:57 +0400
commitcfd729999901c39f6e0aac1c271d56ae6e704d3e (patch)
tree09aa95e118b7c409b8bc4f92850577712a2ae3df /src/Xmobar.hs
parent8c208d5e5ef970f465c4ee903367de8a8b41879a (diff)
downloadxmobar-cfd729999901c39f6e0aac1c271d56ae6e704d3e.tar.gz
xmobar-cfd729999901c39f6e0aac1c271d56ae6e704d3e.tar.bz2
XBM icon support
<icon=/path/to/icon>
Diffstat (limited to 'src/Xmobar.hs')
-rw-r--r--src/Xmobar.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Xmobar.hs b/src/Xmobar.hs
index 5fc0cd4..7730620 100644
--- a/src/Xmobar.hs
+++ b/src/Xmobar.hs
@@ -231,12 +231,15 @@ updateWin v = do
-- $print
-- | Draws in and updates the window
-drawInWin :: Rectangle -> [[(String, String)]] -> X ()
+drawInWin :: Rectangle -> [[(Widget, String)]] -> X ()
drawInWin (Rectangle _ _ wid ht) ~[left,center,right] = do
r <- ask
let (c,d ) = (config &&& display) r
(w,fs) = (window &&& fontS ) r
- strLn = io . mapM (\(s,cl) -> textWidth d fs s >>= \tw -> return (s,cl,fi tw))
+ strLn = io . mapM getWidth
+ getWidth (Text s,cl) = textWidth d fs s >>= \tw -> return (Text s,cl,fi tw)
+ getWidth (Icon s,cl) = return (Icon s,cl,fi ht)
+
withColors d [bgColor c, borderColor c] $ \[bgcolor, bdcolor] -> do
gc <- io $ createGC d w
-- create a pixmap to write to and fill it with a rectangle
@@ -261,11 +264,13 @@ drawInWin (Rectangle _ _ wid ht) ~[left,center,right] = do
-- | An easy way to print the stuff we need to print
printStrings :: Drawable -> GC -> XFont -> Position
- -> Align -> [(String, String, Position)] -> X ()
+ -> Align -> [(Widget, String, Position)] -> X ()
printStrings _ _ _ _ _ [] = return ()
printStrings dr gc fontst offs a sl@((s,c,l):xs) = do
r <- ask
- (as,ds) <- io $ textExtents fontst s
+ let fromWidget (Text t) = t
+ fromWidget (Icon t) = t
+ (as,ds) <- io $ textExtents fontst (fromWidget s)
let (conf,d) = (config &&& display) r
Rectangle _ _ wid ht = rect r
totSLen = foldr (\(_,_,len) -> (+) len) 0 sl