gi-gio-2.0.11: Gio bindings

CopyrightWill Thompson, Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Interfaces.Initable

Contents

Description

Initable is implemented by objects that can fail during initialization. If an object implements this interface then it must be initialized as the first thing after construction, either via initableInit or asyncInitableInitAsync (the latter is only available if it also implements AsyncInitable).

If the object is not initialized, or initialization returns with an error, then all operations on the object except objectRef and objectUnref are considered to be invalid, and have undefined behaviour. They will often fail with g_critical() or g_warning(), but this must not be relied on.

Users of objects implementing this are not intended to use the interface method directly, instead it will be used automatically in various ways. For C applications you generally just call g_initable_new() directly, or indirectly via a foo_thing_new() wrapper. This will call initableInit under the cover, returning Nothing and setting a GError on failure (at which point the instance is unreferenced).

For bindings in languages where the native constructor supports exceptions the binding could check for objects implemention GInitable during normal construction and automatically initialize them, throwing an exception on failure.

Synopsis

Exported types

newtype Initable Source #

Constructors

Initable (ManagedPtr Initable) 

Instances

GObject Initable Source # 
IsObject Initable Source # 
IsInitable Initable Source # 
((~) * info (ResolveInitableMethod t Initable), MethodInfo * info Initable p) => IsLabel t (Initable -> p) Source # 

Methods

fromLabel :: Proxy# Symbol t -> Initable -> p #

((~) * info (ResolveInitableMethod t Initable), MethodInfo * info Initable p) => IsLabelProxy t (Initable -> p) Source # 

Methods

fromLabelProxy :: Proxy Symbol t -> Initable -> p #

HasAttributeList * Initable Source # 
type AttributeList Initable Source # 
type SignalList Initable Source # 

Methods

init

data InitableInitMethodInfo Source #

Instances

((~) * signature (Maybe b -> m ()), MonadIO m, IsInitable a, IsCancellable b) => MethodInfo * InitableInitMethodInfo a signature Source # 

initableInit Source #

Arguments

:: (HasCallStack, MonadIO m, IsInitable a, IsCancellable b) 
=> a

initable: a Initable.

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore.

-> m ()

(Can throw GError)

Initializes the object implementing the interface.

The object must be initialized before any real use after initial construction, either with this function or asyncInitableInitAsync.

Implementations may also support cancellation. If cancellable is not Nothing, then initialization can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned. If cancellable is not Nothing and the object doesn't support cancellable initialization the error IOErrorEnumNotSupported will be returned.

If the object is not initialized, or initialization returns with an error, then all operations on the object except objectRef and objectUnref are considered to be invalid, and have undefined behaviour. See the [introduction][ginitable] for more details.

Implementations of this method must be idempotent, i.e. multiple calls to this function with the same argument should return the same results. Only the first call initializes the object, further calls return the result of the first call. This is so that it's safe to implement the singleton pattern in the GObject constructor function.

Since: 2.22

newv

initableNewv Source #

Arguments

:: (HasCallStack, MonadIO m, IsCancellable a) 
=> GType

objectType: a GType supporting Initable.

-> [Parameter]

parameters: the parameters to use to construct the object

-> Maybe a

cancellable: optional Cancellable object, Nothing to ignore.

-> m Object

Returns: a newly allocated Object, or Nothing on error (Can throw GError)

Helper function for constructing Initable object. This is similar to objectNew but also initializes the object and returns Nothing, setting an error on failure.

Since: 2.22