Commit Graph

467 Commits

Author SHA1 Message Date
Alx Sa 7e6dc23ac1 plug-ins: Fix Foggify color property
Since the color space invasion, GimpRGB
properties do not create widgets anymore.
For Python plug-ins, we need to add
GeglColor properties as GObjects with
GeglColor value types as a workaround.
This patch does this and updates the
Foggify plug-in with the new datatype.
2024-02-25 20:14:13 +00:00
Jehan 7e95211e35 Issue #10834: [Color Space Invasion] Filter Presets not loading deserialized GeglColors. 2024-02-14 18:00:25 +01:00
Jehan 0b6b76a419 Issue #10811: implement GeglParamColor missing in some places.
Though I had already implemented passing GeglColor through the PDB, it was not
complete. In particular, the protocol was not able to pass GeglParamColor specs.

Fixes:

> LibGimp-WARNING **: 16:06:09.451: _gimp_gp_param_def_to_param_spec: GParamSpec type unsupported 'GeglParamColor'

This is part of the fix to issue #10811, though it's not complete yet.
2024-02-13 21:58:40 +01:00
Jehan a7637bfb4a libgimpconfig: special-case GeglColor param comparison if one is NULL.
The current values_cmp() method will segfault if an object contains a NULL
GeglColor value. I fixed it in commit c0477bcb0 in GEGL, but since the GEGL
release is already done, I add this special-casing on GIMP side.

To be removed when we release and depend on GEGL 0.4.50.

The crash was happening when activating the text tool and raised in a comment of
another report: https://gitlab.gnome.org/GNOME/gimp/-/issues/10813#note_2009702
2024-02-12 19:33:29 +01:00
lillolollo 8934a50925 app, libgimpconfig: use G_GSIZE_FORMAT for printf-ing gsize values. 2024-02-12 12:03:03 +00:00
Jehan 924dbb44a8 app, libgimpconfig: GimpFilterTool color_picked() now uses GeglColor.
In particular, the Curves, Levels and Operation tools method implemented
are updated. Also GeglColor arguments in GEGL operations are not
transformed into GimpRGB arguments anymore in GIMP. GeglColor GParamSpec
stay GeglColor now.
2024-02-11 23:28:04 +01:00
Jehan ce887767e7 app, libgimpconfig: color history is now space-invaded.
I also changed a bit the new color serialization by adding a (color …)
symbol framing the contents, for cases where we don't have a specific
property name, e.g. for the color history list stored in colorrc, unlike
for GimpConfig GeglColor properties.

While doing this, I moved GeglColor property deserialization code into
gimp_scanner_parse_color() which is now able to recognize both older
(color-rgb|rgba|hsv|hsva with no color space) and newer serialization
formats ("color", color model agnostic and space aware).
2024-02-11 23:28:03 +01:00
Jehan 1be7892862 libgimpconfig: serialize indexed colors as RGB instead.
Serializing palette colors is not possible right now as far too much
additional data are required, and anyway we likely wouldn't be able to
associate back the color to the right palette on deserialization,
removing any interest of keeping the index data anyway.

With that context in mind, let's just serialize palette data as basic
RGB within the palette's space.
2024-02-11 23:28:03 +01:00
Jehan 559297a5cb app, libgimp*: more GeglColor's space invasion.
- New function gimp_cairo_set_source_color() which is meant to replace
  gimp_cairo_set_source_rgb(a?)() eventually. This new function sets the Cairo
  source color, using the target monitor's profile of the widget where the Cairo
  surface is meant to be drawn on. It also uses the color management settings
  (such as whether a custom profile was set, instead of using system profile, or
  also simply whether color management was disabled at all). It doesn't
  soft-proof the color yet.
- Padding and out-of-gamut colors drawing now use the new
  gimp_cairo_set_source_color(). These don't need any soft-proofing anyway.
