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