|
NAMEGimp::Extension - Easy framework for Gimp-Perl extensionsSYNOPSISuse Gimp; use Gimp::Fu; # necessary for variable insertion and param constants 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... DESCRIPTIONThis 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: 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. 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. FUNCTIONS AVAILABLE TO EXTENSIONSThese are all exported by default.podregisterAs discussed above.add_listenerThis is a convenience wrapper around "Glib::IO->add_watch". It takes parameters:
podregister_temppodregister_temp perl_fu_procname => sub { ... }; =head1 TEMPORARY PROCEDURES =head2 procname - blurb Longer help text. =head3 SYNOPSIS <Image>/File/Label... =head3 PARAMETERS # 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. register_tempThis 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:
AUTHOREd JSEE ALSOperl(1), Gimp, Gimp::Fu.
Visit the GSP FreeBSD Man Page Interface. |