From ca41c2609aa71bc21158ea0b4448bd0e754e4f63 Mon Sep 17 00:00:00 2001 From: Marc Lehmann Date: Wed, 3 Mar 1999 15:14:45 +0000 Subject: [PATCH] see plug-ins/perl/Changes --- plug-ins/perl/Changes | 2 ++ plug-ins/perl/Gimp/Fu.pm | 39 +++++++++++++++++++++++++++++++++------ plug-ins/perl/Gimp/UI.pm | 18 +++++++++--------- plug-ins/perl/Makefile.PL | 2 +- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/plug-ins/perl/Changes b/plug-ins/perl/Changes index 6b6e5a12a0..a18b373273 100644 --- a/plug-ins/perl/Changes +++ b/plug-ins/perl/Changes @@ -13,6 +13,8 @@ Revision history for Gimp-Perl extension. collisions. CGI-scripts should use either tcp or specify the path directly using GIMP_HOST (see Gimp::Net for details). - use _much_ saner defaults for the Scale types in Gimp::Fu. + - Gimp::Fu's optionmenus didn't work in net()-mode. + - implemented PF_CUSTOM (untested). 1.055 Mon Feb 22 22:38:44 CET 1999 - applied seth's script changes. diff --git a/plug-ins/perl/Gimp/Fu.pm b/plug-ins/perl/Gimp/Fu.pm index d06b30d480..06296f8189 100644 --- a/plug-ins/perl/Gimp/Fu.pm +++ b/plug-ins/perl/Gimp/Fu.pm @@ -80,6 +80,7 @@ sub PF_BRUSH () { PARAM_END+6 }; sub PF_PATTERN () { PARAM_END+7 }; sub PF_GRADIENT () { PARAM_END+8 }; sub PF_RADIO () { PARAM_END+9 }; +sub PF_CUSTOM () { PARAM_END+10 }; sub PF_BOOL () { PF_TOGGLE }; sub PF_INT () { PF_INT32 }; @@ -103,6 +104,7 @@ sub Gimp::RUN_FULLINTERACTIVE (){ Gimp::RUN_INTERACTIVE+100 }; # you don't want &PF_SPINNER => 'integer', &PF_ADJUSTMENT => 'integer', &PF_RADIO => 'string', + &PF_CUSTOM => 'string', &PF_IMAGE => 'NYI', &PF_LAYER => 'NYI', &PF_CHANNEL => 'NYI', @@ -113,7 +115,7 @@ sub Gimp::RUN_FULLINTERACTIVE (){ Gimp::RUN_INTERACTIVE+100 }; # you don't want PF_STRING PF_COLOR PF_COLOUR PF_TOGGLE PF_IMAGE PF_DRAWABLE PF_FONT PF_LAYER PF_CHANNEL PF_BOOL PF_SLIDER PF_INT PF_SPINNER PF_ADJUSTMENT - PF_BRUSH PF_PATTERN PF_GRADIENT PF_RADIO); + PF_BRUSH PF_PATTERN PF_GRADIENT PF_RADIO PF_CUSTOM); @EXPORT = (qw(register main),@_params); @EXPORT_OK = qw(interact $run_mode save_image); @@ -313,7 +315,7 @@ sub interact($$$@) { my $res; $a=new Gtk::HBox (0,5); my $b=new Gtk::OptionMenu; - $b->set_menu(new Gimp::UI::ImageMenu(sub {1},-1,$res)); + $b->set_menu(new Gimp::UI::ImageMenu(sub {1},-1,\$res)); $a->pack_start ($b,1,1,0); push(@setvals,sub{}); push(@getvals,sub{$res}); @@ -328,21 +330,21 @@ sub interact($$$@) { } elsif($type == PF_LAYER) { my $res; $a=new Gtk::OptionMenu; - $a->set_menu(new Gimp::UI::LayerMenu(sub {1},-1,$res)); + $a->set_menu(new Gimp::UI::LayerMenu(sub {1},-1,\$res)); push(@setvals,sub{}); push(@getvals,sub{$res}); } elsif($type == PF_CHANNEL) { my $res; $a=new Gtk::OptionMenu; - $a->set_menu(new Gimp::UI::ChannelMenu(sub {1},-1,$res)); + $a->set_menu(new Gimp::UI::ChannelMenu(sub {1},-1,\$res)); push(@setvals,sub{}); push(@getvals,sub{$res}); } elsif($type == PF_DRAWABLE) { - my $res; + my $res=13; $a=new Gtk::OptionMenu; - $a->set_menu(new Gimp::UI::DrawableMenu(sub {1},-1,$res)); + $a->set_menu(new Gimp::UI::DrawableMenu(sub {1},-1,\$res)); push(@setvals,sub{}); push(@getvals,sub{$res}); @@ -373,6 +375,11 @@ sub interact($$$@) { push(@getvals,sub{$a->get('active')}); } + } elsif($type == PF_CUSTOM) { + $a=$extra->[0]; + push(@setvals,$extra->[1]); + push(@getvals,$extra->[2]); + } else { $label="Unsupported argumenttype $type"; push(@setvals,sub{}); @@ -472,6 +479,7 @@ sub string2pf($$) { || $type==PF_FONT || $type==PF_PATTERN || $type==PF_BRUSH + || $type==PF_CUSTOM || $type==PF_RADIO # for now! #d# || $type==PF_GRADIENT) { $s; @@ -588,6 +596,7 @@ sub query { $_->[0]=PARAM_STRING if $_->[0] == PF_BRUSH; $_->[0]=PARAM_STRING if $_->[0] == PF_PATTERN; $_->[0]=PARAM_STRING if $_->[0] == PF_GRADIENT; + $_->[0]=PARAM_STRING if $_->[0] == PF_CUSTOM; $_; } @$params], $results); @@ -762,6 +771,24 @@ In older Gimp-Versions a user-supplied string is returned. Lets the user select a brush/pattern/gradient whose name is returned as a string. The default brush/pattern/gradient-name can be preset. +=item PF_CUSTOM + +PF_CUSTOM is for those of you requiring some non-standard-widget. Just supply an array reference +with three elements as extra argument: + + [widget, settor, gettor] + +C is Gtk widget that should be used. + +C is a function that takes a single argument, the new value for +the widget (the widget should be updated accordingly). + +C is a function that should return the current value of the widget. + +While the values can be of any type (as long as it fits into a scalar), +you should be prepared to get a string when the script is started from the +commandline. + =back =cut diff --git a/plug-ins/perl/Gimp/UI.pm b/plug-ins/perl/Gimp/UI.pm index ea37d9ae80..751c5e5464 100644 --- a/plug-ins/perl/Gimp/UI.pm +++ b/plug-ins/perl/Gimp/UI.pm @@ -23,10 +23,10 @@ reimplement all of it in perl. =over 4 - $option_menu = new Gimp::UI::ImageMenu; - $option_menu = new Gimp::UI::LayerMenu; - $option_menu = new Gimp::UI::ChannelMenu; - $option_menu = new Gimp::UI::DrawableMenu; + $option_menu = new Gimp::UI::ImageMenu + $option_menu = new Gimp::UI::LayerMenu + $option_menu = new Gimp::UI::ChannelMenu + $option_menu = new Gimp::UI::DrawableMenu (constraint_func, active_element, \var); $button = new Gimp::UI::PatternSelect; $button = new Gimp::UI::BrushSelect; @@ -67,24 +67,24 @@ sub Gimp::UI::DrawableMenu::_items { } sub new($$$$) { - my($class,$constraint,$active)=@_; + my($class,$constraint,$active,$var)=@_; my(@items)=$class->_items; my $menu = new Gtk::Menu; for(@items) { my($constraints,$result,$name)=@$_; next unless $constraint->(@{$constraints}); my $item = new Gtk::MenuItem $name; - $item->show; - $item->signal_connect(activate => sub { $_[3]=$result }); + $item->signal_connect(activate => sub { $$var=$result }); $menu->append($item); } if (@items) { - $_[3]=$items[0]->[1]; + $$var=$items[0]->[1]; } else { my $item = new Gtk::MenuItem "(none)"; - $item->show; $menu->append($item); + $$var=undef; } + $menu->show_all; $menu; } diff --git a/plug-ins/perl/Makefile.PL b/plug-ins/perl/Makefile.PL index afa9996c06..7f94c5c86d 100644 --- a/plug-ins/perl/Makefile.PL +++ b/plug-ins/perl/Makefile.PL @@ -1,4 +1,4 @@ -require 5.004_04; +require 5.004; use ExtUtils::MakeMaker; use Config;