Commit graph

206 commits

Author SHA1 Message Date
Alx Sa
9ab17bf034 python: Add import/export support for ORA extensions
The OpenRaster specification has two official extensions
for layers - storing if they are pixel locked, and if they are
selected. Krita and MyPaint already support these extensions
on import and export. This patch adds that support to GIMP
as well.
2025-06-06 20:25:04 +00:00
Bruno Lopes
2ce3c604e2
build, plug-ins: Generate *associations.list automatically at build-time
This is way easier to maintain and creates a bigger list of
associations by following the libraries that GIMP links
(but does not work with more complex code like file-gegl).

Also helps with
https://gitlab.gnome.org/Infrastructure/gimp-macos-build/-/issues/3
2025-05-30 19:23:41 -03:00
Bruno Lopes
c9f77c7228
build/windows: Alternative approach to Inno reading of config*.h
Closes: #14101

Partially reverts: f69dd75a17
2025-05-27 15:34:13 -03:00
Alx Sa
befacfd0d4 python: Add export support for Krita .kpl palette
Resolves #13889
Adds support for exporting palettes in
Krita's .kpl format (zipped .xml data).
Colors are currently saved as 32-bit
floating point RGB values.
Future work includes supporting other
color spaces like CMYK, other precisions,
and including color profiles for colors.
2025-05-25 15:50:12 +00:00
Jacob Boerema
6268eb5ed4 tests: Update location of eps loading tests from Pillow 2025-05-19 12:53:38 -04:00
Jacob Boerema
d7901a8890 plug-ins, testing: add two tests for fli and ico...
based on the ZDI-CAN poc images
2025-05-07 17:57:38 +00:00
Bruno Lopes
00ab5e3a19
.gitlab: Move cp-plug-in-subfolder.py to build/meson
It is not a CI-specific file.
2025-04-18 13:36:31 -03:00
Jehan
884353ed3d plug-ins: fix relocatability of the Python Console.
If we were running Gimp.locale_directory() at the very start of the
script, it would append before _gimp_reloc_init_lib() had happened, and
therefore the returned value would be the non-relocated locale
directory.

Calling this inside set_i18n() happens later, and also feels like the
proper place for this code.
2025-04-09 00:20:03 +02:00
Bruno Lopes
87cfc65ab6 Issue #13367: use correct python*.exe on insider MSIX from stable series 2025-04-06 20:19:31 +00:00
Alx Sa
6af4c13139 python: Set error color based on theme
This patch changes the color of the error text in the
Python console based on the luminance of the
background-color (using GIMP_RGB_LUMINANCE
values).
2025-03-19 12:42:17 +00:00
Alx Sa
4cd3360d53 python: Fix crash when exporting indexed ORA images
Exporting ORA images involves first creating PNGs of
the layers. To do this, we create separate images for
each layer with Gimp.Image.new ().
However, if the original image was indexed, we lose
the palette when passing the temporary image to
the PDB call. This caused us to try saving a NULL
palette, which resulted in the crash.

