From 05554f239c79d738848f5453b16b8ad01e9a5f50 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Sun, 14 Sep 2014 14:28:26 +0400 Subject: Add iconRoot config option For all if path does not start with "/", "./", "../" it will have iconRoot ++ "/" prepended to it. --- src/Bitmap.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Bitmap.hs') diff --git a/src/Bitmap.hs b/src/Bitmap.hs index ff79262..63baf6a 100644 --- a/src/Bitmap.hs +++ b/src/Bitmap.hs @@ -23,6 +23,7 @@ import Control.Monad.Trans(MonadIO(..)) import Data.Map hiding (foldr, map, filter) import Graphics.X11.Xlib import System.Directory (doesFileExist) +import System.FilePath (()) import System.Mem.Weak ( addFinalizer ) import ColorCache import Parsers (Widget(..)) @@ -41,15 +42,19 @@ data Bitmap = Bitmap { width :: Dimension , bitmapType :: BitmapType } -updateCache :: Display -> Window -> Map FilePath Bitmap -> +updateCache :: Display -> Window -> Map FilePath Bitmap -> FilePath -> [[(Widget, String, Maybe [Action])]] -> IO (Map FilePath Bitmap) -updateCache dpy win cache ps = do +updateCache dpy win cache iconRoot ps = do let paths = map (\(Icon p, _, _) -> p) . concatMap (filter icons) $ ps icons (Icon _, _, _) = True icons _ = False + expandPath path@('/':_) = path + expandPath path@('.':'/':_) = path + expandPath path@('.':'.':'/':_) = path + expandPath path = iconRoot path go m path = if member path m then return m - else do bitmap <- loadBitmap dpy win path + else do bitmap <- loadBitmap dpy win $ expandPath path return $ maybe m (\b -> insert path b m) bitmap foldM go cache paths -- cgit v1.2.3