see plug-ins/perl/Changes

This commit is contained in:
Marc Lehmann 1998-12-19 02:53:19 +00:00
parent 7808a83ea0
commit b442819a52
9 changed files with 165 additions and 69 deletions

View File

@ -1,5 +1,13 @@
Revision history for Gimp-Perl extension.
1.05 Fri Dec 18 22:05:25 CET 1998
- some 5.006 compatibility fixes
- disabled some functionality for poor gtk-1.0 which
is borken to no end
- fixed PARASITE_PERSISTENT typoe
- new functions: gimp_{major,minor,micro}_version
- PF_BRUSH, PATTERN and GRADIENT widgets are "emulated" in gimp-1.0
1.049 Mon Nov 23 20:54:41 CET 1998
- updated configure to require 1.0.2
- added some more scripts to the dist

View File

@ -12,7 +12,7 @@ use base qw(DynaLoader);
require DynaLoader;
$VERSION = 1.049;
$VERSION = 1.05;
@_param = qw(
PARAM_BOUNDARY PARAM_CHANNEL PARAM_COLOR PARAM_DISPLAY PARAM_DRAWABLE

View File

@ -192,7 +192,7 @@ BOOT:
#endif
#if GIMP_PARASITE
newCONSTSUB(stash,"PARAM_PARASITE",newSViv(PARAM_PARASITE));
newCONSTSUB(stash,"PARASITE_PERSISTANT",newSViv(PARASITE_PERSISTANT));
newCONSTSUB(stash,"PARASITE_PERSISTENT",newSViv(PARASITE_PERSISTENT));
#endif
newCONSTSUB(stash,"ALL_HUES", newSViv(0));
newCONSTSUB(stash,"RED_HUES", newSViv(1));

View File

@ -159,16 +159,18 @@ sub interact($$$@) {
my($help)=shift;
my(@types)=@{shift()};
my(@getvals,@setvals,@lastvals,@defaults);
my($w,$t,$button,$box,$bot,$g);
my($button,$box,$bot,$g);
my $res=0;
my $gimp_10 = Gimp->major_version==1 && Gimp->minor_version==0;
init Gtk;
parse Gtk::Rc Gimp->gtkrc;
for(;;) {
$t = new Gtk::Tooltips;
$w = new Gtk::Dialog;
my $t = new Gtk::Tooltips;
my $w = new Gtk::Dialog;
set_title $w $0;
my $h = new Gtk::HBox 0,2;
@ -187,6 +189,14 @@ sub interact($$$@) {
my($type,$name,$desc,$default,$extra)=@$_;
my($value)=shift;
local *new_PF_STRING = sub {
$a=new Gtk::Entry;
set_usize $a 0,25;
push(@setvals,sub{set_text $a defined $_[0] ? $_[0] : ""});
#select_region $a 0,1;
push(@getvals,sub{get_text $a});
};
if($type == PF_ADJUSTMENT) { # support for scm2perl
my(@x)=@$default;
$default=shift @x;
@ -202,11 +212,7 @@ sub interact($$$@) {
|| $type == PF_INT32 # into the scalar
|| $type == PF_FLOAT # domain.
|| $type == PF_STRING) { # I love it
$a=new Gtk::Entry;
set_usize $a 0,25;
push(@setvals,sub{set_text $a defined $_[0] ? $_[0] : ""});
#select_region $a 0,1;
push(@getvals,sub{get_text $a});
&new_PF_STRING;
} elsif($type == PF_FONT) {
my $fs=new Gtk::FontSelectionDialog "Font Selection Dialog ($desc)";
@ -316,19 +322,31 @@ sub interact($$$@) {
push(@getvals,sub{$res});
} elsif($type == PF_PATTERN) {
$a=new Gimp::UI::PatternSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
push(@getvals,sub{$a->get('active')});
if ($gimp_10) {
&new_PF_STRING;
} else {
$a=new Gimp::UI::PatternSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
push(@getvals,sub{$a->get('active')});
}
} elsif($type == PF_BRUSH) {
$a=new Gimp::UI::BrushSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
push(@getvals,sub{$a->get('active')});
if ($gimp_10) {
&new_PF_STRING;
} else {
$a=new Gimp::UI::BrushSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
push(@getvals,sub{$a->get('active')});
}
} elsif($type == PF_GRADIENT) {
$a=new Gimp::UI::GradientSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
push(@getvals,sub{$a->get('active')});
if ($gimp_10) {
&new_PF_STRING;
} else {
$a=new Gimp::UI::GradientSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
push(@getvals,sub{$a->get('active')});
}
} else {
$label="Unsupported argumenttype $type";
@ -401,7 +419,7 @@ sub interact($$$@) {
show_all $w;
main Gtk;
$w->destroy;
#$w->destroy; # buggy in gtk-1.1 (?)
return undef if $res == 0;
@_ = map {&$_} @getvals;
@ -932,6 +950,14 @@ EOF
};
sub logo {
if ($Gimp::UI::gtk_10) {
new Gtk::Label "Gimp-Perl";
} else {
&logo_xpm;
}
}
sub logo_xpm {
new Gtk::Pixmap(Gtk::Gdk::Pixmap->create_from_xpm_d($_[0]->window,$_[0]->style->black,
#%XPM:logo%
'79 33 25 1', ' c None', '. c #020204', '+ c #848484', '@ c #444444',

View File

@ -8,6 +8,11 @@
#include <libgimp/gimpui.h>
#endif
#if GIMP_MAJOR_VERSION>1 || (GIMP_MAJOR_VERSION==1 && GIMP_MINOR_VERSION>=1)
#define GIMP11 1
#define GIMP_PARASITE 1
#endif
/* FIXME */
/* sys/param.h is redefining these! */
#undef MIN
@ -25,21 +30,17 @@
# define ERRSV perl_get_sv("@",FALSE)
#endif
/* And also for newer perls... */
#ifndef na
# define na PL_na
#ifndef dTHR
#define dTHR
#endif
/* FIXME */
/* dirty is used in gimp.h. */
/* dirty is used in gimp.h AND in perl < 5.005 or with PERL_POLLUTE. */
#ifdef dirty
#undef dirty
#endif
#include "extradefs.h"
#if GIMP_MAJOR_VERSION>1 || (GIMP_MAJOR_VERSION==1 && GIMP_MINOR_VERSION>=1)
#define GIMP11 1
#define GIMP_PARASITE 1
#endif
#define GIMP_PKG "Gimp::" /* the package name */
#define PKG_COLOR GIMP_PKG "Color"
@ -133,11 +134,14 @@ GTile *old_tile (SV *sv)
GPixelRgn *old_pixelrgn (SV *sv)
{
dTHR;
STRLEN dc;
if (!sv_derived_from (sv, PKG_PIXELRGN))
croak ("argument is not of type " PKG_PIXELRGN);
/* the next line lacks any type of checking. */
return (GPixelRgn *)SvPV(*(hv_fetch ((HV*)SvRV(sv), "_rgn", 4, 0)),na);
return (GPixelRgn *)SvPV(*(hv_fetch ((HV*)SvRV(sv), "_rgn", 4, 0)), dc);
}
/* tracing stuff. */
@ -307,10 +311,10 @@ dump_params (int nparams, GParam *args, GParamDef *params)
gint32 found = 0;
trace_printf ("[%s, ", args[i].data.d_parasite.name);
if (args[i].data.d_parasite.flags & PARASITE_PERSISTANT)
if (args[i].data.d_parasite.flags & PARASITE_PERSISTENT)
{
trace_printf ("PARASITE_PERSISTANT");
found |= PARASITE_PERSISTANT;
trace_printf ("PARASITE_PERSISTENT");
found |= PARASITE_PERSISTENT;
}
if (args[i].data.d_parasite.flags & ~found)
@ -342,6 +346,8 @@ dump_params (int nparams, GParam *args, GParamDef *params)
static int
convert_array2paramdef (AV *av, GParamDef **res)
{
dTHR;
STRLEN dc;
int count = 0;
GParamDef *def = 0;
@ -382,8 +388,8 @@ convert_array2paramdef (AV *av, GParamDef **res)
}
def->type = SvIV (type);
def->name = name ? SvPV (name, na) : 0;
def->description = help ? SvPV (help, na) : 0;
def->name = name ? SvPV (name, dc) : 0;
def->description = help ? SvPV (help, dc) : 0;
def++;
}
else
@ -596,7 +602,7 @@ push_gimp_sv (GParam *arg, int array_as_ref)
PUTBACK;
}
#define SvPv(sv) SvPV((sv), na)
#define SvPv(sv) SvPV((sv), dc)
#define Sv32(sv) unbless ((sv), PKG_ANY, croak_str)
#define av2gimp(arg,sv,datatype,type,svxv) { \
@ -628,6 +634,9 @@ push_gimp_sv (GParam *arg, int array_as_ref)
static int
convert_sv2gimp (char *croak_str, GParam *arg, SV *sv)
{
dTHR;
STRLEN dc;
switch (arg->type)
{
case PARAM_INT32: arg->data.d_int32 = sv2gimp_extract_noref (SvIV, "INT32");
@ -765,6 +774,7 @@ static void pii_run(char *name, int nparams, GParam *param, int *xnreturn_vals,
static int nreturn_vals;
dSP;
STRLEN dc;
int i, count;
GParamDef *return_defs;
char *err_msg = 0;
@ -828,7 +838,7 @@ static void pii_run(char *name, int nparams, GParam *param, int *xnreturn_vals,
}
if (SvTRUE (ERRSV))
err_msg = g_strdup (SvPV (ERRSV, na));
err_msg = g_strdup (SvPV (ERRSV, dc));
else
{
int i;
@ -954,6 +964,7 @@ int
gimp_main(...)
PREINIT:
CODE:
STRLEN dc;
SV *sv;
if ((sv = perl_get_sv ("Gimp::help", FALSE)) && SvTRUE (sv))
@ -967,11 +978,11 @@ gimp_main(...)
{
AV *av = perl_get_av ("ARGV", FALSE);
argv [argc++] = SvPV (perl_get_sv ("0", FALSE), na);
argv [argc++] = SvPV (perl_get_sv ("0", FALSE), dc);
if (av && av_len (av) < 10-1)
{
while (argc-1 <= av_len (av))
argv [argc] = SvPV (*av_fetch (av, argc-1, 0), na),
argv [argc] = SvPV (*av_fetch (av, argc-1, 0), dc),
argc++;
}
else
@ -987,6 +998,27 @@ gimp_main(...)
PROTOTYPES: ENABLE
int
gimp_major_version()
CODE:
RETVAL = gimp_major_version;
OUTPUT:
RETVAL
int
gimp_minor_version()
CODE:
RETVAL = gimp_minor_version;
OUTPUT:
RETVAL
int
gimp_micro_version()
CODE:
RETVAL = gimp_micro_version;
OUTPUT:
RETVAL
# checks wether a gimp procedure exists
int
_gimp_procedure_available(proc_name)
@ -1239,19 +1271,20 @@ gimp_set_data(id, data)
{
STRLEN dlen;
STRLEN len;
STRLEN dc;
void *dta;
dta = SvPV (data, dlen);
/* do not remove this comment */
#ifdef HAVE_GET_DATA_SIZE
gimp_set_data (SvPV (id, na), dta, dlen);
gimp_set_data (SvPV (id, dc), dta, dlen);
#else
{
char str[1024]; /* hack */
SvUPGRADE (id, SVt_PV);
len = SvCUR (id);
Copy (SvPV (id, na), str, len, char);
Copy (SvPV (id, dc), str, len, char);
str[len+1] = 0;
str[len] = 'S'; gimp_set_data (str, &dlen, sizeof (STRLEN));
str[len] = 'C'; gimp_set_data (str, dta, dlen);
@ -1267,22 +1300,23 @@ gimp_get_data(id)
SV *data;
STRLEN dlen;
STRLEN len;
STRLEN dc;
/* do not remove this comment */
#ifdef HAVE_GET_DATA_SIZE
dlen = gimp_get_data_size (SvPV (id, na));
dlen = gimp_get_data_size (SvPV (id, dc));
/* I count on dlen being zero if "id" doesn't exist. */
data = newSVpv ("", 0);
gimp_get_data (SvPV (id, na), SvGROW (data, dlen+1));
gimp_get_data (SvPV (id, dc), SvGROW (data, dlen+1));
SvCUR_set (data, dlen);
*((char *)SvPV (data, na) + dlen) = 0;
*((char *)SvPV (data, dc) + dlen) = 0;
RETVAL = data;
#else
{
char str[1024]; /* hack */
SvUPGRADE (id, SVt_PV);
len = SvCUR (id);
Copy (SvPV (id, na), str, len, char);
Copy (SvPV (id, dc), str, len, char);
str[len+1] = 0;
dlen = (STRLEN) -1;
@ -1293,7 +1327,7 @@ gimp_get_data(id)
data = newSVpv ("", 0);
str[len] = 'C'; gimp_get_data (str, SvGROW (data, dlen+1));
SvCUR_set (data, dlen);
*((char *)SvPV (data, na) + dlen) = 0;
*((char *)SvPV (data, dc) + dlen) = 0;
RETVAL = data;
}
else
@ -1437,7 +1471,8 @@ gimp_pixel_rgn_init(gdrawable, x, y, width, height, dirty, shadow)
static HV *stash;
HV *hv = newHV ();
SV *sv = newSVn (sizeof(GPixelRgn));
GPixelRgn *pr = (GPixelRgn *)SvPV (sv,na);
STRLEN dc;
GPixelRgn *pr = (GPixelRgn *)SvPV (sv, dc);
gimp_pixel_rgn_init (pr, old_gdrawable (gdrawable), x, y, width, height, dirty, shadow);
@ -1487,8 +1522,10 @@ gimp_pixel_rgn_get_pixel(pr, x, y)
int x
int y
CODE:
STRLEN dc;
RETVAL = newSVn (pr->bpp);
gimp_pixel_rgn_get_pixel (pr, SvPV(RETVAL,na), x, y);
gimp_pixel_rgn_get_pixel (pr, SvPV(RETVAL, dc), x, y);
OUTPUT:
RETVAL
@ -1499,8 +1536,10 @@ gimp_pixel_rgn_get_row(pr, x, y, width)
int y
int width
CODE:
STRLEN dc;
RETVAL = newSVn (pr->bpp * width);
gimp_pixel_rgn_get_row (pr, SvPV(RETVAL,na), x, y, width);
gimp_pixel_rgn_get_row (pr, SvPV(RETVAL, dc), x, y, width);
OUTPUT:
RETVAL
@ -1511,8 +1550,10 @@ gimp_pixel_rgn_get_col(pr, x, y, height)
int y
int height
CODE:
STRLEN dc;
RETVAL = newSVn (pr->bpp * height);
gimp_pixel_rgn_get_col (pr, SvPV(RETVAL,na), x, y, height);
gimp_pixel_rgn_get_col (pr, SvPV(RETVAL, dc), x, y, height);
OUTPUT:
RETVAL
@ -1524,8 +1565,10 @@ gimp_pixel_rgn_get_rect(pr, x, y, width, height)
int width
int height
CODE:
STRLEN dc;
RETVAL = newSVn (pr->bpp * width * height);
gimp_pixel_rgn_get_rect (pr, SvPV(RETVAL,na), x, y, width, height);
gimp_pixel_rgn_get_rect (pr, SvPV(RETVAL, dc), x, y, width, height);
OUTPUT:
RETVAL
@ -1536,9 +1579,11 @@ gimp_pixel_rgn_set_pixel(pr, data, x, y)
int x
int y
CODE:
STRLEN dc;
if (SvCUR (data) != pr->bpp)
croak ("gimp_pixel_rgn_set_pixel called with incorrect datasize");
gimp_pixel_rgn_set_pixel (pr, SvPV(data,na), x, y);
gimp_pixel_rgn_set_pixel (pr, SvPV(data, dc), x, y);
void
gimp_pixel_rgn_set_row(pr, data, x, y)
@ -1547,9 +1592,11 @@ gimp_pixel_rgn_set_row(pr, data, x, y)
int x
int y
CODE:
STRLEN dc;
if (SvCUR (data) % pr->bpp)
croak ("gimp_pixel_rgn_set_row called with incorrect datasize");
gimp_pixel_rgn_set_row (pr, SvPV(data,na), x, y, SvCUR (data) / pr->bpp);
gimp_pixel_rgn_set_row (pr, SvPV(data, dc), x, y, SvCUR (data) / pr->bpp);
void
gimp_pixel_rgn_set_col(pr, data, x, y)
@ -1558,9 +1605,11 @@ gimp_pixel_rgn_set_col(pr, data, x, y)
int x
int y
CODE:
STRLEN dc;
if (SvCUR (data) % pr->bpp)
croak ("gimp_pixel_rgn_set_col called with incorrect datasize");
gimp_pixel_rgn_set_col (pr, SvPV(data,na), x, y, SvCUR (data) / pr->bpp);
gimp_pixel_rgn_set_col (pr, SvPV(data, dc), x, y, SvCUR (data) / pr->bpp);
void
gimp_pixel_rgn_set_rect(pr, data, x, y, width)
@ -1570,9 +1619,11 @@ gimp_pixel_rgn_set_rect(pr, data, x, y, width)
int y
int width
CODE:
STRLEN dc;
if (SvCUR (data) % (pr->bpp * width))
croak ("gimp_pixel_rgn_set_rect called with incorrect datasize");
gimp_pixel_rgn_set_rect (pr, SvPV(data,na), x, y, width, SvCUR (data) / (pr->bpp * width));
gimp_pixel_rgn_set_rect (pr, SvPV(data, dc), x, y, width, SvCUR (data) / (pr->bpp * width));
# ??? any possibility to implement these in perl? maybe replacement functions in Gimp.pm?
@ -1604,11 +1655,13 @@ set_data(tile, data)
GTile * tile
SV * data
CODE:
STRLEN dc;
if (SvCUR (data) != gimp_tile_width() * gimp_tile_height() * tile->bpp)
croak ("set_data called with incorrect datasize");
gimp_tile_ref_zero (tile);
memcpy (tile->data, SvPV (data, na), SvCUR (data));
memcpy (tile->data, SvPV (data, dc), SvCUR (data));
gimp_tile_unref (tile, 1);
BOOT:
@ -1623,12 +1676,13 @@ gimp_patterns_get_pattern_data(name)
SV * name
PPCODE:
{
STRLEN dc;
GParam *return_vals;
int nreturn_vals;
return_vals = gimp_run_procedure ("gimp_patterns_get_pattern_data",
&nreturn_vals,
PARAM_STRING, SvPV (name, na),
PARAM_STRING, SvPV (name, dc),
PARAM_END);
if (nreturn_vals == 7

View File

@ -4,6 +4,8 @@ use Carp;
use Gimp;
use Gtk;
$gtk_10 = Gtk->major_version==1 && Gtk->minor_version==0;
$VERSION = $Gimp::VERSION;
=head1 NAME
@ -85,7 +87,16 @@ package Gimp::UI::PreviewSelect;
use Gtk;
use base 'Gtk::Button';
register_type Gimp::UI::PreviewSelect;
# this is an utter HACK for the braindamanged gtk (NOT Gtk!)
sub register_types {
unless ($once) {
$once=1;
register_type Gimp::UI::PreviewSelect;
register_type Gimp::UI::PatternSelect;
register_type Gimp::UI::BrushSelect;
register_type Gimp::UI::GradientSelect;
}
}
sub GTK_CLASS_INIT {
my $class = shift;
@ -150,7 +161,7 @@ sub GTK_OBJECT_INIT {
$l->selection and
$self->set_preview($l->selection->children->get);
});
$s->add ($l);
$gtk_10 ? $s->add ($l) : $s->add_with_viewport ($l);
my $button = new Gtk::Button "OK";
signal_connect $button "clicked", sub {
@ -178,8 +189,6 @@ package Gimp::UI::PatternSelect;
use Gtk;
use base 'Gimp::UI::PreviewSelect';
register_type Gimp::UI::PatternSelect;
sub get_title { "Pattern Selection Dialog" }
sub get_list { Gimp->patterns_list }
@ -219,6 +228,7 @@ sub set_preview {
}
sub new {
Gimp::UI::PreviewSelect::register_types;
new Gtk::Widget @_;
}
@ -227,8 +237,6 @@ package Gimp::UI::BrushSelect;
use Gtk;
use base 'Gimp::UI::PreviewSelect';
register_type Gimp::UI::BrushSelect;
sub get_title { "Brush Selection Dialog" }
sub get_list { Gimp->brushes_list }
@ -263,6 +271,7 @@ sub set_preview {
}
sub new {
Gimp::UI::PreviewSelect::register_types;
new Gtk::Widget @_;
}
@ -271,8 +280,6 @@ package Gimp::UI::GradientSelect;
use Gtk;
use base 'Gimp::UI::PreviewSelect';
register_type Gimp::UI::GradientSelect;
sub get_title { "Gradient Selection Dialog" }
sub get_list { keys %gradients }
@ -288,6 +295,7 @@ sub set_preview {
}
sub new {
Gimp::UI::PreviewSelect::register_types;
unless (defined %gradients) {
undef @gradients{Gimp->gradients_get_list};
}

View File

@ -14,7 +14,7 @@ DOCUMENTATION
information can be found on the Gimp-perl homepage, where
you should get an overview over the Gimp-perl extension:
http://lehmann.home.ml.org/gimp.html
http://www.goof.com/pcg/marc/gimp.html
Dov Grobgeld has written a nice tutorial as well, you
can find it at:

View File

@ -26,7 +26,7 @@ important issues
* gimp->object_id, drawable_object_id remove!
* PF_CUSTOM
* gimp_display_image
* wamp up homepage
* vamp up homepage
* --ui and --noui for Gimp::Fu
* [PF_CUSTOM]
* Gimp::ping

View File

@ -35,7 +35,7 @@ register "webify",
$drawable->by_color_select($bg,$thresh,SELECTION_REPLACE,1,0,0,0);
$drawable->edit_cut if $img->selection_bounds;
}
Plugin->autocrop(RUN_NONINTERACTIVE,$img,$drawable) if $autocrop;
Plugin->autocrop($drawable) if $autocrop;
$img->convert_indexed (1, $colours) if $colours;
eval { $img->undo_group_end };