Gimp::Extension - Easy framework for Gimp-Perl extensions


  use Gimp;
  use Gimp::Fu; # necessary for variable insertion and param constants
  use Gimp::Extension;
  podregister {
    # your code
  exit main;
  =head1 NAME

  function_name - Short description of the function

  =head1 SYNOPSIS



  Longer description of the function...


This module provides all the infrastructure you need to write Gimp-Perl extensions.

Your main interface for using Gimp::Extension is the podregister function. This works in exactly the same way as "PODREGISTER" in Gimp::Fu, including declaring/receiving your variables for you.

Before control is passed to your function, these procedures are called:

  Gimp::gtk_init; # sets up Gtk2, ready for event loop
  Gimp->extension_ack; # GIMP hangs till this is called
  Gimp->extension_enable; # adds an event handler in Glib mainloop for
                          # GIMP messages

Your function will then either proceed as if it were a plugin, or call the Glib/Gtk2 mainloop:


Values returned by your function will still be returned to a caller, as with a plugin.

One benefit of being an extension vs a plugin is that you can keep running, installing temporary procedures which are called by the user. When they are called, the perl function you have registered will be called, possibly accessing your persistent data or at least benefiting from the fact that you have already started up.

Another benefit is that you can respond to events outside of GIMP, such as network connections (this is how the Perl-Server is implemented).

Additionally, if no parameters are specified, then the extension will be started as soon as GIMP starts up. Make sure you specify menupath <None>, so no parameters will be added for you.

If you need to clean up on exit, just register a callback with Gimp::on_quit. This is how Perl-Server removes its Unix-domain socket on exit.


These are all exported by default.


As discussed above.


This is a convenience wrapper around Glib::IO->add_watch. It takes parameters:


This will be an IO::Socket subclass object, a listener socket. When it becomes readable, its accept method will be called.


This mandatory parameter is a function that is installed as the new connection's Glib handler. Its parameters are: $fd, $condition, $fh - in Glib terms, the file handle will be registered as the "data" parameter. When it returns false, the socket will be closed.


This optional parameter will, if defined, be a function that is called one time with the new socket as a parameter, possibly logging and/or sending an initial message down that socket.


  podregister_temp perl_fu_procname => sub {


  =head2 procname - blurb

  Longer help text.

  =head3 SYNOPSIS



    # params...

Registers a temporary procedure, reading from the POD the SYNOPSIS, PARAMETERS, RETURN VALUES, IMAGE TYPES, etc, as for Gimp::Fu. As you can see above, the temporary procedure's relevant information is in similarly-named sections, but at level 2 or 3, not 1, within the suitably-named level 2 section. Unlike podregister, it will not interpolate variables for you.


This is a convenience wrapper around Gimp->install_temp_proc, supplying a number of parameters from information in the extension's POD. The registration will only happen when the extension's on_run callback is called. It takes parameters:


The name of the new PDB procedure.


All as per "Gimp->install_procedure" in Gimp.



Ed J


perl(1), Gimp, Gimp::Fu.