[gimp-perl] Run mode added except for <None>, remove from sub params into $*::run_mode.
- From: Ed J <edj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Run mode added except for <None>, remove from sub params into $*::run_mode.
- Date: Tue, 20 May 2014 05:37:04 +0000 (UTC)
commit 9a46d6cd90c3f6c89d7efac37ae087382139c62d
Author: Ed J <edj src gnome org>
Date: Tue May 20 06:36:44 2014 +0100
Run mode added except for <None>, remove from sub params into $*::run_mode.
Gimp/Extension.pm | 49 +++++++++++++++++++++++++++++++++++++------------
Gimp/Fu.pm | 13 +++++++------
Net/Net.pm | 7 +++----
examples/Perl-Server | 1 -
t/extension.t | 3 +--
5 files changed, 48 insertions(+), 25 deletions(-)
---
diff --git a/Gimp/Extension.pm b/Gimp/Extension.pm
index 4bcdfcc..7f76687 100644
--- a/Gimp/Extension.pm
+++ b/Gimp/Extension.pm
@@ -21,24 +21,24 @@ FILTER {
};
our @EXPORT = qw(podregister main add_listener register_temp);
+our $run_mode;
my @register_params;
my @temp_procs;
-Gimp::on_query { Gimp->install_procedure(@register_params); };
+my @pod_temp_procs;
+Gimp::on_query {
+ unshift @{$register_params[9]}, [&Gimp::PDB_INT32,"run_mode","Interactive:0=yes,1=no"]
+ if defined $register_params[6];
+ Gimp->install_procedure(@register_params);
+};
sub podregister (&) {
no strict 'refs';
my ($function, $blurb, $help, $author, $copyright, $date, $menupath,
$imagetypes, $params, $results, $code) = fixup_args(('')x9, @_);
- for my $p (@$params,@$results) {
- next unless ref $p;
- croak __"$function: argument/return value '$p->[1]' has illegal type '$p->[0]'"
- unless int($p->[0]) eq $p->[0];
- carp(__"$function: argument name '$p->[1]' contains illegal characters, only 0-9, a-z and _ allowed")
- unless $p->[1]=~/^[0-9a-z_]+$/;
- }
Gimp::register_callback $function => sub {
warn "$$-Gimp::Extension sub: $function(@_)" if $Gimp::verbose;
+ $run_mode = defined($menupath) ? shift : undef;
for my $tp (@temp_procs) {
my (
$tfunction, $tblurb, $thelp, $tmenupath, $timagetypes,
@@ -58,7 +58,6 @@ sub podregister (&) {
Gimp->extension_enable;
goto &$code;
};
- $menupath = undef if $menupath eq '<None>';
@register_params = (
$function, $blurb, $help, $author, $copyright, $date, $menupath,
$imagetypes, &Gimp::EXTENSION, $params, $results
@@ -81,9 +80,8 @@ sub add_listener {
}, $listen_socket);
}
-sub register_temp ($$$$$$$&) {
- push @temp_procs, [ @_ ];
-}
+sub register_temp ($$$$$$$&) { push @temp_procs, [ @_ ]; }
+sub podregister_temp { push @pod_temp_procs, [ @_ ]; }
1;
__END__
@@ -198,6 +196,33 @@ sending an initial message down that socket.
=back
+=head2 podregister_temp
+
+ podregister_temp perl_fu_procname => sub {
+ ...
+ };
+
+ =head1 TEMPORARY PROCEDURES
+
+ =head2 perl_fu_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 L<Gimp::Fu>. As
+you can see above, the temporary procedure's relevant information is in
+similarly-named sections, but at level 3, not 1, within the suitably-named
+level 2 section. Like C<podregister>, it will not interpolate variables
+for you.
+
=head2 register_temp
This is a convenience wrapper around C<Gimp-E<gt>install_temp_proc>,
diff --git a/Gimp/Fu.pm b/Gimp/Fu.pm
index c04efd6..d2a831f 100644
--- a/Gimp/Fu.pm
+++ b/Gimp/Fu.pm
@@ -149,7 +149,7 @@ sub string2pf($$) {
} elsif($type == PF_IMAGE) {
my $image;
if ((my $arg) = $s =~ /%(.+)/) {
- die "Image % argument not integer - if file, put './' in front\n"
+ die "Image %argument '$arg' not integer - if file, put './' in front\n"
unless $arg eq int $arg;
$image = Gimp::Image->existing($arg);
die "'$arg' not a valid image - need to run Perl Server?\n"
@@ -271,7 +271,8 @@ Gimp::on_query {
next if $p->[0] < Gimp::PDB_END;
$p->[0] = $pf2info{$p->[0]}->[1] // datatype(values %{+{ {$p->[4]}}});
}
- unshift @{$s->[9]}, [Gimp::PDB_INT32,"run_mode","Interactive:0=yes,1=no"];
+ unshift @{$s->[9]}, [&Gimp::PDB_INT32,"run_mode","Interactive:0=yes,1=no"]
+ if defined $s->[6];
Gimp->install_procedure(@$s);
}
};
@@ -288,7 +289,7 @@ sub register($$$$$$$$$;@) {
if $function =~ y/-//;
Gimp::register_callback $function => sub {
- $run_mode = shift; # global!
+ $run_mode = defined($menupath) ? shift : undef; # global!
my(@pre,@defaults,@lastvals);
Gimp::ignore_functions(@Gimp::GUI_FUNCTIONS)
@@ -321,7 +322,9 @@ sub register($$$$$$$$$;@) {
}
}
warn "perlsub: rm=$run_mode" if $Gimp::verbose >= 2;
- if ($run_mode == Gimp::RUN_INTERACTIVE
+ if ($run_mode == Gimp::RUN_NONINTERACTIVE or not defined $run_mode) {
+ # nop
+ } elsif ($run_mode == Gimp::RUN_INTERACTIVE
|| $run_mode == Gimp::RUN_WITH_LAST_VALS) {
my $fudata = $Gimp::Data{"$function/_fu_data"};
if ($fudata) {
@@ -348,8 +351,6 @@ sub register($$$$$$$$$;@) {
unshift @$params, @hide;
}
}
- } elsif ($run_mode == Gimp::RUN_NONINTERACTIVE) {
- # nop
} else {
die __"run_mode must be INTERACTIVE, NONINTERACTIVE or RUN_WITH_LAST_VALS\n";
}
diff --git a/Net/Net.pm b/Net/Net.pm
index 65f4953..5d62f25 100644
--- a/Net/Net.pm
+++ b/Net/Net.pm
@@ -239,10 +239,9 @@ $use_tcp = 1; # tcp is enabled only when authorization is available
my $unix_path;
my $max_pkt = 1024*1024*8;
-my $run_mode;
sub slog {
- return if $run_mode == &Gimp::RUN_NONINTERACTIVE;
+ return if $Gimp::Extension::run_mode == &Gimp::RUN_NONINTERACTIVE;
print localtime.": $$-slog(",@_,")\n";
}
@@ -363,9 +362,9 @@ sub setup_listen_tcp {
}
sub perl_server_run {
- ($run_mode, my $filehandle, $Gimp::verbose) = @_;
+ (my $filehandle, $Gimp::verbose) = @_;
warn "$$-".__PACKAGE__."::perl_server_run(@_)\n" if $Gimp::verbose;
- if ($run_mode == &Gimp::RUN_NONINTERACTIVE) {
+ if ($Gimp::Extension::run_mode == &Gimp::RUN_NONINTERACTIVE) {
die __"unable to open Gimp::Net communications socket: $!\n"
unless open my $fh,"+<&$filehandle";
$fh->autoflush;
diff --git a/examples/Perl-Server b/examples/Perl-Server
index 724862d..b822779 100755
--- a/examples/Perl-Server
+++ b/examples/Perl-Server
@@ -39,7 +39,6 @@ option), thereby eliminating any network-related security risk.
=head1 PARAMETERS
- [&Gimp::PDB_INT32, "run_mode", "Interactive:0=yes,1=no"],
[&Gimp::PDB_INT32, "filehandle", "Batch file-handle"],
[&Gimp::PDB_INT32, "verbose", "Gimp verbose var"],
diff --git a/t/extension.t b/t/extension.t
index 6643866..3bddfad 100644
--- a/t/extension.t
+++ b/t/extension.t
@@ -3,7 +3,7 @@ use Test::More;
our ($dir, $DEBUG);
my $tpf_name;
BEGIN {
-# $Gimp::verbose = 1;
+# $Gimp::verbose = 3;
$DEBUG = 0;
require 't/gimpsetup.pl';
use Config;
@@ -36,7 +36,6 @@ Description.
=head1 PARAMETERS
- [&Gimp::PDB_INT32, "run_mode", "Interactive:0=yes,1=no"],
[&Gimp::PDB_INT32, "num", "internal flags (must be 0)"],
=head1 RETURN VALUES
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]