[gimp-perl] Namespace pollution iff ':pollute'. Bug 726952



commit 8ea4ae20fdb09c59e25da860b8463ec0a4190155
Author: Ed J <m8r-35s8eo mailinator com>
Date:   Mon Mar 24 05:05:36 2014 +0000

    Namespace pollution iff ':pollute'. Bug 726952

 Gimp.pm                  |   98 ++++++++++++++++++++++++++++++----------------
 Gimp/OO.pod              |   59 +++++++++++++--------------
 examples/ditherize       |    4 +-
 examples/example-fu      |    4 +-
 examples/example-net     |    2 +-
 examples/example-oo      |    2 +-
 examples/gouge           |    4 +-
 examples/iland           |    4 +-
 examples/map_to_gradient |    4 +-
 examples/pixelmap        |    8 ++--
 examples/randomart1      |    2 +-
 examples/redeye          |    4 +-
 t/import.t               |   19 +++++++++
 t/run.t                  |    6 +-
 14 files changed, 134 insertions(+), 86 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index 8183681..992e293 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -184,6 +184,7 @@ use Carp qw(croak);
 my @_procs = ('main', '__', 'N_');
 #my @_default = (@_procs, ':consts' ,':_auto2');
 my @_default = (@_procs, ':consts');
+my @POLLUTE_CLASSES;
 
 # we really abuse the import facility..
 sub import($;@) {
@@ -213,6 +214,11 @@ sub import($;@) {
             #*{$AUTOLOAD} = sub { Gimp->$name(@_) }; # old version
             goto &$AUTOLOAD;
          };
+      } elsif ($_ eq ":pollute") {
+       for my $class (@POLLUTE_CLASSES) {
+         push @{"$class\::ISA"}, "Gimp::$class";
+         push @{"$class\::PREFIXES"}, @{"Gimp::$class\::PREFIXES"};
+       }
       } elsif ($_ eq ":consts") {
          push(@export,@_consts);
       } elsif ($_ eq ":param") {
@@ -272,8 +278,8 @@ sub wrap_text {
 $spawn_opts = "";
 
 # extra check for Gimp::Feature::import
-$in_query=0 unless defined $in_query;          # perl -w is SOOO braindamaged
-$in_top=$in_quit=$in_run=$in_net=$in_init=0;   # perl -w is braindamaged
+$in_query=0 unless defined $in_query;
+$in_top=$in_quit=$in_run=$in_net=$in_init=0;
 ($function)=$0=~/([^\/\\]+)$/;
 
 $verbose=0 unless defined $verbose;
@@ -530,25 +536,28 @@ sub _pseudoclass {
   my ($class, @prefixes)= @_;
   unshift(@prefixes,"");
   *{"Gimp::$class\::AUTOLOAD"} = \&AUTOLOAD;
-  push(@{"$class\::ISA"}               , "Gimp::$class");
   push(@{"Gimp::$class\::PREFIXES"}    , @prefixes); @prefixes= {"Gimp::$class\::PREFIXES"};
-  push(@{"$class\::PREFIXES"}          , @prefixes); @prefixes= {"$class\::PREFIXES"};
+  push @POLLUTE_CLASSES, $class;
 }
 
-_pseudoclass qw(Item           gimp_item_);
-_pseudoclass qw(Layer          gimp_layer_ gimp_drawable_ gimp_item_ gimp_floating_sel_ gimp_image_ gimp_ 
plug_in_ perl_fu_ gimp_drawable_);
-_pseudoclass qw(Image          gimp_image_ gimp_ plug_in_ perl_fu_);
-_pseudoclass qw(Drawable       gimp_drawable_ gimp_item_ gimp_channel_ gimp_image_ gimp_ plug_in_ perl_fu_);
+my @plugin_prefixes = qw(plug_in_ perl_fu_);
+my @image_prefixes = (qw(gimp_image_ gimp_), @plugin_prefixes);
+my @item_prefixes = (qw(gimp_item_), @image_prefixes);
+my @drawable_prefixes = (qw(gimp_drawable_), @item_prefixes);
+
+_pseudoclass qw(Item           ), @item_prefixes;
+_pseudoclass qw(Layer          gimp_layer_ gimp_floating_sel_), @drawable_prefixes;
+_pseudoclass qw(Image          ), @image_prefixes;
+_pseudoclass qw(Drawable       ), @drawable_prefixes;
 _pseudoclass qw(Selection      gimp_selection_);
 _pseudoclass qw(Vectors        gimp_vectors_);
-_pseudoclass qw(Channel                gimp_channel_ gimp_drawable_ gimp_item_ gimp_selection_ gimp_image_ 
gimp_ plug_in_ perl_fu_);
+_pseudoclass qw(Channel                gimp_channel_ gimp_selection_), @drawable_prefixes;
 _pseudoclass qw(Display                gimp_display_ gimp_);
-_pseudoclass qw(Plugin         plug_in_ perl_fu_);
+_pseudoclass qw(Plugin         ), @plugin_prefixes;
 _pseudoclass qw(Gradient       gimp_gradient_);
 _pseudoclass qw(Gradients      gimp_gradients_);
 _pseudoclass qw(Edit           gimp_edit_);
 _pseudoclass qw(Progress       gimp_progress_);
-_pseudoclass qw(Region         );
 _pseudoclass qw(GimpParasite   );
 
 push @Gimp::Drawable::ISA, qw(Gimp::Item);
@@ -612,7 +621,7 @@ Gimp - a Perl extension for writing Gimp Extensions/Plug-ins/Load &
 Save-Handlers
 
 This is a release of gimp-perl for gimp-2.8.  It is not compatible with
-version 2.6 or below of The Gimp.
+version 2.6 or below of GIMP.
 
 This is mostly a reference manual. For a quick intro, look at
 L<Gimp::Fu>. 
@@ -633,17 +642,35 @@ available to your plug-in.
 
 Import useful constants, like RGB, RUN_NONINTERACTIVE... as well as all
 libgimp and pdb functions automagically into the caller's namespace. 
-This will overwrite your AUTOLOAD function, if you have one.
+This will overwrite your AUTOLOAD function, if you have one. The AUTOLOAD
+function that gets installed must only be used in OO mode - either as
+an object or a class method call - the only exception is when the first
+argument is a reference (including objects):
+
+ use Gimp qw(:auto);
+ Gimp->displays_flush; # fine
+ my $name = $layer->get_name; # also fine
+ gimp_quit(0); # will lose its parameter, due to Perl's OO implementation!
+ Gimp->quit(0); # works correctly
+ gimp_image_undo_disable($image); # as does this, by a coincidence
 
 =item :param
 
-Import PARAM_* constants (PDB_INT32, PDB_STRING etc.) only.
+Import constants for plugin parameter types (PDB_INT32, PDB_STRING
+etc.) only.
 
 =item :consts
 
-All constants from gimpenums.h (BG_IMAGE_FILL, RUN_NONINTERACTIVE,
+All constants found by querying GIMP (BG_IMAGE_FILL, RUN_NONINTERACTIVE,
 NORMAL_MODE, PDB_INT32 etc.).
 
+=item :pollute
+
+In previous version of C<gimp-perl>, you could refer to GIMP classes
+as either e.g. Gimp::Image, OR Image. Now in order to not pollute the
+namespace, the second option will be available only when this option
+is specified.
+
 =item spawn_options=I<options>
 
 Set default spawn options to I<options>, see L<Gimp::Net>.
@@ -664,16 +691,16 @@ or specialized execution.  Lots of examples are in the C<examples/>
 directory of your gimp-perl source tree, or installed in your plug-ins
 directory if you are running from a package.
 
-Using the C<Xtns-E<gt>DB Browser> is a good way to learn The GIMP's
+Using the C<Help/Procedure Browser> is a good way to learn GIMP's
 Procedural Database(pdb).  For referencing functions you already know of,
-the included script gimpdoc is useful.
+the included script L<gimpdoc> is useful.
 
 =head1 DESCRIPTION
 
 Gimp-Perl is a module for writing plug-ins, extensions, standalone
 scripts, and file-handlers for The GNU Image Manipulation Program (The
 GIMP).  It can be used to automate repetitive tasks, achieve a precision
-hard to get through manual use of The GIMP, interface to a web server,
+hard to get through manual use of GIMP, interface to a web server,
 or other tasks that involve Gimp.
 
 It is developed on Linux, and should work with similar OSes.
@@ -683,7 +710,7 @@ Some highlights:
 =over 2
 
 =item *
-Access to The GIMP's Procedural Database (pdb) for manipulation of
+Access to GIMP's Procedural Database (pdb) for manipulation of
 most objects.
 
 =item *
@@ -695,7 +722,7 @@ Image(600,300,RGB)>
 Networked plug-ins look/behave the same as those running from within gimp.  
 
 =item *
-Gimp::Fu will start The GIMP for you, if it cannot connect to an existing
+Gimp::Fu will start GIMP for you, if it cannot connect to an existing
 GIMP process.
 
 =item *
@@ -710,8 +737,9 @@ Over 50 example scripts to give you a good starting point, or use as is.
 =head1 ARCHITECTURE
 
 There are two modes of operation: the perl is called by GIMP (as a
-plugin/filter), or GIMP is called by perl (which uses the Gimp::Net
-functionality).
+plugin/filter) ("plugin mode"), or GIMP is called by perl (which uses the
+Gimp::Net functionality) - either connecting to an existing GIMP process
+("net mode"), or starting its own one ("batch mode").
 
 =head2 Plugin
 
@@ -755,19 +783,19 @@ Before the call to C<Gimp::main>, I<no> other PDB function must be called.
 In a C<Gimp::Fu>-script, it will actually call C<Gimp::Fu::main> instead
 of C<Gimp::main>:
 
- exit main;            # Gimp::Fu::main is exported by default when using Gimp::Fu
+ exit main; # Gimp::Fu::main is exported by default when using Gimp::Fu
 
 This is similar to Gtk, Tk or similar modules, where you have to call the
 main eventloop. 
 
 Although you call C<exit> with the result of C<main>, the main function
-might not actually return. This depends on both the version of Gimp and
+might not actually return. This depends on both the version of GIMP and
 the version of the Gimp-Perl module that is in use.  Do not depend on
 C<main> to return at all, but still call C<exit> immediately.
 
 =head2 CALLBACKS
 
-The Gimp module provides routines to be optionally filled in by a
+The C<Gimp> module provides routines to be optionally filled in by a
 plug-in writer.  This does not apply if using C<Gimp::Fu>, as these are
 done automatically.
 
@@ -781,11 +809,12 @@ gimp_install_procedure.
 
 =item Gimp::on_net
 
-Run when called from a network interface (from the Perl-Server or from running it standalone).
+Run when called from a network interface (from the Perl-Server or from
+running it standalone).
 
 =item Gimp::on_lib
 
-Run only when called itneractively from within Gimp.
+Run only when called interactively from within Gimp.
 
 =item Gimp::on_run
 
@@ -800,15 +829,16 @@ B<PDB> (the Procedural DataBase), and functions from B<libgimp> (the
 C-language interface library).
 
 You can get a listing and description of every PDB function by starting
-the B<DB Browser> extension in the GIMP B<Xtns> menu (but remember to change 
+the B<DB Browser> extension in GIMP's B<Xtns> menu (but remember to change 
  "-" (dashes) to  "_" (underscores)).
 
 B<libgimp> functions can't be traced (and won't be traceable in the
 foreseeable future).
 
 To call pdb functions (or equivalent libgimp functions), just treat them like
-normal perl (this requires the use of the C<:auto> import tag, but see below
-for another possibility!):
+normal perl (this requires the use of the C<:auto> import tag - see
+the import C<:auto> note for non-OO limitation; see below for another
+possibility!):
 
  gimp_palette_set_foreground([20,5,7]);
  gimp_palette_set_background("cornsilk");
@@ -840,7 +870,7 @@ supported. Initializations can later be done in the init function.
 
 =item Gimp::gtk_init()
 
-Initialize Gtk in a similar way the Gimp itself did it. This automatically
+Initialize Gtk in a similar way GIMP itself did it. This automatically
 parses gimp's gtkrc and sets a variety of default settings (visual,
 colormap, gamma, shared memory...).
 
