Commit Graph

2984 Commits

Author SHA1 Message Date
Jehan 86f588224b libgimp, libgimpbase: create special functions to get/set boxed array properties.
While the work on NULL-terminated array types make it much easier in C,
bindings don't have enough information to create native array/list types
in some generic functions such as g_object_get|set(), or else we just
don't know the right annotations to use for this to be possible. This is
report gobject-introspection#492.

So for the time being, we are creating dedicated functions for GeglColor
arrays and for other core object arrays (arrays of images, items, etc.).

E.g. in Python, while you can set a single GimpImage like this:

> config.set_property('image', image)

… you need to set a list of images like this:

> config.set_core_object_array('images', [image1, image2])
2024-10-28 22:08:45 +01:00
Jehan 8900967a81 extensions, libgimp, plug-ins: remove n_drawables arg from GimpImageProcedure's…
… run() function.

This is more consistent with recent changes in PDB, and now the
drawables argument is NULL-terminated.
2024-10-28 22:08:45 +01:00
Jehan ea5824ebd7 app, libgimp, pdb: fix other int sizes.
Avoid the stack smashing bug from yesterday in other functions.
Additionally to fixing other functions, do not cast the pointer to size
in the PDB generation scripts so that we can quickly spot such bugs in
the future, through compilation time warnings, instead of hiding them.
2024-10-28 22:08:45 +01:00
Jehan e02b8819e5 app, libgimp, pdb: fix “Stack smashing detected” crash.
Building with clang and various stack protection flags (as is done in
our flatpak apparently), we can trigger a crash when a gint on the stack
is set as a pointer to gsize.
Anyway now all array size must be gsize.

See: https://discourse.gnome.org/t/problem-with-select-polygon-in-gimp-2-99/24753
2024-10-28 02:03:57 +01:00
Jehan f490a8eb63 app, libgimp: fix crash when selecting a gradient from plug-in.
As reported by Anders in !1919. This is because
gimp_pdb_execute_procedure_by_name() now expects a proper GimpArray for
float and int arrays, not a C array preceded by a size value.
2024-10-25 23:31:42 +02:00
Jehan 48cb7e76d3 app, libgimp, pdb: add g_return*_if_fail() test for array size args.
Generated libgimp functions' arguments are normally tested through the
PDB, so that you get proper error messages when trying to call a
function with invalid arguments.
This is not true anymore for array arguments since the size argument is
not a PDB arg, only in the C function. Therefore I'm adding an
infrastructure asserting on invalid size, using the same PDB type
annotations as other args. It is important to assert valid input on
plug-in side (i.e. libgimp) so that the core doesn't make any assumption
on having received valid input when it has not.

Also changing size argument of gimppainttools PDB-generated functions to
proper gsize.
2024-10-25 23:31:06 +02:00
Jehan ac2bef4410 app, libgimp, pdb, plug-ins: array size's type should be gsize.
This changes the signature of generated functions in libgimp with array
arguments.
2024-10-25 23:28:42 +02:00
Jehan 3a2cbb4162 app, libgimp, pdb: array length are not PDB arguments anymore.
Yet they still are generated libgimp functions' arguments.

For instance gimp_context_get_line_dash_pattern() still has a num_dashes
integer argument and a dashes C array, but when calling the PDB
procedure "gimp-context-get-line-dash-pattern", we only set the
GimpArray.

This will allow simpler direct PDB calls too, included in script-fu,
where the size argument is really redundant.
2024-10-25 23:28:42 +02:00
Jehan 096c45599d app, libgimp*, pdb, plug-ins: float arrays don't need size arguments too. 2024-10-25 23:28:42 +02:00
Jehan 60eb27ab18 app, libgimp*, pdb, plug-ins: first step to make int32array PDB type aware of its length.
PDB code is now looking directly into the GimpArray length for
determining the data length.

Also adding a 'size' argument (number of elements, not bytes) to
gimp_value_(get|dup)_int32_array() to make it actually introspectable.
Until now, it was somehow introspected but was segfaulting on run.
I.e. that, e.g. in Python, calling Gimp.value_set_int32_array(v, [1, 2, 3])
followed by Gimp.value_get_int32_array(v) would actually make a
segmentation fault. Now the binding works flawlessly.

