File tree Expand file tree Collapse file tree 4 files changed +13
-5
lines changed
Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ initApp = do
2828 menuBar <- Gtk. menuBarNew
2929 OSX. applicationSetMenuBar app menuBar
3030 logo <- $ loadLogo
31- OSX. applicationSetDockIconPixbuf app ( Just logo)
31+ OSX. applicationSetDockIconPixbuf app logo
3232 OSX. applicationReady app
3333
3434#else
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE ScopedTypeVariables #-}
12{-# LANGUAGE TemplateHaskell #-}
23module GUI.DataFiles
34 ( ui
45 , loadLogo
56 ) where
7+ import Control.Exception (IOException , Handler (.. ), catches )
68import System.IO
79
810import Data.FileEmbed
911import Graphics.UI.Gtk (Pixbuf , pixbufNewFromFile )
1012import Language.Haskell.TH
13+ import System.Glib (GError )
1114import System.IO.Temp
1215import qualified Data.ByteString as B
1316import qualified Data.Text.Encoding as TE
@@ -22,12 +25,17 @@ logoFile = "threadscope.png"
2225ui :: Q Exp
2326ui = [| TE. decodeUtf8 $ (makeRelativeToProject uiFile >>= embedFile) | ]
2427
25- renderLogo :: B. ByteString -> IO Pixbuf
28+ renderLogo :: B. ByteString -> IO ( Maybe Pixbuf )
2629renderLogo bytes =
2730 withSystemTempFile logoFile $ \ path h -> do
2831 B. hPut h bytes
2932 hClose h
30- pixbufNewFromFile path
33+ Just <$> pixbufNewFromFile path
34+ `catches`
35+ -- in case of a failure in the file IO or pixbufNewFromFile, return Nothing
36+ [ Handler $ \ (_ :: IOException ) -> return Nothing
37+ , Handler $ \ (_ :: GError ) -> return Nothing
38+ ]
3139
3240-- | Load the logo file as a 'Pixbuf'.
3341loadLogo :: Q Exp
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ aboutDialog parent
2828 " Mikolaj Konarski <mikolaj@well-typed.com>" ,
2929 " Nicolas Wu <nick@well-typed.com>" ,
3030 " Eric Kow <eric@well-typed.com>" ],
31- aboutDialogLogo := Just logo,
31+ aboutDialogLogo := logo,
3232 aboutDialogWebsite := " http://www.haskell.org/haskellwiki/ThreadScope" ,
3333 windowTransientFor := toWindow parent
3434 ]
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ mainWindowNew builder actions = do
141141 ------------------------------------------------------------------------
142142
143143 logo <- $ loadLogo
144- set mainWindow [ windowIcon := Just logo ]
144+ set mainWindow [ windowIcon := logo ]
145145
146146 ------------------------------------------------------------------------
147147 -- Status bar functionality
You can’t perform that action at this time.
0 commit comments