start working on a better handler for the dictionaries

This commit is contained in:
千住柱間 2025-09-16 20:15:55 -04:00
commit 170bc26cd4
Signed by: hashirama
GPG key ID: 53E62470A86BC185
2 changed files with 23 additions and 8 deletions

View file

@ -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

View file

@ -37,3 +37,6 @@ selectFolder fd w k =
p <- MaybeT $ fileGetPath f
p <$ (liftIO (doesDirectoryExist p) >>= guard)
k mbPath
-- compose the two here: [TODO]