I'm experimenting with writing some GIMP Python plugins, and have a programming style question before getting too involved. I have had success getting a few plugins up and running. For example, I have written a plugin that dumps the contents of the pdb to an xml-file, and have written a C# "viewer" for it that duplicates GIMP's PDB Browser so I can peruse the pdb outside of GIMP. Python, however, is not my first language. I'm using GIMP 2.8 on Win7.
It seems to me that there are often two ways of doing the same task. For example, I can create a new vectors by using...
pdb.gimp_vectors_new( image, name )
or gimp.Vectors( image, name )
Another example - the foreground colour can be set using...
pdb.gimp_context_set_foreground( colour )
or gimp.set_foreground( colour )
Similarly, I can access an image's vectors using...
( num, ids ) = pdb.gimp_image_get_vectors( image )
or vectors = image.vectors
Here, however, it seems the ids (INT32s) returned by the pdb function need to be converted into the actual vectors objects, using gimp.Vectors.from_id( id ), since almost every pdb function dealing with vectors do not accept the INT32 id. It seems to make more sense to just use image.vectors.
While there is a gimp.Image, gimp.Layer, gimp.Vectors, etc., there does not seem to be gimp.Brush, gimp.Context, etc. Thus while some taks can be handled using GIMP objects, other tasks require the use of pdb.gimp_... functions.
So after all this rambling, my question is this:
Is it better coding practice to consistently use the pdb.gimp_... functions directly, or, where possible, use the GIMP objects like image.vectors (which would be my preference)?