start working on a better handler for the dictionaries
This commit is contained in:
parent
8e89fc621e
commit
170bc26cd4
2 changed files with 23 additions and 8 deletions
|
|
@ -12,9 +12,9 @@ import qualified GI.Gtk as GTK
|
|||
import GI.Gio hiding (Application)
|
||||
import Wazahs
|
||||
import Control.Concurrent
|
||||
import Control.Concurrent.STM
|
||||
|
||||
|
||||
|
||||
-- Wrapper to make FileDialog synchronous
|
||||
main :: IO ()
|
||||
main = do
|
||||
app <- new Application []
|
||||
|
|
@ -26,12 +26,24 @@ main = do
|
|||
GTK.fileDialogSetModal fd True
|
||||
GTK.fileDialogSetAcceptLabel fd (Just "Select")
|
||||
|
||||
selectFolder fd w $ maybe
|
||||
(putStrLn "No valid directory selected")
|
||||
(\dir -> do
|
||||
files <- listFiles dir
|
||||
putStrLn "Selected directory:"
|
||||
mapM_ putStrLn files)
|
||||
filesVar <- newTVarIO []
|
||||
|
||||
selectFolder fd w $ \maybeDir -> do
|
||||
case maybeDir of
|
||||
Nothing -> putStrLn "No valid directory selected"
|
||||
Just dir -> do
|
||||
fs <- listFiles dir
|
||||
atomically $ writeTVar filesVar fs
|
||||
putStrLn "Selected directory:"
|
||||
mapM_ putStrLn fs
|
||||
|
||||
-- Later, anywhere else in your program:
|
||||
files <- readTVarIO filesVar
|
||||
|
||||
|
||||
mapM_ putStrLn files
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,3 +37,6 @@ selectFolder fd w k =
|
|||
p <- MaybeT $ fileGetPath f
|
||||
p <$ (liftIO (doesDirectoryExist p) >>= guard)
|
||||
k mbPath
|
||||
|
||||
-- compose the two here: [TODO]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue