Commit 5235edbe0e0c75846b353060547960befafb5575 Parent: e1003adb9258a8813914bc632112b3ae244bfb4e Author: mcol <mcol@posteo.net> Date: 2021-10-31 15:42:30 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-10-31 15:42:30 +0000 Improve Icons.hs style
xanadu.cabal Modified
@@ -20,6 +20,7 @@ default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , directory + , filepath , gi-gdk , gi-gdkpixbuf , gi-gio
src/Icons.hs Modified
@@ -5,13 +5,12 @@ ) where import Control.Applicative -import Control.Monad (liftM) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Maybe -import Data.Maybe import Data.Text (pack) import System.Directory (doesDirectoryExist, listDirectory, getHomeDirectory) import System.Environment (lookupEnv) +import System.FilePath ((</>)) import System.IO (hFlush, stdout) import Data.GI.Base @@ -42,12 +41,12 @@ getRoot = do fromEnv <- lookupEnv "XDG_DESKTOP_DIR" case fromEnv of - Nothing -> liftM (flip (<>) "/Desktop") getHomeDirectory - Just "" -> liftM (flip (<>) "/Desktop") getHomeDirectory + Nothing -> (</> "/Desktop") <$> getHomeDirectory + Just "" -> (</> "/Desktop") <$> getHomeDirectory Just path -> return path populate :: Gtk.ListStore -> Gtk.IconTheme -> FilePath -> IO () -populate listStore iconTheme root = getItems root >>= mconcat . map (addItem listStore iconTheme) +populate listStore iconTheme root = mconcat . map (addItem listStore iconTheme) =<< getItems root addItem :: Gtk.ListStore -> Gtk.IconTheme -> Item -> IO () addItem listStore iconTheme item = do @@ -74,7 +73,7 @@ getItems :: FilePath -> IO [Item] getItems root = do path <- listDirectory root - isDir <- sequence $ doesDirectoryExist . ((<>) $ root <> "/") <$> path + isDir <- mapM (doesDirectoryExist . (root </>)) path return . getZipList $ Item <$> ZipList path <*> ZipList isDir onItemActivated :: Gtk.ListStore -> FilePath -> Gtk.TreePath -> IO ()