glib-0.13.5.0: Binding to the GLIB library for Gtk2Hs.

Maintainer | gtk2hs-users@lists.sourceforge.net
Stability | provisional
Portability | portable (depends on GHC)
Safe Haskell | None
Language | Haskell98

System.Glib.MainLoop

Description

main event loop, and events

Synopsis

- type HandlerId = CUInt
- timeoutAdd :: IO Bool -> Int -> IO HandlerId
- timeoutAddFull :: IO Bool -> Priority -> Int -> IO HandlerId
- timeoutRemove :: HandlerId -> IO ()
- idleAdd :: IO Bool -> Priority -> IO HandlerId
- idleRemove :: HandlerId -> IO ()
- data IOCondition
  - = IOIn
  - | IOOut
  - | IOPri
  - | IOErr
  - | IOHup
  - | IOInvalid
- inputAdd :: FD -> [IOCondition] -> Priority -> IO Bool -> IO HandlerId
- inputRemove :: HandlerId -> IO ()
- type Priority = Int
- priorityLow :: Int
- priorityDefaultIdle :: Int
- priorityHighIdle :: Int
- priorityDefault :: Int
- priorityHigh :: Int
- data MainLoop
- mainLoopNew :: Maybe MainContext -> Bool -> IO MainLoop
- mainLoopRun :: MainLoop -> IO ()
- mainLoopQuit :: MainLoop -> IO ()
- mainLoopIsRunning :: MainLoop -> IO Bool
- data MainContext
- mainContextNew :: IO MainContext
- mainContextDefault :: MainContext
- mainContextIteration :: MainContext -> Bool -> IO Bool
- mainContextFindSourceById :: MainContext -> HandlerId -> IO Source
- newtype Source = Source (ForeignPtr Source)
- sourceAttach :: Source -> MainContext -> IO HandlerId
- sourceSetPriority :: Source -> Priority -> IO ()
- sourceGetPriority :: Source -> IO Priority
- sourceDestroy :: Source -> IO ()
- sourceIsDestroyed :: Source -> IO Bool

# Documentation

type HandlerId = CUInt Source #

timeoutAdd :: IO Bool -> Int -> IO HandlerId Source #

Sets a function to be called at regular intervals, with the default priority `priorityDefault`. The function is called repeatedly until it returns `False`, after which point the timeout function will not be called again. The first call to the function will be at the end of the first interval.

Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to 'catch up' time lost in delays).

timeoutAddFull :: IO Bool -> Priority -> Int -> IO HandlerId Source #

Sets a function to be called at regular intervals, with the given priority. The function is called repeatedly until it returns `False`, after which point the timeout function will not be called again. The first call to the function will be at the end of the first interval.

Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to 'catch up' time lost in delays).

timeoutRemove :: HandlerId -> IO () Source #

Remove a previously added timeout handler by its `HandlerId`.

idleAdd :: IO Bool -> Priority -> IO HandlerId Source #

Add a callback that is called whenever the system is idle.

- A priority can be specified via an integer. This should usually be `priorityDefaultIdle`.
- If the function returns `False` it will be removed.

idleRemove :: HandlerId -> IO () Source #

Remove a previously added idle handler by its `HandlerId`.

data IOCondition Source #

Flags representing a condition to watch for on a file descriptor.

`IOIn`
  There is data to read.
`IOOut`
  Data can be written (without blocking).
`IOPri`
  There is urgent data to read.
`IOErr`
  Error condition.
`IOHup`
  Hung up (the connection has been broken, usually for pipes and sockets).
`IOInvalid`
  Invalid request. The file descriptor is not open.

Constructors

IOIn |
IOOut |
IOPri |
IOErr |
IOHup |
IOInvalid |

Instances

Bounded IOCondition Source # |
Methods minBound :: IOCondition # maxBound :: IOCondition #
Enum IOCondition Source # |
Methods succ :: IOCondition -> IOCondition # pred :: IOCondition -> IOCondition # toEnum :: Int -> IOCondition # fromEnum :: IOCondition -> Int # enumFrom :: IOCondition -> [IOCondition] # enumFromThen :: IOCondition -> IOCondition -> [IOCondition] # enumFromTo :: IOCondition -> IOCondition -> [IOCondition] # enumFromThenTo :: IOCondition -> IOCondition -> IOCondition -> [IOCondition] #
Eq IOCondition Source # |
Methods (==) :: IOCondition -> IOCondition -> Bool # (/=) :: IOCondition -> IOCondition -> Bool #
Flags IOCondition Source # |

inputAdd Source #

Arguments

:: FD | a file descriptor
-> [IOCondition] | the condition to watch for
-> Priority | the priority of the event source
-> IO Bool | the function to call when the condition is satisfied. The function should return False if the event source should be removed.
-> IO HandlerId | the event source id

Adds the file descriptor into the main event loop with the given priority.

inputRemove :: HandlerId -> IO () Source #

type Priority = Int Source #

Priorities for installing callbacks.

priorityLow :: Int Source #

priorityDefaultIdle :: Int Source #

priorityHighIdle :: Int Source #

priorityDefault :: Int Source #

priorityHigh :: Int Source #

data MainLoop Source #

A main event loop abstraction.

mainLoopNew Source #

Arguments

:: Maybe MainContext | `context` - the context to use, or `Nothing` to use the default context
-> Bool | `isRunning` - `True` to indicate that the loop is running; `False` otherwise
-> IO MainLoop | the new `MainLoop`

Create a new `MainLoop`.

mainLoopRun :: MainLoop -> IO () Source #

Runs a main loop until `mainLoopQuit` is called on the loop. If this is called for the thread of the loop's `MainContext`, it will process events from the loop, otherwise it will simply wait.

mainLoopQuit :: MainLoop -> IO () Source #

Stops a `MainLoop` from running. Any calls to mainLoopRun for the loop will return.

mainLoopIsRunning :: MainLoop -> IO Bool Source #

Checks to see if the main loop is currently being run via mainLoopRun.

data MainContext Source #

An opaque datatype representing a set of sources to be handled in a main loop.

mainContextNew :: IO MainContext Source #

Creates a new `MainContext`.

mainContextDefault :: MainContext Source #

The default `MainContext`. This is the main context used for main loop functions when a main loop is not explicitly specified.

mainContextIteration :: MainContext -> Bool -> IO Bool Source #

Runs a single iteration for the given main loop. This involves checking to see if any event sources are ready to be processed, then if no events sources are ready and `mayBlock` is `True`, waiting for a source to become ready, then dispatching the highest priority events sources that are ready. Note that even when `mayBlock` is `True`, it is still possible for `mainContextIteration` to return `False`, since the the wait may be interrupted for other reasons than an event source becoming ready.

mainContextFindSourceById :: MainContext -> HandlerId -> IO Source Source #

newtype Source Source #

Constructors

Source (ForeignPtr Source) |

sourceAttach :: Source -> MainContext -> IO HandlerId Source #

sourceSetPriority :: Source -> Priority -> IO () Source #

sourceGetPriority :: Source -> IO Priority Source #

sourceDestroy :: Source -> IO () Source #

sourceIsDestroyed :: Source -> IO Bool Source #