Commit graph

191 commits

Author SHA1 Message Date
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
Anders Jonsson
7f9e819b50 Export histogram: fix blank lines on Windows
For the Python 3 case in issue #6096 following the
instructions of zjw and the Python 3 manual.
2024-06-27 21:21:30 +00:00
Alx Sa
2bd598bcfd plug-ins: Fix crash in Export Histogram on file save
Resolves #11742
gimp_procedure_dialog_get_file_chooser () does not
work with GtkFileChooserAction.SAVE enums yet.
This was incorrectly left in by f5b7f734.
This patch removes the command to fix a crash.
2024-06-27 11:14:12 +00:00
Anders Jonsson
36f6b476f0 python: don't translate test plug-in
Following the note of 'no i18n' in the header
2024-06-18 11:13:06 +00:00
Anders Jonsson
ef91ab25eb python: remove accelerator in title bar 2024-06-11 20:22:15 +00:00
Alx Sa
f5b7f734e2 python: Minor enhancements to python plug-ins
* colorxhtml.py was converted to use
GimpProcedureDialog. A new aux
argument was added so that a widget
could be created in the GUI. The text
field and the file widgets were made
to be sensitive to the source-file bool to
better indicate to the user which one will
be used.

* palette-sort.py now uses babl instead of
colormath libraries to get CIE LAB and
CIE LCH(ab) values. This means all users
will be able to sort by those options even
if the colormath library isn't installed.

* histogram-export.py's out-format
widget was converted to a radio frame
as it is in 2.10.
2024-06-11 17:17:41 +00:00
Anders Jonsson
5841e9f8af python: translation fixes
Followup to 292cb01fc2,
taking care of remaining untranslated strings and a stray
accelerator in a tooltip.
2024-06-10 20:58:39 +00:00
Alx Sa
292cb01fc2 python: Port arguments code to use functions
This patch ports the first-party Python plug-ins
to use the new argument API.
This restores the ability to add dropdown menus from
enums and Gimp.Choice parameters, and also allows
defaults to be set for custom datatypes like Gegl.Color.
2024-06-10 15:22:02 +00:00
Alx Sa
6be4e7029a plug-ins: Use combobox in histogram-export
Currently, we can not use Gimp.Choice as a parameter type for
Python plug-ins. This means that we're using a string instead for
the "output-format" parameter, which creates a textbox in the GUI.

This patch manually creates a GimpStringComboBox in the GUI and
syncs it with the "output-format" string parameter. Once Gimp.Choice
can be used in Python, we should be able to swap this out without
impacting plug-in developers (since it would also take in a string)
2024-06-06 04:54:05 +00:00
Jacob Boerema
64b9a00484 plug-ins, ci: add basic support for junit reports for...
file plug-in testing.
The name and location of the xml results will be the same as for the
log file, but with the extension replaced by .xml.

Just some basic support is added which adds failed testcases when
a plug-in has a failure result, which should be the most common
case of failures.
Not all cases where we make errors in our test setup will generate
failed testcases yet, although they should show up in the number of
failures.
Disabled tests won't show up as skipped tests.
We also don't track time.
2024-05-04 19:06:38 +00:00
Alx Sa
443947c6aa plug-ins: Remove n_drawables parameter
Port all plug-ins to retrieve the layers
directly from the image rather than
having them passed in. This resolves some
issues with introspection and sets the
foundation for future API work.
2024-05-03 15:22:39 +00:00
Jacob Boerema
97671dbab7 plug-ins, tests: fix #11408 test-file-plug-ins: permission error ...
for gimp-tests.log

On Linux we may not have permission to create a log at our default
location, so we need to check for that.

First we should not init the log when our plug-in is asked for info.
Only create it when we actually run the import or export tests.

Second, try to catch the permission error and write a message either
in GIMP or in the terminal for non-interactive.
2024-04-27 22:46:02 +00:00
Jacob Boerema
5def9ffd09 plug-ins: don't crash file export tests when sections is None 2024-04-27 13:10:18 -04:00
Jacob Boerema
3478e1c00f plug-ins: add file-plug-in testing framework
Copied over from the original separate work in:
https://gitlab.gnome.org/Wormnest/gimp-file-plugin-tests
After that further improved and changed and added more file format
tests.

Added meson.build files to integrate it in our build, but we do not
install it for releases.
2024-04-26 12:28:47 -04:00
Jehan
3fbf34dabc meson: fails to compile with -Dpython=disabled flag.
We compile GObject-Introspection anyway (except for cross-builds, where
anyway we don't rely on local Python scripts), so even if not installing
the Python plug-ins, still use them locally.
2024-04-24 19:48:59 +02:00
bootchk
c5c0976ed7 app: GUI: Delete root menu "Test", move its item to Demos
Its contents is a test plugin, "Test dialog".
I am responsible for it, and it is ugly, even in unstable.
Is only installed in an unstable build.

We need a convention that menu items for plugins named like "Test foo"
should only be installed in unstable build,
and should require no translations.

Note that if the Demos menu does not exist,
Gimp creates it, and it is not translated,
but only present in an unstable build.
2024-04-22 16:06:38 -04:00