| 1 | import Graphics.UI.Gtk |
|---|
| 2 | |
|---|
| 3 | connectAction actg accg id accelerator command = |
|---|
| 4 | do action <- actionNew id "" Nothing Nothing |
|---|
| 5 | actionGroupAddActionWithAccel actg action (Just accelerator) |
|---|
| 6 | actionSetAccelGroup action accg |
|---|
| 7 | actionConnectAccelerator action |
|---|
| 8 | |
|---|
| 9 | on action actionActivated command |
|---|
| 10 | |
|---|
| 11 | return action |
|---|
| 12 | main = |
|---|
| 13 | do initGUI |
|---|
| 14 | window <- windowNew |
|---|
| 15 | |
|---|
| 16 | ag <- actionGroupNew "AGR" |
|---|
| 17 | ui <- uiManagerNew |
|---|
| 18 | acg <- uiManagerGetAccelGroup ui |
|---|
| 19 | uiManagerInsertActionGroup ui ag 0 |
|---|
| 20 | windowAddAccelGroup window acg |
|---|
| 21 | connectAction ag acg "CLSE" "<Control>w" (putStrLn "Ctrl-W") |
|---|
| 22 | connectAction ag acg "TBAD" "<Control>t" (putStrLn "Ctrl-T") |
|---|
| 23 | connectAction ag acg "TBADs" "<Alt>1" (putStrLn "Ctasdrl-T") |
|---|
| 24 | |
|---|
| 25 | onDestroy window mainQuit |
|---|
| 26 | widgetShowAll window |
|---|
| 27 | |
|---|
| 28 | mainGUI |
|---|