{-# LANGUAGE CPP #-}
module GUI.Utils
( listBox
, createTextSaveDisplay
, askFileNameAndSave
, infoDialog
#if defined GTKGLADE || defined UNI_PACKAGE
, createTextDisplay
, errorDialog
, warningDialog
, questionDialog
, fileOpenDialog
, fileSaveDialog
, displayTheoryWithWarning
, progressBar
, pulseBar
#endif
) where
#ifdef GTKGLADE
import GUI.GtkUtils
( infoDialogExt
, errorDialogExt
, warningDialogExt
, questionDialogExt
, fileSaveDialogExt
, fileOpenDialogExt
, listChoiceExt
, textViewExt
, displayTheoryWithWarningExt
, progressBarExt
, pulseBarExt
)
import Static.GTheory (G_theory)
infoDialog :: String
-> String
-> IO ()
infoDialog :: String -> String -> IO ()
infoDialog = String -> String -> IO ()
infoDialogExt
errorDialog :: String
-> String
-> IO ()
errorDialog :: String -> String -> IO ()
errorDialog = String -> String -> IO ()
errorDialogExt
warningDialog :: String
-> String
-> IO Bool
warningDialog :: String -> String -> IO Bool
warningDialog = String -> String -> IO Bool
warningDialogExt
questionDialog :: String
-> String
-> IO Bool
questionDialog :: String -> String -> IO Bool
questionDialog = String -> String -> IO Bool
questionDialogExt
fileSaveDialog :: FilePath
-> [(String, [String])]
-> Maybe (FilePath -> IO ())
-> IO (Maybe FilePath)
fileSaveDialog :: String
-> [(String, [String])]
-> Maybe (String -> IO ())
-> IO (Maybe String)
fileSaveDialog = String
-> [(String, [String])]
-> Maybe (String -> IO ())
-> IO (Maybe String)
fileSaveDialogExt
fileOpenDialog :: FilePath
-> [(String, [String])]
-> Maybe (FilePath -> IO ())
-> IO (Maybe FilePath)
fileOpenDialog :: String
-> [(String, [String])]
-> Maybe (String -> IO ())
-> IO (Maybe String)
fileOpenDialog = String
-> [(String, [String])]
-> Maybe (String -> IO ())
-> IO (Maybe String)
fileOpenDialogExt
displayTheoryWithWarning :: String
-> String
-> String
-> G_theory
-> IO ()
displayTheoryWithWarning :: String -> String -> String -> G_theory -> IO ()
displayTheoryWithWarning = String -> String -> String -> G_theory -> IO ()
displayTheoryWithWarningExt
progressBar :: String
-> String
-> IO (Double -> String -> IO (), IO ())
progressBar :: String -> String -> IO (Double -> String -> IO (), IO ())
progressBar = String -> String -> IO (Double -> String -> IO (), IO ())
progressBarExt
pulseBar :: String
-> String
-> IO (String -> IO (), IO ())
pulseBar :: String -> String -> IO (String -> IO (), IO ())
pulseBar = String -> String -> IO (String -> IO (), IO ())
pulseBarExt
listBox :: String
-> [String]
-> IO (Maybe Int)
listBox :: String -> [String] -> IO (Maybe Int)
listBox = String -> [String] -> IO (Maybe Int)
listChoiceExt
createTextDisplay :: String
-> String
-> IO ()
createTextDisplay :: String -> String -> IO ()
createTextDisplay t :: String
t m :: String
m = String -> String -> Maybe String -> IO ()
textViewExt String
t String
m Maybe String
forall a. Maybe a
Nothing
createTextSaveDisplay :: String
-> FilePath
-> String
-> IO ()
createTextSaveDisplay :: String -> String -> String -> IO ()
createTextSaveDisplay t :: String
t f :: String
f m :: String
m = String -> String -> Maybe String -> IO ()
textViewExt String
t String
m (Maybe String -> IO ()) -> Maybe String -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> Maybe String
forall a. a -> Maybe a
Just String
f
askFileNameAndSave :: FilePath
-> String
-> IO ()
askFileNameAndSave :: String -> String -> IO ()
askFileNameAndSave f :: String
f m :: String
m = do
String
-> [(String, [String])]
-> Maybe (String -> IO ())
-> IO (Maybe String)
fileSaveDialogExt String
f [] (Maybe (String -> IO ()) -> IO (Maybe String))
-> Maybe (String -> IO ()) -> IO (Maybe String)
forall a b. (a -> b) -> a -> b
$ (String -> IO ()) -> Maybe (String -> IO ())
forall a. a -> Maybe a
Just (\ f' :: String
f' -> String -> String -> IO ()
writeFile String
f' String
m)
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#elif defined UNI_PACKAGE
import GUI.HTkUtils
( listBox
, errorMess
, confirmMess
, messageMess
, createTextSaveDisplay
, askFileNameAndSave
, newFileDialogStr
, fileDialogStr
, displayTheoryWithWarning
, sync
)
import qualified GUI.HTkUtils (createTextDisplay)
infoDialog :: String
-> String
-> IO ()
infoDialog _ m = messageMess m
errorDialog :: String
-> String
-> IO ()
errorDialog _ m = errorMess m
warningDialog :: String
-> String
-> IO Bool
warningDialog _ = confirmMess
questionDialog :: String
-> String
-> IO Bool
questionDialog _ = confirmMess
fileOpenDialog :: FilePath
-> [(String, [String])]
-> Maybe (FilePath -> IO ())
-> IO (Maybe FilePath)
fileOpenDialog f _ mAction = do
evnt <- fileDialogStr "Open..." f
mPath <- sync evnt
case mPath of
Just path -> case mAction of
Just action -> action path
Nothing -> return ()
Nothing -> return ()
return mPath
fileSaveDialog :: FilePath
-> [(String, [String])]
-> Maybe (FilePath -> IO ())
-> IO (Maybe FilePath)
fileSaveDialog f _ mAction = do
evnt <- newFileDialogStr "Save as..." f
mPath <- sync evnt
case mPath of
Just path -> case mAction of
Just action -> action path
Nothing -> return ()
Nothing -> return ()
return mPath
createTextDisplay :: String
-> String
-> IO ()
createTextDisplay t m = GUI.HTkUtils.createTextDisplay t m []
progressBar :: String
-> String
-> IO (Double -> String -> IO (), IO ())
progressBar _ _ = return (\ _ _ -> return (), return ())
pulseBar :: String
-> String
-> IO (String -> IO (), IO ())
pulseBar _ _ = return (\ _ -> return (), return ())
#else
import GUI.ConsoleUtils
#endif