frpnow-gtk3-0.2.0: Program GUIs with GTK3 and frpnow!

Copyright(c) Atze van der Ploeg 2015 George Steel 2017
LicenseBSD3
Maintainergeorge.steel@gmail.org
Safe HaskellNone
LanguageHaskell2010

Control.FRPNow.GTK.Core

Contents

Description

Core functions for inteoperability between GTK and FRPNow

Synopsis

Documentation

ffor :: Functor f => f a -> (a -> b) -> f b Source #

Flipped version of fmap for defining trandformations inline.

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 b) => ReadWriteAttr w a b -> w -> Behavior b -> Now () Source #

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

getUnrealize :: WidgetClass w => w -> Now (Event ()) Source #

Get an event that fires when a widget is destroyed. Useful for cutting off event streams with beforeEs.

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 convert a signal with handler (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

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

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

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 ()

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 number of seconds.

Orphan instances

Monoid a => Monoid (Behavior a) Source #

Carry monoidial structure through Behaviors

Methods

mempty :: Behavior a #

mappend :: Behavior a -> Behavior a -> Behavior a #

mconcat :: [Behavior a] -> Behavior a #