# Gimp.PlugIn

    from gi.repository import Gimp

    plug_in = Gimp.PlugIn(program_name=value, read_channel=value, write_channel=value)

The base class for plug-ins to derive from.

GimpPlugIn manages the plug-in's [class@Procedure] objects. The procedures a plug-in implements are registered with GIMP by returning a list of their names from either [vfunc@GimpPlugIn.query_procedures] or [vfunc@GimpPlugIn.init_procedures].

Every GIMP plug-in has to be implemented as a subclass and make it known to the libgimp infrastructure and the main GIMP application by passing its `GType` to [func@MAIN].

[func@MAIN] passes the 'argc' and 'argv' of the platform's main() function, along with the `GType`, to [func@main], which creates an instance of the plug-in's `GimpPlugIn` subclass and calls its virtual functions, depending on how the plug-in was called by GIMP.

There are 3 different ways GIMP calls a plug-in: "query", "init" and "run".

The plug-in is called in "query" mode once after it was installed, or when the cached plug-in information in the config file "pluginrc" needs to be recreated. In "query" mode, [vfunc@GimpPlugIn.query_procedures] is called and returns a list of procedure names the plug-in implements. This is the "normal" place to register procedures, because the existence of most procedures doesn't depend on things that change between GIMP sessions.

The plug-in is called in "init" mode at each GIMP startup, and [vfunc@PlugIn.init_procedures] is called and returns a list of procedure names this plug-in implements. This only happens if the plug-in actually implements [vfunc@GimpPlugIn.init_procedures]. A plug-in only needs to implement init_procedures if the existence of its procedures can change between GIMP sessions, for example if they depend on the presence of external tools, or hardware like scanners, or online services, or whatever variable circumstances.

In order to register the plug-in's procedures with the main GIMP application in the plug-in's "query" and "init" modes, [class@PlugIn] calls [vfunc@PlugIn.create_procedure] on all procedure names in the exact order of the list returned by [vfunc@PlugIn.query_procedures] or [vfunc@PlugIn.init_procedures] and then registers the returned [class@Procedure].

The plug-in is called in "run" mode whenever one of the procedures it implements is called by either the main GIMP application or any other plug-in. In "run" mode, one of the procedure names returned by [vfunc@PlugIn.query_procedures] or [vfunc@PlugIn.init_procedures] is passed to [vfunc@PlugIn.create_procedure] which must return a [class@Procedure] for the passed name. The procedure is then executed by calling [method@Procedure.run].

In any of the three modes, [vfunc@PlugIn.quit] is called before the plug-in process exits, so the plug-in can perform whatever cleanup necessary.

Since 3.0

## Hierarchy

- GObject.Object
  - Gimp.PlugIn

## Methods

- Gimp.PlugIn.add_menu_branch
- Gimp.PlugIn.add_temp_procedure
- Gimp.PlugIn.extension_enable
- Gimp.PlugIn.extension_process
- Gimp.PlugIn.get_pdb_error_handler
- Gimp.PlugIn.get_temp_procedure
- Gimp.PlugIn.get_temp_procedures
- Gimp.PlugIn.remove_temp_procedure
- Gimp.PlugIn.set_help_domain
- Gimp.PlugIn.set_pdb_error_handler

## Static Functions

- Gimp.PlugIn.directory
- Gimp.PlugIn.error_quark

## Properties

- program-name
- read-channel
- write-channel

## Virtual functions

- Gimp.PlugIn::create_procedure
- Gimp.PlugIn::init_procedures
- Gimp.PlugIn::query_procedures
- Gimp.PlugIn::quit
- Gimp.PlugIn::set_i18n

## Fields

- Gimp.PlugIn->parent_instance
- Gimp.PlugIn->priv