
Notes for developers of this package.


Disambiguation

The gimpfu module is only a part of PyGimp.
Other parts are the gimpui, etc. modules (I am not sure of the list).
This is about gimpfu module.
The gimpfu module imports some of the other modules.
It might be that gimpfu can be ported (for many usecases)
without porting the other modules.


Requirements

Ideally this package would do everything documented by:

The user's guide for PyGimp:
https://www.gimp.org/docs/python/pygimp.html

The v2 code:
see the Gimp repository say for v2.10
in the plug-ins/pygimp directory



Other Requirements

v2 allowed "tdrawable.width" i.e.
v3 requires author change to tdrawable.width()
i.e. incoming args are Gimp types, and properties of those are not accessible using property syntax of Python

v2 allowed passing ints where Gimp procedure expected float
v3 requires author to float(arg)
We could fix that when marshalling args via introspection of procedure args spec param_specs


Obsoleted

tiles and pixel_rgn
pixel_rgn => gegl buffer anyway





New features

Tell v2 authors they should not use gettext.install




Strategy

v2 used static binding to Gimp (binding written in C)
v3 uses dynamic binding with GI (GObject Introspection)



Decorator pattern

Makes heavy use of "dynamic decorator pattern".
See https://python-patterns.guide/gang-of-four/decorator-pattern/


Guide to source files

gimpfu_gimp
gimpfu_pdb

Provide the aliases "gimp" and "pdb" which GimpFu has always promised,
more or less to Gimp and Gimp.pdb

adapters.image
adapters.layer
etc.

Wrappers which provide additional convenience methods provided by GimpFu v2.
They adapt Gimp.Image, Gimp.Layer, etc.


gimpfu_types  private Python types to GimpFu

In v2 these were inside gimpfu.py, or non-existant types


gimpfu_maps   supports PF_ constants
gimpfu_widgets supports auto generation of GUI for a plugin

In v2 these were inside gimpfu.py


gimpfu_enums  provided Gimp enums to s

In v2 a C language module gimpenumsmodule.c


Other

Some functionality of v2 has migrated to Gimp:
  "defaults" aka "persistent settings" now in Gimp as procedure_config
  Thus gimpshelf module is obsolete.
  gimpshelf module might still be necessary if any plugin in the wild used it
  for off-label(?) uses e.g. persisting other plugin private data

Some modules of v2 might be little used and thus not ported immediately:
Whether ported depends on use in the wild ????
   gimpthumb     thumbnail i.e. previews???
   gimpcolor, gimpui     ????



Misc snippets off the internet, pertinent to hoops GimpFu must jump through

mail list "pdb.gimp_get_item_by_id(), or ids and layers and layer groups"

In Python, a "layer" is a reference to a data structure (in C terminology, a pointer to a struct).
One of the fields is the layer's ID number.
The PDB only deals with these ID numbers, and PyGimp doesn't provide a direct way to handle IDs.


Frequent Bugs

If you omit to adapt a property of a GimpFu class (say Layer.mask_bounds)
then it engenders TypeError.
The attribute resolves to a type funcInfo object on Gimp.Layer,
while GimpFu expects it to have a more ordinary type, such as tuple or int.
