Commit Graph

437 Commits

Author SHA1 Message Date
lloyd konneker d59a7af38c libgimp: API refactor GUI for GimpResource
Simplifies chooser widgets (e.g. GimpBrushSelect) by eliminating attributes (e.g. opacity) of chosen resource.
See #8745, but this commit fixes that by first refactoring the code.

Refactors GUI widgets (e.g. GimpBrushSelectButton and GimpBrushSelect etc.)

Refactor by "Extract class" GimpResourceSelectButton from GimpBrushSelectButton etc.
This moves common code into an inherited class (formerly called GimpSelectButton)
but the subclasses still exist.
The subclasses mainly just do drawing now.

Refactor by "Extract module" GimpResourceSelect from GimpBrushSelect etc.
Moves common code into one file, generic at runtime on type of GimpResource,
that is, the new code dispatches on type i.e. switch statements.
In the future, when core is changed some of that can be deleted.
The files gimpbrushselect.[c,h] etc. are deleted.
The module adapts the API from core to the API of callbacks to libgimp.

Note that core is running the resource chooser (select) widgets remotely.
Core is still calling back over the wire via PDB with more attributes
than necessary.
The new design gets the attributes from the resource themselves,
instead of receiving them from core callback.
The libgimp side adapts by discarding unneeded attributes.
In the future, core (running choosers for plugins) can be simplified also.

Fix gimp_prop_chooser_brush_new same as other resources.

Finish changes, and clean style.

Annotations
2023-01-14 16:38:40 +00:00
lloyd konneker d720375e97 2.99 libgimp: add GimpResource, GimpBrush, GimpPropWidgetBrush
So procedures can declare args and GimpProcedureDialog show chooser
widgets

Fix so is no error dialog on id_is_valid for resources

Palette.pdb changes and testing

Memory mgt changes

Gradient pdb

Font and Pattern tests

Test  brush, palette

Cleanup, remove generator

Rebase, edit docs, install test-dialog.py

Whitespace, and fix failed distcheck

Fix some clang-format, fix fail distcheck

Fix distcheck

Cleanup from review Jehan
2023-01-14 12:58:05 +00:00
Alx Sa 3d54665a94 libgimpconfig: Retain color scale preferences
RGB 0..255/0..100 and LCh/HSV settings are now remembered when closing
and reopening GIMP.
A few enums were explicitly cast to GimpColorSelectorChannel to clear
some compiler warnings.
2023-01-10 00:20:22 +00:00
Jehan 75dd13981a libgimpconfig: more param spec types to ignore (GeglParamFormat). 2022-10-26 23:29:32 +02:00
Jehan e5d5be4277 Issue #8062: error when offsetting a layer. 2022-10-26 23:10:51 +02:00
Jehan ca230cb770 meson: fix warnings of deprecated features.
Now that we bumped our meson requirement, meson is complaining about
several features now deprecated even in the minimum required meson
version:

s/meson.source_root/meson.project_source_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.

s/meson.build_root/meson.project_build_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.build_root. use meson.project_build_root() or meson.global_build_root() instead.

Fixing using path() on xdg_email and python ExternalProgram variables:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead

s/get_pkgconfig_variable *(\([^)]*\))/get_variable(pkgconfig: \1)/ to
fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
2022-08-31 01:29:37 +02:00
Jehan ccbf3c4bb0 app, libgimp*: add various stamp files to CLEANFILES.
Fixes:

> ERROR: files left in build directory after distclean:
2022-08-01 23:34:50 +02:00
Jehan 83e465ec16 app, libgimp*: updating autotools script in sync with meson.
Generated *enums.c now have an additional stamp no-op header include
(see last 2 commits). Sync this change into the autotools generation
scripts to prevent back and forth useless generation of these files each
time we switch from one build system to another.
2022-08-01 20:00:01 +02:00
Jehan 979acaaae2 app, libgimp*: commit the newly generated *enums.c files.
They are nearly the same as initially, except that now they include an
intermediate stamp header which will be generated by the build system.

The only 2 enums which don't need these includes (and are not versioned)
are libgimp/gimpenums.c and libgimpthumb/gimpthumb-enums.c.
2022-08-01 20:00:01 +02:00
Jehan 106f2a061d Issue #8145: meson: generation of '*-enums.c' files.
Our meson build system was not properly building the enums.c file,
because they are versionned.

I did a similar trick as what I did for the pdbgen, which is that I used
a wrapper script around the existing perl script, which sets proper
options and generate a stamp file in the end (which is considered by
meson as the actual custom target, not the C file since it is generated
in the source dir).

The most important part is that the stamp file is a generated header
source (not just a random text file) which is **included** by the
generated C file. This is what will force meson to regenerate the C file
if the header is updated, **then** build using this new version, not use
an outdated versionned version (which would make for hard to diagnose
bugs), through the indirection of the intermediate stamp header.

See #4201.
See also: https://github.com/mesonbuild/meson/issues/10196#issuecomment-1080742592
2022-08-01 19:59:53 +02:00
lloyd konneker 42750c25a7 libgimpconfig: fix missing GimpChannel in gimp_config_param_spec_duplicate
Partial fix to issue 8062

Only fixing the part that I understand, that impedes enhancements to ScriptFu.
2022-07-20 23:09:55 +00:00
Jehan 3e256451e4 libgimpconfig: fix small typo. 2022-03-04 16:09:09 +01:00
Jehan 29f23c8f98 libgimp, libgimpconfig: fixing gi-docgen "qualifier fragments".
Fixing these 2 warnings in the CI which end up fatal:

WARNING: Invalid fragment for 'Gimp.Parasite': it should be struct
Serializes the object properties of @config to a [class@Parasite].
                                                 ^~~~~~~~~~~~~~~~
WARNING: Invalid fragment for 'GLib.MainLoop': it should be struct
it has a GUI and is hanging around in a [class@GLib.MainLoop], it must call
                                        ^~~~~~~~~~~~~~~~~~~~~
2022-02-18 12:11:01 +01:00
Niels De Graef 8eb7f6df9e Remove GimpStringArray in favor of GStrv
GLib has a specific type of NULL-terminated string arrays:
`G_TYPE_STRV`, which is the `GType` of `char**` aka `GStrv`.

