Commit Graph

2932 Commits

Author SHA1 Message Date
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
bootchk fc310e0bed libgimpui: annotation of gimp_ui_init say it can be called often. 2024-03-20 11:35:48 +00:00
bootchk 2c664fac72 API PDB: resource-get-by-name return NULL instead of error
Without this, there is no easy way to quietly check for existence of a resource by name.
Needed when plugin authors can name defaults for resource args by name.

Add tests to script-fu/test/tests
2024-03-19 12:05:28 +00:00
Alx Sa 05af8c91c1 widgets: Minor GimpRGB to GeglColor ports
Mainly fixing GimpRGB comments and
parameters that are unused (or in unused
functions).
GimpCircle and GimpGradientChooser
have color conversions ported to use
GeglColor exclusively.
2024-03-19 04:40:14 +00:00
Alx Sa 28b236b578 libgimpbase: Replace GimpRGB in gimpchecks
Converted to gdouble[] and updated in all 
calls to the enums in gegl_color_set_pixel()
2024-03-17 16:19:25 +00:00
Alx Sa 917506d16e libgimp, dialogs, plug-ins: Minor fixes
- Replaces GimpRGB in Channel Dialog
with gdouble array, as was done in
channel_options_color_changed ()
- Replace %ld with G_GSIZE_FORMAT
in libgimp checkboard color message to
fix warning in Windows build
- Set file-gih documentation text as
translatable.
2024-03-14 01:41:31 +00:00
Alx Sa 625b74ea00 pdb: Update text-layer-set-color to GeglColor
Resolves #10992.

