-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Binding to the GLIB library for Gtk2Hs.
--
-- The GNU Library is a collection of C data structures and utility
-- function for dealing with Unicode. This package only binds as much
-- functionality as required to support the packages that wrap libraries
-- that are themselves based on GLib.
@package glib
@version 0.12.2
-- | Attributes interface
--
-- Attributes of an object can be get and set. Getting the value of an
-- object's attribute is straingtforward. As an example consider a
-- button widget and an attribute called buttonLabel.
--
--
-- value <- get button buttonLabel
--
--
-- The syntax for setting or updating an attribute is only slightly more
-- complex. At the simplest level it is just:
--
--
-- set button [ buttonLabel := value ]
--
--
-- However as the list notation would indicate, you can set or update
-- multiple attributes of the same object in one go:
--
--
-- set button [ buttonLabel := value, buttonFocusOnClick := False ]
--
--
-- You are not limited to setting the value of an attribute, you can also
-- apply an update function to an attribute's value. That is the function
-- receives the current value of the attribute and returns the new value.
--
--
-- set spinButton [ spinButtonValue :~ (+1) ]
--
--
-- There are other variants of these operators, (see AttrOp).
-- :=> and :~> and like := and :~ but
-- operate in the IO monad rather than being pure. There is also
-- ::= and ::~ which take the object as an extra parameter.
--
-- Attributes can be read only, write only or both read/write.
module System.Glib.Attributes
-- | An ordinary attribute. Most attributes have the same get and set
-- types.
type Attr o a = ReadWriteAttr o a a
-- | A read-only attribute.
type ReadAttr o a = ReadWriteAttr o a ()
-- | A write-only attribute.
type WriteAttr o b = ReadWriteAttr o () b
-- | A generalised attribute with independent get and set types.
data ReadWriteAttr o a b
-- | A set or update operation on an attribute.
data AttrOp o
-- | Assign a value to an attribute.
(:=) :: ReadWriteAttr o a b -> b -> AttrOp o
-- | Apply an update function to an attribute.
(:~) :: ReadWriteAttr o a b -> (a -> b) -> AttrOp o
-- | Assign the result of an IO action to an attribute.
(:=>) :: ReadWriteAttr o a b -> (IO b) -> AttrOp o
-- | Apply a IO update function to an attribute.
(:~>) :: ReadWriteAttr o a b -> (a -> IO b) -> AttrOp o
-- | Assign a value to an attribute with the object as an argument.
(::=) :: ReadWriteAttr o a b -> (o -> b) -> AttrOp o
-- | Apply an update function to an attribute with the object as an
-- argument.
(::~) :: ReadWriteAttr o a b -> (o -> a -> b) -> AttrOp o
-- | Get an Attr of an object.
get :: o -> ReadWriteAttr o a b -> IO a
-- | Set a number of properties for some object.
set :: o -> [AttrOp o] -> IO ()
-- | Create a new attribute with a getter and setter function.
newNamedAttr :: String -> (o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
-- | Create a new read-only attribute.
readNamedAttr :: String -> (o -> IO a) -> ReadAttr o a
-- | Create a new write-only attribute.
writeNamedAttr :: String -> (o -> b -> IO ()) -> WriteAttr o b
-- | Create a new attribute with a getter and setter function.
newAttr :: (o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
-- | Create a new read-only attribute.
readAttr :: (o -> IO a) -> ReadAttr o a
-- | Create a new write-only attribute.
writeAttr :: (o -> b -> IO ()) -> WriteAttr o b
instance Show (ReadWriteAttr o a b)
-- | This module defines a type class for flags that are marshaled as
-- bitflags.
module System.Glib.Flags
class (Enum a, Bounded a) => Flags a
fromFlags :: Flags a => [a] -> Int
toFlags :: Flags a => Int -> [a]
-- | Defines functions to extract data from a GString.
module System.Glib.GString
type GString = Ptr (())
readGString :: GString -> IO (Maybe String)
fromGString :: GString -> IO (Maybe String)
-- | Defines functions to extract data from a GList and to produce a GList
-- from a list of pointers.
--
--
-- - The same for GSList.
--
module System.Glib.GList
type GList = Ptr (())
readGList :: GList -> IO [Ptr a]
fromGList :: GList -> IO [Ptr a]
toGList :: [Ptr a] -> IO GList
withGList :: [Ptr a] -> (GSList -> IO b) -> IO b
type GSList = Ptr (())
readGSList :: GSList -> IO [Ptr a]
fromGSList :: GSList -> IO [Ptr a]
fromGSListRev :: GSList -> IO [Ptr a]
toGSList :: [Ptr a] -> IO GSList
withGSList :: [Ptr a] -> (GSList -> IO b) -> IO b
-- | This module implements only the necessities for the GTK binding.
module System.Glib.GType
type GType = CUInt
-- | Check if an object is of the specific type or derived from it.
--
--
-- - Internally used by Hierarchy.
--
typeInstanceIsA :: Ptr () -> GType -> Bool
-- | Prior to any use of the glib type/object system, glibTypeInit
-- has to be called to initialise the system.
--
-- Note that this is not needed for gtk applications using
-- initGUI since that initialises everything itself. It is only
-- needed for applications using glib directly, without also using gtk.
glibTypeInit :: IO ()
-- | This module implements only the necessities for the GTK binding.
--
--
module System.Glib.GValue
newtype GValue
GValue :: (Ptr (GValue)) -> GValue
-- | Clear a GValue.
valueInit :: GValue -> GType -> IO ()
-- | Get the type of the value stored in the GValue
valueGetType :: GValue -> IO GType
-- | Temporarily allocate a GValue.
allocaGValue :: (GValue -> IO b) -> IO b
-- | Storable instance for GParameter, used by objectNew
module System.Glib.GParameter
newtype GParameter
GParameter :: (String, GValue) -> GParameter
instance Storable GParameter
module System.Glib.GTypeConstants
invalid, boxed, object, string, double, float, pointer, flags, enum, bool, char, uchar, int64, uint64, int, uint, none :: GType
-- | This module adds CString-like functions that handle UTF8 strings.
module System.Glib.UTFString
-- | Like withCString but using the UTF-8 encoding.
withUTFString :: String -> (CString -> IO a) -> IO a
-- | Like withCStringLen but using the UTF-8 encoding.
withUTFStringLen :: String -> (CStringLen -> IO a) -> IO a
-- | Like newCString but using the UTF-8 encoding.
newUTFString :: String -> IO CString
-- | Like Define newUTFStringLen to emit UTF-8.
newUTFStringLen :: String -> IO CStringLen
-- | Like peekCString but using the UTF-8 encoding.
peekUTFString :: CString -> IO String
-- | Like peekCStringLen but using the UTF-8 encoding.
peekUTFStringLen :: CStringLen -> IO String
-- | Like maybePeek peekCString but using the UTF-8 encoding
-- to retrieve UTF-8 from a CString which may be the
-- nullPtr.
maybePeekUTFString :: CString -> IO (Maybe String)
-- | Like like peekUTFString but then frees the string using g_free
readUTFString :: CString -> IO String
-- | Like peekCString but then frees the string using
-- g_free.
readCString :: CString -> IO String
-- | Temporarily allocate a list of UTF-8 CStrings.
withUTFStrings :: [String] -> ([CString] -> IO a) -> IO a
-- | Temporarily allocate an array of UTF-8 encoded CStrings.
withUTFStringArray :: [String] -> (Ptr CString -> IO a) -> IO a
-- | Temporarily allocate a null-terminated array of UTF-8 encoded
-- CStrings.
withUTFStringArray0 :: [String] -> (Ptr CString -> IO a) -> IO a
-- | Convert an array (of the given length) of UTF-8 encoded
-- CStrings to a list of Haskell Strings.
peekUTFStringArray :: Int -> Ptr CString -> IO [String]
-- | Convert a null-terminated array of UTF-8 encoded CStrings to a
-- list of Haskell Strings.
peekUTFStringArray0 :: Ptr CString -> IO [String]
-- | Like peekUTFStringArray0 but then free the string array
-- including all strings.
--
-- To be used when functions indicate that their return value should be
-- freed with g_strfreev.
readUTFStringArray0 :: Ptr CString -> IO [String]
-- | Offset correction for String to UTF8 mapping.
data UTFCorrection
-- | Create a list of offset corrections.
genUTFOfs :: String -> UTFCorrection
ofsToUTF :: Int -> UTFCorrection -> Int
ofsFromUTF :: Int -> UTFCorrection -> Int
instance Show UTFCorrection
-- | The base object type for all glib objects
module System.Glib.GObject
newtype GObject
GObject :: (ForeignPtr (GObject)) -> GObject
class GObjectClass o
toGObject :: GObjectClass o => o -> GObject
unsafeCastGObject :: GObjectClass o => GObject -> o
mkGObject :: (ForeignPtr GObject -> GObject, FinalizerPtr a)
unGObject :: GObject -> ForeignPtr GObject
castToGObject :: GObjectClass obj => obj -> obj
-- | Decrease the reference counter of an object
objectUnref :: FinalizerPtr a
-- | Construct a new object (should rairly be used directly)
objectNew :: GType -> [(String, GValue)] -> IO (Ptr GObject)
-- | Increase the reference counter of an object
objectRef :: GObjectClass obj => Ptr obj -> IO ()
-- | Reference and sink an object.
objectRefSink :: GObjectClass obj => Ptr obj -> IO ()
-- | This function wraps any object that does not derive from Object. It
-- should be used whenever a function returns a pointer to an existing
-- GObject (as opposed to a function that constructs a new
-- object).
--
--
-- - The first argument is the contructor of the specific object.
--
makeNewGObject :: GObjectClass obj => (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
-- | This function wraps any newly created objects that derives from
-- GInitiallyUnowned also known as objects with "floating-references".
-- The object will be refSink (for glib versions >= 2.10). On
-- non-floating objects, this function behaves exactly the same as
-- makeNewGObject.
constructNewGObject :: GObjectClass obj => (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
-- | This function wraps any newly created object that does not derived
-- from GInitiallyUnowned (that is a GObject with no floating reference).
-- Since newly created GObjects have a reference count of one,
-- they don't need ref'ing.
wrapNewGObject :: GObjectClass obj => (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
-- | The type constant to check if an instance is of GObject type.
gTypeGObject :: GType
-- | Determine if this is an instance of a particular GTK type
isA :: GObjectClass o => o -> GType -> Bool
type DestroyNotify = FunPtr (((Ptr ()) -> (IO ())))
-- | Many methods in classes derived from GObject take a callback function
-- and a destructor function which is called to free that callback
-- function when it is no longer required. This constants is an address
-- of a functions in C land that will free a function pointer.
destroyFunPtr :: DestroyNotify
-- | The address of a function freeing a StablePtr. See
-- destroyFunPtr.
destroyStablePtr :: DestroyNotify
type Quark = CUInt
-- | Create a unique id based on the given string.
quarkFromString :: String -> IO Quark
-- | Add an attribute to this object.
--
--
-- - The function returns a new attribute that can be set or retrieved
-- from any GObject. The attribute is wrapped in a Maybe
-- type to reflect the circumstance when the attribute is not set or if
-- it should be unset.
--
objectCreateAttribute :: GObjectClass o => IO (Attr o (Maybe a))
-- | Set the value of an association.
objectSetAttribute :: GObjectClass o => Quark -> o -> Maybe a -> IO ()
-- | Get the value of an association.
--
--
-- - Note that this function may crash the Haskell run-time since the
-- returned type can be forced to be anything. See
-- objectCreateAttribute for a safe wrapper around this
-- funciton.
--
objectGetAttributeUnsafe :: GObjectClass o => Quark -> o -> IO (Maybe a)
-- | This is used by the implementation of properties and by the
-- Graphics.UI.Gtk.TreeList.TreeModel and related modules.
module System.Glib.GValueTypes
valueSetUInt :: GValue -> Word -> IO ()
valueGetUInt :: GValue -> IO Word
valueSetInt :: GValue -> Int -> IO ()
valueGetInt :: GValue -> IO Int
valueSetUInt64 :: GValue -> Word64 -> IO ()
valueGetUInt64 :: GValue -> IO Word64
valueSetInt64 :: GValue -> Int64 -> IO ()
valueGetInt64 :: GValue -> IO Int64
valueSetBool :: GValue -> Bool -> IO ()
valueGetBool :: GValue -> IO Bool
valueSetPointer :: GValue -> (Ptr ()) -> IO ()
valueGetPointer :: GValue -> IO (Ptr ())
valueSetFloat :: GValue -> Float -> IO ()
valueGetFloat :: GValue -> IO Float
valueSetDouble :: GValue -> Double -> IO ()
valueGetDouble :: GValue -> IO Double
valueSetEnum :: Enum enum => GValue -> enum -> IO ()
valueGetEnum :: Enum enum => GValue -> IO enum
valueSetFlags :: Flags flag => GValue -> [flag] -> IO ()
valueGetFlags :: Flags flag => GValue -> IO [flag]
valueSetString :: GValue -> String -> IO ()
valueGetString :: GValue -> IO String
valueSetMaybeString :: GValue -> Maybe String -> IO ()
valueGetMaybeString :: GValue -> IO (Maybe String)
valueSetBoxed :: (boxed -> (Ptr boxed -> IO ()) -> IO ()) -> GValue -> boxed -> IO ()
valueGetBoxed :: (Ptr boxed -> IO boxed) -> GValue -> IO boxed
valueSetGObject :: GObjectClass gobj => GValue -> gobj -> IO ()
valueGetGObject :: GObjectClass gobj => GValue -> IO gobj
valueSetMaybeGObject :: GObjectClass gobj => GValue -> (Maybe gobj) -> IO ()
valueGetMaybeGObject :: GObjectClass gobj => GValue -> IO (Maybe gobj)
-- | Functions for getting and setting GObject properties
module System.Glib.Properties
objectSetPropertyInt :: GObjectClass gobj => String -> gobj -> Int -> IO ()
objectGetPropertyInt :: GObjectClass gobj => String -> gobj -> IO Int
objectSetPropertyUInt :: GObjectClass gobj => String -> gobj -> Int -> IO ()
objectGetPropertyUInt :: GObjectClass gobj => String -> gobj -> IO Int
objectSetPropertyInt64 :: GObjectClass gobj => String -> gobj -> Int64 -> IO ()
objectGetPropertyInt64 :: GObjectClass gobj => String -> gobj -> IO Int64
objectSetPropertyUInt64 :: GObjectClass gobj => String -> gobj -> Word64 -> IO ()
objectGetPropertyUInt64 :: GObjectClass gobj => String -> gobj -> IO Word64
objectSetPropertyChar :: GObjectClass gobj => String -> gobj -> Char -> IO ()
objectGetPropertyChar :: GObjectClass gobj => String -> gobj -> IO Char
objectSetPropertyBool :: GObjectClass gobj => String -> gobj -> Bool -> IO ()
objectGetPropertyBool :: GObjectClass gobj => String -> gobj -> IO Bool
objectSetPropertyEnum :: (GObjectClass gobj, Enum enum) => GType -> String -> gobj -> enum -> IO ()
objectGetPropertyEnum :: (GObjectClass gobj, Enum enum) => GType -> String -> gobj -> IO enum
objectSetPropertyFlags :: (GObjectClass gobj, Flags flag) => GType -> String -> gobj -> [flag] -> IO ()
objectGetPropertyFlags :: (GObjectClass gobj, Flags flag) => GType -> String -> gobj -> IO [flag]
objectSetPropertyFloat :: GObjectClass gobj => String -> gobj -> Float -> IO ()
objectGetPropertyFloat :: GObjectClass gobj => String -> gobj -> IO Float
objectSetPropertyDouble :: GObjectClass gobj => String -> gobj -> Double -> IO ()
objectGetPropertyDouble :: GObjectClass gobj => String -> gobj -> IO Double
objectSetPropertyString :: GObjectClass gobj => String -> gobj -> String -> IO ()
objectGetPropertyString :: GObjectClass gobj => String -> gobj -> IO String
objectSetPropertyMaybeString :: GObjectClass gobj => String -> gobj -> Maybe String -> IO ()
objectGetPropertyMaybeString :: GObjectClass gobj => String -> gobj -> IO (Maybe String)
objectSetPropertyBoxedOpaque :: GObjectClass gobj => (boxed -> (Ptr boxed -> IO ()) -> IO ()) -> GType -> String -> gobj -> boxed -> IO ()
objectGetPropertyBoxedOpaque :: GObjectClass gobj => (Ptr boxed -> IO boxed) -> GType -> String -> gobj -> IO boxed
objectSetPropertyBoxedStorable :: (GObjectClass gobj, Storable boxed) => GType -> String -> gobj -> boxed -> IO ()
objectGetPropertyBoxedStorable :: (GObjectClass gobj, Storable boxed) => GType -> String -> gobj -> IO boxed
objectSetPropertyGObject :: (GObjectClass gobj, GObjectClass gobj') => GType -> String -> gobj -> gobj' -> IO ()
objectGetPropertyGObject :: (GObjectClass gobj, GObjectClass gobj') => GType -> String -> gobj -> IO gobj'
newAttrFromIntProperty :: GObjectClass gobj => String -> Attr gobj Int
readAttrFromIntProperty :: GObjectClass gobj => String -> ReadAttr gobj Int
newAttrFromUIntProperty :: GObjectClass gobj => String -> Attr gobj Int
newAttrFromCharProperty :: GObjectClass gobj => String -> Attr gobj Char
writeAttrFromUIntProperty :: GObjectClass gobj => String -> WriteAttr gobj Int
newAttrFromBoolProperty :: GObjectClass gobj => String -> Attr gobj Bool
readAttrFromBoolProperty :: GObjectClass gobj => String -> ReadAttr gobj Bool
newAttrFromFloatProperty :: GObjectClass gobj => String -> Attr gobj Float
newAttrFromDoubleProperty :: GObjectClass gobj => String -> Attr gobj Double
newAttrFromEnumProperty :: (GObjectClass gobj, Enum enum) => String -> GType -> Attr gobj enum
readAttrFromEnumProperty :: (GObjectClass gobj, Enum enum) => String -> GType -> ReadAttr gobj enum
writeAttrFromEnumProperty :: (GObjectClass gobj, Enum enum) => String -> GType -> WriteAttr gobj enum
newAttrFromFlagsProperty :: (GObjectClass gobj, Flags flag) => String -> GType -> Attr gobj [flag]
newAttrFromStringProperty :: GObjectClass gobj => String -> Attr gobj String
readAttrFromStringProperty :: GObjectClass gobj => String -> ReadAttr gobj String
writeAttrFromStringProperty :: GObjectClass gobj => String -> WriteAttr gobj String
newAttrFromMaybeStringProperty :: GObjectClass gobj => String -> Attr gobj (Maybe String)
readAttrFromMaybeStringProperty :: GObjectClass gobj => String -> ReadAttr gobj (Maybe String)
writeAttrFromMaybeStringProperty :: GObjectClass gobj => String -> WriteAttr gobj (Maybe String)
newAttrFromBoxedOpaqueProperty :: GObjectClass gobj => (Ptr boxed -> IO boxed) -> (boxed -> (Ptr boxed -> IO ()) -> IO ()) -> String -> GType -> Attr gobj boxed
readAttrFromBoxedOpaqueProperty :: GObjectClass gobj => (Ptr boxed -> IO boxed) -> String -> GType -> ReadAttr gobj boxed
writeAttrFromBoxedOpaqueProperty :: GObjectClass gobj => (boxed -> (Ptr boxed -> IO ()) -> IO ()) -> String -> GType -> WriteAttr gobj boxed
newAttrFromBoxedStorableProperty :: (GObjectClass gobj, Storable boxed) => String -> GType -> Attr gobj boxed
newAttrFromObjectProperty :: (GObjectClass gobj, GObjectClass gobj', GObjectClass gobj'') => String -> GType -> ReadWriteAttr gobj gobj' gobj''
writeAttrFromObjectProperty :: (GObjectClass gobj, GObjectClass gobj') => String -> GType -> WriteAttr gobj gobj'
readAttrFromObjectProperty :: (GObjectClass gobj, GObjectClass gobj') => String -> GType -> ReadAttr gobj gobj'
newAttrFromMaybeObjectProperty :: (GObjectClass gobj, GObjectClass gobj', GObjectClass gobj'') => String -> GType -> ReadWriteAttr gobj (Maybe gobj') (Maybe gobj'')
writeAttrFromMaybeObjectProperty :: (GObjectClass gobj, GObjectClass gobj') => String -> GType -> WriteAttr gobj (Maybe gobj')
readAttrFromMaybeObjectProperty :: (GObjectClass gobj, GObjectClass gobj') => String -> GType -> ReadAttr gobj (Maybe gobj')
objectGetPropertyInternal :: GObjectClass gobj => GType -> (GValue -> IO a) -> String -> gobj -> IO a
objectSetPropertyInternal :: GObjectClass gobj => GType -> (GValue -> a -> IO ()) -> String -> gobj -> a -> IO ()
module System.Glib.StoreValue
data TMType
TMinvalid :: TMType
TMuint :: TMType
TMint :: TMType
TMboolean :: TMType
TMenum :: TMType
TMflags :: TMType
TMfloat :: TMType
TMdouble :: TMType
TMstring :: TMType
TMobject :: TMType
-- | A union with information about the currently stored type.
--
--
data GenericValue
GVuint :: Word -> GenericValue
GVint :: Int -> GenericValue
GVboolean :: Bool -> GenericValue
GVenum :: Int -> GenericValue
GVflags :: Int -> GenericValue
GVfloat :: Float -> GenericValue
GVdouble :: Double -> GenericValue
GVstring :: (Maybe String) -> GenericValue
GVobject :: GObject -> GenericValue
valueSetGenericValue :: GValue -> GenericValue -> IO ()
valueGetGenericValue :: GValue -> IO GenericValue
instance Enum TMType
module System.Glib.Signals
-- | Perform an action in response to a signal.
--
-- Use it like this:
--
--
-- on obj sig $ do
-- ...
--
--
-- or if the signal handler takes any arguments:
--
--
-- on obj sig $ \args -> do
-- ...
--
on :: object -> Signal object callback -> callback -> IO (ConnectId object)
-- | Perform an action in response to a signal.
--
--
-- - Like on but the signal is executed after Gtk's default
-- handler has run.
--
after :: object -> Signal object callback -> callback -> IO (ConnectId object)
-- | The type of signal handler ids. If you ever need to disconnect
-- a signal handler then you will need to retain the ConnectId you
-- got when you registered it.
data GObjectClass o => ConnectId o
ConnectId :: (CULong) -> o -> ConnectId o
-- | Disconnect a signal handler. After disconnecting the handler will no
-- longer be invoked when the event occurs.
signalDisconnect :: GObjectClass obj => ConnectId obj -> IO ()
-- | Block a specific signal handler.
--
--
-- - Blocks a handler of an instance so it will not be called during
-- any signal emissions unless it is unblocked again. Thus "blocking" a
-- signal handler means to temporarily deactive it, a signal handler has
-- to be unblocked exactly the same amount of times it has been blocked
-- before to become active again.
--
signalBlock :: GObjectClass obj => ConnectId obj -> IO ()
-- | Unblock a specific signal handler.
--
--
-- - Undoes the effect of a previous signalBlock call. A blocked
-- handler is skipped during signal emissions and will not be invoked,
-- unblocking it (for exactly the amount of times it has been blocked
-- before) reverts its "blocked" state, so the handler will be recognized
-- by the signal system and is called upon future or currently ongoing
-- signal emissions (since the order in which handlers are called during
-- signal emissions is deterministic, whether the unblocked handler in
-- question is called as part of a currently ongoing emission depends on
-- how far that emission has proceeded yet).
--
signalUnblock :: GObjectClass obj => ConnectId obj -> IO ()
-- | Stops a signal's current emission.
--
--
-- - This will prevent the default method from running. The sequence in
-- which handlers are run is "first", "on", "last" then "after" where
-- Gtk-internal signals are connected either at "first" or at "last".
-- Hence this function can only stop the signal processing if it is
-- called from within a handler that is connected with an "on" signal and
-- if the Gtk-internal handler is connected as "last". Gtk prints a
-- warning if this function is used on a signal which isn't being
-- emitted.
--
signalStopEmission :: GObjectClass obj => obj -> SignalName -> IO ()
-- | main event loop, and events
module System.Glib.MainLoop
type HandlerId = CUInt
-- | 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).
timeoutAdd :: IO Bool -> Int -> IO HandlerId
-- | 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).
timeoutAddFull :: IO Bool -> Priority -> Int -> IO HandlerId
-- | Remove a previously added timeout handler by its HandlerId.
timeoutRemove :: HandlerId -> IO ()
-- | 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.
--
idleAdd :: IO Bool -> Priority -> IO HandlerId
-- | Remove a previously added idle handler by its HandlerId.
idleRemove :: HandlerId -> IO ()
-- | 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.
--
data IOCondition
IOIn :: IOCondition
IOOut :: IOCondition
IOPri :: IOCondition
IOErr :: IOCondition
IOHup :: IOCondition
IOInvalid :: IOCondition
-- | Adds the file descriptor into the main event loop with the given
-- priority.
inputAdd :: FD -> [IOCondition] -> Priority -> IO Bool -> IO HandlerId
inputRemove :: HandlerId -> IO ()
-- | Priorities for installing callbacks.
type Priority = Int
priorityLow :: Int
priorityDefaultIdle :: Int
priorityHighIdle :: Int
priorityDefault :: Int
priorityHigh :: Int
-- | A main event loop abstraction.
data MainLoop
-- | Create a new MainLoop.
mainLoopNew :: Maybe MainContext -> Bool -> IO MainLoop
-- | 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.
mainLoopRun :: MainLoop -> IO ()
-- | Stops a MainLoop from running. Any calls to mainLoopRun for the
-- loop will return.
mainLoopQuit :: MainLoop -> IO ()
-- | Checks to see if the main loop is currently being run via mainLoopRun.
mainLoopIsRunning :: MainLoop -> IO Bool
-- | An opaque datatype representing a set of sources to be handled in a
-- main loop.
data MainContext
-- | Creates a new MainContext.
mainContextNew :: IO MainContext
-- | The default MainContext. This is the main context used for main
-- loop functions when a main loop is not explicitly specified.
mainContextDefault :: MainContext
-- | 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 (0), since the the wait may be
-- interrupted for other reasons than an event source becoming ready.
mainContextIteration :: MainContext -> Bool -> IO Bool
mainContextFindSourceById :: MainContext -> HandlerId -> IO Source
newtype Source
Source :: (ForeignPtr (Source)) -> Source
sourceAttach :: Source -> MainContext -> IO HandlerId
sourceSetPriority :: Source -> Priority -> IO ()
sourceGetPriority :: Source -> IO Priority
sourceDestroy :: Source -> IO ()
sourceIsDestroyed :: Source -> IO Bool
instance Eq IOCondition
instance Bounded IOCondition
instance Flags IOCondition
instance Enum IOCondition
-- | Error Reporting, glib's system for reporting errors.
--
-- GErrors are used by glib to report recoverable runtime errors.
--
-- This module provides functions for checking glib/gtk functions that
-- report GErrors. It also provides functions for throwing and
-- catching GErrors as Haskell exceptions.
module System.Glib.GError
-- | A GError consists of a domain, code and a human readable message.
data GError
GError :: !GErrorDomain -> !GErrorCode -> !GErrorMessage -> GError
-- | A code used to identify the 'namespace' of the error. Within each
-- error domain all the error codes are defined in an enumeration. Each
-- gtk/gnome module that uses GErrors has its own error domain. The
-- rationale behind using error domains is so that each module can
-- organise its own error codes without having to coordinate on a global
-- error code list.
type GErrorDomain = GQuark
-- | A code to identify a specific error within a given
-- GErrorDomain. Most of time you will not need to deal with this
-- raw code since there is an enumeration type for each error domain. Of
-- course which enumeraton to use depends on the error domain, but if you
-- use catchGErrorJustDomain or handleGErrorJustDomain,
-- this is worked out for you automatically.
type GErrorCode = Int
-- | A human readable error message.
type GErrorMessage = String
-- | This will catch just a specific GError exception. If you need to catch
-- a range of related errors, catchGErrorJustDomain is probably
-- more appropriate. Example:
--
--
-- do image <- catchGErrorJust PixbufErrorCorruptImage
-- loadImage
-- (\errorMessage -> do log errorMessage
-- return mssingImagePlaceholder)
--
catchGErrorJust :: GErrorClass err => err -> IO a -> (GErrorMessage -> IO a) -> IO a
-- | Catch all GErrors from a particular error domain. The handler function
-- should just deal with one error enumeration type. If you need to catch
-- errors from more than one error domain, use this function twice with
-- an appropriate handler functions for each.
--
--
-- catchGErrorJustDomain
-- loadImage
-- (\err message -> case err of
-- PixbufErrorCorruptImage -> ...
-- PixbufErrorInsufficientMemory -> ...
-- PixbufErrorUnknownType -> ...
-- _ -> ...)
--
catchGErrorJustDomain :: GErrorClass err => IO a -> (err -> GErrorMessage -> IO a) -> IO a
-- | A verson of handleGErrorJust with the arguments swapped around.
handleGErrorJust :: GErrorClass err => err -> (GErrorMessage -> IO a) -> IO a -> IO a
-- | A verson of catchGErrorJustDomain with the arguments swapped
-- around.
handleGErrorJustDomain :: GErrorClass err => (err -> GErrorMessage -> IO a) -> IO a -> IO a
-- | This will catch any GError exception. The handler function will
-- receive the raw GError. This is probably only useful when you want to
-- take some action that does not depend on which GError exception has
-- occured, otherwise it would be better to use either
-- catchGErrorJust or catchGErrorJustDomain. For example:
--
--
-- catchGError
-- (do ...
-- ...)
-- (\(GError dom code msg) -> fail msg)
--
catchGError :: IO a -> (GError -> IO a) -> IO a
-- | A verson of catchGError with the arguments swapped around.
--
--
-- handleGError (\(GError dom code msg) -> ...) $
-- ...
--
handleGError :: (GError -> IO a) -> IO a -> IO a
-- | Catch all GError exceptions and convert them into a general failure.
failOnGError :: IO a -> IO a
-- | Use this if you need to explicitly throw a GError or re-throw an
-- existing GError that you do not wish to handle.
throwGError :: GError -> IO a
-- | Each error domain's error enumeration type should be an instance of
-- this class. This class helps to hide the raw error and domain codes
-- from the user. This interface should be implemented by calling the
-- approrpiate {error_domain}_error_quark. It is safe to use a
-- pure FFI call for this.
--
-- Example for Graphics.UI.Gtk.Gdk.Pixbuf.PixbufError:
--
--
-- instance GErrorClass PixbufError where
-- gerrorDomain _ = {#call pure unsafe pixbuf_error_quark#}
--
class Enum err => GErrorClass err
gerrorDomain :: GErrorClass err => err -> GErrorDomain
-- | Glib functions which report GErrors take as a parameter a
-- GError **error. Use this function to supply such a parameter.
-- It checks if an error was reported and if so throws it as a Haskell
-- exception.
--
-- Example of use:
--
--
-- propagateGError $ \gerrorPtr ->
-- {# call g_some_function_that_might_return_an_error #} a b gerrorPtr
--
propagateGError :: (Ptr (Ptr ()) -> IO a) -> IO a
-- | Like propagateGError but instead of throwing the GError as an
-- exception handles the error immediately using the supplied error
-- handler.
--
-- Example of use:
--
--
-- checkGError
-- (\gerrorPtr -> {# call g_some_function_that_might_return_an_error #} a b gerrorPtr)
-- (\(GError domain code msg) -> ...)
--
checkGError :: (Ptr (Ptr ()) -> IO a) -> (GError -> IO a) -> IO a
instance Typeable GError
instance Storable GError
instance Exception GError
instance Show GError
module System.Glib.GDateTime
type GTimeValPart = CLong
data GTimeVal
GTimeVal :: GTimeValPart -> GTimeValPart -> GTimeVal
gTimeValSec :: GTimeVal -> GTimeValPart
gTimeValUSec :: GTimeVal -> GTimeValPart
gGetCurrentTime :: IO GTimeVal
gUSleep :: GTimeValPart -> IO ()
gTimeValAdd :: GTimeVal -> GTimeValPart -> GTimeVal
gTimeValFromISO8601 :: String -> Maybe GTimeVal
gTimeValToISO8601 :: GTimeVal -> String
newtype GDate
GDate :: GDateJulianDay -> GDate
gDateJulianDay :: GDate -> GDateJulianDay
data GDateDay
data GDateMonth
data GDateYear
type GDateJulianDay = CUInt
data GDateWeekday
gDateValidJulian :: GDateJulianDay -> Bool
gDateValidDMY :: GDateDay -> GDateMonth -> GDateYear -> Bool
gDateNewJulian :: GDateJulianDay -> Maybe GDate
gDateNewDMY :: GDateDay -> GDateMonth -> GDateYear -> Maybe GDate
gDateSetDay :: GDate -> GDateDay -> Maybe GDate
gDateSetMonth :: GDate -> GDateMonth -> Maybe GDate
gDateSetYear :: GDate -> GDateYear -> Maybe GDate
gDateNewTimeVal :: GTimeVal -> GDate
gDateParse :: String -> IO (Maybe GDate)
gDateAddDays :: GDate -> Word -> GDate
gDateSubtractDays :: GDate -> Word -> GDate
gDateAddMonths :: GDate -> Word -> GDate
gDateSubtractMonths :: GDate -> Word -> GDate
gDateAddYears :: GDate -> Word -> GDate
gDateSubtractYears :: GDate -> Word -> GDate
gDateDaysBetween :: GDate -> GDate -> Int
gDateCompare :: GDate -> GDate -> Ordering
gDateClamp :: GDate -> GDate -> GDate -> GDate
gDateDay :: GDate -> GDateDay
gDateMonth :: GDate -> GDateMonth
gDateYear :: GDate -> GDateYear
gDateWeekday :: GDate -> GDateWeekday
instance Eq GTimeVal
instance Ord GTimeVal
instance Eq GDateDay
instance Ord GDateDay
instance Eq GDateMonth
instance Ord GDateMonth
instance Eq GDateYear
instance Ord GDateYear
instance Eq GDate
instance Eq GDateWeekday
instance Ord GDateWeekday
instance Ord GDate
instance Bounded GDateWeekday
instance Enum GDateWeekday
instance Storable GDate
instance Bounded GDateYear
instance Bounded GDateMonth
instance Enum GDateMonth
instance Bounded GDateDay
instance Storable GTimeVal
-- | This module binds GLib-specific utility procedures.
module System.Glib.Utils
-- | Gets a human-readable name for the application, as set by
-- setApplicationName. This name should be localized if possible,
-- and is intended for display to the user. Contrast with
-- getProgramName, which gets a non-localized name. If
-- setApplicationName has not been performed, returns the result
-- of getProgramName (which may be Nothing if
-- setProgramName has also not been performed).
getApplicationName :: IO (Maybe String)
-- | Sets a human-readable name for the application. This name should be
-- localized if possible, and is intended for display to the user.
-- Contrast with setProgramName, which sets a non-localized name.
-- setProgramName will be performed automatically by
-- initGUI, but setApplicationName will not.
--
-- Note that for thread safety reasons, this computation can only be
-- performed once.
--
-- The application name will be used in contexts such as error messages,
-- or when displaying an application's name in the task list.
setApplicationName :: String -> IO ()
-- | Gets the name of the program. This name should not be
-- localized, contrast with getApplicationName. If you are using
-- GDK or GTK+, the program name is set in initGUI to the last
-- component of argv[0].
getProgramName :: IO (Maybe String)
-- | Sets the name of the program. This name should not be
-- localized, contrast with setApplicationName. Note that for
-- thread-safety reasons this computation can only be performed once.
setProgramName :: String -> IO ()
module System.Glib