[gimp-perl] If on_net and $interact and no $outputfile, ask.



commit 881f1a59908bd7f5661f971f341f16fd00b39a29
Author: Ed J <edj src gnome org>
Date:   Thu May 8 05:39:02 2014 +0100

    If on_net and $interact and no $outputfile, ask.

 Gimp/Fu.pm |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/Gimp/Fu.pm b/Gimp/Fu.pm
index 27a244f..db576b5 100644
--- a/Gimp/Fu.pm
+++ b/Gimp/Fu.pm
@@ -141,7 +141,7 @@ sub this_script {
    die __"function '$exe' not found in this script (must be one of ".join(", ",@names).")\n";
 }
 
-my $latest_image;
+my ($latest_image, $latest_imagefile);
 
 sub string2pf($$) {
    my ($s, $type, $name, $desc) = ($_[0], @{$_[1]});
@@ -167,6 +167,7 @@ sub string2pf($$) {
            unless $image->is_valid;
       } else {
         $image = Gimp->file_load(Gimp::RUN_NONINTERACTIVE, $s, $s),
+        $latest_imagefile = $s;
       }
       $latest_image = $image; # returned as well
    } elsif($type == PF_DRAWABLE) {
@@ -222,14 +223,18 @@ Gimp::on_net {
       die __"parameter '$entry->[1]' is not optional\n"
         unless defined $args[$i] or $interact>0;
    }
-   $interact = !!$interact;
+   $interact = $interact > 0;
    for my $i (0..$#args) {
       eval { $args[$i] = string2pf($args[$i], $params->[$i]); };
       die $@ if $@ and not $interact;
    }
    if ($interact) {
+      push @$params, [
+        PF_FILE, 'gimp_fu_outputfile', 'Output file', $latest_imagefile
+      ] unless $outputfile;
       (my $res,@args)=interact($function,$blurb,$help,$params,$menupath,@args);
       return unless $res;
+      $outputfile = pop @args unless $outputfile;
    }
    my $input_image = $args[0] if ref $args[0] eq "Gimp::Image";
    my @retvals = Gimp::callback(


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]