| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.GI.Base.GObject
Description
This module constains helpers for dealing with GObject-derived
types.
Synopsis
- constructGObject :: (GObject o, MonadIO m) => (ManagedPtr o -> o) -> [AttrOp o 'AttrConstruct] -> m o
- new' :: (HasCallStack, MonadIO m, GObject o) => (ManagedPtr o -> o) -> [m (GValueConstruct o)] -> m o
- gobjectGetUserData :: (HasCallStack, GObject o) => o -> GQuark a -> IO (Maybe a)
- gobjectSetUserData :: (HasCallStack, GObject o) => o -> GQuark a -> a -> IO ()
- gobjectModifyUserData :: (HasCallStack, GObject o) => o -> GQuark a -> (Maybe a -> a) -> IO ()
- class GObject a => DerivedGObject a where
- type GObjectParentType a
- type GObjectPrivateData a
- objectTypeName :: Text
- objectClassInit :: GObjectClass -> IO ()
- objectInstanceInit :: GObjectClass -> a -> IO (GObjectPrivateData a)
- objectInterfaces :: [(IO GType, Ptr () -> IO (), Maybe (Ptr () -> IO ()))]
- registerGType :: (HasCallStack, DerivedGObject o, GObject (GObjectParentType o), GObject o) => (ManagedPtr o -> o) -> IO GType
- gobjectGetPrivateData :: (HasCallStack, DerivedGObject o) => o -> IO (GObjectPrivateData o)
- gobjectSetPrivateData :: (HasCallStack, DerivedGObject o) => o -> GObjectPrivateData o -> IO ()
- gobjectModifyPrivateData :: (HasCallStack, DerivedGObject o) => o -> (GObjectPrivateData o -> GObjectPrivateData o) -> IO ()
- newtype GObjectClass = GObjectClass (Ptr GObjectClass)
- gtypeFromClass :: GObjectClass -> IO GType
- gtypeFromInstance :: GObject o => o -> IO GType
- gobjectInstallProperty :: DerivedGObject o => GObjectClass -> PropertyInfo o a -> IO ()
- gobjectInstallCIntProperty :: DerivedGObject o => GObjectClass -> CIntPropertyInfo o -> IO ()
- gobjectInstallCStringProperty :: DerivedGObject o => GObjectClass -> CStringPropertyInfo o -> IO ()
- gobjectInstallGBooleanProperty :: DerivedGObject o => GObjectClass -> GBooleanPropertyInfo o -> IO ()
Constructing new GObjects
constructGObject :: (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' :: (HasCallStack, MonadIO m, GObject o) => (ManagedPtr o -> o) -> [m (GValueConstruct o)] -> m o Source #
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.
gobjectModifyUserData :: (HasCallStack, GObject o) => o -> GQuark a -> (Maybe a -> a) -> IO () Source #
A combination of gobjectGetUserData and gobjectSetUserData,
for convenience.
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.
Minimal complete definition
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 -> a -> 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).
objectInterfaces :: [(IO GType, Ptr () -> IO (), Maybe (Ptr () -> IO ()))] Source #
List of interfaces implemented by the type. Each element is a
triplet (gtype, interfaceInit, interfaceFinalize), where
gtype :: IO GType is a constructor for the type of the
interface, interfaceInit :: Ptr () -> IO () is a function that
registers the callbacks in the interface, and interfaceFinalize
:: Maybe (Ptr () -> IO ()) is the (optional) finalizer.
registerGType :: (HasCallStack, DerivedGObject o, GObject (GObjectParentType o), GObject 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 :: (HasCallStack, DerivedGObject o) => o -> IO (GObjectPrivateData o) Source #
Get the private data associated with the given object.
gobjectSetPrivateData :: (HasCallStack, DerivedGObject o) => o -> GObjectPrivateData o -> IO () Source #
Set the private data associated with the given object.
gobjectModifyPrivateData :: (HasCallStack, DerivedGObject o) => o -> (GObjectPrivateData o -> GObjectPrivateData o) -> IO () Source #
Modify the private data for the given object.
newtype GObjectClass Source #
Wrapper around GObjectClass on the C-side.
Constructors
| GObjectClass (Ptr GObjectClass) |
gtypeFromClass :: GObjectClass -> IO GType Source #
Find the GType associated to a given GObjectClass.
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.
gobjectInstallGBooleanProperty :: DerivedGObject o => GObjectClass -> GBooleanPropertyInfo o -> IO () Source #
Add a `${type gboolean}`-valued property to the given object class.