This patch adds a check if the image is indexed, and
copies over the palette to the temporary image.
2025-03-15 02:36:20 +00:00
Jacob Boerema
acead5642e plug-ins, tests: add tests for more file formats...
using example files from the nomacs testset.
2025-03-12 21:51:19 +00:00
Jacob Boerema
f87ecbe0db plug-ins: add a reminder to the main plug-in tests configuration...
about adding any new ini files to meson.build,
since that is what I often keep forgetting.
2025-02-26 20:31:17 +00:00
Jacob Boerema
321e0a545f plug-ins, tests: add tests for loading xcf images 2025-02-26 20:31:17 +00:00
Alx Sa
ca6ea27c3e python: Update suggestion for GimpCoreObjectArray parameters
Resolves #12973
Since the standard 'drawables' argument for procedures
is now a GimpCoreObjectArray, the suggested syntax for
setting it in a Python call was incorrect. This impacts other
parameters as well, so we add a check for the argument type
being Gimp.ParamCoreObjectArray and then provide the
correct Python code to set them.
2025-02-22 03:45:55 +00:00
Alx Sa
7d363d125f python: Use context Palette/Gradient in GUI
Interactive scripts should use the context
palette or gradient rather than the saved
one, as the user is more likely wanting to
edit the gradient or palette they have
actively selected. This is also in line with
how 2.10 operated.
This patch clears out the palette or
gradient property of Python scripts
when the GUI is created, so that it
uses the context version. It does not
affect non-interactive usage.
2025-02-01 02:59:51 +00:00
Alx Sa
ebc4a245e4 python: Fix Autoslice in Sort Palette after Color Space Invasion
Resolves #12827.
The Autoslice option was not updated to expect GeglColors instead of GimpRGB
arrays after the Color Space invasion. This patch updates the find_index() and
hexcolor() functions accordingly.
2025-01-30 01:52:26 +00:00
Anders Jonsson
255e942087 python, libgimp: rename gimp_palette_entry_[gs]et_*()
Followup to 151cb9c40c
to make the palette offset and sort scripts work again.
2025-01-29 21:02:22 +01:00
Jehan
10808f2830 libgimp, plug-ins: create automatically a GimpFileChooser for GimpParamSpecFile arguments.
This new widget is much nicer, with proper label to document the GUI and
also with support to save files or create folders. It also has mnemonic
support and the label is put into the same size group as other so that
it's nicely aligned.

As a consequence, I remove bad support of object arguments with a GFile
value. People should just create proper GimpParamSpecFile arguments
(also GimpProcedure API now has a function only for such type of file
argument).

I also remove gimp_procedure_dialog_get_file_chooser() which was only
useful when we didn't know what action a file argument was for. Now it's
part of the param spec definition.

libscriptfu was updated too because SF-DIRNAME arguments don't need
special casing anymore.