This will also make these functions much more usable in general.
2024-10-25 23:28:42 +02:00
Jehan 87d3d921da libgimp, pdb: improve free function information on array types.
Core object arrays must also be freed with g_free() (since elements are
not ref-ed).

Also color arrays must be freed with gimp_color_array_free().
2024-10-25 23:28:42 +02:00
Jehan 4137dce97b libgimp*: get rid of GimpObjectArray and GimpParamSpecObjectArray.
These have now been completely replace with the new GimpCoreObjectArray.
2024-10-25 23:28:42 +02:00
Jehan e1e2941d9e app, libgimp*, plug-ins: move all GimpObjectArray procedure args to GimpCoreObjectArray. 2024-10-25 23:28:42 +02:00
Jehan 08fd3a3f0d app, libgimp, pdb: imagearray PDB type as GimpCoreObjectArray. 2024-10-25 23:28:42 +02:00
Jehan 64f9c71ad5 app, libgimp, pdb: all resource (and subtype) array PDB types as GimpCoreObjectArray. 2024-10-25 23:28:42 +02:00
Jehan 59c040323c app, libgimp, pdb, plug-ins: patharray PDB type as GimpCoreObjectArray. 2024-10-25 23:28:42 +02:00
Jehan 255cda73c1 app, libgimp, pdb: channelarray PDB type as GimpCoreObjectArray. 2024-10-25 23:28:42 +02:00
Jehan d484b591d9 app, libgimp, pdb, plug-ins: layerarray PDB type is now a GimpCoreObjectArray. 2024-10-25 23:28:42 +02:00
Jehan 318f7451cd app, libgimp*, pdb, plug-ins: change itemarray PDB type to use GimpCoreObjectArray. 2024-10-25 23:28:42 +02:00
Jehan 38c2cd3b15 app, libgimp, pdb, plug-ins: new GimpCoreObjectArray type and drawablearray…
… PDB type.

This is a first step for #7369. Clearly our GimpObjectArray was meant to
be used with C arrays, hence the wrapper function
gimp_value_set_object_array() which was taking a C array and actually
creating and setting a GimpObjectArray.

This is why our new type is actually a C array aliased as a boxed type
and containing its own size (thanks to NULL-termination).

Eventually GimpCoreObjectArray is meant to replace GimpObjectArray.

The only issue is that such a type does not allow NULL as a valid
element in such an array, but fact is that I don't think we currently
have any use case where this matters. If ever such a case arise in the
future, we may introduce back GimpObjectArray.

In this first commit, I replaced all itemarray PDB types with a new
drawablearray using this new boxed type when relevant.
2024-10-25 23:28:42 +02:00
Massimo Valentini 542d2af2a5 pdb, libgimp: Add API to get/set Emulate Brush Dynamics
This patch adds a pdb getter/setter for GimpStrokeOptions'
emulate-brush-dynamics property. This allows users to change
the "Direction" of strokes via Script-fu/Python API calls.
2024-10-21 10:55:27 +00:00
Jehan f6edf596bf app, libgimp: move gimp_env_init() to a non-shipped header.
Since we consider it private, yet it's still needed in libgimp and app,
let's at least put it in a private header because there is no need for
people to try it out.

I'm also editing a bit the annotations for gimp_main() and GIMP_MAIN().
2024-10-17 16:11:15 +02:00
Jehan f75569c9dd Issue #12096: fix Windows build.
Commit 5b981adc7f was not taking into account that on Windows, the
gimp_resource_select_*() functions were made invisible and still needed
to be in the def file.

So this makes the 2 functions technically still exposed in the binary
even though the functions stay officially private (they are not in
header) and people are not supposed to use them directly in plug-ins.
2024-09-30 17:12:34 +02:00
Jehan 596ce11b5c libgimp, plug-ins: following up the renaming of GIMP_PDB_PROC_TYPE_EXTENSION…
… to GIMP_PDB_PROC_TYPE_PERSISTENT, let's rename some procedures.

