I don’t understand why these procedures are in the PDB because it’s a much more complicated/contrived way to call things compared to the GI API (I use the PDB only for plugins).
However the API doc is mostly done from a C user’s perspective so, in the description:
gboolean
gimp_drawable_get_offsets (
GimpDrawable* drawable,
gint* offset_x,
gint* offset_y
)
… the trained eye notices that the gint*
are really pointers (*
) to integers (gint
), so the caller is passing the address of where it wants the results so these are likely outputs[1]. Fortunately the Python API derived from this restores some sanity, so you can just do (because a layer is a drawable):
>>> result=layer.get_offset().
Note that I said “some” sanity because the result now includes both the offsets and the True/False success indicator, so it is packaged as some kind of on-the-fly namedtuple
where the first element has no name:
>>> layer.get_offsets()
(True, offset_x=-23, offset_y=68)
So academically you do:
offsets=layer.get_offsets()
if offsets[0]:
# then you can use offsets.offset_x and offsets.offset_y
But you can unpack the result directly, and even ignore the True/False in most cases (if what you passed is a drawable, it has offsets, and if that wasn’t a drawable I hope you have a try/except
block around that code):
>>> _,offsetX,offsetY=layer.get_offsets()
[1] but of course you also have a GimpDrawable*
and it is an input. But in C arguments can only be native types (int/float/pointer) so you cannot pass a full object as an argument, only a pointer to it. So yes it’s ambiguous for object types, but then common sense can also apply. You will also note that you are not calling a gimp_drawable_get_offsets()
function but a Gimp.Drawable::get_offsets()
method.