Gimp::Extension - Easy framework for Gimp-Perl extensions
use Gimp; use Gimp::Extension; podregister { # your code }; exit main; __END__ =head1 NAME function_name - Short description of the function =head1 SYNOPSIS <Image>/Filters/Menu/Location... =head1 DESCRIPTION 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, with a few crucial differences. See below for those differences.
Gimp::Extension
podregister
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:
Gtk2->main;
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.
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.
Gimp::on_quit
Perl-Server
The podregister function here is different from in Gimp::Fu in that parameters and return values are not added for you, and your function name will not be changed but passed to GIMP verbatim.
The run_mode is passed on to your function, rather than being stripped off as with Gimp::Fu.
run_mode
These are all exported by default.
As discussed above.
This is a convenience wrapper around Glib::IO->add_watch. It takes parameters:
Glib::IO->add_watch
This will be an IO::Socket subclass object, a listener socket. When it becomes readable, its accept method will be called.
accept
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.
$fd, $condition, $fh
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.
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:
Gimp->install_temp_proc
on_run
The name of the new PDB procedure.
All as per "Gimp->install_procedure" in Gimp.
=head1 TEMPORARY PROCEDURES =head2 autosave_configure - blurb text Longer help text. =head3 PARAMETERS # gets interpolated vars per Gimp::Fu podregister_ui 'autosave_configure' => sub { ... }; podregister will have interpolated vars too, and add vars based on menupath, etc menupath <Autostart> - die if get any params/retvals
Ed J
perl(1), Gimp, Gimp::Fu.
To install Gimp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gimp
CPAN shell
perl -MCPAN -e shell install Gimp
For more information on module installation, please visit the detailed CPAN module installation guide.