s/gimp_plug_in_extension_enable/gimp_plug_in_persistent_enable/
s/gimp_plug_in_extension_process/gimp_plug_in_persistent_process/
s/gimp_procedure_extension_ready/gimp_procedure_persistent_ready/
2024-09-29 18:43:49 +02:00
Jehan a9bc4c6c1b gimp-ux#93: GIMP_PDB_PROC_TYPE_EXTENSION renamed GIMP_PDB_PROC_TYPE_PERSISTENT.
Even though it's not public yet (and won't really be for GIMP 3.0), I
created a new concept of "GIMP Extension" (.gex files) which bundles
various types of data for GIMP, such as plug-ins but also brushes and
other resources, themes, icons, etc.

Having 2 different concepts named the same is confusing, especially
since one of them is not really self-explaining IMO (why are "always-ON"
plug-ins called "extensions"?). So even though this is the older
concept, and since we are anyway massively breaking the API for GIMP
3.0, let's rename this older concept. "Persistent Plug-Ins" is much more
self-defining.
2024-09-29 18:08:40 +02:00
Jehan 3f3c576399 libgimp: make GimpZoomPreview a final type. 2024-09-29 12:27:50 +02:00
Jehan 84b4f48432 libgimp: fix .def file indentation. 2024-09-29 12:27:50 +02:00
Jehan 5b981adc7f libgimp: make gimp_resource_select_*() API private. 2024-09-29 12:27:50 +02:00
Jehan 81fcb71209 libgimp: set 2 functions to GimpResourceChooser as private. 2024-09-29 12:27:50 +02:00
Jehan eb07b7f8f8 libgimp: GimpProcBrowserDialog is a final type. 2024-09-29 12:27:50 +02:00
Jehan 16cfc9d681 libgimp: mark various private functions as G_GNUC_INTERNAL.
It may be more efficient this way on supported compilers.

Some of the private functions cannot be marked with this macro because
they are used across GIMP libraries (for instance some libgimp
functions are used in libgimpui, but are not meant to be public), while
they are not made public in headers. These are still considered private,
as far as API stability is concerned.
2024-09-29 12:27:50 +02:00
Jehan 12ad579843 libgimp: fix disabling various metadata export per Preferences.
Preferences > Image Import and Export tab has various Export Policies,
which are mostly for safety reasons. One may want to default at never
exporting specific metadata. This got broken and anyway the logic was
not good enough.

Now these policies are followed in interactive mode, unless an export
has already happened for this specific export plug-in on this specific
file (in this case, we reuse the last values). We don't want settings to
unexpectedly change in such a case.

In last-vals and non-interactive run-mode though, we don't follow the
Preferences policies, since in the former case, we want to reuse exactly
the same settings (e.g. we don't want an Export discarding metadata
which explicitly checked in the Export As) and in the latter case, it is
the developer's responsibility to set up expected options.
2024-09-29 12:27:50 +02:00
Jehan 68ee943200 libgimp: clean up the GimpImage's metadata API.
gimp_image_metadata_load_prepare(), gimp_image_metadata_load_finish()
and gimp_image_metadata_save_finish() are only ever used internally now,
so there is no need to expose them.

If we realize that we need them as public functions later, or someone
reports a valid use case, we can always bring them back later.

Also improves a bit various annotations.
2024-09-29 12:27:50 +02:00
Jehan aa2527843b libgimp: use G_DECLARE_FINAL_TYPE() for GimpImageComboBox. 2024-09-29 12:27:50 +02:00
Jehan 9e0a75cd87 libgimp: improves docs and annotations for GimpImage's color profile API. 2024-09-29 12:27:50 +02:00
Jehan 993fae97df libgimp: make GimpDrawablePreview a final type. 2024-09-29 12:27:50 +02:00
Jehan 3051796f3e app, libgimp, pdb, plug-ins: merge gimp_channel_new() in libgimp and PDB.
Why have 2 functions if one is basically just redirecting to the other.
All we needed to do was to reorder the PDB args.
2024-09-29 12:27:49 +02:00
Jehan bd287d6f89 libgimp, plug-ins: variosu gimp_*_chooser_new() should use specific type…
… for default value.