@@ -864,7 +894,7 @@ and the net callback. At the moment it only works for the Net interface
  use Gimp;
  
  Gimp::init;
- <do something with the gimp>
+ <do something with GIMP>
 
 The optional argument to init has the same format as the GIMP_HOST variable
 described in L<Gimp::Net>. Calling C<Gimp::end> is optional.  This is used
@@ -872,7 +902,7 @@ in the process of testing the module ('make test').
 
 =item Gimp::lock(), Gimp::unlock()
 
-These functions can be used to gain exclusive access to the Gimp. After
+These functions can be used to gain exclusive access to GIMP. After
 calling lock, all accesses by other clients will be blocked and executed
 after the call to unlock. Calls to lock and unlock can be nested.
 
@@ -896,7 +926,7 @@ usually only the case after gimp_main or gimp_init have been called.
 =item Gimp::register_callback(gimp_function_name, perl_function)
 
 Using this function you can overwrite the standard Gimp behaviour of
-calling a perl subroutine of the same name as the gimp function.
+calling a perl subroutine of the same name as the GIMP function.
 
 The first argument is the name of a registered gimp function that you want
 to overwrite ('perl_fu_make_something'), and the second argument can be
diff --git a/Gimp/OO.pod b/Gimp/OO.pod
index 7067788..7aedbe7 100644
--- a/Gimp/OO.pod
+++ b/Gimp/OO.pod
@@ -28,29 +28,27 @@ etc. Of course, your fingers will suffer from severe injuries as well.
 
 A solution to this situation is to use OO-syntax. Gimp plays some (very)
 dirty tricks and provides a number of classes, like C<Gimp::Image> and
