{-# LANGUAGE OverloadedStrings #-}
module System.Taffybar.Widget.SimpleCommandButton (
simpleCommandButtonNew)
where
import Control.Monad.IO.Class
import GI.Gtk
import System.Process
import qualified Data.Text as T
simpleCommandButtonNew
:: MonadIO m
=> T.Text
-> T.Text
-> m Widget
simpleCommandButtonNew :: forall (m :: * -> *). MonadIO m => Text -> Text -> m Widget
simpleCommandButtonNew Text
txt Text
cmd = do
Button
button <- Text -> m Button
forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Button
buttonNewWithLabel Text
txt
SignalHandlerId
_ <- Button
-> ((?self::Button) => ButtonClickedCallback) -> m SignalHandlerId
forall a (m :: * -> *).
(IsButton a, MonadIO m) =>
a -> ((?self::a) => ButtonClickedCallback) -> m SignalHandlerId
onButtonClicked Button
button (((?self::Button) => ButtonClickedCallback) -> m SignalHandlerId)
-> ((?self::Button) => ButtonClickedCallback) -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ String -> IO ProcessHandle
spawnCommand (Text -> String
T.unpack Text
cmd) IO ProcessHandle -> ButtonClickedCallback -> ButtonClickedCallback
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> ButtonClickedCallback
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Button -> m Widget
forall (m :: * -> *) o. (MonadIO m, IsWidget o) => o -> m Widget
toWidget Button
button