- Out-of-gamut color property in GimpColorConfig is now a GeglColor property.
2024-02-11 23:28:02 +01:00
Jehan b1178c51a3 libgimpconfig: support the GimpRGB format for GeglColor.
Some old config files will contain (color-rgb) contents. Also some data, such as
historical tool presets (.gtp files) will have such values in their
(tool-options).
2024-02-11 23:28:02 +01:00
Jehan cd32b3bffa libgimpconfig: add support for GeglColor config properties.
GeglColor properties are serialized this way:
(propname "encoding" bpp pixel-data profile-size profile-data)
2024-02-11 23:28:02 +01:00
Jehan 4d0df90e26 libgimpconfig: fix some memory leaks when deserializing raw data. 2024-02-11 23:28:02 +01:00
Jehan dbbcfb16d5 app, libgimp*, pdb, plug-ins: GimpContext is now using only GeglColor.
- app: gimp_context_get_(foreground|background)() are now returning a GeglColor.
- libgimp: PDB functions named similarly in libgimp are returning a newly
  allocated GeglColor too.
- A few other PDB functions (the ones using these functions) were updated and
  their signature changed to use GeglColor too, when relevant. Plug-ins which
  use any of the changed libgimp functions were fixed.
- GimpContext: signals "(foreground|background)-changed" are now passing a
  GeglColor.
- libgimpconfig: new macro GIMP_CONFIG_PROP_COLOR using gegl_param_spec_color().
- GimpContext: properties "foreground" and "background" are now GeglParamColor
  properties.
- app: All code interacting with GimpContext objects were updated to receive a
  GeglColor (that they may still convert, or no, to GimpRGB for now).
- app: gimp_prop_gegl_color_button_new() was added as an alternative to
  gimp_prop_color_button_new() when the property is a GeglParamColor. Eventually
  the former should replace completely the latter.
- libgimpwidgets: gimp_prop_color_area_new() now works on GeglParamColor
  properties only.
- libgimp: gimp_procedure_dialog_get_widget() will generate a GimpColorArea for
  GeglTypeParamColor arguments.
2024-02-11 23:28:02 +01:00
Alx Sa 4a10b11e3e libgimpconfig: Fix cross-platform gsize warning
gimp_config_writer_printf () is used to print out a gsize variable, data_length.
gsize's actual size varies depending on platform, so using the format "%lu" throws
a warning on some platforms and switching to "%llu" throws a warning on others.
@Wormnest suggested ("%" G_GSIZE_FORMAT) as a universal format to resolve
this warning.
2024-01-26 12:08:18 +00:00
sonia 9f762f5e4b plug-ins: Fix JPEG2000 warning
Removes duplicate parenthesis in the CMYK color space check.
2024-01-14 11:17:29 -05:00
Alx Sa c01ffee74f plug-ins, libgimpconfig: Fix minor warnings
- file-psd, sig[4] and block_len variables are initialized to stop uninitialized warnings
- file-xpm, g_file_peek_path () is cast to (char *) to stop "discarded const" warnings
- gimpconfig-serialized.c, %llu is used instead of %lu to stop overflow warning
2024-01-14 14:30:32 +00:00
Jacob Boerema 6cca73516a libgimpconfig: fix #10278 Script-Fu API display commands are failing
on input arguments

This is the same issue as #10194 but for GimpDisplay. We fix it in
the same manner.
2023-11-28 15:38:47 -05:00
bootchk 3646b86ce0 2.99 libgimpconfig: #10194 broken API GimpItem
And GimpTextLayer, GimpLayerMask
2023-10-20 09:04:42 -04:00
Jehan b7bff4ee9a libgimpconfig: a NULL GBytes is also a proper argument value.
Do not fail serialization when a GBytes argument is set to NULL by adding a
special case for this.
2023-10-01 21:02:33 +02:00
Jehan 6601e861c4 libgimp*: support having procedure arguments of generic type GimpResource. 2023-10-01 21:02:33 +02:00
Jehan 4163a29af3 app, libgimp: new GimpChoice procedure argument.
These will replace the int arguments used in place of enums. The problem of int
arguments used as list of choices is that it makes calling PDB functions very
opaque. This is especially bad when a list is long, so you constantly have to
refer to the documentation to understand what a series of numbers mean in
argument lists.

