EExtensible

## EExtensible EExtensible — an interface for extending objects |

## Synopsis

    #include <e-util/e-extensible.h>

                        EExtensible;
    void                e_extensible_load_extensions        (EExtensible *extensible);
    GList *		           e_extensible_list_extensions        (EExtensible *extensible,
                                                             GType extension_type);

## Object Hierarchy

      GInterface
       +----EExtensible

## Prerequisites

EExtensible requires GObject.

## Known Implementations

EExtensible is implemented by EShell, EShellContent, EShellSearchbar, EShellSidebar, EShellSwitcher, EShellTaskbar, EShellView and EShellWindow.

## Description

EExtension objects can be tacked on to any GObject instance that implements the EExtensible interface. A GObject type can be made extensible in two steps:

1. Add the EExtensible interface when registering the GType. There are no methods to implement.

    1
    2
    3
    4
    5
    #include <e-util/e-extensible.h>

    G_DEFINE_TYPE_WITH_CODE (
            ECustomWidget, e_custom_widget, GTK_TYPE_WIDGET,
            G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL))

2. Load extensions for the class at some point during GObject initialization. Generally this should be done toward the end of the initialization code, so extensions get a fully initialized object to work with.

    1
    2
    3
    4
    5
    6
    7
    static void
    e_custom_widget_init (ECustomWidget *widget)
    {
            Initialization code goes here...

            e_extensible_load_extensions (E_EXTENSIBLE (widget));
    }

## Details

### EExtensible

    typedef struct _EExtensible EExtensible;

### e_extensible_load_extensions ()

    void                e_extensible_load_extensions        (EExtensible *extensible);

Creates an instance of all instantiable subtypes of EExtension which target the class of `extensible`. The lifetimes of these newly created EExtension objects are bound to `extensible` such that they are finalized when `extensible` is finalized.

`extensible` : | an EExtensible

### e_extensible_list_extensions ()

    GList *		           e_extensible_list_extensions        (EExtensible *extensible,
                                                             GType extension_type);

Returns a list of EExtension objects bound to `extensible` whose types are ancestors of `extension_type`. For a complete list of extension objects bound to `extensible`, pass `E_TYPE_EXTENSION`.

The list itself should be freed with `g_list_free()`. The extension objects are owned by `extensible` and should not be unreferenced.

`extensible` : | an EExtensible
`extension_type` : | the type of extensions to list
Returns : | a list of extension objects derived from `extension_type`