Gio.IOExtensionPoint

Fields

None

Methods

class

implement (extension_point_name, type, extension_name, priority)

class

lookup (name)

class

register (name)

get_extension_by_name (name)

get_extensions ()

get_required_type ()

set_required_type (type)

Details

class Gio.IOExtensionPoint

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 [method`Gio`.IOExtensionPoint.set_required_type] 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 Gio.IOExtensionPoint *ep;

// Register an extension point ep = Gio.IOExtensionPoint.register (“my-extension-point”); Gio.IOExtensionPoint.set_required_type (ep, MY_TYPE_EXAMPLE); ```

``c // 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.

classmethod implement(extension_point_name, type, extension_name, priority)[source]
Parameters:
  • extension_point_name (str) – the name of the extension point

  • type (GObject.GType) – the GObject.GType to register as extension

  • extension_name (str) – the name for the extension

  • priority (int) – the priority for the extension

Returns:

a Gio.IOExtension object for GObject.GType

Return type:

Gio.IOExtension

Registers type as extension for the extension point with name extension_point_name.

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

classmethod lookup(name)[source]
Parameters:

name (str) – the name of the extension point

Returns:

the Gio.IOExtensionPoint, or None if there is no registered extension point with the given name.

Return type:

Gio.IOExtensionPoint

Looks up an existing extension point.

classmethod register(name)[source]
Parameters:

name (str) – The name of the extension point

Returns:

the new Gio.IOExtensionPoint. This object is owned by GIO and should not be freed.

Return type:

Gio.IOExtensionPoint

Registers an extension point.

get_extension_by_name(name)[source]
Parameters:

name (str) – the name of the extension to get

Returns:

the Gio.IOExtension for self that has the given name, or None if there is no extension with that name

Return type:

Gio.IOExtension

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

get_extensions()[source]
Returns:

a GLib.List of Gio.IOExtensions. The list is owned by GIO and should not be modified.

Return type:

[Gio.IOExtension]

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

get_required_type()[source]
Returns:

the GObject.GType that all implementations must have, or GObject.TYPE_INVALID if the extension point has no required type

Return type:

GObject.GType

Gets the required type for self.

set_required_type(type)[source]
Parameters:

type (GObject.GType) – the GObject.GType to require

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