-C<Gimp::Palette> that allow shorter identifiers to be used (all these appear
-with the C<Gimp::> prefix as well as without, i.e. C<Gimp::Palette> is the
-same class as C<Palette>).
+C<Gimp::Palette> that allow shorter identifiers to be used.
 
 If you call a method, C<Gimp> tries to find a gimp function by
 prepending a number of prefixes until it finds a valid function:
 
  $image = Gimp->image_new(...); # calls gimp_image_new(...)
- $image = Image->new(...);     # calls gimp_image_new as well
- $image = new Image(...);      # the same in green
- Palette->set_foreground(...)  # calls gimp_palette_set_foreground(..)
+ $image = Gimp::Image->new(...);       # calls gimp_image_new as well
+ $image = new Gimp::Image(...);        # the same in green
+ Gimp::Palette->set_foreground(...)    # calls gimp_palette_set_foreground(..)
 
 Return values from functions are automatically blessed (through
 The Magic Autobless feature ;) to their corresponding classes, i.e.
 
- $image = new Image(...);      # $image is now blessed to Gimp::Image
+ $image = new Gimp::Image(...);        # $image is now blessed to Gimp::Image
  $image->height;               # calls gimp_image_height($image)
  $image->flatten;              # likewise gimp_flatten($image)
  $image->histogram(...);       # calls gimp_histogram($image,...), since
                                # gimp_image_histogram does not exist
 
-The class argument (C<$image> in the above examples) is prepended to the
-argument list.
+The object argument (C<$image> in the above examples) is prepended to the
+argument list - this is how Perl does OO.
 
 Another shortcut: many functions want a (redundant) image argument, like
 
@@ -74,15 +72,15 @@ these three calls are equivalent:
 You can call all sorts of sensible and not-so-sensible functions,
 so this feature can be abused:
 
- patterns_list Image;          # will call gimp_patterns_list
- quit Plugin;                  # will quit the Gimp, not an Plugin.
+ patterns_list Gimp::Image;    # will call gimp_patterns_list
+ quit Gimp::Plugin;            # will quit the Gimp, not an Plugin.
 
 there is no image involved here whatsoever...
 
 =head1 AVAILABLE CLASSES
 
-The following classes (with and without Gimp::) are available. The prefixes
-that are checked are shown as well (the null prefix "" is implicit).
+The following classes are available. The prefixes that are checked are
+shown as well (the null prefix "" is implicit).
 
 =over 4
 
@@ -90,7 +88,7 @@ that are checked are shown as well (the null prefix "" is implicit).
 
  gimp_
 
-=item Layer
+=item Gimp::Layer
 
  gimp_layer_
  gimp_drawable_
@@ -100,7 +98,7 @@ that are checked are shown as well (the null prefix "" is implicit).
  plug_in_
  perl_fu_
 
-=item Image
+=item Gimp::Image
 
  gimp_image_
  gimp_drawable_
@@ -108,7 +106,7 @@ that are checked are shown as well (the null prefix "" is implicit).
  plug_in_
  perl_fu_
 
-=item Drawable
+=item Gimp::Drawable
 
  gimp_drawable_
  gimp_layer_
@@ -117,11 +115,11 @@ that are checked are shown as well (the null prefix "" is implicit).
  plug_in_
  perl_fu_
 
-=item Selection
+=item Gimp::Selection
 
  gimp_selection_
 
-=item Channel
+=item Gimp::Channel
 
  gimp_channel_
  gimp_drawable_
@@ -131,52 +129,53 @@ that are checked are shown as well (the null prefix "" is implicit).
  plug_in_
  perl_fu_
 
-=item Display
+=item Gimp::Display
 
  gimp_display_
  gimp_
 
-=item Palette
+=item Gimp::Palette
 
  gimp_palette_
 
-=item Plugin
+=item Gimp::Plugin
 
  plug_in_
+ perl_fu_
 
-=item Gradients
+=item Gimp::Gradients
 
  gimp_gradients_
 
-=item Edit
+=item Gimp::Edit
 
  gimp_edit_
 
-=item Progress
+=item Gimp::Progress
 
  gimp_progress_
 
-=item Region
+=item Gimp::Region
 
 (none except the implicit null prefix)
 
-=item Tile
+=item Gimp::Tile
 
  gimp_tile_
 
-=item PixelRgn
+=item Gimp::PixelRgn
 
  gimp_pixel_rgn_
 
-=item GDrawable
+=item Gimp::GimpDrawable
 
  gimp_gdrawable_
 
-=item Brushes
+=item Gimp::Brushes
 
  gimp_brushes_
 
-=item Patterns
+=item Gimp::Patterns
 
  gimp_patterns_
 
diff --git a/examples/ditherize b/examples/ditherize
index bc13fd0..9428dcb 100755
--- a/examples/ditherize
+++ b/examples/ditherize
@@ -55,9 +55,9 @@ register "plug_in_ditherize",
    $sel->selection_load;
    $sel->remove_channel;
 
-   my $copy = new Image($w, $h, $image->base_type);
+   my $copy = new Gimp::Image($w, $h, $image->base_type);
    $copy->undo_disable;