GimpTextLayer's color attribute was
updated from GimpRGB to GeglColor,
but gimp-text-layer-set-color still passed
in GimpRGB. This patch updates the PDB
call to match the property type.
2024-03-05 01:42:22 +00: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 bf0b774261 libgimp: gimp_pdb_lookup_procedure() returns NULL if procedure doesn't exist.
Right now, it was always returning a GimpProcedure even if the PDB procedure
didn't exist (the GimpProcedure was therefore invalid).
2024-02-29 14:13:21 +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
Jehan 71d03d5828 Issue #10885: gimp-palette-get-colors warning and critical.
We were missing GimpColorArray support in one function. Note that the specific
example in Python in #10885 still doesn't work, but for a second reason:
gimp_value_array_index() returns a GValue which pygobject automatically tries to
transform to the contained data. And unfortunately it doesn't know about our
GimpColorArray type so we end with unusable boxed type generic data.
2024-02-27 22:46:48 +01:00
Jehan eacb3ebf82 app, libgimp, pdb: gimp_layer_new() allows a NULL name.
Our core code allows a NULL name, so there is no reason not to. We just have to
explain the rules (basically: you don't choose the name!).
2024-02-26 23:19:55 +01:00
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 700d0c7c91 libgimp: add macros for GeglColor arguments for GimpProcedure. 2024-02-14 23:46:03 +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 65f8afee68 app, libgimp, libgimpbase, pdb: GimpColorArray as a typedef to…
… NULL-terminated array of GeglColor is now a boxed type usable in PDB.
2024-02-11 23:28:04 +01:00
Jehan b53da69f3c app, libgimp, pdb, plug-ins: canvas grid now using GeglColor. 2024-02-11 23:28:03 +01:00
Jehan dc1f5ea227 app, libgimp, pdb, plug-ins: GimpPalette are now GeglColor based. 2024-02-11 23:28:03 +01:00
Jehan b6856af9d8 app: GimpGradient now uses GeglColor.
I still see some limitations in GimpGradient, and in particular, they are still
always stored as RGB in GGR files. It would be nice if we could store the actual
color format. This way, if someone chooses a gradient stop as Lab or CMYK color,
that's what the gradient file would keep track of. But also even storing the
space of a color (instead of storing/loading always in sRGB, even though this
may still work fine as we store unbounded double values). This might warrant for
a v2 of GGR file format.

This commit also fixes loading of SVG gradient which was apparently broken
regarding hexadecimal color parsing.

Finally I improve gegl_color_set_alpha() by adding an alpha channel when the
initial format had none.
2024-02-11 23:28:03 +01:00
Jehan 916d032f67 app, libgimp*, plug-ins: GimpColorButton now space-invaded.
The invasion extended to some core widgets too, in particular GimpColorPanel (a
subclass of GimpColorButton). There was quite a lot of code depending on these
widgets.
2024-02-11 23:28:03 +01:00
Jehan b06fe36970 app, libgimp*, plug-ins, tools: settings custom check colors now space-invaded.
We pass 2 GeglColor through the wire now. Since it is passed very early
(when sharing the configuration), I had some issues with initialization
order of GEGL, and in particular when calling gegl_init() before
gegl_config() inside _gimp_config(), I had a bunch of such criticals:

> Plugin script-fu: GLib-GObject: CRITICAL: Two different plugins tried to register 'GeglOpPlugIn-transform-core'

Anyway in the end, I store the passed colors as raw bytes and strings in
the GPConfig object, and re-construct the GeglColor last minute in
_gimp_config().
2024-02-11 23:28:02 +01:00
Jehan 4879ab7b7f app, libgimp, pdb, plug-ins: move more code to GeglColor.
In particular, I updated the channel and quick-mask colors, padding colors and
more.
2024-02-11 23:28:02 +01:00
Jehan e992ca3e51 app, libgimp, pdb, plug-ins: GimpText* using GeglColor.
One of the big improvement in this commit is that text layers are now much
better at space accuracy. They were already space-aware, yet rendered as sRGB u8
only before being converted to the image's space. It means that text layers had
the following limitations:

* Any color out of sRGB gamut were trimmed.
* Precision was always 8-bit (even if the image was high-bit depth).

Now GimpTextLayout keeps track of its source space (for RGB and CMYK only, this
won't be as easy when we will support more backend, since Cairo has only RGB
support for image data) and the image TRC (in case it bypasses the color space's
TRB) and it draws within this gamut and space.
It means first that we are not limited to sRGB colors; we will draw text main
color in the full image gamut, with still 2 remaining limitations:

* Unbounded colors are impossible because Pango format (to color text) uses
  hexadecimal (so even with half/float images, you can't draw out-of-gamut text
  unfortunately).
* Main color precision is still 8-bit, yet a tiny bit better than before as we
  at least follow TRC (so we avoid some of the precision loss when converting,
  even though the bit-depth is still the biggest loss).

The outline color on the other hand is drawn through Cairo API entirely, in
float. This means that the outline color will now be without any precision loss.

Note that this depends on CAIRO_FORMAT_RGBA128F which is only available since
Cairo 1.17.2 which is not in Debian bookworm (our current baseline for GIMP
3.0). It means that the old precision will still happen with older Cairo
version, as determined by #if code at compilation.
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
Jehan f18266cb04 app, libgimp, pdb, plug-ins: gimp_context_[gs]et_foreground() now using GeglColor.
Also the color is internally stored as GeglColor, though there are still get
APIs and signals using GimpRGB.

The equivalent PDB functions are also changed to use GeglColor, same as app/
functions.
2024-02-11 23:28:02 +01:00
Jehan ecf4cfb3c5 app, libgimp, pdb, plug-ins: getting rid of some GimpRGB usage.
This is a first commit to really getting rid of GimpRGB within core and
PDB/plug-in code. This will make color conversion reliability a lot better as
GeglColor will handle conversions for us. The goal is that we should keep origin
color space (for instance when picking colors in a GimpPickable, or when storing
in the FG/BG colors or in paletters) until the last second and convert at use
only.
It's still very much work-in-progress.
2024-02-11 23:28:02 +01:00
Jehan 75efbf77d3 Issue #9790: reimplement gimp_drawable_[gs]et_pixel().
These 2 functions were removed in commit 89c359ce. They were in fact used and
clearly this historical API seems interesting (though we can likely do the same
thing using the drawable GeglBuffer, but this way is much easier).

This is now reimplemented using GeglColor instead of raw data.
2024-02-11 23:28:02 +01:00
Jehan 7814f011d0 libgimp*, pdb: support of GeglColor in the PDB.
Eventually this is meant to fully replace GimpRGB (as well as GimpHSV, GimpHSL
and GimpCMYK), both in libgimp and in core code, as part of both the space
invasion and the API rework. For this first commit, I keep this new object side
by side to GimpRGB.
2024-02-11 23:28:02 +01:00
Stanislav Grinkov 31b4e8122b
libgimp: new gimp_procedure_dialog_get_preview_from_drawable() function.
This allows plug-in developers to create GimpPreviewDrawable widgets
with the procedure dialog API.
2024-02-03 21:02:40 +06:00
bootchk 68cc92f939 libgimp: fix #10730 gimp_procedure_dialog_get_file_chooser precondition wrong 2024-02-01 11:39:00 -05:00
Jacob Boerema f78186e03b Get rid of old Windows specific defines
MINGW64
- uses 0x601 as value for _WIN32_WINNT. No need for us to define
it to that value or even lower values in some places.
This also gets rid of:  warning: "_WIN32_WINNT" redefined
- has 0x0502 for WINVER, so get rid of us setting it to 0x0500 in
gimp-app-test-utils.h. It also seems that the need to use G_OS_WIN32
has disappeared here.
- DIRECTINPUT_VERSION is 0x0800, no need for us to set it to that value.
- AI_ADDRCONFIG was apparently missing from the MINGW headers in the
past, but not anymore.
2024-01-24 12:10:00 -05:00
Jehan a489345e77 app: a few fixups to MR !958 (initial non-destructive editing).
- Do not leak allocated return value of gegl_node_to_xml_full().
- When merging layer effects, use gimp_drawable_filter_commit(), making
  sure we use the exact same code path as when applying layer effects
  destructively from the start. This also ensures that filters are
  properly removed from the filter stack (unlike
  gimp_drawable_merge_filter()), which was the reason why the rendering
  was wrong (hence getting the buffer without effects first, then
  reapplying it after was only a workaround to an actual bug).
- When removing a filter, verify the object still exists before doing
  anything with it. If this was the last reference, we don't want to
  call functions on this object. In gimp_drawable_filter_commit(), we
  set up a weak pointer. In gimp_drawable_filter_remove_filter() itself,
  we save the pointer to the filter's drawable before actual removal (as
  we don't want to dereference a freed object later on).
- export_merge_layer_effects() should merge filters recursively through
  layer groups.
- clean up the XCF code:
  * No need to wrap the effect pointers list into 2 zero offset. Only
    have one zero offset to indicate the list end.
  * Add the layer effect mask in the effect structure (not in the layer
    structure), similar as for layer masks.
  * Effect name and icon made as main data in the structure, not as
    properties.
2024-01-23 15:39:09 +00:00
Alx Sa e678a20951 core: Initial non-destructive editing implementation
This patch implements an initial form of
non-destructive editing. Filters now stay active
instead of being immediately merged down.
A new column is added to the layer tree view, which
can be clicked to show a pop-over menu.
Filters can currently be hidden/shown, edited, reordered,
deleted, and merged down from this pop-over menu.

Currently, this works on layers and layer selections only.
Plenty of room for improvement!
2024-01-23 15:39:09 +00:00
Alx Sa 21d24467ad scripts: Fix "Remove all Guides" script bug
Resolves #10651
The "Remove All Guides" script calls
gimp-image-find-next-guide, which per
its description can take in 0. However,
the parameter sets 1 as the minimum
value.
This patch fixes the range so that it can
accept 0, which enables the Remove All
Guides script to work again.
It also updates the script to the new
multi-layer aware API.
2024-01-19 11:17:36 +00:00
bootchk 0edf079d4e Fix wire contention for gradient data 2024-01-09 19:21:27 +00:00
bootchk 1553f8b88c Fix #10589 CRTICAL on empty label on resource chooser widget 2024-01-07 10:47:54 +00:00
Jacob Boerema 7a8f465b2d Issue #10588: enumerations for RotationType can't be used in Python
Due to GObject Introspection we can't have the last part of an
identifier start with a digit, since that part will be used in Python
as the identifier, and Python doesn't allow that to start with a digit.
e.g. GIMP_ROTATE_90 would be used in Python as
image.rotate(Gimp.RotationType.90)

To fix this we add DEGREES in front of the number, without a '_',
even though that looks ugly.
2024-01-05 13:28:49 -05:00
bootchk 1ccceccb01 Fix #10460 2023-12-11 15:09:07 +00:00
Jehan 10f86c69d1 libgimp: fixing annotations. 2023-12-08 21:18:03 +09:00
Idriss Fekir e8ad8af0f7 Fix fonts when exporting to pdf 2023-12-08 11:09:22 +00:00
bootchk 86921b45f4 Fix #9317
Also revise annotation 0=>%NULL and other wording changes.
2023-12-01 21:55:36 +00:00
bootchk 5a2c725bbb app/vectors : fix annotations on gimp_vectors_export_foo
Better describe what the functions do.

Also rename a variable vectors->path_list,
since the variable is type list of path.

No functional changes!!!
2023-12-01 21:55:36 +00:00
Jehan 2dcc8eea93 app, libgimp, pdb: remove the internal PDB function _gimp_pdb_get_data_size().
We exchange GBytes structs which know their own data size already and is much
safer.
2023-10-27 10:16:45 +00:00
Jehan 7a03b3ea09 libgimp: gimp_pdb_get_data() and gimp_pdb_set_data() are made internal.
These are not usable by plug-ins anymore which should store their data between
runs as arguments or aux arguments (in case of values which should be stored
from one run to another but are not really usable for non-interactive scripts).
These are per-plug-in (not polluting the whole process space with just random
strings as identifiers which could be used by other plug-ins) and even survive
restarts of GIMP.

I still keep these functions, but only internally, as they are used to store
settings of GimpAspectPreview, GimpDrawablePreview and GimpZoomPreview across
plug-in runs. Still I changed their API to set and return a GBytes directly
(mimicking the private PDB functions' API).
Also I remove gimp_pdb_get_data_size() which is useless when exchanging GBytes
directly.

Note that the 2 functions are still exported in the library, and only not
advertized through headers (so they are not really internal, just hidden), on
purpose, because we need to call them in libgimpui. So it is still relatively
easy for a plug-in to use them. Nevertheless I made clear in the function
documentation that these must not be considered public and could end up deleted
at any time. Any plug-in still trying to call these takes the risk of having
their code relying on unreliable API.
2023-10-27 10:16:45 +00:00
Jehan 410ff342bc libgimp: fix double free crash.
gimp_procedure_new_return_values() takes ownership of the passed GError (it
allows, among other things, to call it directly as return value). So we must not
try and free it afterwards.
2023-10-20 19:01:38 +02:00
Jehan c3e59b071f libgimp: allowing NULL passed as value to a GimpObjectArray PDB argument.
A NULL will be transformed into an array of size 0.
2023-10-20 19:01:38 +02:00
Jehan 8ca6f1ac5b libgimp: gimp_procedure_new_arguments() can now be made static. 2023-10-20 19:01:38 +02:00
Jehan 57ca3f4807 libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.

A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).

Concretely:

* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
  gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
  GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
  which don't have variable args support through a (rename-to
  gimp_procedure_run) annotation.
