From a39bf381a4e02f59e7560328b08aba0bc9ca17e5 Mon Sep 17 00:00:00 2001 From: Marc Lehmann Date: Sun, 8 Nov 1998 21:04:20 +0000 Subject: [PATCH] see plug-ins/perl/Changes --- plug-ins/perl/TODO | 3 ++- plug-ins/perl/examples/PDB | 52 +++++++++++++++++++++++++++++++------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/plug-ins/perl/TODO b/plug-ins/perl/TODO index e5c7ae496a..4a5dc81dd2 100644 --- a/plug-ins/perl/TODO +++ b/plug-ins/perl/TODO @@ -19,9 +19,10 @@ bugs important issues + * gimp_blend && 15 doesn't work * gradient button * implement Perl-Server RSET and shared lock(!) - * Gimp::lock && unlock +[DONE] * Gimp::lock && unlock [DONE] * do not special-case INT32 in convert_sv2gimp * substr 4th argument form for Net:: -> require 5.005!!!! DO IT! * use Gimp qw(GIMP_HOST=jfjf)??? diff --git a/plug-ins/perl/examples/PDB b/plug-ins/perl/examples/PDB index ec510f9a47..500b5e80bd 100755 --- a/plug-ins/perl/examples/PDB +++ b/plug-ins/perl/examples/PDB @@ -17,6 +17,7 @@ my $rlist; # the results list my $inputline; # the input entry my $result; # the result entry my $synopsis; # the synopsis label +my $statusbar; # the statusbar my $idle; # the idle function id @@ -105,13 +106,13 @@ sub complete_function { my @matches = sort grep /$name/i,@function; if(@matches>70) { set_clist map(($_,$_),@matches[0..69]); - $synopsis->set("showing only the first 70 matches (of ".scalar@matches.")"); + $synopsis->set(1,"showing only the first 70 matches (of ".scalar@matches.")"); } elsif(@matches>1) { set_clist map(($_,$_),@matches); - $synopsis->set(scalar@matches." matching functions"); + $ssynopsis->set(1,scalar@matches." matching functions"); } else { set_clist @matches,@matches; - $synopsis->set($matches[0]); + $synopsis->set($matches[0]." (press F1 to complete)"); } } @@ -121,11 +122,11 @@ sub complete_type { if($type==PARAM_IMAGE) { set_clist(map(("$$_: ".$_->get_filename,$$_),Gimp->list_images)); } elsif($type==PARAM_LAYER) { - set_clist(map { my $i = $_; map(("$$i: ".$i->get_filename."/".$_->get_name,$$_),$i->get_layers)} Gimp->list_images); + set_clist(map { my $i = $_; map(("$$_: ".$i->get_filename."/".$_->get_name,$$_),$i->get_layers)} Gimp->list_images); } elsif($type==PARAM_CHANNEL) { - set_clist(map { my $i = $_; map(("$$i: ".$i->get_filename."/".$_->get_name,$$_),$i->get_channels)} Gimp->list_images); + set_clist(map { my $i = $_; map(("$$_: ".$i->get_filename."/".$_->get_name,$$_),$i->get_channels)} Gimp->list_images); } elsif($type==PARAM_DRAWABLE) { - set_clist(map { my $i = $_; map(("$$i: ".$i->get_filename."/".$_->get_name,$$_),($i->get_layers,$i->get_channels))} Gimp->list_images); + set_clist(map { my $i = $_; map(("$$_: ".$i->get_filename."/".$_->get_name,$$_),($i->get_layers,$i->get_channels))} Gimp->list_images); } elsif ($type==PARAM_INT32) { if ($name eq "run_mode") { set_clist("RUN_NONINTERACTIVE","RUN_NONINTERACTIVE", @@ -154,6 +155,7 @@ sub update_completion { return unless $idx ne $last_arg; $last_arg=$idx; + $statusbar->set_percentage($idx/@args) if @args; set_current_function $words[0]; @@ -190,6 +192,18 @@ sub do_completion { undef $last_arg; } +sub execute_command { + my($idx,$pos,$fun,@args)=get_words; + $res=eval { Gimp->$fun(@args) }; + if ($@) { + $result->set_text($@); + Gtk::Gdk->beep; + } else { + $result->set_text($res); + $rlist->prepend_items(new Gtk::ListItem $res); + } +} + sub idle { Gtk->idle_remove($idle) if $idle; undef $idle; @@ -202,6 +216,7 @@ sub do_idle { sub inputline { my $e = new Gtk::Entry; + $e->set_text("gimp_blend 0,2,3,6,6,100,10,1,1,1,0,10,20,30,40"); $e->signal_connect("changed",sub { return if $block_changed; undef $last_arg; @@ -222,6 +237,7 @@ sub inputline { (); } }); + $e->signal_connect("activate",\&execute_command); $e->set_usize(300,0); $inputline=$e; @@ -258,6 +274,7 @@ sub create_main { $window = $w; $w->set_title('PDB Browser - the early alpha version'); + $w->signal_connect("destroy",sub {main_quit Gtk}); $b = new Gtk::Button "Close"; $w->action_area->add($b); @@ -271,7 +288,7 @@ sub create_main { $synopsis = new Gtk::Label ""; $synopsis->set_justify(-left); - my $table = new Gtk::Table 3,3,0; + my $table = new Gtk::Table 3,4,0; $w->vbox->add($table); my $cs = new Gtk::ScrolledWindow undef,undef; @@ -287,14 +304,20 @@ sub create_main { $result->set_editable(0); $result->set_usize(200,0); +# $statusbar = new Gtk::Statusbar; + $statusbar = new Gtk::ProgressBar; + $table->attach(new Gtk::Label("Synopsis") ,0,1,0,1,{},{},0,0); - $table->attach($synopsis ,1,3,0,1,{},{},0,0); + $table->attach($synopsis ,1,2,0,1,{},{},0,0); +# $table->attach(new Gtk::Pixmap(logo $w),2,3,0,1,{},{},0,0); $table->attach(new Gtk::Label("Command") ,0,1,1,2,{},{},0,0); $table->attach($inputline,1,2,1,2,['expand','fill'],{},0,0); $table->attach($result,2,3,1,2,['expand','fill'],{},0,0); $table->attach(new Gtk::Label("Shortcuts"),0,1,2,3,{},{},0,0); $table->attach($cs ,1,2,2,3,['expand','fill'],['expand','fill'],0,0); $table->attach($rs,2,3,2,3,['expand','fill'],['expand','fill'],0,0); + $table->attach(new Gtk::Label("Status"),0,1,3,4,{},{},0,0); + $table->attach($statusbar,1,3,3,4,['expand','fill'],['expand','fill'],0,0); idle; @@ -322,7 +345,18 @@ register "extension_pdb_browser", init Gtk; exit main; - +sub logo { + my $pm = new Gtk::Gdk::Pixmap->create_from_data($window, + 0, #%logo-width% + 0, #%logo-height% + 3, + #%PM:logo% + #%PM% + ); + + #%BM:logo% + #%BM% +}