-   my $draw = new Layer($copy, $w, $h,
+   my $draw = new Gimp::Layer($copy, $w, $h,
                         $imagetype2layertype{$image->base_type},
                         "temporary layer", 100, NORMAL_MODE);
    $copy->add_layer ($draw, 1);
diff --git a/examples/example-fu b/examples/example-fu
index a4295e9..8651799 100755
--- a/examples/example-fu
+++ b/examples/example-fu
@@ -44,14 +44,14 @@ register "gimp_fu_example_script",                  # fill in a function name
    # store current context, so that present settings aren't affected
    Context->push();
 
-   my $img = new Image ($width, $height, RGB);
+   my $img = new Gimp::Image ($width, $height, RGB);
 
    # put an undo group around any modifications, so that
    # they can be undone in one step.
    $img->undo_group_start;
 
    # the __ before the string in the next line indicates text that must be translated
-   my $l = new Layer ($img, $width, $height, RGB, __"Background", 100, NORMAL_MODE);
+   my $l = new Gimp::Layer ($img, $width, $height, RGB, __"Background", 100, NORMAL_MODE);
    $l->add_layer(0);
 
    # now a few syntax examples
diff --git a/examples/example-net b/examples/example-net
index a7f5cdb..2dbd6e6 100755
--- a/examples/example-net
+++ b/examples/example-net
@@ -16,7 +16,7 @@ Gimp::on_net {
   # simple benchmark ;)
   $img=new Gimp::Image(600,300,RGB);
 
-# the is the same as $img = new Image(600,300,RGB)
+# the is the same as $img = new Gimp::Image(600,300,RGB)
   $bg=$img->layer_new(30,20,RGB_IMAGE,"Background",100,NORMAL_MODE);
 # you have to add a layer after you create it
   $bg->add_layer(1);
diff --git a/examples/example-oo b/examples/example-oo
index 751da9b..6b6362a 100755
--- a/examples/example-oo
+++ b/examples/example-oo
@@ -19,7 +19,7 @@ sub plug_in_example_oo {
   my $bg=new Layer($img,300,200,RGB_IMAGE,"Background",100,NORMAL_MODE);
 
 # instead of gimp_display_new($img);
-  new Display($img);
+  new Gimp::Display($img);
 
 # For any of Image, Drawable, Layer, Palette, Edit, Gradients, Patterns, 
 # Progress, Channel, Selection, Display, Plugin, you can use a syntax
diff --git a/examples/gouge b/examples/gouge
index 3f4eb23..c307433 100755
--- a/examples/gouge
+++ b/examples/gouge
@@ -20,8 +20,8 @@ sub iterate {
    $bounds[2]-- if $bounds[0]+$bounds[2] >= ($drawable->offsets)[0]+$drawable->width;
    $bounds[3]-- if $bounds[1]+$bounds[3] >= ($drawable->offsets)[1]+$drawable->height;
    {
-      my $src = new PixelRgn ($drawable,@bounds[0,1],$bounds[2]+1,$bounds[3]+1,0,0);
-      my $dst = new PixelRgn ($drawable,@bounds,1,1);
+      my $src = new Gimp::PixelRgn ($drawable,@bounds[0,1],$bounds[2]+1,$bounds[3]+1,0,0);
+      my $dst = new Gimp::PixelRgn ($drawable,@bounds,1,1);
 
       my $iter = Gimp->pixel_rgns_register ($dst);
       my $area = $bounds[2]*$bounds[3];
diff --git a/examples/iland b/examples/iland
index 472aecd..ecbdfe2 100755
--- a/examples/iland
+++ b/examples/iland
@@ -28,12 +28,12 @@ sub landscape {
        my $gdrawable=$drawable->get();
 
        #Pixel region of selection
-       my $src= new PixelRgn ($drawable, 0,0,$width, $height, 0, 0);
+       my $src= new Gimp::PixelRgn ($drawable, 0,0,$width, $height, 0, 0);
        my $newimage=gimp_image_new($src->w, $src->h, 0);
        $layer=gimp_layer_new($newimage,$src->w, $src->h, RGB_IMAGE, "L1", 100, NORMAL_MODE);
        gimp_image_add_layer($layer, -1);
        $newdrawable=gimp_image_active_drawable($newimage);
-       my $dest = new PixelRgn ($newdrawable, 0,0,$width, $height,1,1);
+       my $dest = new Gimp::PixelRgn ($newdrawable, 0,0,$width, $height,1,1);
        Gimp->progress_init("Rendering...");
        my $relord=$src->w/255;
        
diff --git a/examples/map_to_gradient b/examples/map_to_gradient
index 1864e06..4d163cb 100755
--- a/examples/map_to_gradient
+++ b/examples/map_to_gradient
@@ -44,8 +44,8 @@ register "map_to_gradient",
 
    my @bounds = $drawable->bounds;
    {
-      my $src = new PixelRgn ($drawable,@bounds,0,0);
-      my $dst = new PixelRgn ($drawable,@bounds,1,1);
+      my $src = new Gimp::PixelRgn ($drawable,@bounds,0,0);
+      my $dst = new Gimp::PixelRgn ($drawable,@bounds,1,1);
 
       my $iter = Gimp->pixel_rgns_register($src,$dst);
       my $area = $bounds[2]*$bounds[3];
diff --git a/examples/pixelmap b/examples/pixelmap
index 5b65f80..a32ee5d 100755
--- a/examples/pixelmap
+++ b/examples/pixelmap
@@ -29,8 +29,8 @@ sub pixelmap {                                        # es folgt das eigentliche Skript...
    {
       # $src and $dst must either be scoped or explicitly undef'ed
       # before merge_shadow.
-      my $src  = new PixelRgn $drawable->get,@_bounds,0,0;
-      my $_dst = new PixelRgn $drawable,@_bounds,1,1;
+      my $src  = new Gimp::PixelRgn $drawable->get,@_bounds,0,0;
+      my $_dst = new Gimp::PixelRgn $drawable,@_bounds,1,1;
 
       $_expr = eval $_expr; die "$@" if $@;
 
@@ -83,10 +83,10 @@ register "pixelgen",
          [PF_IMAGE],
          sub {
    my($w,$h,$type,$expr)= _;
-   my $image = new Image $w, $h, Gimp->layer2imagetype($type);
+   my $image = new Gimp::Image $w, $h, Gimp->layer2imagetype($type);
    my $layername = $expr;
    $layername =~ s/\n//g;
-   my $layer = new Layer $image, $w, $h, $type, $layername, 100, NORMAL_MODE;
+   my $layer = new Gimp::Layer $image, $w, $h, $type, $layername, 100, NORMAL_MODE;
    $image->add_layer($layer, 0);
    eval { pixelmap($image, $layer, $expr) };
    if ($@) {
diff --git a/examples/randomart1 b/examples/randomart1
index 68bfaa8..ae59c41 100755
--- a/examples/randomart1
+++ b/examples/randomart1
@@ -40,7 +40,7 @@ register "random_art_1",                      # Funktionsname
    Context->push();
 
    # Erzeuge ein neues Bild
-   my $image = new Image($w,$h,RGB);
+   my $image = new Gimp::Image($w,$h,RGB);
    $image->undo_disable;
 
    # Erzeuge die erste Ebene f�r das Bild
diff --git a/examples/redeye b/examples/redeye
index dcf1ee5..1c54ba9 100755
--- a/examples/redeye
+++ b/examples/redeye
@@ -25,8 +25,8 @@ sub dynamic_redeye
 
     my @bounds = $drawable->bounds;
 
-    my $src = new PixelRgn($drawable, @bounds, 0, 0);
-    my $dst = new PixelRgn($drawable, @bounds, 1, 1);
+    my $src = new Gimp::PixelRgn($drawable, @bounds, 0, 0);
+    my $dst = new Gimp::PixelRgn($drawable, @bounds, 1, 1);
 
     my $iter = Gimp->pixel_rgns_register($src, $dst);
     my $area = $bounds[2] * $bounds[3];
diff --git a/t/import.t b/t/import.t
new file mode 100644
index 0000000..6ff9680
--- /dev/null
+++ b/t/import.t
@@ -0,0 +1,19 @@
+use strict;
+use Test::More;
+#BEGIN { $Gimp::verbose = 1; }
+use Gimp qw(:auto);
+#Gimp::set_trace(TRACE_ALL);
+
+our $dir;
+our $DEBUG = 0;
+require 't/gimpsetup.pl';
+
+Gimp::init("spawn/");
+
+eval { Image->new(10,10,RGB); };
+ok($@, 'polluting version should fail');
+
+Gimp->import(':pollute');
+ok(Image->new(10,10,RGB), 'polluting version should now work');
+
+done_testing;
diff --git a/t/run.t b/t/run.t
index a427029..f5ab3a8 100644
--- a/t/run.t
+++ b/t/run.t
@@ -10,7 +10,7 @@ require 't/gimpsetup.pl';
 
 Gimp::init("spawn/");
 
-ok((my $i = new Image(10,10,RGB)), 'OO Syntax for new image');
+ok((my $i = new Gimp::Image(10,10,RGB)), 'OO Syntax for new image');
 ok(
   (my $l = $i->layer_new(10,10,RGBA_IMAGE,"new layer",100,VALUE_MODE)),
   'Different OO syntax for creating a layer',
@@ -26,8 +26,8 @@ ok(
   'paint without default value',
 );
 ok(
-  !Plugin->sharpen(RUN_NONINTERACTIVE,$i,$l,10),
-  'call external plugin through Plugin->, use explicit RUN_NONINTERACTIVE',
+  !Gimp::Plugin->sharpen(RUN_NONINTERACTIVE,$i,$l,10),
+  'call plugin through Gimp::Plugin->, use explicit RUN_NONINTERACTIVE',
 );
 ok(!$l->sharpen(10), 'call with maximum fu magic');
 ok(!Gimp->plug_in_sharpen($i,$l,10), 'call plugin using default');


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]