haskell-gi-base-0.22.2: Foundation for libraries generated by haskell-gi

Safe HaskellNone
LanguageHaskell98

Data.GI.Base.GObject

Contents

Description

This module constains helpers for dealing with GObject-derived types.

Synopsis

Constructing new GObjects

constructGObject :: forall o m. (GObject o, MonadIO m) => (ManagedPtr o -> o) -> [AttrOp o AttrConstruct] -> m o Source #

Construct a GObject given the constructor and a list of settable attributes. See new for a more general version.

new' :: (MonadIO m, GObject o) => (ManagedPtr o -> o) -> [IO (GValueConstruct o)] -> m o Source #

Construct the given GObject, given a set of actions constructing desired GValues to set at construction time.

User data

gobjectGetUserData :: (HasCallStack, GObject o) => o -> GQuark a -> IO (Maybe a) Source #

Get the value of a given key for the object.

gobjectSetUserData :: (HasCallStack, GObject o) => o -> GQuark a -> a -> IO () Source #

Set the value of the user data for the given GObject to a StablePtr to the given Haskell object. The StablePtr will be freed when the object is destroyed, or the value is replaced.

Deriving new object types

class GObject a => DerivedGObject a where Source #

This typeclass contains the data necessary for defining a new GObject type from Haskell.

Associated Types

type GObjectParentType a Source #

The parent type

type GObjectPrivateData a Source #

Type of the private data for each instance.

Methods

objectTypeName :: Text Source #

Name of the type, it should be unique.

objectClassInit :: GObjectClass -> IO () Source #

Code to run when the class is inited. This is a good place to register signals and properties for the type.

objectInstanceInit :: GObjectClass -> IO (GObjectPrivateData a) Source #

Code to run when each instance of the type is constructed. Returns the private data to be associated with the new instance (use gobjectGetPrivateData and gobjectSetPrivateData to manipulate this further).

registerGType :: forall o. (HasCallStack, DerivedGObject o, GObject (GObjectParentType o)) => (ManagedPtr o -> o) -> IO GType Source #

Register the given type into the GObject type system and return the resulting GType, if it has not been registered already. If the type has been registered already the existing GType will be returned instead.

Note that for this function to work the type must be an instance of DerivedGObject.

gobjectGetPrivateData :: forall o. (HasCallStack, DerivedGObject o) => o -> IO (GObjectPrivateData o) Source #

Get the private data associated with the given object.

gobjectSetPrivateData :: forall o. (HasCallStack, DerivedGObject o) => o -> GObjectPrivateData o -> IO () Source #

Set the private data associated with the given object.

data GObjectClass Source #

Opaque wrapper around GObjectClass on the C-side.

gtypeFromClass :: GObjectClass -> IO GType Source #

Find the GType associated to a given GObjectClass.

gtypeFromInstance :: GObject o => o -> IO GType Source #

Find the GType for a given GObject.

Installing properties for derived objects

gobjectInstallProperty :: DerivedGObject o => GObjectClass -> PropertyInfo o a -> IO () Source #

Add a Haskell object-valued property to the given object class.

gobjectInstallCIntProperty :: DerivedGObject o => GObjectClass -> CIntPropertyInfo o -> IO () Source #

Add a CInt-valued property to the given object class.

gobjectInstallCStringProperty :: DerivedGObject o => GObjectClass -> CStringPropertyInfo o -> IO () Source #

Add a CString-valued property to the given object class.