2023-10-18 17:11:20 +02:00
Jehan 701357c02f libgimp, plug-ins: no need for GType of argument in gimp_pdb_run_procedure().
Passing (name, type, value) triplets is actually useless because we can get the
type information from the procedure/config anyway. That only adds one more
verification to do. Let's just change the function so that we pass (name, value)
couples instead, pretty much like in `g_object_set()`.
2023-10-17 15:49:32 +02:00
Jehan 475dafcee4 libgimp, pdb: make gimp_pdb_run_procedure_array() internal.
Apart from all regenerated PDB files, this commit fixes the few manual usages in
libgimp too.
2023-10-16 22:12:08 +02:00
Jehan 70438028aa libgimp: PDB procedure arguments are not order-based anymore (API-wise).
As far as plug-in API is concerned, at least the calling API, order of arguments
when calling PDB procedures doesn't matter anymore.

Order still matters for creating procedures with standard arguments (for
instance, "run-mode" is first, then image, or file, drawables or whatnot,
depending on the subtype of procedure), but not for calling with libgimp.

Concretely in this commit:

- gimp_pdb_run_procedure_argv() was removed as it's intrinsically order-based.
- gimp_pdb_run_procedure() and gimp_pdb_run_procedure_valist() stay but their
  semantic changes. Instead of an ordered list of (type, value) couple, it's now
  an unordered list of (name, type, value) triplets. This way, you can also
  ignore as many args as you want if you intend to keep them default. For
  instance, say you have a procedure with 20 args and you only want to change
  the last one and keep the 19 first with default values: while you used to have
  to write down all 20 args annoyingly, now you can just list the only arg you
  care about.

There are 2 important consequences here:

1. Calling PDB procedures becomes much more semantic, which means scripts with
   PDB calls are simpler (smaller list of arguments) and easier to read (when
   you had 5 int arguments in a row, you couldn't know what they refer to,
   except by always checking the PDB source; now you'll have associated names,
   such as "width", "height" and so on) hence maintain.
2. We will have the ability to add arguments and even order the new arguments in
   middle of existing arguments without breaking compatibility. The only thing
   which will matter will be that default values of new arguments will have to
   behave like when the arg didn't exist. This way, existing scripts will not be
   broken. This will avoid us having to always create variants of PDB procedure
   (like original "file-bla-save", then variant "file-bla-save-2" and so on)
   each time we add arguments.

Note: gimp_pdb_run_procedure_array() was not removed yet because it's currently
used by the PDB. To be followed.
2023-10-16 21:56:37 +02:00
Jehan a101fd60eb libgimp: export again gimp_procedure_config_*_default() functions.
This partially revert some of the changes in commit 652a1b4388 because the
Windows CI suddenly failed because of this (my local build on Linux didn't have
any problem though) with:

> /usr/bin/x86_64-w64-mingw32-ld: libgimp/libgimpui-3.0-0.dll.p/gimpproceduredialog.c.obj: in function `gimp_procedure_dialog_save_defaults':
> /builds/GNOME/gimp/_build/../libgimp/gimpproceduredialog.c:2570:(.text+0x633): undefined reference to `_gimp_procedure_config_save_default'
> /usr/bin/x86_64-w64-mingw32-ld: /builds/GNOME/gimp/_build/../libgimp/gimpproceduredialog.c:2576:(.text+0x644): undefined reference to `_gimp_procedure_config_has_default'
> /usr/bin/x86_64-w64-mingw32-ld: libgimp/libgimpui-3.0-0.dll.p/gimpproceduredialog.c.obj: in function `gimp_procedure_dialog_load_defaults':
> /builds/GNOME/gimp/_build/../libgimp/gimpproceduredialog.c:2549:(.text+0xa2f): undefined reference to `_gimp_procedure_config_load_default'
> /usr/bin/x86_64-w64-mingw32-ld: libgimp/libgimpui-3.0-0.dll.p/gimpproceduredialog.c.obj: in function `gimp_procedure_dialog_constructed':
> /builds/GNOME/gimp/_build/../libgimp/gimpproceduredialog.c:368:(.text+0x11b1): undefined reference to `_gimp_procedure_config_has_default'

This is because these functions are used not only inside libgimp but also
across inside libgimpui. As a consequence, the build fails when linking
libgimpui.
2023-10-15 23:20:44 +02:00
Jehan f25e0448b2 libgimp, plug-ins: gimp_procedure_config_[gs]et_values() not public anymore.
This goes with our planned change of not making GimpProcedure arguments order
relevant anymore regarding the PDB API. In particular, it means we don't want to
use GimpValueArray for various procedure arguments API, but directly
GimpProcedureConfig objects.

This change will allow to add or reorder arguments in the future, so that we
won't have to create new PDB procedures when adding new arguments, while still
keeping PDB API stability.
2023-10-15 22:10:38 +02:00
Jehan 652a1b4388 libgimp: do not export private GimpProcedureConfig functions in the lib.
Some of these should not even be visible by libgimp and were just fine as static
as well! For the rest, I make them really private (not only with a private
header).
2023-10-15 17:32:04 +02:00
Jehan b2f633a26c libgimp: all _gimp_procedure_config_begin|end_*() functions made private.
Since now all GimpProcedure and subclasses run these before and after the
relevant run() functions, there is no need to keep these public.
2023-10-15 17:19:30 +02:00
Jehan 317be5f4ce Issue #3912: Object proxy management not happy with bindings.
We cannot be 100% sure generically (i.e. for all possible bindings available
with GObject Introspection) if bindings add their own reference to objects or
not. Clearly we have cases when they always do (Lua, Javascript), cases when
they do only in certain conditions (global Python variables) and cases when they
don't (Vala). What we know for sure is that in these script languages,
developers don't manually manage memory anyway. So the additional reference is
not their fact.

So let's just maintain a list of automatic memory managed binding languages,
among the few we officially support (i.e. the ones for which we have working
test plug-ins) and verify by executable extension if the plug-in is written in
one of these.
Both keeping a manually-updated list and verifying by extension are not so
pretty solution, but for now it will do.
2023-10-15 16:45:15 +02:00
Jehan d1297b8c2b libgimp: do not unref the additional object reference hold by a plug-in.
As explained in the comment above, the reference might actually be owned by the
binding code (not by the plug-in code) and therefore can still be released
afterwards. Freeing it now while we don't own the reference exposes us to
double-free crashes.
2023-10-15 11:53:27 +00:00
bootchk b3cd0f2539 Fix #10162 critical on null brush to prop chooser widget 2023-10-11 08:59:27 -04:00
Jehan dbaa8b6a1c app, pdb: make it possible to delete a color from a colormap if unused.
Until now, it was not really possible to delete a colormap color, but since we
now use GimpPalette, people would definitely try to do so. It just makes sense
to allow doing this, but only if the color is unused.

Additionally when we do this, all the pixels refering to bigger indexes will be
edited so that they continue to refer to the same color (bigger indexes are
shifted by -1). Therefore removing an unused color does not change the image
render.

I wondered if we might want more options, e.g. the ability to delete a color
without fixing indexes (i.e. that colors over the deleted color index would
shift to the next color). This would even allow to delete used colors (though
now the last index would have to be unused one, unless we cycle colors).
Yet I don't think this should belong to this basic API. The most expected
behavior when deleting a color from an image colormap is to fix all indexes
stored in pixels so that the image still shows the same. So that's what this
function will do in this generic usage.
2023-10-09 15:28:20 +02:00
Jehan d931098d36 app, libgimp, pdb: new gimp_image_get_palette().
This is meant to replace gimp_image_get_colormap() (see also #9477).

We likely won't need a gimp_image_set_palette() because we can simply edit the
image's colormap/palette with GimpPalette API now and it is directly updated.

For instance, the following code changes the first entry in the image palette to
red, immediately:

```python
i = Gimp.list_images()[0]
p = i.get_palette()
c = Gimp.RGB()
c.r = 1.0
p.entry_set_color(0, c)
```

For this to work fine, I added a new concept to GimpData, which is that they can
be tied to a GimpImage (instead of a GFile). Image palettes are not considered
internals, they are just tied to their image, therefore they can be edited by
scripts/plug-ins.

Additionally with this commit, editing an image's colormap from libgimp API also
generates undo steps now.
2023-10-06 22:04:34 +02:00
Jehan dfe803e882 Issue #9478: gimp_image_get_thumbnail_data() is not introspectable. 2023-10-05 22:58:29 +02:00
Jehan bdcd9cd38a libgimp, plug-ins: let's just call gegl_init() in gimp_ui_init().
bootchk had the case in commit 6781a35668. I again had it with gfig. I think it
just makes sense to init GEGL, especially as the errors are not that explicit
and that the plug-in code may not even call GEGL code directly (so it makes it
harder to guess).
2023-10-05 22:36:40 +02:00
Jehan eab9d8da28 app, libgimp, pdb: new PDB function gimp_fonts_get_by_name().
It returns all the fonts (possibly more than 1) with a given name. I left the
function gimp_font_get_by_name() as a utility when one don't want to choose (or
is not able anyway, e.g. a script with minimal information), though I wondered
if we should not simplify with a single function (the new one, which is the
correct one now that it is possible to have several fonts with a given name).

It is easy to test with fonts named the same. For instance I could find 2
different fonts, both named 'Holiday'. This call in the Python console returns
both:

> Gimp.fonts_get_by_name('Holiday')

As part of this commit, I also implemented resource arrays (or subtype arrays)
as PDB arguments and return types.
2023-10-02 23:22:49 +02:00
Jehan adce3179d4 app, libgimp, pdb: further fix gimp_text_get_extents_font() and improve…
… description.

- The returned value as width/height/etc. of the glyph extents (or bounding
  box), not "of the font" (which doesn't mean much).
- Adding some definition for ascent and descent. This text is straight out
  copied from Pango documentation comments in pango/pango-types.h.
- I don't see why we were negating the descent value. Let's keep the value sign
  as defined in Pango.
2023-10-02 21:30:20 +02:00
Jehan 24a85eebd6 Issue #9987: text related functions crash using string for font name.
- Fonctions were renamed: s/gimp_text_fontname/gimp_text_font/ and
  s/gimp_text_get_extents_fontname/gimp_text_get_extents_font/
- The size_type arguments were removed. Even in 2.10, this argument was marked
  as "dead" and ignored. It was only kept for API compatibility.
- The font name (string) was replaced by a GimpFont argument.

gimp_text_font() is easily tested in the Python console with:

> Gimp.text_font(Gimp.list_images()[0], None, 10, 40, "Hello World!", 1.0, True, 100, Gimp.context_get_font())

And gimp_text_get_extents_font() with:

> Gimp.text_get_extents_font("Hello World!", 100, Gimp.context_get_font())
2023-10-02 20:49:53 +02:00
Jehan 278f78fee6 libgimp: fix various GIR build warnings breaking HTML reference generation.
- a few inconsistent parameter naming;
- broken links to other symbols.
2023-10-02 00:25:12 +02:00
Jehan 8694f67918 libgimp: fixing duplicate gimppropwidgets section for introspection docs.
Fixing:

> [809/2421] Generating libgimp/GimpUi-3.0.gir with a custom command (wrapped by meson to set env)
> libgimpwidgets/gimppropwidgets.c:37: Warning: GimpUi: multiple comment blocks documenting 'SECTION:gimppropwidgets:' identifier (already seen at gimppropwidgets.c:23).
2023-10-02 00:05:10 +02:00
Jehan 1d50c81130 libgimp, plug-ins, extensions: gimp_image_procedure_new2() renamed gimp_image_procedure_new(). 2023-10-01 21:02:34 +02:00
Jehan 0273c1031c app, libgimp, pdb: gimp_text_layer_new() now uses GimpFont.
This function is not perfect and in particular doesn't seem usable with binding
because of GimpUnit being some weird mix between an enum and some kind of class.

So this will have to be fixed too. See #8900.
2023-10-01 21:02:34 +02:00
Jehan ea55b7a11a app, devel-docs, libgimp: updating gimp_text_layer_[gs]et_font() and new…
… function gimp_font_get_pango_font_description().

Also updating file-pdf-save which is the only plug-in using these right now.

Note that I am not fully happy with the new function
gimp_font_get_pango_font_description() because I experienced some weird behavior
in file-pdf-save which is that some fonts were wrong if this is called after
pango_cairo_font_map_set_resolution().
But let's say this is a first step looking for improvements.
2023-10-01 21:02:34 +02:00
Jehan 2f4d625059 app, libgimp, pdb: generate widgets for GIMP_PROC_ARG_LAYER|CHANNEL arguments.
I am using the same GimpDrawableChooser with an additional drawable_type
argument to only show the appropriate tab if we want to limit what can be
chosen.

None of our plug-ins actually use a GimpLayer or GimpChannel only arg so far,
but if we have some day, or if some third-party plug-ins want to have such arg,
now they quite easily can!
2023-10-01 21:02:34 +02:00
Jehan 4be1166982 app, libgimp: disable again cross-process transient setting.
After testing, setting a window as transient to another from another process is
still broken on Windows and it's hard to diagnose without using Windows
directly. Since it's not just broken, but it even hangs the whole process, which
is quite a blocker issue, let's disable again the whole code on Windows.
2023-10-01 21:02:34 +02:00
Jehan 1d16c1584f libgimp, pdb: (meson) fix building of libgimp/gimpenums.h inside the source tree.
This was not working properly and needed some external build script as well as
the stamp/bogus header trick like for other similar in-source generated code.

In the same time, I get rid of old meson code which was meant for when using
meson < 0.57.0 (since our requirement is now meson >= 0.59.0).
2023-10-01 21:02:33 +02:00
Jehan a40357a165 libgimp: take into account case when gtk_settings_get_default() returns NULL.
I believe it should not happen in normal GUI case (which is when you create a
GimpProcedureDialog). I had the issue while moving around some plug-in code and
moved dialog creation before gimp_ui_init() by mistake. The issue was not
obvious until I followed the trace inside libgimp. This would be even more
frustrating for plug-in developers so let's have a clear warning message giving
the possible plug-in crash reason.
2023-10-01 21:02:33 +02:00
Jehan 36576c7276 libgimp: new GimpDrawableChooser widget, associated propwidget function and…
… generation of such a widget for drawable arguments in PDB procedures.
2023-10-01 21:02:33 +02:00
Jehan 63a97d3be6 app, libgimp, pdb: new PDB group gimpdrawableselect.
Similarly to the various GimpResource select PDB calls, this allows to call a
core dialog in order to choose a drawable which will be returned back to the
calling plug-in.

This new GimpPickableSelect dialog is a subclass of GimpPdbDialog and uses the
same GimpPickableChooser widget as GimpPickablePopup, except that since it's
inter-process window management, it is harder to make a popup positioned
accurately relatively to a parent (especially on Wayland). This is why it's a
separate widget as a simpler dialog (which we will still try to make transient
as much as possible across platforms).
2023-10-01 21:02:33 +02:00
Jehan 62a3889617 libgimp: rename Gimp*SelectButton widgets to Gimp*Chooser.
This name was really irking me because it's not a button (anymore? Maybe it used
to be just a button). Depending on the specific widget, it will have several
sub-widgets, including a label. And it can theoretically even be something else
than a button.

So let's just rename these widgets with the more generic "chooser" name.
2023-10-01 21:02:33 +02:00
Jehan 55d6f6c26e libgimp: move GimpFont, GimpGradient and GimpPalette to their own file.
Even though we don't have specific additional functions right now, it's just
much more cleaner this way.
2023-10-01 21:02:33 +02:00
Jehan 457f52a6d1 app, libgimp, pdb: new gimp_pattern_get_buffer() and improved GimpPatternSelectButton.
Similar to the latest commits for GimpBrush:

- gimp_pattern_get_buffer() returns a GeglBuffer and allow getting a scaled
  version of the pattern.
- Old gimp_pattern_get_pixels() is made private.
- Moved GimpPattern into its own file and store the buffer to avoid re-querying
  it through PDB continuously.

No as for the widget to select a pattern:

- Preview frame ensured to be square.
- Default size increased.
- Drawing code using the new gimp_pattern_get_buffer().
- Cleaned up code.
2023-10-01 21:02:33 +02:00
Jehan 330d05e2fc libgimp: gimp_brush_get_buffer() returns a buffer with alpha.
So what I realized was that the core was sending contents without transparency.
Actually the mask was our transparency channel here. Since in most use cases,
what you want to do when you request a brush buffer is to be able to draw it
somewhere, having a buffer already with alpha is much better, even more because
by default, it looks like background color is black which is possibly not what
you expect usually from a brush preview.

If someone wants absolutely no-alpha, it's easy to get rid of the channel. It's
simply better that the default behavior is the most expected use case.
2023-10-01 21:02:33 +02:00
Jehan 0e6c06044c libgimp, plug-ins: massively improve GimpBrushSelectButton.
- Increase the default size to 40x40 and multiply it by the current window scale
  factor to have decent preview size.
- Make the brush preview always square with a GtkAspectFrame: even though
  brushes are not necessarily square, this is a much more obvious size rather
  than letting GTK choose a random allocation size which ends up very weird
  looking.
- Scale down the brush to the biggest possible dimensions which fit the square
  preview area (if the brush native size is already smaller, I don't scale up
  though) while keeping aspect ratio: previous implementation was really weird,
  as we were only seeing a tiny corner of much brushes as we weren't scaling
  them down. Obviously I use new gimp_brush_get_buffer|mask() functions for
  this as it supports scaling.
- Implement drawing color brushes too: the previous implementation was only
  drawing the brush mask, which was absolutely not what would be expected for
  such brushes.
- Add a white background behind color brushes with transparency.
- Simplify and clean up the code.

One of the consequences of this new implementation is obviously that it's
mandatory to call gegl_init() when using this widget.
2023-10-01 21:02:33 +02:00
Jehan 1ff9c12b1e libgimp, pdb: replacing gimp_brush_get_pixels() by gimp_brush_get_buffer()…
… and gimp_brush_get_mask().

gimp_brush_get_pixels() was a bit crappy, returning raw data with only
dimensions and bpp to go with (no color model/space, no bit depth…). So the
assumption is that we work with 8-bit per channel data, possibly with alpha
depending of number of channels as deduced from bpp, and very likely in sRGB
color space. It might be globally ok with many of the brush formats (and
historical brushes) but won't fare well as we improve brush capabilities.

- gimp_brush_get_pixels() is in fact made private.
- The 2 new functions are using this old PDB call _gimp_brush_get_pixels() to
  construct buffers. This has some limitations, in particular that it returns
  only 8-bit per channel sRGB data, but at least the signature won't change when
  we will improve things in the future (so if some day, we pass fancy brushes in
  high-bit depth, the method will stay the same).
- This new implementation also allows scaling down the brush (keeping aspect
  ratio) which is useful when you need to fit a brush preview into a drawing
  widget.
- Current implementation stores the buffers at native size in the libgimp's
  GimpBrush object, hence save re-querying the core every time you need an
  update. This can be improved as current implementation also means that you
  don't get updates if the brush changed. This should handle most common use
  cases for now, though.
- Also with this change, I move GimpBrush class implementation into its own
  dedicated file.
2023-10-01 21:02:33 +02:00
Jehan ead5d01d27 libgimp*, plug-ins: reorganize the resource property choosers.
- Move the property widget functions for GimpResource properties into a new
  libgimp/gimppropwidgets.[ch] file. This mirrors the files
  libgimpwidgets/gimppropwidgets.[ch] which are for more generic property types.
- Rename the functions gimp_prop_chooser_*_new() to gimp_prop_*_chooser_new().
- gimp_prop_chooser_factory() doesn't need to be public.
- Add a label to GimpResourceSelectButton, make so that the
  gimp_prop_chooser_*_new() functions set the property nick to this label and
  add this label to the size group in GimpProcedureDialog.
2023-10-01 21:02:33 +02:00
Jehan 538cdea996 libgimp: make GimpResourceSelectButton abstract.
Rather than *saying* it is abstract, make it really so with
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE().
2023-10-01 21:02:33 +02:00
Jehan d84c4d763b app, libgimp, pdb: all gimp_*_popup() PDB calls now take a resource object as…
… argument (not a resource name).
2023-10-01 21:02:33 +02:00
Jehan b578fd8cf1 app, libgimp, plug-ins: a lot of cleanup in GimpResourceSelect* code.
- Removing useless or redundant code.
- Simplifying various logics.
- Using GimpResource directly in temporary PDB procedures, not resource names.
- Better cleanup of the core resource chooser when the plug-in dialog quits (we
  need it to ask core to close also any visible resource chooser dialog).
- Replace the "Close" button by more common OK/Cancel. In particular, the
  GimpPdbDialog now properly keeps track of the initial object and when hitting
  "Cancel" (or Escape key), this initial object is set back.
- Clean up some of the comments, especially when the code is self explanatory.

There is still much more to clean and improve, but it's a first welcome step.
2023-10-01 21:02:33 +02:00
Jehan 19a005ad0f libgimp: properly free resources from the config.
Found by the definitely useful libgimp warnings:

> gimp_plug_in_destroy_proxies: ERROR: GimpPattern proxy with ID 13 was refed by plug-in, it MUST NOT do that!
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 f759c1e3d9 app, libgimp, pdb: use objects in various gimp_*_set_popup() functions. 2023-10-01 21:02:33 +02:00
Jehan 6aeb456e17 app, libgimp, pdb: add a parent_window parameter to gimp_*_popup() PDB calls.
Brush, font, gradient, palette and pattern choices are currently chosen through
a dialog created by the core, which then returns the user choice to the calling
plug-in. This has the unfortunate consequence of having a pile of likely at
least 3 windows (main GIMP window by core process, plug-in window by plug-in
process, then the choice popup by the core process) shared in 2 processes, which
often end up under each other and that's messy. Even more as the choice popup is
kinda expected to be like a sub-part of the plug-in dialog.

So anyway, now the plug-in can send its window handle to the core so that the
resource choice dialog ends up always above the plug-in dialog.

Of course, it will always work only on platforms where we have working
inter-process transient support.
2023-10-01 21:02:33 +02:00
Jehan 9a57ab54e9 app, libgimp*: window handle on Windows have the type HANDLE.
Instead of passing a guint32, pass the proper type, since our the HANDLE type
can be 64-bit on Windows (according to links I found).
I was hoping it might be the reason for the breakage under Windows, though I
also found Microsoft documentation saying that the 64-bit handle can be safely
truncated: https://learn.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication?redirectedfrom=MSDN

Nevertheless I'd appreciate testing again from NikcDC or anyone else, as I
reactivated setting transient between processes on Windows.

Note that I also pass the proper types on X11 now (Window), even though guint32
worked fine. Better be thorough.
2023-10-01 21:02:33 +02:00
Jehan 58b3b14082 app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:

In core:

- get_window_id() virtual function in core GimpProgress is changed to
  return a GBytes, as a generic "data" to represent a window differently
  on different systems.
- All implementations of get_window_id() in various classes implementing
  this interface are updated accordingly:
  * GimpSubProgress
  * GimpDisplay returns the handle of its shell.
  * GimpDisplayShell now creates its window handle at construction with
    libgimpwidget's gimp_widget_set_native_handle() and simply return
    this handle every time it's requested.
  * GimpFileDialog also creates its window handle at construction with
    gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
  GimpProgress as argument (instead of a guint32 ID), requests and
  process the ID itself, according to the running platform. In
  particular, the following were improved:
  * Unlike old code, it will work even if the window is not visible yet.
    In such a case, the function simply adds a signal handler to set
    transient at mapping. It makes it easier to use it at construction
    in a reliable way.
  * It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
  GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.

PDB/libgimp:

- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
  now return a GBytes to represent a window handle in an opaque way
  (depending on the running platform).

In libgimp:

- GimpProgress's get_window() virtual function changed to return a
  GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
  get_window_handle(). It creates its handle at object construction with
  libgimpwidget's gimp_widget_set_native_handle() and the virtual
  method's implementation simply returns the GBytes.

In libgimpUi:

- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
  removed. We should not assume anymore that it is possible to create a
  GdkWindow to be used. For instance this is not possible with Wayland
  which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
  gimp_window_set_transient() now use an internal implementation similar
  to core gimp_window_set_transient_for(), with the same improvements
  (works even at construction when the window is not visible yet + works
  for Wayland too).

In libgimpwidgets:

- New gimp_widget_set_native_handle() is a helper function used both in
  core and libgimp* libraries for widgets which we want to be usable as
  possible parents. It takes care of getting the relevant window handle
  (depending on the running platform) and stores it in a given pointer,
  either immediately or after a callback once the widget is mapped. So
  it can be used at construction. Also it sets a handle for X11 or
  Wayland.

In plug-ins:

- Screenshot uses the new gimp_progress_get_window_handle() directly now
  in its X11 code path and creates out of it a GdkWindows itself with
  gdk_x11_window_foreign_new_for_display().

Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.

There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(

Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-10-01 21:02:33 +02:00
Jehan 77a30bfd28 app, libgimp: core loads thumbnail from metadata if no GimpThumbnailProcedure…
… is set.

The order for thumbnail creation in gimp_imagefile_create_thumbnail() is now:

1. If there is a GimpThumbnailProcedure, it is run first.
2. Otherwise we check if a thumbnail is in the metadata.
3. As last resort, we just load the full image.

Part of the fix was to copy gimp_image_metadata_load_thumbnail() into the core
code. I have been wondering if we could not drop the same function from libgimp
and remove the GimpThumbnailProcedure frome file-jpeg, since it just uses the
metadata thumbnail and it is the only plug-in using this code.
Also it is much faster to run this in core and it's generic function which makes
thumbnail loading from Exif data working for every format supported by Exiv2.

On the other hand, the file-jpeg thumbnail procedure also gathers a few more
useful information, such as the color model (in a reliably manner, since based
on JPEG header, unlike from metadata which may be wrong).
2023-10-01 21:02:33 +02:00
Jehan fa67a6ce0e libgimp, plug-ins: properly document the return values of GimpThumbnailProcedure.
The various information (width, height, image type and number of layers) are
those of the full image, not of the thumbnail. Make it clear in the docs of
GimpRunThumbnailFunc.

Additionally:

- file-xmc was returning the proper information but variables were wrongly
  named, which was confusing.
- Fix file-ico thumbnail proc which was returning the thumbnail width/height.
- In file-darktable, initialize width/height to 0 so that we just don't show any
  size when we don't get the information. It's better not to show anything than
  completely wrong information (the thumbnail target size).
2023-10-01 21:02:33 +02:00
Jehan ed98b990c5 plug-ins, libgimp: GimpRunThumbnailFunc now uses a GimpProcedureConfig rather…
… than a GimpValueArray.

Similar to other GimpProcedure, move to using a config object. A difference is
that thumbnail procedures are always run non-interactively.

Also fixing WMF load thumbnail procedure: the dimension computation was wrong
when the image was wider than tall.
2023-10-01 21:02:32 +02:00
Jehan 9e2a7e8759 libgimp, plug-ins: rename gimp_load_procedure_new2() as gimp_load_procedure_new().
All C load procedures are now moved to the new API.
2023-10-01 21:02:32 +02:00
Jehan af644b1950 libgimp, libgimpbase: new gimp_load_procedure_new2() for run() function using…
… a GimpProcedureConfig for arguments.

This also factorizes the code to load metadata. By default, a GimpLoadProcedure
will try and load metadata from a file (if Exiv2 knows the format). The run()
function will be allowed to edit the GimpMetadata object but also the load flags
before it is actually attached to the image, allowing plug-ins to have custom
metadata handling code when needed.
2023-10-01 20:52:02 +02:00
Jehan 555c428b70 libgimp: new utility method gimp_procedure_config_get_choice_id().
This is just a method to simplify transforming a GimpChoice argument into an
enum value, which is easier to deal with, in C. It also allows to benefit from
switch() warnings or the like to make sure no cases are missing.
2023-10-01 20:52:02 +02:00
Jehan 9a0cfa67bf libgimp: generate a list of possible choices for a GimpChoice argument.
Developers won't have to maintain manually a list of the possible values in the
help string. It can now be generated from the GimpChoice and will be therefore
ensured to always be up-to-date, and nicely formatted.

I also add some pango markup to the type helper texts to differentiate it from
the main argument docs.
2023-10-01 20:52:02 +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 1dc5635d32 libgimp: support all subtypes of GFile.
In particular if a GFile is created with g_file_new_for_path(), it will be a
GLocalFile. We need this to be supported too.
2023-10-01 20:52:02 +02:00
Jehan fcc810d7d3 libgimp, plug-ins: rename to gimp_save_procedure_new().
Also the mimetype is already set by gimp_file_procedure_set_mime_types() so
transform the mimetype argument into an export_metadata argument.
2023-10-01 20:52:02 +02:00
Jehan 92e77a4541 libgimp: add ability to sync a label to a string property of a procedure.
Now gimp_procedure_dialog_get_label() can work both with an existing property ID
or a new property ID. In the former case, it will simply sync the label with the
procedure argument, which will make it easy to update the label contents. In the
latter case, it just initialize with the provided text.
2023-10-01 20:52:02 +02:00
Jehan 51b14a7978 libgimp: fix object memory management in GimpPlugIn.
The expectation of 2 references per object in gimp_plug_in_destroy_proxies() was
wrong. It is true during most of the plug-in life, because both the
GimpProcedure and the GimpPlugIn have a hash-table keeping their own reference
to it, except that in gimp_plug_in_pop_procedure(), we release the reference
owned by the procedure with _gimp_procedure_destroy_proxies() first. So at this
point of the object life, its reference count is supposed to be 1.

The source of the bug was in fact in _gimp_plug_in_get_*() (where * can be
display, image, item or resource) which was behaving differently the first time
it is called for an object with the successive calls. In the first call only, it
was creating then refing into the table (so the object started directly with 2
references) whereas on successive calls, it just returned the hashtable-looked
up reference. In other words, it behaved as a (transfer full) on the first call
and (transfer none) on successive calls. And so did all public API which were
making use of this infrastructure (in particular gimp_*_get_by_id() functions).
2023-10-01 20:52:01 +02:00
Jehan 48f0ac3ad5 libgimp: release leaked reference to resource object.
The widget_creator_func() given to gimp_prop_chooser_factory() will create an
object which will take its own reference. We must release the one we got with
g_object_get().
2023-10-01 20:52:01 +02:00
Jehan dac29b17a8 libgimp: some memory leak fixed. 2023-10-01 20:52:01 +02:00
Jehan da7e8f3388 libgimp: new gimp_save_procedure_new2() meant to replace gimp_save_procedure_new().
Metadata handling is also integrated in this API:

* while giving a possibility to disable metadata saving if you want to do it
  yourself (e.g. in file-heif), by setting a NULL MimeType;
* and the GimpMetadata object is added as run() argument, allowing one to edit
  the metadata during the run, while still letting the infrastucture handle the
  save (e.g. in file-jpeg);
* or to save intermediate metadata with gimp_procedure_config_save_metadata()
  (e.g. in file-tiff).
2023-10-01 20:52:01 +02:00
Jehan 602345143f libgimp: more removal of over-refing. 2023-10-01 20:52:01 +02:00
Jehan f37c3c42c7 libgimp: simplify GimpFileProcedure public API with G_DECLARE_DERIVABLE_TYPE().
While we definitely should not use this inside app/, because having the private
structure easily accessible as a member is very convenient, it is clear that it
makes for a much nicer public signature. Also the priv member is of no help to
third-party developers using this API to make plug-ins and is better hidden in
such a case.
2023-10-01 20:52:01 +02:00
Jehan 5cc1c898d7 libgimp, plug-ins: enhance gimp_procedure_dialog_get_label() with markup and…
… mnemonic abilities.
2023-10-01 20:52:01 +02:00
Jehan 2f1c569249 libgimp: new gimp_procedure_dialog_fill_paned() function. 2023-10-01 20:52:01 +02:00
Jehan 334febdebb libgimp: new gimp_procedure_dialog_fill_notebook*() functions. 2023-10-01 20:52:01 +02:00
Jehan fc9a720b31 libgimp: some debug printing for plug-in developers.
This will be useful for plug-in developers but also for us. Seeing we leak the
config object is often a good indication that something is wrong in our handling
of internal references (since everything relies on the config object in plug-ins
now, in particular all the GUI).
2023-10-01 20:52:01 +02:00
Jehan e6e3545959 libgimp: all the over-reffing was wrong.
I was clearly confused when I wrote this. The sinking part matters to take
ownership of a reference in the widgets table, but we don't need to ref widgets
again before inserting them in containers. We were leaking widgets and as a
consequence the config object (and as a second consequence, some objects such as
resources for resource-selection widgets).
2023-10-01 20:52:01 +02:00
Jehan 8c8c64a9ee libgimp: temporary gimp_image_procedure_new2() until port is over.
Same as with gimp_procedure_new2(), I will end up renaming the function to
gimp_image_procedure_new() once all usage of this function will have been ported
to the new function using GimpProcedureConfig instead of GimpValueArray
arguments.
2023-10-01 20:52:01 +02:00
Jehan 2b38a2df86 libgimp, plug-ins: rename gimp_procedure_new2() as gimp_procedure_new() and…
… remove the latter.

Now all GimpProcedure use this new implementation with use a config object.
2023-10-01 20:52:01 +02:00
Jehan f6f622b93d libgimp: port 2 usages of gimp_procedure_new() to gimp_procedure_new2().
The one in GimpResourceSelect is a very nice example of why using config objects
is much nicer, getting arguments by their name instead of an index (which in
this case had to be tracked down by a private function to handle different
cases).
2023-10-01 20:52:01 +02:00
Jehan a2acf24ecb libgimp, plug-ins: Script-fu scripts now use gimp_procedure_new2() too.
Also in gimp_procedure_config_begin_run(), make sure we sync the arguments with
the config object first thing, even in interactive and with-last-vals case
(where the args may be further overridden). This was especially important for
Script-fu scripts as the image and drawable were not provided separately, so we
need to make sure that the config file has the right values.
2023-10-01 20:52:01 +02:00
Jehan 5d3112a2f1 plug-ins, libgimp: move GimpBatchProcedure's run function to use config objects.
Also port more script-fu procedures to gimp_procedure_new2(), which were sharing
some code with the script-fu batch procedure.
2023-10-01 20:52:01 +02:00
Jehan c09711beaa libgimp: the default run (if no run-mode parameter) should be non-interactive.
Otherwise we will always try to reuse previous values or use the default,
bypassing the actual passed values.

I encountered this issue while porting file-glob and realizing that the
"pattern" argument was always passed to NULL, ignoring the explicitly set
pattern.

When a procedure has no run-mode argument, we should simply not assume anything
and use the passed arguments (which is what the non-interactive mode does).
2023-10-01 20:52:01 +02:00
Jehan 60aeff5623 libgimp: new gimp_procedure_dialog_set_ok_label() function.
This allows to set a custom label for the OK button.
2023-10-01 20:52:01 +02:00
Jehan 59edcde06f libgimp: new function gimp_procedure_dialog_set_sensitive_if_in().
This function allows to change the sensitivity of a widget depending on the
value of another property.
We already had gimp_procedure_dialog_set_sensitive() except it was only syncing
with a boolean property, whereas the new function can compare with any property
type.
2023-10-01 20:52:01 +02:00
Jehan edab39a868 libgimp: fix the sometimes wrong run-mode value in the config object. 2023-10-01 20:52:01 +02:00
Jehan 7ab87d2b15 Issue #50: new gimp_procedure_new2() which automatically stores procedure config.
This new function is meant to replace gimp_procedure_new() when all plug-in
usage will have been switched.

This function creates the GimpProcedureConfig object on behalf of the plug-in
and calls gimp_procedure_config_begin_run() and gimp_procedure_config_end_run().
This way we ensure that all plug-in calls with successful result are properly
stored without asking the developer not to forget to call these (if a "good
practice" is in fact something we request to do every time, especially for good
user experience, we might as well make it rather a core process).

Advantages:

* Better interactive experience: using any plug-in will result in saved
  previously used settings.
* for developers, working on config objects is also much more comfortable than
  working on GValueArray;
* step forward for the future macro infrastructure: if we can ensure that all
  plug-in calls are properly logged, then we can replay plug-in actions, in
  NON_INTERACTIVE with the same settings.
2023-10-01 20:52:00 +02:00
Jacob Boerema b53f7c10e4 libgimp: fix #9902 Critical when calling gimp_text_layer_new ...
from plug-in

I get a critical error when calling gimp_text_layer_new and the function
doesn't return a GimpTextLayer:

(file-psd:47120): LibGimp-CRITICAL **: 16:00:59.035:
gimp_gp_param_to_value: type name GimpTextLayer is not registered

Adding the above line to libgimp/gimp.c fixes the problem.
2023-08-31 21:42:13 +00:00
Sabri Ünal b7ab467cde plug-ins: Mark JPEG export dialog related strings translatable
These strings are related to JPEG export dialog which
some strings seem not marked as translatable.
2023-08-25 19:41:42 +00:00
Anders Jonsson 369a7782a1 app, libgimp, libgimpbase: fix gi-docgen rendering 2023-08-12 14:52:52 +00:00
lillolollo 4d7c2ab2b9 libgimp: missed break 2023-08-10 15:20:54 +00:00
Jehan 22f120333f Issue #9655: both @blurb and @help arguments should be localized.
Looking further, the @help is only used in gimp_proc_view_new() so far (for the
Procedure Browser) where the blurb and argument descriptions are already
localized. It makes no sense to only keep this in English. So let's ask to have
both arguments translated.

Now clearly we should not ask for @help to be mandatory. Very often, it makes no
sense to have a longer help string (the small blurb and the few arguments may be
very self-explanatory). So I make this argument nullable.

There is only the @help_id which I wonder if we could not have a simpler
function gimp_procedure_set_documentation_uri(). Indeed while having a unified
infrastructure with a XML summary and help IDs and whatelse makes sense for GIMP
as a whole, I think that many third-party plug-ins would work much better with a
very simple direct URL. Or it could even be a GFile to a local file (for
plug-ins which want to embed their documentation in the plug-in folder for
instance). To be continued…
2023-07-27 22:59:51 +02: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 38c717b149 app, libgimp, pdb: private _gimp_resource_get_by_identifiers() PDB function.
This finds the core resource knowing its type, name, collection and internal
state (in other words, the values returned by _gimp_resource_get_identifiers()).
2023-07-27 15:32:16 +02:00
Jehan fe58de7f81 app, libgimp, pdb: new private PDB call _gimp_resource_get_identifiers(). 2023-07-27 15:30:14 +02:00
Jehan 41ed091879 app, libgimp, pdb: add an internal gimp_context_get_resource().
This will be useful in an incoming code to serialize GimpResource PDB arguments.
2023-07-27 15:27:53 +02:00
Jehan d439e9ff5c app, libgimp, pdb: factorize a bunch of similar code into gimp_pdb_get_resource().
Rather than reimplementing the same checks for every possible resource data
type, just do it once and redirect to the correct factory container.

For the libgimp API, we leave per-type functions `gimp_*_get_by_name()` (where *
can be brush|gradient|font|palette|pattern so far), but internally they all use
gimp_pdb_get_resource().

Note that eventually we want these functions to return a list of resources as it
should be possible to have several resources of a given type with the same name
(since they are made by third-party who might have had the same idea of a name).
2023-07-27 15:25:32 +02:00
Jehan ba5b4794e1 libgimp: remove outdated recommendation about sending non-localized strings.
gimp_plug_in_set_translation_domain() was removed in GIMP 2.99.12. Plug-ins are
now fully responsible for their own localization.
2023-07-22 16:17:24 +02:00
Jacob Boerema 18408ce966 app, libgimp, libgimpwidgets, plug-ins, etc: rename behaviour to behavior
We use US English which uses behavior. So we replace all occurrences of
behaviour.

Most notable is File Open behavior in preferences. Besides that several
mentions in function documentation and a few in comments.
2023-07-21 15:35:23 -04:00
Jehan dfdb698ce0 libgimp: update function's documentation. 2023-07-14 17:02:19 +02:00
Jehan ae29736ee0 app, libgimp, pdb: fix annotations for resources as return values.
Resources are stored by the plug-in infrastructure and their memory should not
be managed by plug-in code.

My commit 4f69995b46 was crappy and modified a generated function. I was just
too tired with all the heat in here, I guess!
2023-07-11 16:16:21 +02:00
Jehan 4f69995b46 libgimp: fix annotations for gimp_brush_get_by_name().
Similarly to how we handled image items, all resources are handled and stored by
the plug-in infrastructure and should not be destroyed. This wrong annotation
was triggering bindings to unref resources when going out of scope, hence
crashing plug-ins.
2023-07-11 12:00:22 +02:00
Jacob Boerema 97a71cfd41 libgimp: fix resource leak in gimpimagemetadata-save 2023-07-10 14:19:07 -04:00
Jehan 274b734e61 libgimp: fix double free crash in gimp_drawable_get_thumbnail(). 2023-07-01 23:24:33 +02:00
bootchk ef662fa02a libgimp: fix #9304 API TextLayer
Adds needed change missing in commit that added class GimpTextLayer
2023-06-21 21:54:04 +00:00
Alx Sa 6be4549e46 libgimp: new gimp_procedure_get_size_entry ()
This allows plug-in developers to create GimpSizeEntry
widgets with the procedure dialog API.
2023-06-21 14:05:19 +00:00
Jehan 4136166d12 libgimp: fix gimp_drawable_get_sub_thumbnail_data().
Since commit 89c359ce47, it's supposed to return a GBytes, yet it was returning
raw data (probably intermediate hacking state which was not properly cleaned
up).

It was crashing for instance GimpDrawablePreview widgets at drawing time.
2023-06-21 00:12:20 +02:00
Michael Natterer a858474fe8 pdb: GimpResource: add is_editable(), rename(), duplicate(). delete()
and remove the API from its subclasses.
2023-06-06 16:33:36 +02:00
Michael Natterer 2adb283077 libgimp: add API docs for gimp_resource_get_by_name() 2023-06-05 14:41:57 +02:00
Michael Natterer bb7ed43eac app: make the GimpResource dummy class the parent of GimpData
It does absolutely nothing except sitting there, providing an is-a
relation (both ways because GimpData is its only subclass). This will
simplify having more libgimp API on GimpResource, without having to
add different PDB code for app and libgimp.
2023-06-05 14:33:23 +02:00
Michael Natterer a4920611d1 libgimp: remove gimpparamspecs-resource.h
and merge it into libgimp/gimpparamspecs.h
2023-06-05 13:06:01 +02:00