gi-gio-2.0.32: Gio bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | Safe-Inferred
Language | Haskell2010

GI.Gio.Structs.IOExtensionPoint

Contents

- Exported types
- Methods
  - getExtensionByName
  - getExtensions
  - getRequiredType
  - implement
  - lookup
  - register
  - setRequiredType

Description

`GIOExtensionPoint` provides a mechanism for modules to extend the functionality of the library or application that loaded it in an organized fashion.

An extension point is identified by a name, and it may optionally require that any implementation must be of a certain type (or derived thereof). Use [func`gio`.IOExtensionPoint.register] to register an extension point, and `iOExtensionPointSetRequiredType` to set a required type.

A module can implement an extension point by specifying the [type`gObject`.Type] that implements the functionality. Additionally, each implementation of an extension point has a name, and a priority. Use [func`gio`.IOExtensionPoint.implement] to implement an extension point.

### c code

    GIOExtensionPoint *ep;

    // Register an extension point
    ep = g_io_extension_point_register ("my-extension-point");
    g_io_extension_point_set_required_type (ep, MY_TYPE_EXAMPLE);

### c code

    // Implement an extension point
    G_DEFINE_TYPE (MyExampleImpl, my_example_impl, MY_TYPE_EXAMPLE)
    g_io_extension_point_implement ("my-extension-point",
                                    my_example_impl_get_type (),
                                    "my-example",
                                    10);

It is up to the code that registered the extension point how it uses the implementations that have been associated with it. Depending on the use case, it may use all implementations, or only the one with the highest priority, or pick a specific one by name.

To avoid opening all modules just to find out what extension points they implement, GIO makes use of a caching mechanism, see gio-querymodules. You are expected to run this command after installing a GIO module.

The `GIO_EXTRA_MODULES` environment variable can be used to specify additional directories to automatically load modules from. This environment variable has the same syntax as the `PATH`. If two modules have the same base name in different directories, then the latter one will be ignored. If additional directories are specified GIO will load modules from the built-in directory last.

Synopsis

- newtype IOExtensionPoint = IOExtensionPoint (ManagedPtr IOExtensionPoint)
- iOExtensionPointGetExtensionByName :: (HasCallStack, MonadIO m) => IOExtensionPoint -> Text -> m IOExtension
- iOExtensionPointGetExtensions :: (HasCallStack, MonadIO m) => IOExtensionPoint -> m [IOExtension]
- iOExtensionPointGetRequiredType :: (HasCallStack, MonadIO m) => IOExtensionPoint -> m GType
- iOExtensionPointImplement :: (HasCallStack, MonadIO m) => Text -> GType -> Text -> Int32 -> m IOExtension
- iOExtensionPointLookup :: (HasCallStack, MonadIO m) => Text -> m IOExtensionPoint
- iOExtensionPointRegister :: (HasCallStack, MonadIO m) => Text -> m IOExtensionPoint
- iOExtensionPointSetRequiredType :: (HasCallStack, MonadIO m) => IOExtensionPoint -> GType -> m ()

# Exported types

newtype IOExtensionPoint Source #

Memory-managed wrapper type.

Constructors

IOExtensionPoint (ManagedPtr IOExtensionPoint) |

#### Instances

Instances details

Eq IOExtensionPoint Source # |
Instance details Defined in GI.Gio.Structs.IOExtensionPoint Methods (==) :: IOExtensionPoint -> IOExtensionPoint -> Bool Source # (/=) :: IOExtensionPoint -> IOExtensionPoint -> Bool Source #
BoxedPtr IOExtensionPoint Source # |
Instance details Defined in GI.Gio.Structs.IOExtensionPoint Methods boxedPtrCopy :: IOExtensionPoint -> IO IOExtensionPoint Source # boxedPtrFree :: IOExtensionPoint -> IO () Source #
ManagedPtrNewtype IOExtensionPoint Source # |
Instance details Defined in GI.Gio.Structs.IOExtensionPoint Methods toManagedPtr :: IOExtensionPoint -> ManagedPtr IOExtensionPoint Source #

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

None.

#### Getters

getExtensionByName, getExtensions, getRequiredType.

#### Setters

setRequiredType.

## getExtensionByName

iOExtensionPointGetExtensionByName Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> IOExtensionPoint | `extensionPoint`: a `IOExtensionPoint`
-> Text | `name`: the name of the extension to get
-> m IOExtension | Returns: the `IOExtension` for `extensionPoint` that has the given name, or `Nothing` if there is no extension with that name

Finds a `IOExtension` for an extension point by name.

## getExtensions

iOExtensionPointGetExtensions Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> IOExtensionPoint | `extensionPoint`: a `IOExtensionPoint`
-> m [IOExtension] | Returns: a `List` of `GIOExtensions`. The list is owned by GIO and should not be modified.

Gets a list of all extensions that implement this extension point. The list is sorted by priority, beginning with the highest priority.

## getRequiredType

iOExtensionPointGetRequiredType Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> IOExtensionPoint | `extensionPoint`: a `IOExtensionPoint`
-> m GType | Returns: the `GType` that all implementations must have, or `G_TYPE_INVALID` if the extension point has no required type

Gets the required type for `extensionPoint`.

## implement

iOExtensionPointImplement Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `extensionPointName`: the name of the extension point
-> GType | `type`: the `GType` to register as extension
-> Text | `extensionName`: the name for the extension
-> Int32 | `priority`: the priority for the extension
-> m IOExtension | Returns: a `IOExtension` object for `GType`

Registers `type` as extension for the extension point with name `extensionPointName`.

If `type` has already been registered as an extension for this extension point, the existing `IOExtension` object is returned.

## lookup

iOExtensionPointLookup Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `name`: the name of the extension point
-> m IOExtensionPoint | Returns: the `IOExtensionPoint`, or `Nothing` if there is no registered extension point with the given name.

Looks up an existing extension point.

## register

iOExtensionPointRegister Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `name`: The name of the extension point
-> m IOExtensionPoint | Returns: the new `IOExtensionPoint`. This object is owned by GIO and should not be freed.

Registers an extension point.

## setRequiredType

iOExtensionPointSetRequiredType Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> IOExtensionPoint | `extensionPoint`: a `IOExtensionPoint`
-> GType | `type`: the `GType` to require
-> m () |

Sets the required type for `extensionPoint` to `type`. All implementations must henceforth have this type.