Finally I change gradients-save-as-css to just make use of the new
automatic widget creation (more than 60 lines of plug-in code replaced
by… 0 lines because it's automatic!).

This whole commit is mostly a lot of code removal now that we have
proper automatization for file arguments! \o/
2025-01-26 18:13:55 +01:00
Alx Sa
eb8076526d python: Update Spyro-Plus after GEGL Color update
Resolves #12795
After the Color Space Invasion, gimp_gradient_get_uniform_samples ()
returns an array of GeglColors rather than GimpRGB values and a status
variable. This patch fixes the Spyro-Plus plug-in to expects the new
return values.
It also restores code that utilized the second color gradient in the output
when the Gradient's Repeat Mode is Triangular Wave. This appears to
have been lost during the port from GIMP 2.10.
2025-01-24 02:51:34 +00:00
Alx Sa
8db404516e python: Fix file arguments after 161b3c53
We accidentally missed updating the
Python file parameters after 161b3c53.
This patch updates the API as well.
2025-01-22 21:29:16 +01:00
Jacob Boerema
f3d6c9326f image loading plug-in tests: add cmyk pam tests 2025-01-08 13:15:56 -05:00
Alx Sa
f8436b67cf python: Fix function API in Palette-to-Gradient
We were still calling palette.entry_get_color () rather than the new API
palette.get_colors(), which returns the full array of colors. 
This patch updates the script to use the correct API.
2024-12-30 17:55:51 +00:00
Jehan
03e9fbbd92 gitlab, meson, plug-ins: add a -Dfile-plug-ins-test meson option.
This option is run by the CI and makes so that the test-file-plug-ins
plug-in is always installed in the CI, even on stable releases. But by
default, they are not installed on stable releases.
2024-12-27 15:15:25 +01:00
Jehan
363f37d866 plug-ins: also update the prompt when searching.
When searching backward, it will show '^^^' and forward 'vvv' instead of
'>>>' and also the searched text will appear next to the prompt between
parentheses. This makes searching a lot easier as we have clear feedback
of where we are at and what we are searching.
2024-12-18 00:16:06 +01:00
Jehan
70da73ee0d plug-ins: implement Ctrl-R and Ctrl-S in Python Console for searching.
These are the common shell shortcuts for respectively searching backward
and forward in command history. I use the Python Console plug-in so much
for testing that it started to weigh on me on how ineffective it was not
to be able to search through the history and laboriously hit Up/Down
buttons instead.

While doing a search, most navigation keys would trigger to stop the
search (and stay at the current history item followed by whatever the
key was supposed to do, such as changing cursor position, etc.). Esc in
particular would just stop the search and do nothing else.

Ctrl-C though would reset the search and get the text back to what it
was before search started.
2024-12-17 23:53:34 +01:00
Jehan
9588132849 plug-ins: do not cycle through Python Console history.
When you want to get back to the latest command, it is very confusing
when it starts cycling from the oldest history command!
2024-12-17 23:15:53 +01:00
Jehan
b0ac59b421 app, pdb, plug-ins: replace (plug-in-plasma).
This time, it's a Python plug-in, which is a bit more involved than C or
Script-fu usage (where we have variable args one-liner function) though
it's not too bad either. It's actually very similar (on purpose) to how
PDB procedures are run.
2024-12-17 16:24:54 +00:00
Jehan
7b4211b24e plug-ins: PageUp/Down is also commonly used same as Up/Down arrows in terminals. 2024-12-06 15:42:55 +09:00
Bruno
de3cf104e3
build, plug-ins: Bundle and distribute correct python*.exe
According to Jernej and my searches pythonw.exe should be used for stable
releases and python.exe for unstable as commented in the changed files.
2024-11-19 09:30:57 -03:00
Jacob Boerema
15f5b15e69 ci: fix test-file-plug-ins job
This job fails because our test plug-ins isn't installed in stable or
release versions. However we are in a RC1 status which leaves stable
and release true.

Let's fix this by checking for "+git" at the end of the version string
and also installing our plug-in if that is found.
2024-11-05 12:03:41 -05:00
Jehan
2559138931 libgimp*, pdb, plug-ins: remove deprecated GIMP_PRECISION_*_GAMMA.
These were the last deprecated values in libgimp AFAICS.
2024-11-03 20:18:52 +01:00
Jehan
8900967a81 extensions, libgimp, plug-ins: remove n_drawables arg from GimpImageProcedure's…
… run() function.

This is more consistent with recent changes in PDB, and now the
drawables argument is NULL-terminated.
2024-10-28 22:08:45 +01:00
Jehan
97fb23e5b3 plug-ins: python-fu-eval should correctly exit with error.
When the passed code had a bug, the plug-in was crashing along with the
code given in argument. Instead, we must catch all exceptions and pass
the error message raised by exec() to the core application.
2024-10-27 22:55:51 +01:00
Alx Sa
d054a87d2c plug-ins: Fix naming conventions for Python plug-ins
Per Lloyd Konneker, all Python plug-ins except
histogram-export and gradients-save-as-css
have "python-fu-" in front of their name.
In fact, gradients-save-as-css does have
this prefix in some places already.
Since this is also how it was written in 2.10,
let's rename them now to be consistent.
2024-10-26 01:05:15 +00:00
Jehan
94c7ca6809 plug-ins: support saving the history of commands.
Since I use the Python console a lot myself to test GIMP API, the
ability to recall previously ran commands is extremely useful. Let's
just add support for this as an AUX argument. This was already done in
the Script-fu console, now in the Python console too!
2024-09-22 23:26:33 +02:00
Jehan
6cd39dc442 plug-ins: fix test-dialog after commit 75a50ce87b. 2024-09-06 17:33:49 +02:00
Jehan
75a50ce87b app, libgimp, pdb, plug-ins: add ability to default to context for all resource args.
Also fixes the passing of the resource param definitions through PDB.
There was some weird assumption, with a comment, in commit 73733335c8
that this was unneeded, which meant that we were not able to properly
recreate the right param spec over the wire.
2024-09-06 16:33:24 +02:00
Jehan
7f9b8e8dbf plug-ins: fix typo and install rules for test-dialog. 2024-09-05 22:44:10 +02:00
Anders Jonsson
4c2ff66bdd python: rename Vectors to Path
spyro-plus ran into errors since it called old names
containing Vectors. Fix this by changing to Path to
follow the current API.
2024-09-04 22:29:14 +00:00
bootchk
73733335c8 libgimp: plugins: fix #10950 resource defaults not effective
Now you can declare a default value when declaring resource arguments to
a PDB procedure.

Add default behavior to GimpParamSpecResource.
Add field and override g_param_spec_value_set_default.

Fix the plugins that have resource arguments.
Some plugins temporarily use a hardcoded default instead of declared default.
ScriptFu plugins, TODO.

Misc fix to the test plugin for this case: test-dialog.py.
Dev>Demo>Test dialog...

TODO 10822 Lava plugin issue depends on this.

Note film.c fixed but still doesn't work.
2024-09-04 21:32:28 +02:00
Alx Sa
bcdd4974bb core, pdb, plug-ins: Create GimpExportOptions class
This patch creates a GimpExportOptions class in both
libgimpbase and in libgimp. Currently it is a mostly empty
object, but it will be added to after 3.0 to allow for
additional export options (like resizing on export while
leaving the original image intact)

libgimp/gimpexport.c was removed, and most of its content
was copied into libgimp/gimpexportoptions.c. gimp_export_image ()
was replaced with gimp_export_options_get_image () in all
export plug-ins.

GimpExportProcedure has a new function to set the default
image capabilities for each plug-in on creation. It also sets up
a new callback function, which allows the options to respond to
user setting changes (such as toggling 'Save as Animation' in the
GIF or WEBP Plug-in).
2024-08-18 22:03:14 +02:00
lloyd konneker
634f3d674f build: plugins: ensure test plugins not installed in stable version
Menu Filters>Development>Demos not appear in a stable version,
and not appear in unstable version unless buildtype==debug.
2024-08-10 14:58:58 +00:00
Jehan
93cc81281c Issue #11317: make Python plug-ins mandatory.
Unlike the other bindings (Lua, JS, Vala) where we only have a demo
plug-in, we actually have a bunch of interesting and useful Python
plug-ins.

Furthermore, we are running several Python scripts through GIMP during
our build (to generate a few images), so pygobject becomes a build
dependency anyway, even if it may not be a run dependency with
-Dpython=disabled.

This all becomes a bit confusing and in fact handling this case (of not
installing Python plug-ins) seems like an annoyance while we lose good
core plug-ins. So let's just make Python plug-ins mandatory. It's not
like Python is very controversial these days, and AFAWK, it is available
on every platform out there.
2024-08-09 01:01:58 +02:00
Anders Jonsson
221f8ab14d plug-ins: fix pyconsole syntax for Python 3.12
With Python 3.12, every run of the Python console shows
a SyntaxWarning about invalid escape sequence unless the
string is marked as a raw string.
2024-07-13 20:09:25 +00:00
Alx Sa
d10a8c357f plug-ins: Allow Python GUI resources to be empty
Resolves #11772
While ba79fd00 fixed the number of
arguments in the resource arguments,
setting them to False prevented the GUI
from opening if the gradient wasn't set.
This patch switches the value to True to
fix the problem.
2024-07-07 19:19:16 +00:00
Alx Sa
86ef74ae95 plug-ins, tests: Update Python plug-ins after b1736a67
Two instances of Gimp.Layer.group_new ()
were missed during the initial port.
2024-07-07 12:37:33 +00:00
Alx Sa
ba79fd00d3 plug-ins: Update Python plug-ins after 6d36d143
A new parameter was added to indicate if
it was okay to run without setting these
resource values.
2024-07-07 12:05:54 +00:00
Jehan
8b6d90700a libgimp, pdb, plug-ins: don't skip gimp_*get_*() API from GObject Introspection anymore.
The original reason to skip these was because the new _list_ API were
introspected basically to a similar function signature, except with a
useless return value, at least in pygobject binding where the list size
was also returned.
Though it seems that in fact, only the docstring was wrong. The real
signature was apparently already the same.
See: https://gitlab.gnome.org/GNOME/pygobject/-/issues/352

Therefore since the _get_ naming is more consistent compared to other
existing function, let's re-integrate the _get_ functions for array of
items or images.

This basically reverts commit 15ec254148.
2024-07-06 14:44:45 +02:00
Jehan
caffd09b5b libgimp, plug-ins: getting rid of gimp_procedure_add_*_from_property() functions.
These were created because of some limitation/bug in pygobject, which is
now much better worked around by having specific functions for every
argument type supported by the PDB.
2024-07-04 22:11:53 +02:00