{-# LANGUAGE OverloadedStrings #-}
module Yi.Frontend.Pango.Utils where
import Control.Exception (catch, throw)
import Data.Text (append)
import Paths_yi_frontend_pango
import System.FilePath
import Graphics.UI.Gtk
import System.Glib.GError
loadIcon :: FilePath -> IO Pixbuf
loadIcon :: FilePath -> IO Pixbuf
loadIcon FilePath
fpath = do
FilePath
iconfile <- FilePath -> IO FilePath
getDataFileName (FilePath -> IO FilePath) -> FilePath -> IO FilePath
forall a b. (a -> b) -> a -> b
$ FilePath
"art" FilePath -> FilePath -> FilePath
</> FilePath
fpath
Pixbuf
icoProject <-
IO Pixbuf -> (GError -> IO Pixbuf) -> IO Pixbuf
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
catch (FilePath -> IO Pixbuf
forall fp. GlibFilePath fp => fp -> IO Pixbuf
pixbufNewFromFile FilePath
iconfile)
(\(GError GErrorDomain
dom GErrorCode
code Text
msg) ->
GError -> IO Pixbuf
forall a e. Exception e => e -> a
throw (GError -> IO Pixbuf) -> GError -> IO Pixbuf
forall a b. (a -> b) -> a -> b
$ GErrorDomain -> GErrorCode -> Text -> GError
GError GErrorDomain
dom GErrorCode
code (Text -> GError) -> Text -> GError
forall a b. (a -> b) -> a -> b
$
Text
msg Text -> Text -> Text
`append` Text
" -- use the yi_datadir environment variable to"
Text -> Text -> Text
`append` Text
" specify an alternate location")
Pixbuf -> Maybe (Word8, Word8, Word8) -> IO Pixbuf
pixbufAddAlpha Pixbuf
icoProject ((Word8, Word8, Word8) -> Maybe (Word8, Word8, Word8)
forall a. a -> Maybe a
Just (Word8
0,Word8
255,Word8
0))