taffybar 3.2.3 → 3.2.4
raw patch · 5 files changed
+30/−10 lines, 5 files
Files
- src/System/Taffybar/Util.hs +16/−5
- src/System/Taffybar/Widget/MPRIS2.hs +1/−1
- src/System/Taffybar/Widget/Util.hs +11/−2
- src/System/Taffybar/Widget/WttrIn.hs +1/−1
- taffybar.cabal +1/−1
src/System/Taffybar/Util.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : System.Taffybar.Util@@ -21,6 +22,7 @@ import Control.Monad.Trans.Class import Control.Monad.Trans.Maybe import Control.Monad.Trans.Reader+import Data.Maybe import Data.Either.Combinators import Data.GI.Base.GError import qualified Data.GI.Gtk.Threading as Gtk@@ -127,17 +129,26 @@ catchGErrorsAsLeft :: IO a -> IO (Either GError a) catchGErrorsAsLeft action = catch (Right <$> action) (return . Left) -safePixbufNewFromFile :: FilePath -> IO (Either GError Gdk.Pixbuf)-safePixbufNewFromFile filepath =- catchGErrorsAsLeft (Gdk.pixbufNewFromFile filepath)+catchGErrorsAsNothing :: IO a -> IO (Maybe a)+catchGErrorsAsNothing = fmap rightToMaybe . catchGErrorsAsLeft +safePixbufNewFromFile :: FilePath -> IO (Maybe Gdk.Pixbuf)+safePixbufNewFromFile =+ handleResult . catchGErrorsAsNothing . Gdk.pixbufNewFromFile+ where+#if MIN_VERSION_gi_gdkpixbuf(2,0,26)+ handleResult = fmap join+#else+ handleResult = id+#endif+ getPixbufFromFilePath :: FilePath -> IO (Maybe Gdk.Pixbuf) getPixbufFromFilePath filepath = do result <- safePixbufNewFromFile filepath- when (isLeft result) $+ when (isNothing result) $ logM "System.Taffybar.WindowIcon" WARNING $ printf "Failed to load icon from filepath %s" filepath- return $ rightToMaybe result+ return result postGUIASync :: IO () -> IO () postGUIASync = Gtk.postGUIASync
src/System/Taffybar/Widget/MPRIS2.hs view
@@ -59,7 +59,7 @@ newPlayerWidget :: BusName -> IO MPRIS2PlayerWidget newPlayerWidget busName = do- let loadDefault size = catchGErrorsAsLeft (loadIcon size "play.svg")+ let loadDefault size = loadIcon size "play.svg" >>= either failure return where failure err = mprisLog WARNING "Failed to load default image: %s" err >>
src/System/Taffybar/Widget/Util.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE TypeApplications #-}+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : System.Taffybar.Widget.Util@@ -18,6 +19,7 @@ import Control.Concurrent ( forkIO ) import Control.Monad import Control.Monad.IO.Class+import Data.Bifunctor ( first ) import Data.Functor ( ($>) ) import Data.Int import qualified Data.Text as T@@ -155,11 +157,18 @@ Gtk.setWidgetValign widget Gtk.AlignFill >> Gtk.setWidgetHalign widget Gtk.AlignCenter -pixbufNewFromFileAtScaleByHeight :: Int32 -> String -> IO PB.Pixbuf+pixbufNewFromFileAtScaleByHeight :: Int32 -> String -> IO (Either String PB.Pixbuf) pixbufNewFromFileAtScaleByHeight height name =+ fmap (handleResult . first show) $ catchGErrorsAsLeft $ PB.pixbufNewFromFileAtScale name (-1) height True+ where+#if MIN_VERSION_gi_gdkpixbuf(2,0,26)+ handleResult = join . fmap (maybe (Left "gdk function returned NULL") Right)+#else+ handleResult = id+#endif -loadIcon :: Int32 -> String -> IO PB.Pixbuf+loadIcon :: Int32 -> String -> IO (Either String PB.Pixbuf) loadIcon height name = ((</> "icons" </> name) <$> getDataDir) >>= pixbufNewFromFileAtScaleByHeight height
src/System/Taffybar/Widget/WttrIn.hs view
@@ -5,7 +5,7 @@ -- Useful if NOAA data doesn't cover your needs, or if you just like wttr.in -- better. ----- For more information on how to use wttr.in, use:+-- For more information on how to use wttr.in, see <https://wttr.in/:help>. module System.Taffybar.Widget.WttrIn ( textWttrNew ) where import System.Log.Logger
taffybar.cabal view
@@ -1,5 +1,5 @@ name: taffybar-version: 3.2.3+version: 3.2.4 synopsis: A desktop bar similar to xmobar, but with more GUI license: BSD3 license-file: LICENSE