frpnow-gtk-0.11: Program GUIs with GTK and frpnow!

Copyright(c) Atze van der Ploeg 2015
LicenseBSD-style
Maintaineratzeus@gmail.org
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Control.FRPNow.GTK

Contents

Description

This module provides interoperability of FRPNow and the GTK system.

Synopsis

General interface

runNowGTK :: Now () -> IO () Source

Run a Now computation which can interact with GTK. Also starts the GTK system. Call only once, or GTK will freak out.

setAttr :: (WidgetClass w, Eq a) => Attr w a -> w -> Behavior a -> Now () Source

Set a GTK attribute to a behavior. Each time the behavior changes the attribute is updated.

getSignal :: GObjectClass widget => Signal widget callback -> widget -> ((value -> IO ()) -> callback) -> Now (EvStream value) Source

General interface to convert an GTK signal to an event stream.

The signal has type callback, for example (ScrollType -> Double -> IO Bool) and the eventstream gives elements of type value, for instance (ScrollType,Double) The conversion function (3rd argument) takes a function to call for producing the value in our example, a function of type (ScollType,Double) -> IO () and produces a function of the form callback, in our example (ScrollType -> Double -> IO Bool).

In this example we can covert a signal with hander (ScrollType -> Double -> IO Bool) to an eventstream giving elements of type (ScrollType,Double) by letting the handler return False as follows:

scrollToEvStream :: Signal widget (ScrollType -> Double -> IO Bool) -> widget -> Now (EvStream (ScrollType,Double))
scrollToEvStream s w = getSignal s w convert where
  convert call scrolltype double = do call (scrolltype, double)
                                      return False

The signal is automatically disconnected, when the event stream is garbage collected.

getUnitSignal :: GObjectClass widget => Signal widget (IO ()) -> widget -> Now (EvStream ()) Source

Obtain an event stream from a unit GTK signal, i.e. a signal with handler type:

IO ()

getSimpleSignal :: GObjectClass widget => Signal widget (value -> IO ()) -> widget -> Now (EvStream value) Source

Obtain an event stream from a GTK signal giving a single value.

getClock :: Double -> Now (Behavior Double) Source

Get a clock that gives the time since the creation of the clock in seconds, and updates maximally even given numer of seconds.

The clock is automatically destroyed and all resources associated with the clock are freed when the behavior is garbage collected.

Utility functions