summaryrefslogtreecommitdiffhomepage
path: root/src/lib/Xmobar/X11/XPMFile.hsc
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2018-11-25 15:10:29 +0000
committerjao <jao@gnu.org>2018-11-25 15:10:29 +0000
commit77df1ac30fa7af5948f7ff64f5fee9aed64552b3 (patch)
tree647a4eb67ff1c293a5c530538ee88fc0093b577a /src/lib/Xmobar/X11/XPMFile.hsc
parente0d6da82de8d0d1cef98896164c6016b84e47068 (diff)
downloadxmobar-77df1ac30fa7af5948f7ff64f5fee9aed64552b3.tar.gz
xmobar-77df1ac30fa7af5948f7ff64f5fee9aed64552b3.tar.bz2
Back to app/src, since it seems they're the default convention for stack
Diffstat (limited to 'src/lib/Xmobar/X11/XPMFile.hsc')
-rw-r--r--src/lib/Xmobar/X11/XPMFile.hsc60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/lib/Xmobar/X11/XPMFile.hsc b/src/lib/Xmobar/X11/XPMFile.hsc
deleted file mode 100644
index 2daffac..0000000
--- a/src/lib/Xmobar/X11/XPMFile.hsc
+++ /dev/null
@@ -1,60 +0,0 @@
-{-# LANGUAGE FlexibleContexts, ForeignFunctionInterface #-}
------------------------------------------------------------------------------
--- |
--- Module : XPMFile
--- Copyright : (C) 2014, 2018 Alexander Shabalin
--- License : BSD3
---
--- Maintainer : jao@gnu.org
--- Stability : unstable
--- Portability : unportable
---
------------------------------------------------------------------------------
-
-module Xmobar.X11.XPMFile(readXPMFile) where
-
-#if MIN_VERSION_mtl(2, 2, 1)
-import Control.Monad.Except(MonadError(..))
-#else
-import Control.Monad.Error(MonadError(..))
-#endif
-import Control.Monad.Trans(MonadIO(..))
-import Graphics.X11.Xlib(Dimension, Display(..), Drawable, Pixmap)
-import Foreign.C.String(CString, withCString)
-import Foreign.C.Types(CInt(..), CLong)
-import Foreign.Ptr(Ptr)
-import Foreign.Marshal.Alloc(alloca, allocaBytes)
-import Foreign.Storable(peek, peekByteOff, pokeByteOff)
-
-#include <X11/xpm.h>
-
-foreign import ccall "XpmReadFileToPixmap"
- xpmReadFileToPixmap :: Display -> Drawable -> CString -> Ptr Pixmap -> Ptr Pixmap -> Ptr () -> IO CInt
-
-readXPMFile
- :: (MonadError String m, MonadIO m)
- => Display
- -> Drawable
- -> String
- -> m (Dimension, Dimension, Pixmap, Maybe Pixmap)
-readXPMFile display d filename =
- toError $ withCString filename $ \c_filename ->
- alloca $ \pixmap_return ->
- alloca $ \shapemask_return ->
- allocaBytes (#size XpmAttributes) $ \attributes -> do
- (#poke XpmAttributes, valuemask) attributes ((#const XpmReturnAllocPixels) :: CLong)
- res <- xpmReadFileToPixmap display d c_filename pixmap_return shapemask_return attributes
- case res of
- 0 -> do
- width <- (#peek XpmAttributes, width) attributes
- height <- (#peek XpmAttributes, height) attributes
- pixmap <- peek pixmap_return
- shapemask <- peek shapemask_return
- return $ Right (width, height, pixmap, if shapemask == 0 then Nothing else Just shapemask)
- 1 -> return $ Left "readXPMFile: XpmColorError"
- -1 -> return $ Left "readXPMFile: XpmOpenFailed"
- -2 -> return $ Left "readXPMFile: XpmFileInvalid"
- -3 -> return $ Left "readXPMFile: XpmNoMemory"
- -4 -> return $ Left "readXPMFile: XpmColorFailed"
- _ -> return $ Left "readXPMFile: Unknown error"
- where toError m = either throwError return =<< liftIO m