1 {-# LANGUAGE OverloadedStrings #-}
3 module RMCA.GUI.Buttons ( buttonNewFromStockWithLabel
4 , toggleButtonNewFromStock
8 import Data.ReactiveValue
10 import Graphics.UI.Gtk.Reactive
11 import RMCA.GUI.StockId
13 packButton :: (BoxClass a, ButtonClass b, ImageClass i, LabelClass l) =>
14 b -> a -> l -> i -> IO b
15 packButton button buttonBox buttonLabel buttonImg = do
16 containerAdd button buttonBox
17 boxPackStart buttonBox buttonImg PackRepel 0
18 boxPackStart buttonBox buttonLabel PackRepel 0
21 buttonNewFromStockWithLabel :: StockId -> String -> IO Button
22 buttonNewFromStockWithLabel s l = do
24 buttonBox <- hBoxNew False 0
25 buttonImg <- imageNewFromStock s IconSizeButton
26 buttonLabel <- labelNew (Just l)
27 labelSetUseUnderline buttonLabel True
28 packButton button buttonBox buttonLabel buttonImg
30 toggleButtonNewFromStock :: StockId -> IO ToggleButton
31 toggleButtonNewFromStock s = do
32 button <- toggleButtonNew
33 buttonBox <- hBoxNew False 0
34 buttonImg <- imageNewFromStock s IconSizeButton
35 stockTxt <- stockLookupItem s
36 buttonLabel <- labelNew (siLabel <$> stockTxt)
37 labelSetUseUnderline buttonLabel True
38 packButton button buttonBox buttonLabel buttonImg
40 getButtons :: IO ( VBox
41 , ReactiveFieldRead IO ()
42 , ReactiveFieldRead IO ()
43 , ReactiveFieldRead IO Bool
44 , ReactiveFieldRead IO Bool
45 , ReactiveFieldRead IO ()
46 , ReactiveFieldRead IO ()
47 , ReactiveFieldRead IO ()
48 , ReactiveFieldRead IO ()
51 buttonBox <- vBoxNew False 10
53 buttonBoxAddRmLayers <- hBoxNew True 10
54 boxPackStart buttonBox buttonBoxAddRmLayers PackNatural 0
56 buttonAddLayer <- buttonNewFromStockWithLabel gtkMediaAdd "Add layer"
57 let addLayerRV = buttonActivateField buttonAddLayer
58 boxPackStart buttonBoxAddRmLayers buttonAddLayer PackGrow 0
60 buttonRmLayer <- buttonNewFromStockWithLabel gtkMediaRemove "Remove layer"
61 let rmLayerRV = buttonActivateField buttonRmLayer
62 boxPackStart buttonBoxAddRmLayers buttonRmLayer PackGrow 0
64 buttonBoxSaveLoad <- hBoxNew True 10
65 boxPackStart buttonBox buttonBoxSaveLoad PackNatural 0
67 buttonSave <- buttonNewFromStockWithLabel gtkMediaSave "_Save configuration"
68 let confSaveRV = buttonActivateField buttonSave
69 boxPackStart buttonBoxSaveLoad buttonSave PackGrow 0
71 buttonLoad <- buttonNewFromStockWithLabel gtkMediaOpen "_Load configuration"
72 let confLoadRV = buttonActivateField buttonLoad
73 boxPackStart buttonBoxSaveLoad buttonLoad PackGrow 0
76 buttonBoxBot <- hBoxNew True 10
77 boxPackStart buttonBox buttonBoxBot PackNatural 0
78 buttonPlay <- buttonNewFromStock gtkMediaPlay
79 let playRV = buttonActivateField buttonPlay
80 boxPackStart buttonBoxBot buttonPlay PackRepel 0
82 buttonPause <- toggleButtonNewFromStock gtkMediaPause
83 let pauseRV = readOnly $ toggleButtonActiveReactive buttonPause
84 boxPackStart buttonBoxBot buttonPause PackRepel 0
86 buttonStop <- buttonNewFromStock gtkMediaStop
87 let stopRV = buttonActivateField buttonStop
88 boxPackStart buttonBoxBot buttonStop PackRepel 0
90 buttonRecord <- toggleButtonNewFromStock gtkMediaRecord
91 let recordRV = readOnly $ toggleButtonActiveReactive buttonRecord
92 boxPackStart buttonBoxBot buttonRecord PackRepel 0