[gimp-perl] Add code param to UI::interact
- From: Ed J <edj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Add code param to UI::interact
- Date: Thu, 20 Nov 2014 02:20:19 +0000 (UTC)
commit e6c3d14524d0c809f23232dd13b4e89684dd3391
Author: Ed J <edj src gnome org>
Date: Thu Nov 20 02:20:09 2014 +0000
Add code param to UI::interact
Gimp/Fu.pm | 8 ++++++--
TODO | 1 -
UI/UI.pm | 14 ++++++++++----
3 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/Gimp/Fu.pm b/Gimp/Fu.pm
index f99342b..cd5caef 100644
--- a/Gimp/Fu.pm
+++ b/Gimp/Fu.pm
@@ -230,7 +230,9 @@ Gimp::on_net {
push @$params, [
PF_FILE, 'gimp_fu_outputfile', 'Output file', $latest_imagefile
] unless $outputfile;
- (my $res,@args)=interact($function,$blurb,$help,$params,$menupath,@args);
+ (my $res,@args)=interact(
+ $function, $blurb, $help, $params, $menupath, undef, @args
+ );
return unless $res;
$outputfile = pop @args unless $outputfile;
}
@@ -352,7 +354,9 @@ sub make_ui_closure {
my @hide = splice @$params, 0, scalar @pre;
my $res;
- ($res,@_)=interact($function,$blurb,$help,$params,$menupath,@$fudata);
+ ($res,@_) = interact(
+ $function, $blurb, $help, $params, $menupath, undef, @$fudata
+ );
return (undef) x @$results unless $res;
unshift @$params, @hide;
diff --git a/TODO b/TODO
index 8202b3a..218a5d8 100644
--- a/TODO
+++ b/TODO
@@ -5,7 +5,6 @@ Items as of 2014-06-30 (by Ed J)
- issue with removing menus, probably stored in _plug_in data
PDB call added in tools/pdbgen/pdb/gimp.pdb
* Progress bar in UI:
- - adding $code to Gimp::UI::interact so the interact can run the code itself;
- adding a Gimp::UI::ProgressBar;
- allowing the UI to keep updating itself while the code runs - probably
with a Gimp::proc_hook, registered when interact starts and $code is
diff --git a/UI/UI.pm b/UI/UI.pm
index 37f8c94..45bf38b 100644
--- a/UI/UI.pm
+++ b/UI/UI.pm
@@ -621,7 +621,7 @@ my %PF2INFO = (
sub interact {
warn __PACKAGE__ . "::interact(@_)" if $Gimp::verbose >= 2;
- my ($function, $blurb, $help, $params, $menupath) = splice @_, 0, 5;
+ my ($function, $blurb, $help, $params, $menupath, $code) = splice @_, 0, 6;
my (@getvals, @setvals, @lastvals, @defaults);
my $helpwin;
@@ -689,6 +689,7 @@ sub interact {
$button->signal_connect(clicked => sub {
$mainloop->quit;
});
+ my @uservals;
can_default $button 1;
$button = $w->add_button('gtk-ok', 1);
$button->signal_connect(clicked => sub {
@@ -709,10 +710,10 @@ sub interact {
show_all $w;
$mainloop->run;
die $exception_text if $exception_text;
- my @retvals = map {&$_} @getvals if $res;
+ @uservals = map {&$_} @getvals if $res;
$w->destroy;
return unless $res;
- return (1, @retvals);
+ return (1, @uservals);
}
1;
@@ -742,10 +743,15 @@ C<examples/example-no-fu>.
$button = new Gimp::UI::BrushSelect;
$button = new Gimp::UI::GradientSelect;
+ # if $code = undef, just run the UI and return the Ok/Cancel and values
($result, @new_vals) = Gimp::UI::interact(
- $functionname, $blurb, $help, $params, $menupath, @previous_vals
+ $functionname, $blurb, $help, $params, $menupath, undef, @previous_vals
); # $result = true if "Ok", false if "Cancel"
+ @return_vals = Gimp::UI::interact(
+ $functionname, $blurb, $help, $params, $menupath, \&code, @previous_vals
+ );
+
=back
=head1 AUTHOR
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]