Don't use the generic GimpResource which implies that we could set any
GimpResource (which of course makes no sense).
2024-09-29 12:27:49 +02:00
Jehan d49077569d libgimp: GimpAspectPreview can be declared as a final type. 2024-09-29 12:27:49 +02:00
Jehan a38d3d3028 libgimp: fix some copy-paste bug.
Thanks to Alx for spotting this one!
2024-09-25 12:06:44 +02:00
Alx Sa 01af0f78c8 app, libgimp, pdb: Fix generation warnings
On generating our PDB files, we were
getting warnings about uninitialized strings.
This is because descriptions and authors
had been left off three .pdb files. Adding
these in resolved the warnings.
A new PDB author entry was also added
for Idriss Fekir.
2024-09-24 22:56:44 +00:00
Jehan 33ec5b70b1 app, libgimp, pdb: fix our PDB script to try to interpret gi-docgen syntax.
Fixes:

> Possible unintended interpolation of @palette in string at /builds/GNOME/gimp/pdb/groups/image.pdb line 1692.
2024-09-24 23:29:33 +02:00
Jehan 151cb9c40c app, libgimp, pdb, plug-ins: rename gimp_palette_entry_[gs]et_*().
These function names look like they should be applied to a
GimpPaletteEntry, which is a type which doesn't exist in libgimp. This
naming is much more appropriate.
2024-09-23 18:37:27 +02:00
Jehan 1b7f8533ee libgimp, plug-ins: fix a case of not showing dialog.
Fix a generic case when gimp_window_set_transient() is called on an
already mapped window: the handle argument was missing.

The part in bmp-export though, in fact, I am still a bit at a loss.
Somehow calling gimp_window_set_transient() was making the dialog not
showing up at all, yet kinda blocking the bmp plug-in (waiting for a
response to the non-displayed dialog) and various features in the main
GIMP GUI too.
Calling gtk_widget_show() first, before setting transient was enough to
make the dialog finally work as it should, but this is really not ideal.
I compared to other cases in other plug-ins where the set_transient()
function was called before the dialog was shown and it is working fine.
I just cannot find the proper reason. So this will do for now.
2024-09-23 18:20:46 +02:00
Jehan 3bfda4f119 Issue #9477: remove gimp_image_[gs]et_colormap() from libgimp API.
They are now replaced by the more generic gimp_palette_[gs]et_colormap(),
hence making less of a particular concept of "image colormap". It's just
a palette attached to the image (and restricted to the image format).
2024-09-23 18:20:14 +02:00
Jehan 16a2fc58ba libgimp: fixing "palette" libgimp API unit testing.
It was an equality because I think the conversion from palette format to
"RGBA float" should go through the exact same babl code path, however it
is done in the API. And that is the case on my machine where I get
indeed perfect equality. But apparently not on the CI.

Though I guess investigating further would not be a bad idea, let's
consider this a minor issue (as a general rule, comparing float with
epsilon is still a recommended software usage), and just add a comment.
2024-09-23 12:14:19 +02:00
Jehan 9ad05ee6fa app, libgimp, pdb, plug-ins: change gimp_palette_set_colormap() to take a C array.
Similar to previous commit.
2024-09-23 00:01:06 +02:00
Jehan c60512514c app, libgimp, pdb: change gimp_palette_get_colormap() to return a C array.
GBytes are a bit annoying to handle, so I'm renaming the PDB procedure
to a private _gimp_palette_get_bytes() instead, and making a wrapper
function which returns a C array and both the number of colors or number
of bytes. The latter is needed for introspection (otherwise the binding
can't know the size of the C array), but for the C API, both these
returned integers can be considered redundant (since one can be computed
from the oher), so only one at a time is mandatory.
2024-09-23 00:01:06 +02:00
Jehan 9bd69498ca app, libgimp, pdb: new gimp_image_set_palette() procedure.
When we want to set a full palette based on an existing one, no need to
request the full colormap from core to libgimp then back. Just set the
palette which is nothing more than an empty shell around a resource ID.
2024-09-22 23:26:33 +02:00
Jehan 6a35118a8f app, libgimp, pdb: new gimp_palette_set_colormap() PDB procedure. 2024-09-22 23:26:33 +02:00