see plug-ins/perl/Changes

This commit is contained in:
Marc Lehmann
1999-03-11 20:08:58 +00:00
parent a4fd7b62ab
commit 12cd1a5c0e
23 changed files with 772 additions and 104 deletions

View File

@ -7,13 +7,22 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK @EXPORT_FAIL %EXPORT_TAGS
use Gimp qw(:param);
use Gimp::Data;
use File::Basename;
use Data::Dumper;
use base qw(Exporter);
require Exporter;
require DynaLoader;
require AutoLoader;
eval {
require Data::Dumperx;
import Data::Dumper;
};
if ($@) {
*Dumper = sub {
"()";
};
}
=cut
=head1 NAME
@ -130,12 +139,6 @@ sub import {
# the old value of the trace flag
my $old_trace;
sub wrap_text {
my $x=$_[0];
$x=~s/(\G.{$_[1]}\S*)\s+/$1\n/g;
$x;
}
sub _new_adjustment {
my @adj = eval { @{$_[1]} };
@ -155,6 +158,7 @@ sub _find_digits {
sub interact($$$@) {
local $^W=0;
my($function)=shift;
my($blurb)=shift;
my($help)=shift;
my(@types)=@{shift()};
@ -168,7 +172,10 @@ sub interact($$$@) {
require Gtk; import Gtk;
init Gtk; # gross hack...
};
die "The Gtk perl module is required to run perl-scripts in interactive mode!\n" if $@;
if ($@) {
Gimp::logger(message => 'the gtk perl module is required to run in interactive mode', function => $function);
die "The Gtk perl module is required to run this function ($function) in interactive mode!\n";
}
parse Gtk::Rc Gimp->gtkrc;
@ -183,7 +190,7 @@ sub interact($$$@) {
set_title $w $0;
my $h = new Gtk::HBox 0,2;
$h->add(new Gtk::Label wrap_text($blurb,40));
$h->add(new Gtk::Label Gimp::wrap_text($blurb,40));
$w->vbox->pack_start($h,1,1,0);
realize $w;
my $l = logo($w);
@ -412,8 +419,8 @@ sub interact($$$@) {
signal_connect $button "clicked", sub {
my $helpwin = new Gtk::Dialog;
set_title $helpwin $0;
$helpwin->vbox->add(new Gtk::Label "Blurb:\n".wrap_text($blurb,40)
."\n\nHelp:\n".wrap_text($help,40));
$helpwin->vbox->add(new Gtk::Label "Blurb:\n".Gimp::wrap_text($blurb,40)
."\n\nHelp:\n".Gimp::wrap_text($help,40));
my $button = new Gtk::Button "Close";
signal_connect $button "clicked",sub { hide $helpwin };
$helpwin->action_area->add($button);
@ -574,9 +581,20 @@ sub net {
sub query {
my($type);
script:
for(@scripts) {
my($function,$blurb,$help,$author,$copyright,$date,
$menupath,$imagetypes,$params,$results,$code)=@$_;
$menupath,$imagetypes,$params,$results,$features,$code)=@$_;
if(@$features) {
require Gimp::Feature;
for(@$features) {
unless (Gimp::Feature::present($_)) {
Gimp::Feature::missing(Gimp::Feature::describe($_),$function);
next script;
}
}
}
if ($menupath=~/^<Image>\//) {
$type=&Gimp::PROC_PLUG_IN;
@ -607,6 +625,8 @@ sub query {
$_;
} @$params],
$results);
Gimp::logger(message => 'OK', function => $function, fatal => 0);
}
}
@ -624,11 +644,12 @@ sub query {
[
[PF_TYPE,name,desc,optional-default,optional-extra-args],
[PF_TYPE,name,desc,optional-default,optional-extra-args],
etc...
# etc...
],
[
like above, but for return values
# like above, but for return values (optional)
],
['feature1', 'feature2'...], # optionally check for features
sub { code };
=over 2
@ -692,7 +713,13 @@ See the section PARAMETER TYPES for the supported types.
This is just like the parameter array, just that it describes the return
values. Of course, default values don't make much sense here. (Even if they
did, it's not implemented anyway..)
did, it's not implemented anyway..). This argument is optional.
=item the features requirements
See L<Gimp::Features> for a description of which features can be checked
for. This argument is optional (but remember to specify an empty return
value array, C<[]>, if you want to specify it).
=item the code
@ -803,10 +830,15 @@ commandline.
sub register($$$$$$$$$;@) {
no strict 'refs';
my($function,$blurb,$help,$author,$copyright,$date,
$menupath,$imagetypes,$params,$results,$code)=@_;
$menupath,$imagetypes,$params)=splice(@_,0,9);
my($results,$features,$code);
$code or ($results,$code)=([],$results);
$results = (ref $_[0] eq "ARRAY") ? shift : [];
$features = (ref $_[0] eq "ARRAY") ? shift : [];
$code = shift;
@_==0 or die "register called with too many or wrong arguments\n";
for my $p (@$params,@$results) {
int($p->[0]) eq $p->[0] or croak "Argument/return value '$p->[1]' has illegal type '$p->[0]'";
}
@ -842,12 +874,12 @@ sub register($$$$$$$$$;@) {
local $^W=0; # perl -w is braindamaged
my $VAR1; # Data::Dumper is braindamaged
# gimp is braindamaged, is doesn't deliver useful values!!
($res,@_)=interact($blurb,$help,$params,@{eval $Gimp::Data{"$function/_fu_data"}});
($res,@_)=interact($function,$blurb,$help,$params,@{eval $Gimp::Data{"$function/_fu_data"}});
return unless $res;
}
} elsif ($run_mode == &Gimp::RUN_FULLINTERACTIVE) {
my($res);
($res,@_)=interact($blurb,$help,[@image_params,@{$params}],[@pre,@_]);
($res,@_)=interact($function,$blurb,$help,[@image_params,@{$params}],[@pre,@_]);
undef @pre;
return unless $res;
} elsif ($run_mode == &Gimp::RUN_NONINTERACTIVE) {
@ -894,7 +926,7 @@ sub register($$$$$$$$$;@) {
wantarray ? @imgs : $imgs[0];
};
push(@scripts,[$function,$blurb,$help,$author,$copyright,$date,
$menupath,$imagetypes,$params,$results,$code]);
$menupath,$imagetypes,$params,$results,$features,$code]);
}
=cut