Commit Graph

17 Commits

Author SHA1 Message Date
Jehan ddcaa99264 app, libgimp*, pdb, plug-ins: review and enhance MR !1549.
- Fix annotations for gimp_export_options_get_image() to make it
  actually introspectable with the GimpImage being both input and
  output. Even though the logic doesn't change much (the input image may
  be overriden or not), it doesn't matter for introspection because
  images are handled centrally by libgimp and therefore must not be
  freed. Actually deleting the image from the central list of images
  though remains a manual action depending on code logic, not some
  automatic action to be handled by binding engines.
- Add G_GNUC_WARN_UNUSED_RESULT to gimp_export_options_get_image()
  because ignoring the returned value is rarely a good idea (as you
  usually want to delete the image).
- Remove gimp_export_options_new(): we don't need this constructor
  because at this point, the best is to tell plug-in developers to just
  pass NULL everywhere. This leaves us free to create a more useful
  default constructor if needed, in the future. Main description for
  GimpExportOptions has also been updated to say this.
- Add a data_destroy callback for the user data passed in
  gimp_export_procedure_set_capabilities().
- Fixing annotations of 'export_options' object from pdb/pdb.pl: input
  args would actually be (nullable) and would not transfer ownership
  (calling code must still free the object). Return value's ownership on
  the other hand is fully transfered.
- Add C and Python unit testing for GimpExportOptions and
  gimp_export_options_get_image() in particular.
- Fix or improve various details.

Note that I have also considered for a long time changing the signature
of gimp_export_options_get_image() to return a boolean indicating
whether `image` had been replaced (hence needed deletion) or not. This
also meant getting rid of the GimpExportReturn enum. Right now it would
work because there are no third case, but I was considering the future
possibility that for instance we got some impossible conversion for some
future capability. I'm not sure it would ever happen; and for sure, this
is not desirable because it implies an export failure a bit late in the
workflow. But just in case, let's keep the enum return value. It does
not even make the using code that much more complicated (well just a
value comparison instead of a simple boolean test).
2024-08-18 22:46:47 +02:00
Jehan 31cf749f31 libgimp: also add a unit test of gimp_text_layer_new() with pixel unit.
This would help preventing any future regression.
2024-08-18 18:19:23 +02:00
Jehan deea10ed82 libgimp: fixing python unit test for GimpUnit API. 2024-08-06 14:32:25 +02:00
Jehan 2a00a9e60a Issue #434: remove broken plural support for GimpUnit.
Rather than trying to implement full i18n plural support, we just remove
this failed attempt from the past. The fact is that to get proper
support, we'd basically need to reimplement a Gettext-like plural
definition syntax within our API, then ask people to write down this
plural definition for their language, then to write every plural form…
all this for custom units which only them will ever see!

Moreover code investigation shows that the singular form was simply
never used, and the plural form was always used (whatever the actual
unit value displayed).

As for the "identifier", this was a text which was never shown anywhere
(except in the unit editor) and for all built-in units, as well as
default unitrc units, it was equivalent to the English plural value.

So we now just have a unique name which is the "long label" to be used
everywhere in the GUI, and abbreviation will be basically the "short
label". That's it. No useless (or worse, not actually usable because it
was not generic internationalization) values anymore!
2024-08-06 11:39:57 +02:00
Jehan 624e3772e9 libgimp: new unit tests around GimpImage and item API.
Right now, it only tests a few API, such as creating an image, then a
text layer, then inserting it in the image.

This is a test to avoid regression bug after having fixed #9923 in a
previous commit.
2024-08-02 14:12:10 +02:00
Jehan a92e694a19 libgimp: new unit tests for GimpUnit. 2024-08-02 12:14:54 +02:00
Alx Sa 86ef74ae95 plug-ins, tests: Update Python plug-ins after b1736a67
Two instances of Gimp.Layer.group_new ()
were missed during the initial port.
2024-07-07 12:37:33 +00:00
Jehan b1736a6736 app, libgimp, pdb, plug-ins: new GimpGroupLayer class in libgimp.
Also:

- renaming gimp_layer_group_new() to gimp_group_layer_new() in order to keep the
  same name as in core code (i.e. GimpGroupLayer, not GimpLayerGroup).
- renaming gimp_image_merge_layer_group() to gimp_group_layer_merge()
- new functions: gimp_procedure_add_group_layer_argument(),
  gimp_procedure_add_group_layer_aux_argument() and
  gimp_procedure_add_group_layer_return_value().