And the second issue is that plug-in developers have to manually maintain a list
of values both in the GUI and in the documentation string. This help text may
get out-of-sync, may end up with missing values or whatnot. Also if it is used
as tooltips, it makes for very weird tooltips in the graphical interface, with
an overlong technical list of int-values mapping which should ideally only be
made visible in the PDB procedure browser listing.
2023-10-01 20:52:02 +02:00
Jehan 29ce8f234f libgimp*: removing now useless Makefile.gi files.
These were include files for the autotools build and are now unused.
2023-10-01 20:52:02 +02:00
Jehan cd5d221cfa libgimpconfig: add (de)serialization support of GBytes arguments.
Basically the same as GimpParasite, except that we don't same a parasite name
and flags.
2023-10-01 20:52:02 +02:00
Jehan ed4c50ce2e app, libgimpconfig: make the code more robust to random text.
There are 3 fixes here:

1. First, searching for "\"GimpFont\"" to determine whether or not this is a new
   format text parasite is not enough, because this string can be found in a
   text layer with "GimpFont" only as contents. It will serialize as:

   > (text "GimpFont")

   Instead search for "(font \"GimpFont\"" which cannot be created as part of
   the text contents because of the unprotected double quotes).

2. We must verify that strstr() did not return NULL when searching for markup
   delimiters. It may happen if the parasite contents is invalid (we must always
   assume it can be, since it's user data).

3. When deserialization of a text from parasite fails (e.g. because parasite
   doesn't actually exist or its format is wrong), still make sure the GimpText
   has a font (setting the standard one before deserializing). Otherwise GIMP
   crashes down the line.

   For this, I also had to fix gimp_config_deserialize_object(): the object type
   name must be parsed even if an object was already set in a GObject property.
2023-09-12 14:23:40 +00:00
Idriss Fekir a966297498 Port GimpText to GimpFont
In GimpText, The font used to be stored as a string containing its name,
Now, it is stored as a GimpFont object, which makes more sense and makes
operations on fonts easier (such as serialization).
2023-09-12 14:23:40 +00:00
Jehan ce0a84003c libgimp, libgimpconfig: GimpResource can now be (de)serialized.
I add a new class method deserialize_create() to GimpConfigInterface which
returns the GimpConfig object per deserialization, instead of modifying an
existing bare object.

This matters for cases like our GimpResource (and later our GimpItem) classes
which are fully managed by libgimp and should be unique objects per actual
resource. It should even be possible to compare the pointer itself for identity.
That's why we need to let GimpResource create the object (in reality request it
to the infra and only ref it) through this new class method.

With this commit and the previous ones, all GimpResource are now properly stored
as plug-in settings (e.g. the "film" plug-in has a font setting which is now
properly remembered).

These identifiers are not portable (across various installations and therefore
not for XCF either), but at least they are reasonably identifying data on a same
installation (unlike GimpResource's int ID which is only valid within a single
session) which makes them very fine for plug-in settings storage.

When a data file disappears, we fallback to the context default data instead.
2023-07-27 15:34:45 +02:00
Jehan ccde23ebaa libgimpconfig: don't break serializing properties if one property serialization…
… fails.

This happens for plug-in settings storage. Serialization stops at first failed
property serialization, whereas we could store more. This feels like the last
settings feature is broken.
2023-07-27 15:24:56 +02:00
Lloyd Konneker 3cf3097d62 libgimpconfig: support GStrv aka string array 2023-06-15 17:12:44 +00:00
Michael Natterer 26dce72d2c Remove autotools 2023-05-27 00:03:52 +02:00
Niels De Graef 89c359ce47 Remove GimpUint8Array in favor of GBytes
GLib has a specific type for byte arrays: `GBytes` (and it's underlying
GType `G_TYPE_BYTES`).

By using this type, we can avoid having a `GimpUint8Array` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GBytes`, we allow other languages to pass on byte arrays 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 byte 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
2023-05-23 23:37:50 +02:00
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