1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
-- Example of an international dialog box.
import Graphics.UI.Gtk
import Control.Applicative
import Prelude
import Data.Char
import qualified Data.Text as T
import Data.Text (Text)
main :: IO ()
main = do
initGUI
dia <- dialogNew
dialogAddButton dia stockYes ResponseYes
dialogAddButton dia stockNo ResponseNo
contain <- castToBox <$> dialogGetContentArea dia
theText <- labelNew (Nothing :: Maybe Text)
labelSetMarkup theText (T.pack arabic)
boxPackStart contain theText PackNatural 0
widgetShowAll dia
res <- dialogRun dia
case res of
ResponseNo -> yell
_ -> return ()
arabic :: String
arabic = markSpan [FontSize (SizePoint 36)] $
--"Is Haskell a "++markSpan [FontForeground "red"] "fantastic"++" language?"++
-- Do you find Haskell a fantastic language? (language has a grammatical
-- mistake in it)
map chr [0x647,0x644,32,0x62A,0x62C,0x62F,0x646,32]++
markSpan [FontForeground "red"]
(map chr [0x647,0x622,0x633,0x643,0x622,0x644])++
map chr [32,0x644,0x63A,0x62A,32,0x645,0x62F,0x647,0x634,0x62A,0x61F]
yell :: IO ()
yell = do
dia <- dialogNew
dialogAddButton dia stockOk ResponseOk
contain <- castToBox <$> dialogGetContentArea dia
msg <- labelNew (Just "This is not an option.")
boxPackStart contain msg PackNatural 0
widgetShow msg
dialogRun dia
return ()
|