By using this type, we can avoid having a `GimpStringArray` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GStrv`, we allow other languages to pass on string lists as they are
used to, while the bindings will make sure to do the right thing.

In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with string arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).

Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
2022-02-12 00:07:53 +00:00
Jehan e7a7edd29c libgimpconfig: fix gimp_config_param_spec_duplicate() for objects and…
… object arrays.

We were not supporting duplicating object pspec for no good reason. Well
maybe the reason was that libgimpconfig does not see these types which
are in libgimp. But then the trick is to compare by name.

As for object array, they are present as subtypes of GimpArray specs.
Yet most GimpParamSpec*Array-s are subclass of GimpParamSpecArray but
GimpParamSpecObjectArray are their own GParamSpecBoxed subclass (same as
the Gimp*Array-s are just typedef-s of GimpArray but GimpObjectArray is
its own boxed type).
So I had to move the object array test as its own case to fix support.

Finally do not ignore anymore any type in gimp_config_class_init(). When
we create a GimpConfig, we want to know when a type is not implemented
as parameter (and if it's a well known type, we need to implement it).
2022-02-11 17:31:30 +01:00
Jehan e6350f9459 libgimpconfig: this is the appropriate fix for the previous assert.
Since the parsing failure I was experiencing was normal (not a bug), and
since I was not seeing error being passed down to deserialize(), I
assume this assert was always wrong. I hadn't realize that the GError
object was in fact populated by deserialized through g_scanner_error()
calls which were setting the GError passed at creation of the scanner
through a handler.

So there was indeed a bug in one of the functions called by our
deserialize() implementation. There was one failure case where the error
was just reported with g_warning() instead of g_scanner_error().

Now that it's fixed, I brought back the asserts (previous commits)
because the error object is actually always well populated.
2022-02-10 22:18:03 +01:00
Jehan f4c7ea7e02 Revert "libgimp, libgimpconfig: gimp_config_deserialize_file() should not…"
This reverts commit 73c0ee8da7.

Actually I was wrong, there was a bug in gimpconfig-deserialize.c. See
coming commit.
2022-02-10 22:18:03 +01:00
Jehan 1ed8ed8223 Revert "libgimpconfig: remove more g_assert()."
This reverts commit 40bebec273.

Actually I was wrong, there was a bug in gimpconfig-deserialize.c. See
coming commits.
2022-02-10 22:18:03 +01:00
Jehan 40bebec273 libgimpconfig: remove more g_assert().
As discussed with mitch on IRC, these asserts make no sense. They can
happen if we fail to parse user-side data. Also currently deserialize()
does not even pass the GError down so we would always assert on failed
parsing.

What must be done instead if change the signature of deserialize() and
all its implementations, with a GError arg. Then this GError will
properly bubble up to the caller for appropriate handling.
2022-02-10 21:27:33 +01:00
Jehan 73c0ee8da7 libgimp, libgimpconfig: gimp_config_deserialize_file() should not…
… assert the existence of GError.

This is even worse as deserialize() method does not even take a GError
parameter anyway so this assert will always go off when a
deserialization failed (which happened in my case as I was working on a
plug-in API, hence gimp_procedure_config_load_last() actually failed to
load a previous version of the plug-in-settings when I changed a
procedure arg's type).

Just fail the deserialization normally and let the calling code handling
this case. Nevertheless it is kind of useful to bubble-up the error to
calling code, so I add a TODO in the interface header (hopefully to see
and improve this before we release GIMP 3.0).
2022-02-10 18:44:44 +01:00
Niels De Graef 0446a9025a docs: Migrate some gtk-doc comments to gi-docgen 2021-12-29 11:21:19 +01:00
Niels De Graef 5ca9a38ea4 Fix some gobject-introspection annotations 2021-12-02 12:46:05 +01:00
Jehan 49e534247a app, libgimp*, pdb, plug-ins: use g_memdup2() instead of g_memdup()
Since it appeared with GLib 2.68.0, we could not change this until we
bumped the dependency which has only become possible a few days ago
(since Debian testing is our baseline for dependency bumps). Cf.
previous commit.

As this is a drop-in replacement (just a guint parameter changed to
gsize to avoid integer overflow), search-and-replace with:

> sed -i 's/g_memdup\>/g_memdup2/g' `grep -rIl 'g_memdup\>' *`

… followed by a few manual alignment tweaks when necessary.

This gets rid of the many deprecation warnings which we had lately when
building with a recent GLib version.
2021-08-26 17:32:09 +02:00
Jehan c3e3c68a01 libgimpconfig: free a GimpValueArray on deserialization failure.
Thanks to Massimo.
2021-08-21 19:19:23 +02:00
Marie-P c112a55958 libgimp*, plug-ins: fix some warnings 2021-05-24 20:36:31 +00:00
Jehan 5d210667c5 libgimp, libgimpconfig: recognize RGB boxed args containing GimpRGB.
Still the same problem as ever with the Python binding where we have a
hard time creating GParamSpec, hence we make them from object
properties.
See: https://gitlab.gnome.org/GNOME/pygobject/-/issues/227#note_570031

But then again, the Python binding way to create GObject properties does
not seem to give us a way to use our custom param types (or I didn't
find how). So when I create a property with Gimp.RGB type in Python, it
doesn't appear as a GIMP_PARAM_SPEC_RGB to our C code, but as a
G_PARAM_SPEC_BOXED. So my trick is to check the value type instead.
Note that I check the default value, but in reality it doesn't seem to
work much either. Better than no support at all anyway.
2021-04-20 16:54:40 +02:00
Jehan 0b01b812a9 libgimpconfig: implement serializing GimpParasite into a GimpConfig.
Used for instance if a plug-in had a GimpParasite argument (or aux
argument), which might not seem too useful at first. But anyway we
propose the type, so let's support it properly.

And actually I am going to use it in the next commit as a trick to save
binary data in stored last values for a plug-in.
2021-04-06 00:14:40 +02:00
Jehan 353c73457a app, libgimp, libgimpconfig, extensions: image procedures now with…
… drawable array instead of a single drawable.

Instead of expecting a single drawable, GimpImageProcedure's run()
function will now have an array of drawable as parameter.
As a consequence, all existing plug-ins are broken again. I am going to
fix them in the next commit so that this change can be easily reviewed
and examined if needed later.

I only fix the Vala demo plug-in now (or rather, I just use the first
layer in the array for now) because otherwise the build fails.
2021-04-04 01:40:00 +02:00
Niels De Graef dffab0e9a4 Remove GimpInt16Array
It isn't being used by any plug-in or any code in GIMP at all even.
Let's get rid of it while we can still break API, so we can cut down on
all the complexity of the gimp-param stuff a bit.
2021-02-18 11:32:45 +00:00
Jehan 3e4407a315 libgimp, libgimpconfig: use gimp_parasite_get_data().
As previously do not trust that parasite contents is proper text ending
with nul character by always using the parasite size info.
2021-01-30 08:57:43 +01:00
scootergrisen df507c05ae Remove trailing spaces in 3 strings 2020-12-15 15:55:45 +00:00
Jehan 025309b0d7 app, libgimpconfig: "printer-profile" becomes "simulation-profile".
As per a FIXME for 3.0 where various mention to "print" got replaced by
a more generic notion of "simulation".
2020-10-16 19:50:19 +02:00
Jacob Boerema 71ad53ebcf libgimpconfig: fix conversion of negative int values in gimp_scanner_parse_float()
Negative int values were not correctly handled because value.v_int is unsigned
causing a conversion to a large positive value.

To fix this we cast it to gint64 first before making it negative.
2020-09-21 19:36:25 -04:00
Michael Natterer 896286279b libgimpconfig: cache the "gegl-property-keys" Quark
in gimp_config_param_spec_duplicate().
2020-06-17 21:56:31 +02:00
Michael Natterer 2e6656599d libgimpconfig: fix string deserialization for some cases
In gimp_config_deserialize_fundamental(), we can't use
g_value_set_static_string() because that will in the end pass the
GScanner's temporary scanner->value.v_string to
GObject::set_property(), and depending on set_property()'s
implementation, we might not dup the string (for example objects
created via gimp_config_type_register() will simply use g_value_copy()
and end up with a dangling pointer as a string member).
2020-06-08 22:35:42 +02:00
Niels De Graef 842dc7535f gir: (skip) functions with varargs
Bindings can't handle these, so they are not introspectable.
2020-05-21 13:49:38 +02:00
Niels De Graef 7a8a300adc gimpconfig-iface: Use G_DECLARE_INTERFACE 2020-05-10 14:45:19 +00:00
Niels De Graef 57d3837e40 gir: More missing annotations
Especially need to watch out with forgetting `(array)` and `(out)`
annotations, as they can really give a different API in certain (if not
most) bindings.
2020-05-08 16:57:45 +02:00
Niels De Graef 7f58f2d6e5 gir: Add more missing (array) and (out) annotations 2020-05-04 21:29:42 +02:00
Niels De Graef 9c9e310a67 gir: Add missing annotations
Otherwise we won't be able to generate proper API for our bindings
2020-05-04 02:11:57 +02:00
Niels De Graef 99a7d5f7dd gir: Found some more missing (out) annotations 2020-05-03 18:12:37 +02:00
Niels De Graef 52a146604b gir: Add some missing (array length) annotations
This will make sure that bindings can generate a more "native" API so
they don't have to pass the length explicitly.
2020-05-03 18:11:29 +02:00
Ell 46df3642d2 libgimpconfig: in gimp_config_type_register(), don't override GimpConfig::equal()
gimp_config_type_register() currently overrides GimpConfig::equal()
to only compare the properties of the most-derived type.  However,
this prevents the properties of GimpOperationSettings from being
considered during comparison of operation-config objects.  Instead,
don't override GimpConfig::equal(), and rely on
GIMP_CONFIG_PARAM_DONT_COMPARE to exclude specific base-class
properties from comparison.
2020-04-08 00:22:49 +03:00
Ell c5c807d191 libgimpconfig: add GIMP_CONFIG_PARAM_DONT_COMPARE flag
... which excludes a property from comparison in the default
implementation of GimpConfig::equal().
2020-04-08 00:10:42 +03:00
Ell dcea2348c6 libgimpconfig: allow calling gimp_scanner_new_string (NULL, -1, ...)
Allow calling gimp_scanner_new_string() with a NULL `text` and a
negative `text_len` (which is interpreted as 0), instead of
requiring `text_len == 0` in this case.  This allows passing a
negative `text_len` unconditionally to infer the length, even when
the string may be NULL.
2020-01-30 02:51:56 +02:00
Ell 38fff3b6b3 Issue #4172 - Gimp doesn't store negative values between sessions (Text Tool)
In gimp_config_deserialize_fundamental(), cast integer token values
to the target value type *before* negating them, to avoid
performing unsigned negation, which can result in a positive value
when cast to the target value type (in particular, when the target
value type is float/double).
2019-11-03 13:42:04 +02:00
Jehan b8d8424ae0 app, libgimp*: (meson) fix all the generated `*-enums.c`.
More of the files were wrong, or at least not absolutely identical to
the files generated by the autotools. I am not doing any code change
other than trying to make both build systems produce identical files
(except for slight differences on 2 files not worth the effort) even
though maybe some things can be improved (especially on the include
list). Maybe to be improved later.

Also fixing 2 of the previously autotools-generated files because of
space typos which should have been committed earlier.

Finally it is to be noted that there is no logics to copy the generated
files back to the source directory in the meson rules. I am not sure
anyway this is really worth it and maybe we should just stop tracking
these generated files eventually.
2019-10-19 22:32:29 +02:00
Ell 3d30a036de libgimpconfig: relax precondition check in gimp_config_type_register()
Allow passing a non-NULL `pspecs` with `n_pspecs == 0` to
gimp_config_type_register(), in particular since
g_object_class_list_properties() may return such values.
2019-09-23 18:22:19 +03:00
Michael Natterer bfe7bb1d05 libgimpconfig: fix doc typo 2019-09-21 19:02:22 +02:00
Michael Natterer dbd793d631 libgimpconfig: get rid of filenames in all config related APIs
and rename function names which say "gfile" to just "file".
2019-09-21 12:55:12 +02:00