Commit 0dfbbfdf authored by Marc Lehmann's avatar Marc Lehmann

See Changes

parent 11710e1d
Revision history for Gimp-Perl extension.
- t/run.t does much less when no tests are requested
- cleaned up Gimp::UI learned much about Gtk (but still not much)
1.044 Sat Oct 24 03:54:47 CEST 1998
- allow PF_PATTERN etc. to be usable as commandline arguments
- added parasite support -> untested so far
......
......@@ -286,7 +286,7 @@ sub interact($$$@) {
# (my $c = new Gtk::Button "Load")->show;
# signal_connect $c "clicked", sub {$res = 2; main_quit Gtk};
# $g->attach($c,1,2,$res,$res+1,{},{},4,2);
## $g->attach($c,1,2,$res,$res+1,{},{},4,2);
# $a->pack_start ($c,1,1,0);
# set_tip $t $c,"Load an image into the Gimp (NYI)";
......@@ -392,7 +392,7 @@ sub interact($$$@) {
return undef if $res == 0;
@_ = map {&$_} @getvals;
return (1,@_) if $res == 1;
Gimp->file_load(&Gimp::RUN_NONINTERACTIVE,"","");
# Gimp->file_load(&Gimp::RUN_INTERACTIVE,"","");
}
}
......
......@@ -80,16 +80,15 @@ sub new($$$$) {
$menu;
}
package Gimp::UI::PatternSelect;
package Gimp::UI::PreviewSelect;
use Gtk;
@ISA='Gtk::Button';
register_type Gimp::UI::PatternSelect;
register_type Gimp::UI::PreviewSelect;
sub GTK_CLASS_INIT {
my $class = shift;
add_arg_type $class "active","GtkString",3;
}
......@@ -98,15 +97,16 @@ sub GTK_OBJECT_SET_ARG {
if ($arg eq "active") {
my $count;
$self->{set_dialog_preview}->($value);
$value=$self->{dialog_pattern};
$self->{label}->set($value);
$self->{list}->foreach(sub {
if ($_[0]->children->get eq $value) {
$self->{list}->select_item($count);
};
$count++;
});
if (!defined $self->{value} || $value ne $self->{value}) {
$self->{value}=$value=$self->set_preview($value);
$self->{label}->set($value);
$self->{list}->foreach(sub {
if ($_[0]->children->get eq $value) {
$self->{list}->select_item($count);
};
$count++;
});
}
}
}
......@@ -122,54 +122,33 @@ sub GTK_OBJECT_INIT {
$self->{label}=$label;
my $w = new Gtk::Dialog;
$w->set_title("Pattern Selection Dialog");
$w->set_title($self->get_title);
$w->set_usize(400,300);
(my $h=new Gtk::HBox 0,0)->show;
$w->vbox->pack_start($h,1,1,0);
my $cp=new Gtk::Preview "color";
my $gp=new Gtk::Preview "grayscale";
$self->{set_dialog_preview} = sub {
my ($name,$w,$h,$bpp,$mask)=Gimp->patterns_get_pattern_data ($_[0]);
unless (defined $name) {
$name=Gimp->patterns_get_pattern;
($name,$w,$h,$bpp,$mask)=Gimp->patterns_get_pattern_data ($name);
}
hide $cp;
hide $gp;
my $p = $bpp == 1 ? $gp : $cp;
show $p;
$p->size ($w, $h);
while(--$h) {
$p->draw_row (substr ($mask, $w*$bpp*$h), 0, $h, $w);
}
$p->draw(undef);
$self->{dialog_pattern}=$name;
};
(my $preview = $self->new_preview)->show;
(my $s=new Gtk::ScrolledWindow undef,undef)->show;
$s->set_policy(-automatic, -automatic);
$s->set_usize(200,300);
$h->pack_start($s,1,1,0);
$h->pack_start($cp,1,1,0);
$h->pack_start($gp,1,1,0);
$h->pack_start($preview,1,1,0);
my $l=new Gtk::List;
$l->set_selection_mode(-single);
$l->set_selection_mode(-browse);
$self->{list}=$l;
for(Gimp->patterns_list) {
for($self->get_list) {
$l->add(new Gtk::ListItem $_);
}
$l->show_all;
$l->signal_connect("selection_changed",sub {
$l->selection and
$self->{set_dialog_preview}->($l->selection->children->get);
$self->set_preview($l->selection->children->get);
});
$s->add ($l);
......@@ -194,6 +173,51 @@ sub GTK_OBJECT_INIT {
$self->signal_connect("clicked",sub {show $w});
}
package Gimp::UI::PatternSelect;
use Gtk;
@ISA = 'Gimp::UI::PreviewSelect';
register_type Gimp::UI::PatternSelect;
sub get_title { "Pattern Selection Dialog" }
sub get_list { Gimp->patterns_list }
sub new_preview {
my $self = shift;
my $cp = $self->{"color_preview"}=new Gtk::Preview "color";
my $gp = $self->{"gray_preview"} =new Gtk::Preview "grayscale";
my $preview = new Gtk::HBox 0,0;
$preview->add($cp);
$preview->add($gp);
$preview;
}
sub set_preview {
my $self = shift;
my $value = shift;
my $cp = $self->{"color_preview"};
my $gp = $self->{"gray_preview"};
my ($name,$w,$h,$bpp,$mask)=Gimp->patterns_get_pattern_data ($value);
unless (defined $name) {
$name=Gimp->patterns_get_pattern;
($name,$w,$h,$bpp,$mask)=Gimp->patterns_get_pattern_data ($name);
}
hide $cp;
hide $gp;
my $p = $bpp == 1 ? $gp : $cp;
show $p;
$p->size ($w, $h);
while(--$h) {
$p->draw_row (substr ($mask, $w*$bpp*$h), 0, $h, $w);
}
$p->draw(undef);
$name;
}
sub new {
new Gtk::Widget @_;
}
......@@ -202,84 +226,39 @@ package Gimp::UI::BrushSelect;
use Gtk;
@ISA='Gtk::Button';
@ISA='Gimp::UI::PreviewSelect';
register_type Gimp::UI::BrushSelect;
sub GTK_CLASS_INIT {
my $class = shift;
add_arg_type $class "active","GtkString",3;
}
sub GTK_OBJECT_SET_ARG {
my($self,$arg,$id,$value) = @_;
if ($arg eq "active") {
$arg = Gimp->brushes_get_brush unless exists $self->{brushes}->{$arg};
$self->{label}->set($arg);
$self->{list}->select_item($self->{brushes}->{$arg});
}
}
sub get_title { "Brush Selection Dialog" }
sub get_list { Gimp->brushes_list }
sub GTK_OBJECT_GET_ARG {
my($self,$arg,$id) = @_;
$self->{label}->get;
sub new_preview {
my $self=shift;
$self->{"preview"}=new Gtk::Preview "grayscale";
}
sub GTK_OBJECT_INIT {
my $self=shift;
(my $label = new Gtk::Label "")->show;
$self->add($label);
$self->{label}=$label;
my $w = new Gtk::Dialog;
$w->set_title("Brush Selection Dialog");
$w->set_usize(400,300);
(my $h=new Gtk::HBox 0,0)->show;
(my $s=new Gtk::ScrolledWindow undef,undef)->show;
$s->set_policy(-automatic, -automatic);
$s->set_usize(200,300);
$w->vbox->pack_start($s,1,1,0);
sub set_preview {
my $self = shift;
my $value = shift;
my $l=new Gtk::List;
$l->set_selection_mode(-single);
$l->set_selection_mode(-browse);
$self->{list}=$l;
my $count=0;
my $p = $self->{"preview"};
for(Gimp->brushes_list) {
$l->add(new Gtk::ListItem $_);
$self->{brushes}->{$_}=$count++;
my ($name,$opacity,$spacing,$mode,$w,$h,$mask)=eval { Gimp->brushes_get_brush_data ($value) };
if ($@) {
$name=Gimp->brushes_get_brush;
($name,$opacity,$spacing,$mode,$w,$h,$mask)=Gimp->brushes_get_brush_data ($name);
}
$mask=pack("C*",@$mask);
hide $p;
my $l=length($mask);
$p->size ($w, $h);
while(--$h) {
$p->draw_row (substr ($mask, $w*$h), 0, $h, $w);
}
$p->draw(undef);
show $p;
my $dialog_selection;
$l->show_all;
$l->signal_connect("selection_changed",sub {
$dialog_selection = $l->selection->children->get
if $l->selection;
});
$s->add ($l);
my $button = new Gtk::Button "OK";
signal_connect $button "clicked", sub {
hide $w;
$label->set($dialog_selection)
if $l->selection;
};
$w->action_area->pack_start($button,1,1,0);
can_default $button 1;
grab_default $button;
show $button;
$button = new Gtk::Button "Cancel";
signal_connect $button "clicked", sub {hide $w};
$w->action_area->pack_start($button,1,1,0);
show $button;
$self->signal_connect("clicked",sub {show $w});
$name;
}
sub new {
......@@ -290,87 +269,27 @@ package Gimp::UI::GradientSelect;
use Gtk;
@ISA='Gtk::Button';
@ISA='Gimp::UI::PreviewSelect';
register_type Gimp::UI::GradientSelect;
sub GTK_CLASS_INIT {
my $class = shift;
add_arg_type $class "active","GtkString",3;
}
sub get_title { "Gradient Selection Dialog" }
sub get_list { keys %gradients }
sub GTK_OBJECT_SET_ARG {
my($self,$arg,$id,$value) = @_;
if ($arg eq "active") {
$arg = Gimp->gradients_get_active unless exists $self->{gradients}->{$arg};
$self->{label}->set($arg);
$self->{list}->select_item($self->{gradients}->{$arg});
}
sub new_preview {
my $self = shift;
new Gtk::Frame;
}
sub GTK_OBJECT_GET_ARG {
my($self,$arg,$id) = @_;
$self->{label}->get;
}
sub GTK_OBJECT_INIT {
my $self=shift;
(my $label = new Gtk::Label "")->show;
$self->add($label);
$self->{label}=$label;
my $w = new Gtk::Dialog;
$w->set_title("Gradient Selection Dialog");
$w->set_usize(400,300);
(my $h=new Gtk::HBox 0,0)->show;
(my $s=new Gtk::ScrolledWindow undef,undef)->show;
$s->set_policy(-automatic, -automatic);
$s->set_usize(200,300);
$w->vbox->pack_start($s,1,1,0);
my $l=new Gtk::List;
$l->set_selection_mode(-single);
$l->set_selection_mode(-browse);
$self->{list}=$l;
my $count=0;
for(Gimp->gradients_get_list) {
$l->add(new Gtk::ListItem $_);
$self->{gradients}->{$_}=$count++;
}
my $dialog_selection;
$l->show_all;
$l->signal_connect("selection_changed",sub {
$dialog_selection = $l->selection->children->get
if $l->selection;
});
$s->add ($l);
my $button = new Gtk::Button "OK";
signal_connect $button "clicked", sub {
hide $w;
$label->set($dialog_selection)
if $l->selection;
};
$w->action_area->pack_start($button,1,1,0);
can_default $button 1;
grab_default $button;
show $button;
$button = new Gtk::Button "Cancel";
signal_connect $button "clicked", sub {hide $w};
$w->action_area->pack_start($button,1,1,0);
show $button;
$self->signal_connect("clicked",sub {show $w});
sub set_preview {
my $self = shift;
my $value = shift;
exists $gradients{$value} ? $value : Gimp->gradients_get_active;
}
sub new {
unless (defined %gradients) {
undef @gradients{Gimp->gradients_get_list};
}
new Gtk::Widget @_;
}
......
......@@ -21,6 +21,7 @@ bugs
important issues
* brushes look inverted
* zero-copy PDL support
* gimp_init, gimp_deinit
* duplicate HAVE_VPRINTF in gimp
......@@ -28,8 +29,8 @@ important issues
[DONE] * put it into the cvs tree
* weighted movement in drawing tools
* -DMIN_PERL_DEFINE
* PF_PALETTE (maybe not)
* kill RUN_INTERACTIVE/run_mode-shit
[DONE] * PF_PALETTE (maybe not) <-- NOT
[DONE] * kill RUN_INTERACTIVE/run_mode-shit
* --function localfunc to select one of the registered scripts
* brush etc. buttons (maybe use gimp's interface, but
only when local(?))
......
......@@ -23,12 +23,11 @@ $dir=cwd."/test-dir";
do './config.pl';
ok(1);
ok (($plugins = `$GIMPTOOL -n --install-admin-bin /bin/sh`) =~ s{^.*\s(.*?)(?:/+bin/sh)\r?\n?$}{$1});
ok(-d $plugins);
ok(-x "$plugins/script-fu");
$n=!$EXTENSIVE_TESTS;
#$n=1; # disable intensive testing for the moment
skip($n,sub {($plugins = `$GIMPTOOL -n --install-admin-bin /bin/sh`) =~ s{^.*\s(.*?)(?:/+bin/sh)\r?\n?$}{$1}});
skip($n,sub {-d $plugins});
skip($n,sub {-x "$plugins/script-fu"});
use Gimp qw(:consts);
$loaded = 1;
......@@ -48,7 +47,7 @@ sub net {
system("rm","-rf",$dir); #d#FIXME
ok(sub {mkdir $dir,0700});
ok(sub {symlink "../Perl-Server","$dir/Perl-Server"});
ok(symlink "$plugins/script-fu","$dir/script-fu");
skip($n,sub {symlink "$plugins/script-fu","$dir/script-fu"});
ok (
open RC,">$dir/gimprc" and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment