Commit graph

3208 commits

Author SHA1 Message Date
Jehan
309f137ae0 libgimp: gimp_quit() is now deprecated. 2026-04-07 20:08:48 +02:00
Jehan
a85e5286fd Issue #14681: Permission denied opening image - /tmp/gimp/3.0/ cannot be shared.
Let's create the folder returned by gimp_temp_directory() ourselves, the
first time this function is called, using a randomized name. This will
ensure that we won't conflict with another user running GIMP on the same
machine if using the base /tmp/ (which is usually the case on Linux).

Furthermore, since we create the temp folder at this level, we will also
delete it when quitting (but only if it's empty, as it should). Also I
use a single-level folder above the generic temporary directory, this
way, it's easier to track and we don't have to delete 2 levels of
directories anymore.

When the environment variable GIMP3_TEMPDIR is set though, we do not
create the folder, nor do we try and delete it.
2026-04-06 16:29:40 +02:00
Jehan
7dc8fefbfd app, libgimp, pdb, plug-ins: new gimp_resources_loaded() function.
And use the function in script-fu. While we want wrong resource names to
trigger WARNINGs in Script-Fu scripts and plug-ins (because these can be
considered as a bug), we don't want it to happen when the resource is
not loaded on purpose (mostly it means that we run GIMP with --no-data
or --no-fonts). This was happening in our own builds when running GIMP
through the in-build-gimp.py script and that was always very annoying.

Now in such a case, we will only output an INFO message on stderr (it's
still a good idea to warn about this, because if we imagined someone was
running a script non-interactively, which called one of these
procedures, they may have relied on the default value of some arguments.
Therefore they'd want to know about such a behavior change).
2026-04-06 16:29:40 +02:00
Bruno Lopes
9df9cf7ed1 libgimp: Fix last MSVC warning 2026-04-01 08:43:00 -03:00
Bruno Lopes
7ce3ed457e app, libgimp*, modules: More type <> casting fixes 2026-03-31 16:27:25 -03:00
Bruno Lopes
fe185577e2 libgimp: Use new datetime functions to fix CRT_INSECURE_DEPRECATE warnings 2026-03-31 13:31:33 -03:00
Bruno Lopes
3c71c42c31 app, app-tools, libgimp: Use freopen_s on Windows to fix CRT_INSECURE_DEPRECATE 2026-03-31 13:31:33 -03:00
Ondřej Míchal
6aaefa73c2 libgimp: Sanitize path separators in menu paths
Technically not problematic but when inspecting using Plugin Browser,
the resulting hierarchy is confusing because it sometimes shows actions
to be inside "empty" directories if there are doubled path separators or
trailing ones. Let's not depend on the user to do this correctly when we
can do it for them.
2026-03-31 18:02:44 +03:00
Bruno Lopes
2066844166 app, lib*, plug-ins: Use sscanf_s on Windows to fix CRT_INSECURE_DEPRECATE warns 2026-03-30 22:31:57 -03:00
Bruno Lopes
ae339e180e libgimp: Support GLib 2.87.3 platform-specific introspection 2026-03-30 12:31:37 -03:00
Bruno Lopes
f4f1baf5ef app, libgimp, libgimpbase, libgimpwidgets, plug-ins: Add macro to unused code
This fixes Apple Clang warnings about:

- xdiff
- ydiff
- gimp_ui_get_foreign_window
- locale_parser_parse
- use_app_menu
- gimp_unique_dbus*
- transient_set
- gimp_get_foreign_window
- support
2026-03-29 17:19:42 -03:00
Alx Sa
43c57af5d7 libgimp:
Resolves #16102
The active selection can impact the other NDE filters
when exporting, resulting in empty spaces displayed when
the filter is outside the area of that selection.

Similar to what we do with XCF saving, we temporarily save
and clear the selection in the duplicated image. Then we
merge the filters and restore the active selection.
2026-03-28 05:09:31 +00:00
Alx Sa
5b5a39390a libgimp: Connect ResourceChooser mnemonics to button
While it's possible to set mnemonics on GimpResourceChooser
properties (brushes, gradients, palettes, etc), the accelerator
itself wouldn't work because the label wasn't connected to the
button widget.
The buttons are created externally and connected in
_gimp_resource_chooser_set_clickable (). This patch adds a call
to gtk_label_set_mnemonic_widget () if there is a label, so that
pressing the accelerator key on the label triggers the button
click function.
2026-03-18 23:49:46 +00:00
Alfred Wingate
4828b2d3f7 tools: allow use of NM env variable
Bug: https://bugs.gentoo.org/968162
Signed-off-by: Alfred Wingate <parona@protonmail.com>
2026-03-15 18:24:30 -03:00
Jehan
b698354d54 libgimp: improve docs for the GimpImage profile API.
A few things were not clear, if not even kinda wrong.

E.g. the returned effective color profile docs was confused about
returning a preferred profile; or saying that an image can have no color
profile assigned is confusing (it's true, but it sounds like it means
the image has no profile — which makes no sense —; whereas it actually
means the image uses a built-in profile).
2026-03-11 22:09:20 +01:00
Jehan
483a2e0eed app, libgimp, pdb: fix setting NULL to gimp_image_set_color_profile() and…
… gimp_image_set_simulation_profile().

It looks like NULL through the PDB for 'bytes' argument gets passed as a
GBytes of size 0 (which might be something I did, and to be fair, that's
fine; I just forgot having done this).
As a consequence, testing for NULL was wrong, and these 2 functions were
always failing with NULL. Now they behave appropriately.

I also improve the docs for both functions.
2026-03-11 21:39:50 +01:00
Jehan
ef4c0a9504 app, libgimp, pdb: fix gimp_image_convert_color_profile() to allow NULL profile.
The function's documentation was already saying that we could set no
profile, except that in reality, setting NULL for the profile was simply
failing. Unless one checked the return value, the failure is also quite
silent. So let's actually implement what the docs say.

Also the concept of "default" profile might be a bit unclear in GIMP as
it could mean either built-in profiles or preferred ones (as set in
Preferences). I chose the former for this function, so I reword this
part of the docs.
2026-03-11 19:29:06 +01:00
Jehan
51ac9d7f2a Issue #15681: deprecate gimp_drawable_curves_explicit() and…
… gimp_drawable_curves_spline().

We can now run directly "gimp:curves" operation, both destructively or
non-destructively, but also setting the TRC, as well as individual point
types (when the curve is of type "smooth" instead of freehand).
This is much more powerful!
2026-03-01 22:33:58 +01:00
Jehan
b87bab9e8c app, libgimp*: add GimpCurve sample API in libgimp and PDB. 2026-03-01 22:33:58 +01:00
Bruno Lopes
d6f5205a89 tools: Port improved defcheck.py from gegl 2026-03-01 18:30:54 -03:00
Jehan
9a2193bb93 libgimp: adding API docs and clean up a bit the GimpCurve API.
In particular, I am getting rid of several of the properties, which are
really not that good (and even bogus for some, such as "n-points").
Properties tied together like this (number of elements stored in one
prop applying to the array stored in another prop) are often a bad idea
and only end up in messy code ending up in inconsistencies.

Instead let's use signals. I am keeping the "n-samples" for now as it
can clearly be considered more "stable" than "n-points" and not meant to
change.

We'll also have to make a decision on whether we really want to keep the
samples API in libgimp, or drop all current sample functions. Right now
we cannot actually create meaningful sample points.
2026-03-01 16:47:06 +01:00
Alx Sa
804991a215 libgimp, pdb: Allow access to GimpCurve in PDB
Adds a GimpCurve object and functions in libgimp.
Rather than creating a GimpCurve object in core and
passing it back and forth, we just pass the attributes
and reconstruct it across.
In the future, we may combine this with the app/core one
and put it in libgimpbase.
2026-03-01 13:41:35 +00:00
Bruno Lopes
50d4043003 libgimp: Set _NT_SYMBOL_PATH for plug-ins when relocatable
This concludes 63f5ea9d by adding support to CodeView symbols from
plug-ins with DrMingw. (Should not be needed but DrMingw is buggy).
2026-02-25 11:51:34 -03:00
Jacob Boerema
bffa26d995 libgimp: fix #15877 crash in export dialog with long comment line
Our export dialog resizes the width of the dialog based on the size
of the longest comment line. Apparently certain programs save data
that can be very long. On Windows I did not experience a crash, but
the dialog is many screens wide and unusable in that state.

To fix this we change the horizontal scroll policy to
GTK_POLICY_EXTERNAL because GTK_POLICY_NEVER apparently stops GTK
from resizing the window at a reasonable size.

We also set wrap mode of the comment field to GTK_WRAP_WORD_CHAR
to make sure the lines that consist of only numbers without spaces
get wrapped at a reasonable length.
2026-02-18 09:20:47 -05:00
Bruno Lopes
0d14a37975 libgimp: Make build-time .gir patching on macOS consider other libs
This does not fix any bug but reduces noise when some bug appears.
2026-02-15 22:00:42 -03:00
Jehan
fd58ab3bee libgimp: use the file directory as base for pygimp module.
This will allow calling this script from elsewhere.
2026-02-03 10:40:15 +01:00
Jehan
b590dc1a2f app, libgimp, pdb: use deprecated and deprecated_since rather than…
… std_pdb_deprecated for previously deprecated functions.

The &std_pdb_deprecated() call won't set a "Deprecated since"
information since this can't be made generic anyway. We have the info,
it'd be a shame not to document it!

Also it clears the blurb and help string, which I find unhelpful (even
for deprecated functions, it's better to have proper documentation!).
2026-02-01 22:40:27 +01:00
Jehan
98e71ee34e libgimp, pdb: re-generate annotations for deprecated functions. 2026-02-01 22:37:14 +01:00
Jehan
c8c8a68247 app, libgimp, pdb: deprecate various procedures in favor of filters.
I have manually tested each and every of the deprecated functions,
making sure we don't lose any feature. As expected, we don't. Having
dedicated libgimp functions may feel a tiny bit easier to call but this
is not scalable. We can't do this forever, with one function per filter.
And fortunately we won't have to, since now we can call filters on any
drawable directly! It also comes with the following generic advantages:

* It works with any filter, even third-party ones;
* We can also append filters non-destructively for later removal or
  edits (the deprecated functions were always merging the filters);
* If the filter evolves, e.g. with new arguments, it should not affect
  the API (though we should implement GEGL operation versions);
* If we don't need to set all arguments (e.g. leaving many args with
  default value), the filter API may even be simpler and shorter;
* The filter API will be much less "opaque" thanks to argument naming
  (rather than a long list of integers, doubles, etc.).

Specifically to the now deprecated functions, I noted the following
weaknesses on the deprecated API when testing:

* gimp_drawable_colorize_hsl() was missing a "color" argument;
* gimp_drawable_extract_component() had the enum argument "component"
  set as an integer, which is particularly opaque when re-reading
  existing code. Whereas the filter API uses generate choice strings
  which are self-explanatory! For instance choice RGB Red is 0 with the
  deprecated function but "rgb-r" with the filter API.
* gimp_drawable_levels() was missing "trc" argument (as noted in
  #15681).

And as expected, no features are lost.

Note that I didn't deprecate the curves functions yet, because we need
to implement the GimpCurve type in libgimp first.

There are a few more functions which I didn't deprecate yet, because
they don't use a filter directly, but some core functions, though for
some of them, it is very likely they can be efficiently reimplemented
with the filter API too. I'll have to look closer at it. It looks like
we may have to implement GimpHistogram in libgimp too though.
2026-02-01 22:31:02 +01:00
Jehan
8ad5dffa3a app, libgimp, pdb: improve a bit the docs of gimp_drawable_curves_spline().
One point which was raised in #15681 is that the documentation is
lacking.

* Let's write down that the range of the point coordinates is in the [0,
  1] range.
* Also let's rename num_points to num_coordinates because argument
  points will actually contain 2 coordinates per points (so for 10
  points, the points array will be of size 20). We also write that it
  means that num_coordinates must therefore be even.
* Add more spacing in the docs and some better styling and annotations.
2026-01-27 20:48:25 +01:00
Jacob Boerema
0376564f5f libgimp: fix missing GIMP_TYPE_LINK_LAYER initialization
When calling `gimp_link_layer_new` from a plug-in, a critical was
shown:
LibGimp-CRITICAL **: 13:01:54.601: gimp_gp_param_to_value: type name
 GimpLinkLayer is not registered

I noticed that its type was not initialized in libgimp/gimp.c.
This commit adds that initialization.
2026-01-13 14:18:39 -05:00
Jehan
ef69089881 libgimp: coding style fix. 2026-01-09 21:49:42 +01:00
Jehan
726dd4feaf libgimp: clean out ugly trailing whitespaces. 2026-01-09 21:35:31 +01:00
Ondřej Míchal
e735054347 libgimp: Handle integer properties bound to GimpSpinScale in procedure dialogs
Setting a step/page size of less than one for a spin scale bound to an
integer property does not make sense. Similarly the number of decimal
digits shown can be set to 0.
2026-01-07 16:13:57 +02:00
Bruno Lopes
a99910217a libgimp, meson: Port make-in-build-typelib to Python and fix build order
Seems this was the last .sh script pending to ported. Since I was experiencing
problems with the .sh one (not working locally nor on HomeBrew), I just ported.
Now, it is easier to read and fix if needed.

I also fixed the build order on libgimp meson.build to ensure the patched
.typelib being always present at the time GIMP generate splash screen etc.
2026-01-04 17:57:24 -03:00
Gabriele Barbero
08abaa721a libgimpwidgets: make GimpBrowser emit "stop-search" signal
This commit enables GimpBrowser to emit the "stop-search" signal,
originally emitted only by the internal GtkSearchEntry.
It also connects this signal to all widgets embedding a GimpBrowser,
so they can intercept it and close themselves.
This restores the behaviour that existed before the GtkSearchEntry update
2025-12-07 19:46:03 +01:00
Jehan
36dbb5f937 libgimp: improve API function docs. 2025-12-05 21:50:29 +01:00
Jehan
7787a90b8d libgimp: clean comment.
I am unsure about the previous commit (see MR !2568), though it should
not be hurtful either. At least though, let's not leave duplicate
comments. So merging the 2 comments and making the remaining text a bit
more technically correct.
2025-12-05 21:23:58 +01:00
lloyd konneker
0ab24ae1b5 libgimp: fix GimpPlugin init gegl and babl
GIMP hard depends on gegl and babl libraries.
We want to call their init functions early, in the GimpPlugin init.
We want to call gegl_init which calls babl_init.
But gegl_config cannot be called after gegl_init (gegl#427)

So only call babl_init in GimpPlugin init
and rely on _gimp_config to call gegl_config which seems to init gegl
(for wire msg GP_CONFIG, which comes early.)

Related: could eliminate calls to gegl_init in C plugins, now redundant.
The plugin class will do it.
2025-12-05 18:50:24 +01:00
Bruno Lopes
ffcbf8b5dc
libgimp: Do not try to include sys/time.h on Windows
Code taken from: https://gist.github.com/ugovaretto/5875385
We already do that on babl repo.

It does not exist on such platform. What MINGW do on
the pseudo-header is to implement a wrapper to
native Windows functions.
2025-11-29 18:19:00 -03:00
Jehan
93a7e92183 app, libgimp, pdb: clean up some algorithm URLs.
- The "Healing Brush" paper URL is dead. It now leads to one of these
  horrible parasitic websites which reuse domain names. And we for sure
  don't want to promote this! I'm using instead the associated page on
  our developer website. I just created this page and right now it's on
  testing only. But this will be the URL for the main website.
- The URL for the foreground extraction paper is still valid, but from
  my small research today when writing various algorithm' pages, I think
  our own implementation diverged from this original paper (though it
  may still have part of this original paper's algorithm; only a deeper
  check of the code would tell).
  See: https://testing.developer.gimp.org/core/algorithm/foreground-extraction/
  Also this PDB procedure is called generically gimp_drawable_foreground_extract()
  and it even has an argument to choose the algorithm (even though right
  now, there is only a single choice, which is "Matting" algorithm, and
  even there you can't choose which one; it's always Matting Global;
  Matting Levin cannot be chosen for instance).
  So anyway it is not a good idea to point to one specific algorithm,
  and even less to leave an external URL (which may also disappear some
  day) in API docs. So I am just getting rid of this paper title and
  URL, and replace it with actually useful information, which is how to
  set the trimap to represent foreground, background and uncertain
  pixels (note: I notice that it would have been different with Matting
  Levin where uncertain pixels must apparently be set transparent).
2025-11-24 21:45:03 +01:00
Jehan
2e0d9504ed app, libgimp, plug-ins: move our code to use only non-deprecated code.
- Though GimpDrawableChooser itself is deprecated, make it call the
  new items popup API, which will work just as well.
- gimp_procedure_dialog_get_widget() will now return a GimpItemChooser
  widget by default. I did hesitate if for API behavior stability, it
  should not still return a GimpDrawableChooser, but considered that if
  someone set G_TYPE_NONE, they want our "best choice" and are not
  considering tweaking it. If someone wants to make sure this function
  always returns a specific widget type, they should specify said type.
  So I also added a note in the function docs related to this
  assumption.
- Van Gogh plug-in must now use the GimpItemChooser API to set the item
  to show. Also I am specifying the widget type, even though it is now
  the new default, because of the previous point. Since we tweak further
  the widget with its API, let's specify so that any further defaults
  update doesn't break this code.
- Adding some pragma to ignore warnings on the few pieces of code where
  we have to call deprecated functions (because inside other deprecated
  functions themselves).
- gui_pdb_dialog_*() API should just always create GimpItemSelect
  dialogs now. Also I ref rather than peek the class, because even if
  the class has not been instanciated yet (a case I ran into), we still
  want to obtain the class structure.
2025-11-17 12:47:20 +01:00
Jehan
135ed4d2b6 app, libgimp, pdb: set all drawable selection functions as deprecated.
Also fix a bit of "Since:" annotations, some minor spacing fixing and
remove one useless test (if we test if a type is an item, we don't need
to test the children drawable type).
2025-11-17 12:14:56 +01:00
Alx Sa
37a0e37d25 widgets, pdb, libgimp: GimpProcedureDialog Item Widget
This patch adds a GimpItemChooser widget
for use in GimpProcedureDialog Item parameter
GUI creation.
This will deprecate the existing
GimpDrawableChooser, as it covers all the
same cases plus others such as GimpPath.
2025-11-16 16:42:24 +00:00
Alx Sa
a9dc4ddb2c widgets, pdb, libgimp: GimpProcedureDialog Image Widget
This patch adds a GimpImageChooser widget
for use in GimpProcedureDialog Image parameter
GUI creation.
2025-11-12 03:12:24 +00:00
Jehan
5070212903 libgimp: minor cosmetic spacing fix. 2025-11-08 22:44:20 +01:00
Jehan
926d5c6daa app, libgimp*, plug-ins: fix previous commit and add gimp_cairo_surface_get_buffer().
The previous commit was not taking into account usages of
gimp_cairo_surface_create_buffer(), other than the text layer rendering
usage, as it was focused on fixing #14970.

In particular, in other pieces of code, we were using a temporary
GeglBuffer as a way to edit the original Cairo surface but the syncing
back was not happening anymore. So previous commit was breaking all
thumbnails of layers or images, as well as PDF export for all raster
layers.

After some thought, I decided to implement a new function
gimp_cairo_surface_get_buffer() which would do what
gimp_cairo_surface_create_buffer() was doing, but adding a boolean flag
to declare whether or not we were expecting to sync back into the Cairo
surface's data. After all, when we don't need to sync back, better avoid
the useless work of copying possibly huge data.

I also added back the possibility of returning a linear-memory backed
buffer, after some discussion with pippin. Because for very small
surfaces, and if we are indeed looking to sync back into the source
Cairo surface, the advantages of using a linear buffer may still be
worth it, even though it's not true for the general case (where tiled
buffers will be much more efficient). I used 4096 (64^2 because our
current tile dimensions are 64 right now in GIMP), though this number is
kinda random and doesn't matter too much (it doesn't have to be the
square of the tile's width or height). I don't put any info about this
in the new function's documentation because developers should not have
any expectations on the type of buffer they get (only whether or not it
will sync back to the source).

As a consequence of all this, gimp_cairo_surface_create_buffer() has
been deprecated as of GIMP 3.2, though it will still work the same. The
new function will be recommended as a replacement.
2025-11-08 20:34:55 +01:00
Bruno Lopes
c79bf5790d
app, libgimp: Fix truncation and lack of color on attached Windows console 2025-11-08 12:02:56 -03:00
Jacob Boerema
13d9611719 libgimp: fix #15196 tiff specific exif thumbnail tags copied to jpeg
When opening a tiff image with exif metadata including a thumbnail
saved in tiff format, the exif metadata of the opened image will include
tiff specific metadata like Exif.Image.StripOffsets.

These tags are not supposed to be exported to any other formats.
Although we removed these tags for the image itself, we forgot to
remove them for the thumbnail metadata if adding a thumbnail was
selected.
Since GIMP itself saves thumbnails in jpeg format, that caused some
tags to be left behind when the original software writing the tiff
wrote thumbnails in tiff format.

We fix this by always removing all thumbnail metadata first before
writing our own thumbnail metadata.
2025-11-03 14:21:53 -05:00
Bruno Lopes
72cb583489
app, app-tools, libgimp: Fix GIMP not outputing on non-native shells
As per IEEE Std 1003.1-2017, Section 8.3, TERM and
SHELL vars says we are running GIMP on POSIX shell.
They are not set by either the deprecated Windows CMD
nor by Windows PowerShell since they are not POSIX.

POSIX shells are supported by us on Linux and macOS but
actually not on Windows, since they are non-native: they
rely on forking to Cygwin which have terrible performance
(##11385) and do other tricks to make deps believe they
are on Unix which breaks e.g. GObject Introspection (#11424).
Anyway, it is Unix emulation at its prime, tricky by nature.

Even so, does not hurt allow the output on these
unsupported shells on Windows so not disrupt workflows
of adventurous developers but they will be warned that
problems (like the ones above) can and indeed appear.
2025-11-01 14:24:01 -03:00