diff --git a/plug-ins/perl/Changes b/plug-ins/perl/Changes index 8f14e38ceb..cfa6972679 100644 --- a/plug-ins/perl/Changes +++ b/plug-ins/perl/Changes @@ -1,5 +1,7 @@ Revision history for Gimp-Perl extension. + - updated perlotine. + 1.096 Thu Jul 8 21:36:36 CEST 1999 - fix around PDL-2.002 exporting its own ppport.h. - new scripts examples/frame_reshuffle and examples/frame_filter. diff --git a/plug-ins/perl/Gimp.pm b/plug-ins/perl/Gimp.pm index 744aa7d982..344a6e2a64 100644 --- a/plug-ins/perl/Gimp.pm +++ b/plug-ins/perl/Gimp.pm @@ -13,7 +13,7 @@ use subs qw(init end lock unlock canonicalize_color); require DynaLoader; @ISA=qw(DynaLoader); -$VERSION = 1.096; +$VERSION = 1.097; @_param = qw( PARAM_BOUNDARY PARAM_CHANNEL PARAM_COLOR PARAM_DISPLAY PARAM_DRAWABLE diff --git a/plug-ins/perl/Gimp/Fu.pm b/plug-ins/perl/Gimp/Fu.pm index fb9c4fde6e..5c59d97987 100644 --- a/plug-ins/perl/Gimp/Fu.pm +++ b/plug-ins/perl/Gimp/Fu.pm @@ -246,6 +246,9 @@ sub interact($$$$@) { for(;;) { my $t = new Gtk::Tooltips; my $w = new Gtk::Dialog; + my $accel = new Gtk::AccelGroup; + + $accel->attach($w); set_title $w $Gimp::function; @@ -466,19 +469,83 @@ sub interact($$$$@) { $f->cancel_button->signal_connect (clicked => sub { $f->hide }); } elsif($type == PF_TEXT) { - $a = new Gtk::HBox 0,5; + $a = new Gtk::Frame; + my $h = new Gtk::VBox 0,5; + $a->add($h); my $e = new Gtk::Text; - $a->add ($e); - $e->set_editable (1); + my %e; + %e = $$extra if ref $extra eq "HASH"; - push @setvals, sub { + my $sv = sub { + my $t = shift, $e->delete_text(0,-1); - $e->insert_text($_[0],0); + $e->insert_text($t,0); }; - push @getvals, sub { + my $gv = sub { $e->get_chars(0,-1); }; + $h->add ($e); + $e->set_editable (1); + + my $buttons = new Gtk::HBox 1,5; + $h->add($buttons); + + my $load = new Gtk::Button "Load"; $buttons->add($load); + my $save = new Gtk::Button "Save"; $buttons->add($save); + my $edit = new Gtk::Button "Edit"; $buttons->add($edit); + + $edit->signal_connect(clicked => sub { + my $editor = $ENV{EDITOR} || "vi"; + my $tmp = Gimp->temp_name("txt"); + open TMP,">$tmp" or die "FATAL: unable to create $tmp: $!\n"; print TMP &$gv; close TMP; + system ('xterm','-T',"$editor: $name",'-e',$editor,$tmp); + if (open TMP,"<$tmp") { + local $/; &$sv(scalar); close TMP; + } else { + Gimp->message("unable to read temporary file $tmp: $!"); + } + }); + + my $filename = ($e{prefix} || eval { Gimp->directory } || ".") . "/"; + + my $f = new Gtk::FileSelection "FilexSelector for $name"; + $f->set_filename($filename); + $f->cancel_button->signal_connect (clicked => sub { $f->hide }); + my $lf =sub { + $f->hide; + my $fn = $f->get_filename; + if(open TMP,"<$fn") { + local $/; &$sv(scalar); + close TMP; + } else { + Gimp->message("unable to read '$fn': $!"); + } + }; + my $sf =sub { + $f->hide; + my $fn = $f->get_filename; + if(open TMP,">$fn") { + print TMP &$gv; + close TMP; + } else { + Gimp->message("unable to create '$fn': $!"); + } + }; + $load->signal_connect (clicked => sub { + $f->set_title("Load $name"); + $f->ok_button->signal_connect (clicked => $lf); + $f->show_all; + }); + $save->signal_connect (clicked => sub { + $f->set_title("Save $name"); + $f->ok_button->signal_connect (clicked => $sf); + $f->show_all; + }); + + push @setvals,$sv; + push @getvals,$gv; + } else { $label="Unsupported argumenttype $type"; push(@setvals,sub{}); @@ -531,11 +598,13 @@ sub interact($$$$@) { $w->action_area->pack_start($button,1,1,0); can_default $button 1; grab_default $button; + add $accel 0xFF0D, [], [], $button, "clicked"; $button = new Gtk::Button "Cancel"; signal_connect $button "clicked", sub {hide $w; main_quit Gtk}; $w->action_area->pack_start($button,1,1,0); can_default $button 1; + add $accel 0xFF1B, [], [], $button, "clicked"; $res=0; diff --git a/plug-ins/perl/Gimp/Lib.xs b/plug-ins/perl/Gimp/Lib.xs index c8cf289470..041eb8e665 100644 --- a/plug-ins/perl/Gimp/Lib.xs +++ b/plug-ins/perl/Gimp/Lib.xs @@ -1722,9 +1722,25 @@ gimp_color_cube() } -gchar * +char * +gimp_directory() + +char * +gimp_data_directory() + +char * gimp_gtkrc() +SV * +gimp_personal_rc_file(basename) + char * basename + CODE: + basename = gimp_personal_rc_file (basename); + RETVAL = sv_2mortal (newSVpv (basename, 0)); + g_free (basename); + OUTPUT: + RETVAL + guint gimp_tile_width() diff --git a/plug-ins/perl/examples/frame_filter b/plug-ins/perl/examples/frame_filter index 91d5413bdf..3a1af8b037 100755 --- a/plug-ins/perl/examples/frame_filter +++ b/plug-ins/perl/examples/frame_filter @@ -25,6 +25,7 @@ register "layer_apply", my @layers = $image->get_layers; $n = @layers; + $n or die "at least one layer is required\n"; my $func = eval "sub{\n#line 0 \"expression\"\n$function\n}"; die "syntax error in expression '$function': $@\n" if $@; @@ -35,8 +36,8 @@ register "layer_apply", for my $index (0..$n-1) { $i = $index; $I = $n-$i-1; - $p = $i/$#layers; - $P = $I/$#layers; + $p = @layers > 1 ? $i/$#layers : 0; + $P = 1-$p; $d = $layers[$i]; eval { &$func }; @@ -102,7 +103,7 @@ animation onto the corresponding frame in the current animation and using DARKEN_MODE to combine the frames. You might want to use other modes or maybe C<$f->set_opacity(50)> for your animation. - $d2=$d2->image; + $i2=$d2->image; $l2=($i2->get_layers)[$i]; $i2->selection_all; diff --git a/plug-ins/perl/examples/perlotine b/plug-ins/perl/examples/perlotine index efa4b88691..c3670bef18 100755 --- a/plug-ins/perl/examples/perlotine +++ b/plug-ins/perl/examples/perlotine @@ -15,7 +15,7 @@ sub get_vguides { # get back an ordered set of vertical guides $i=0; my @vguides; while ($i=$img->find_next_guide($i)) { - if (!$img->get_guide_orientation($i)){ + if ($img->get_guide_orientation($i) == &Gimp::VERTICAL_GUIDE){ $keyval = sprintf("%4d", $img->get_guide_position($i)); $vkeys{$keyval} = $i; } @@ -32,7 +32,7 @@ sub get_hguides { # get back an ordered set of horizontal guides $i=0; my @hguides; while ($i=$img->find_next_guide($i)) { - if ($img->get_guide_orientation($i)){ + if ($img->get_guide_orientation($i) == &Gimp::HORIZONTAL_GUIDE){ $keyval = sprintf("%4d", $img->get_guide_position($i)); $hkeys{$keyval} = $i; }