1 {-# LANGUAGE OverloadedStrings #-}
3 module RMCA.GUI.Buttons where
5 import Data.ReactiveValue
7 import Graphics.UI.Gtk.Reactive
10 gtkMediaPlay :: DefaultGlibString
11 gtkMediaPlay = stringToGlib "gtk-media-play"
13 gtkMediaStop :: DefaultGlibString
14 gtkMediaStop = stringToGlib "gtk-media-stop"
16 gtkMediaPause :: DefaultGlibString
17 gtkMediaPause = stringToGlib "gtk-media-pause"
19 gtkMediaRecord :: DefaultGlibString
20 gtkMediaRecord = stringToGlib "gtk-media-record"
22 gtkMediaSave :: DefaultGlibString
23 gtkMediaSave = stringToGlib "gtk-save"
25 gtkMediaOpen :: DefaultGlibString
26 gtkMediaOpen = stringToGlib "gtk-open"
28 buttonNewFromStockWithLabel :: StockId -> String -> IO Button
29 buttonNewFromStockWithLabel s l = do
31 buttonBox <- hBoxNew False 0
32 buttonImg <- imageNewFromStock s IconSizeButton
33 buttonLabel <- labelNew (Just l)
34 labelSetUseUnderline buttonLabel True
35 containerAdd button buttonBox
36 boxPackStart buttonBox buttonImg PackRepel 0
37 boxPackStart buttonBox buttonLabel PackRepel 0
40 toggleButtonNewFromStock :: StockId -> IO ToggleButton
41 toggleButtonNewFromStock s = do
42 button <- toggleButtonNew
43 buttonBox <- hBoxNew False 0
44 buttonImg <- imageNewFromStock s IconSizeButton
45 stockTxt <- stockLookupItem s
46 buttonLabel <- labelNew (siLabel <$> stockTxt)
47 labelSetUseUnderline buttonLabel True
48 containerAdd button buttonBox
49 boxPackStart buttonBox buttonImg PackRepel 0
50 boxPackStart buttonBox buttonLabel PackRepel 0
53 getButtons :: IO ( VBox
54 , ReactiveFieldRead IO ()
55 , ReactiveFieldRead IO ()
56 , ReactiveFieldRead IO Bool
57 , ReactiveFieldRead IO Bool
58 , ReactiveFieldRead IO ()
59 , ReactiveFieldRead IO ()
62 buttonBox <- vBoxNew False 10
64 buttonBoxTop <- hBoxNew True 10
65 boxPackStart buttonBox buttonBoxTop PackNatural 0
67 buttonSave <- buttonNewFromStockWithLabel gtkMediaSave "_Save configuration"
68 let confSaveRV = buttonActivateField buttonSave
69 boxPackStart buttonBoxTop buttonSave PackGrow 0
71 buttonLoad <- buttonNewFromStockWithLabel gtkMediaOpen "_Load configuration"
72 let confLoadRV = buttonActivateField buttonLoad
73 boxPackStart buttonBoxTop 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