Plugins: <span class="productname">FileManager-Actions</span>™ Reference Manual

## Plugins Plugins — The FileManager-Actions Extension Interface Definition v 1 |

## Functions

gboolean | fma_extension_startup ()
guint | fma_extension_get_version ()
guint | fma_extension_list_types ()
void | fma_extension_shutdown ()

## Includes

    #include <filemanager-actions/fma-extension.h>

## Description

FileManager-Actions™ accepts extensions as dynamically loadable libraries (aka plugins).

As of today, FileManager-Actions™ may be extended in the following areas:

- Storing menus and actions in a specific storage subsystem . This extension is provided via the public FMAIIOProvider interface; it takes care of reading and writing menus and actions to a specific storage subsystem.

- Exporting menus and actions . This extension is provided via the public FMAIExporter interface; it takes care of exporting menus and actions to the filesystem from the FileManager-Actions™ Configuration Tool user interface.

- Importing menus and actions . This extension is provided via the public FMAIImporter interface; it takes care of importing menus and actions from the filesystem into the FileManager-Actions™ Configuration Tool user interface.

In order to be recognized as a valid FileManager-Actions™ plugin, the library must at least export the functions described as mandatory in this extension API.

### Developing a FileManager-Actions™ plugin

#### Building the dynamically loadable library

The suggested way of producing a dynamically loadable library is to use autoconf, automake and libtool GNU tools.

In this case, it should be enough to use the `-module` option in your `Makefile.am`, as in:

      libfma_io_desktop_la_LDFLAGS = -module -no-undefined -avoid-version

#### Installing the library

At startup time, FileManager-Actions™ searches for its candidate libraries in `PKGLIBDIR` directory, which most often happens to be `/usr/lib/filemanager-actions/` or `/usr/lib64/filemanager-actions/`, depending of your system.

### Versions historic

Table 1. Historic of the versions of this extension API

FileManager-Actions™ version | extension API version |
--- | --- | ---
since 2.30 | 1 | current version

## Functions

### fma_extension_startup ()

    gboolean
    fma_extension_startup (GTypeModule *module);

This function is called by the FileManager-Actions plugin manager when the plugin library is first loaded in memory. The library may so take advantage of this call by initializing itself, registering its internal GType types, etc.

This function is mandatory: a FileManager-Actions extension must implement this function in order to be considered as a valid candidate to dynamic load.

Example 1.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    static GType st_module_type = 0;

    gboolean
    fma_extension_startup( GTypeModule *plugin )
    {
        static GTypeInfo info = {
            sizeof( FMADesktopProviderClass ),
            NULL,
            NULL,
            ( GClassInitFunc ) class_init,
            NULL,
            NULL,
            sizeof( FMADesktopProvider ),
            0,
            ( GInstanceInitFunc ) instance_init
        };

        static const GInterfaceInfo iio_provider_iface_info = {
            ( GInterfaceInitFunc ) iio_provider_iface_init,
            NULL,
            NULL
        };

        st_module_type = g_type_module_register_type( plugin, G_TYPE_OBJECT, "FMADesktopProvider", &info, 0 );

        g_type_module_add_interface( plugin, st_module_type, FMA_TYPE_IIO_PROVIDER, &iio_provider_iface_info );

        return( TRUE );
    }

#### Parameters

module | the GTypeModule of the plugin library being loaded. |

#### Returns

`TRUE` if the initialization is successful, `FALSE` else. In this later case, the library is unloaded and no more considered.

Since: 2.30

### fma_extension_get_version ()

    guint
    fma_extension_get_version (void);

This function is called by the FileManager-Actions™ program each time it needs to know which version of this API the plugin implements.

If this function is not exported by the library, the plugin manager considers that the library only implements the version 1 of this extension API.

#### Returns

the version of this API supported by the module.

Since: 2.30

### fma_extension_list_types ()

    guint
    fma_extension_list_types (const GType **types);

Returned GType types must already have been registered in the GType system (e.g. at `fma_extension_startup()` time), and the objects they describe may implement one or more of the interfaces defined in this FileManager-Actions public API.

The FileManager-Actions plugin manager will instantiate one GTypeInstance- derived object for each returned GType type, and associate these objects to this library.

This function is mandatory: a FileManager-Actions extension must implement this function in order to be considered as a valid candidate to dynamic load.

Example 2.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    /* the count of GType types provided by this extension
     * each new GType type must
     * - be registered in fma_extension_startup()
     * - be addressed in fma_extension_list_types().
     */
    #define TYPES_COUNT    1

    guint
    fma_extension_list_types( const GType **types )
    {
         static GType types_list [1+TYPES_COUNT];

         /* FMA_TYPE_DESKTOP_PROVIDER has been previously
          * registered in fma_extension_startup function
          */
         types_list[0] = FMA_TYPE_DESKTOP_PROVIDER;

         types_list[TYPES_COUNT] = 0;
         *types = types_list;

         return( TYPES_COUNT );
    }

#### Parameters

types | the address where to store the zero-terminated array of instantiable GType types this library implements. |

#### Returns

the number of GType types returned in the `types` array, not counting the terminating zero item.

Since: 2.30

### fma_extension_shutdown ()

    void
    fma_extension_shutdown (void);

This function is called by FileManager-Actions when it is about to shutdown itself.

The dynamically loaded library may take advantage of this call to release any resource, handle, and so on, it may have previously allocated.

This function is mandatory: a FileManager-Actions extension must implement this function in order to be considered as a valid candidate to dynamic load.

Since: 2.30

## Types and Values