This can be tested, e.g. in Python with these calls:

```py
i = Gimp.get_images()[0]
g = Gimp.GroupLayer.new(i, "hello")
i.insert_layer(g, None, 1)
g2 = Gimp.GroupLayer.new(i, "world")
i.insert_layer(g2, g, 1)
g.merge()
```

This was work started long ago, stored in an old stash which I finally
finish now! :-)
2024-07-07 10:27:04 +02:00
Jehan 62ab8e2604 libgimp, libgimpcolor: make real unit test of old (compiled but unused) …
… test-color-parser.c file.

The file libgimpcolor/test-color-parser.c was compiled but never actually called
by the build. Now that we have a nice infrastructure to test libgimp API, I am
moving it there with the new format. Doing this also allowed me to discover some
bugs in CSS parsing, as well as discover Python binding was failing here (cf.
the few previous commits).

Only one test is disabled so far, the one where 4 digits are used per channel in
hexadecimal notation: "#64649595eded". This format simply doesn't appear
anywhere in the spec, and also the result values in the samples listing don't
even fit. So far, I'm just unsure what to do with it, if we want to keep this
support (of some kind of higher precision hex notation, but not specified, so is
it even used by anyone?) or not.

All the other tests just work in both C and Python!
2024-04-20 12:39:52 +02:00
Jehan 94853968b3 libgimp: also update unit testing for GimpColorArray.
Making sure not only that the PDB passes correctly the number of colors, but
taking one random color in the array and verifying it is correct.
2024-04-18 16:00:42 +02:00
Jehan 266e694920 libgimp: library unit testing should use a separate environment.
The comment I had written back then was wrong. Meson in fact can create an env
object from another with a simple assignment (which copies the object, rather
than pointing to a same object), per the answer which has been given to me in:
https://github.com/mesonbuild/meson/issues/13045

This allows to have a properly separate environment (when using GIMP as a build
tool, we don't want to load the test files).
2024-04-18 00:01:30 +02:00
Jehan a78c41d2a3 meson: on macOS temporarily update rpath to find libraries of non-installed GIMP.
The DYLD_LIBRARY_PATH trick was working fine on CI, but not on local builds for
Lukas. Apparently there are security measures disabling the environment
variable. Instead let's temporarily add then remove libgimp libraries folders
from rpath.

See: https://gitlab.gnome.org/Infrastructure/gimp-macos-build/-/merge_requests/292#note_2075291
2024-04-16 17:43:15 +00:00
Jacob Boerema 7aa33bf771 app, pdb: fix #8363 gimp_selection_float() crash
Calling gimp_selection_float from a Python plug-in could make it crash
with an error like Calling error for procedure 'gimp-selection-float':
Item x cannot be used because it is not a group item.

This is caused by an incorrect check for group layers.
gimp_pdb_item_is_group returns an error when the condition is False,
while we only want an error when a group layer is selected (True).
Thus we need to use gimp_pdb_item_is_not_group, which returns an error
when the item is a group, which is what we want.

These function names are a little confusing, we might need to think
about better naming sometime.

I added C/Python tests for this function, so that we can test whether
this works correctly.
2024-04-15 18:13:32 -04:00
Jehan 378e80408d meson: share a same environment for all usages of self-built GIMP
In particular GIMP used for unit-testing, or in other cases as a build tool,
from the non-installed binaries, can use a same meson `env` object.
2024-04-08 20:30:51 +02:00
Jehan baae7287be libgimp: allow to run gimp_procedure_run_config() with no config object.
This is the equivalent to run the procedure with its defaults.
2024-02-29 16:33:32 +01:00
Jehan 01cdf777a6 libgimp: add C tests to the libgimp testing infrastructure.
Most of the C boiler-plate code is generated so that all you have to do is
implement the run() function with test code in it.

Also adding a README to make it all very clear and easy to add new tests.
2024-02-29 16:19:49 +01:00
Jehan 7b43a7492f libgimp: new unit testing framework for libgimp.
With Python binding, it gets very easy to test new functions. I've been
wondering if we need C counterparts, but really since it's a GObject
Introspection binding, if a function succeeds there, it should also succeed in C
code.

For now, I'm testing a few of GimpPalette API. Not all of it yet. Also I test
both the direct C binding and PDB procedure since in some cases, one or the
other may not properly working. See #10885.
2024-02-28 22:55:58 +01:00