-- | Spinner for integer values.
gtkSpinner :: Int -- ^ Min value
           -> Int -- ^ Max value
           -> WidgetNetwork (React.Discrete Int)
gtkSpinner min max = WidgetNetwork {
    widgetNetworkRealize = \realize -> do
        sb <- liftIO $ Gtk.spinButtonNewWithRange (fromIntegral min) (fromIntegral max) (fromIntegral 1)
        liftIO $ do
            realize (Gtk.toWidget sb)
        let
            valueChanges = React.fromAddHandler add
            add handler = do
                cid <- Gtk.afterValueSpinned sb (Gtk.spinButtonGetValueAsInt sb >>= handler)
                return (Gtk.signalDisconnect cid)
        fmap (React.stepperD min) valueChanges
}
gtkSpinner :: Int -- ^ Min value
           -> Int -- ^ Max value
           -> WidgetNetwork (React.Discrete Int)
gtkSpinner min max = WidgetNetwork {
    widgetNetworkRealize = \realize -> do
        sb <- liftIO $ Gtk.spinButtonNewWithRange (fromIntegral min) (fromIntegral max) (fromIntegral 1)
        liftIO $ do
            realize (Gtk.toWidget sb)
        let
            valueChanges = React.fromAddHandler add
            add handler = do
                cid <- Gtk.afterValueSpinned sb (Gtk.spinButtonGetValueAsInt sb >>= handler)
                return (Gtk.signalDisconnect cid)
        fmap (React.stepperD min) valueChanges
}
gtkSpinner min max = WidgetNetwork {
    widgetNetworkRealize = \realize -> do
        sb <- liftIO $ Gtk.spinButtonNewWithRange (fromIntegral min) (fromIntegral max) (fromIntegral 1)
        liftIO $ do
            realize (Gtk.toWidget sb)
        let
            valueChanges = React.fromAddHandler add
            add handler = do
                cid <- Gtk.afterValueSpinned sb (Gtk.spinButtonGetValueAsInt sb >>= handler)
                return (Gtk.signalDisconnect cid)
        fmap (React.stepperD min) valueChanges
}