Commit Graph

164 Commits

Author SHA1 Message Date
Jehan 0f7c6285ca plug-ins: move py-slice.py to gimp-data-extras.
Per polls on Twitter, Reddit, Patreon and Tipeee, most people were
willing to drop this plug-in as not being relevant anymore (247 for
dropping and 63 for keeping it, so nearly 80% out of 310 participants).

So let's move it to gimp-data-extras allowing it to still have a
possible life, and who knows, maybe to even evolve.

See also corresponding commit beffc6b to gimp-data-extras repository.
2020-12-15 01:46:46 +01:00
luz paz bb322d94d7 Fix typos
Found via:
```
codespell -q 3 -S ./ChangeLog*,*.po,./.git,./NEWS* -L als,ang,ba,chello,daa,doubleclick,foto,hist,iff,inport,klass,mut,nd,ower,paeth,params,pard,pevent,sinc,thru,tim,uint
```
2020-11-19 21:56:25 +01:00
Jacob Boerema dbc198001e plug-ins: Fix incomplete port of file-openraster.
This fixes #5838 which was caused by an incomplete port
of this plug-in to the new introspection API.

For now we do keep the n_drawables parameter of save_ora until
issue #5312 is fixed. Not doing this would cause saving to fail.
2020-10-31 12:49:54 -04:00
Jehan c86d909dda plug-ins: fix parameters of Gimp.file_save().
It now requires a list of drawables (even though still mostly useless,
but this comes with the change of multi-selected layers).
2020-10-23 15:20:21 +02:00
Jehan 02cb754b4a plug-ins: run gimp_displays_flush() in foggify.
Without this call, the display is not properly updated and does not show
the newly added fog layer.
2020-10-18 00:41:22 +02:00
Jehan 2e73e30afd libgimp: 'gimp_ui' as priority prefix for GimpUi introspected module.
Since meson 0.43.0 (below our current requirement), 'symbol_prefix'
argument of gnome.generate_gir() allows an ordered list. If I prepend
'gimp_ui', it makes any gimp_ui_*() function to not start with 'ui_'.

In particular, GimpUi.ui_init() becomes GimpUi.init() which is much less
redundant.
2020-09-26 22:11:53 +02:00
Jehan 2271b5bbdb Issue #4368: remove 2 more outdated Python plug-ins.
shadow_bevel.py and sphere.py are unfinished and have been in the
"Unstable" only builds for years. This is probably not worth porting
them. Let's just delete them.

I have actually move these (as well clothify and whirlpinch removed
yesterday) to the gimp-data-extras repository so if anyone wants to
revive them, and port them to GIMP 3, they can start off from there.
2020-09-21 17:14:51 +02:00
Jehan e154cd220d plug-ins: delete Python whirlpinch and clothify without porting them.
Following Elad Shahar advice (cf. #4368), let's delete whirlpinch.py and
clothify.py.

The rational is that whirlpinch.py does the same thing as the existing
"plug-in-whirl-pinch" which is itself a compat plug-in to
"gegl:whirl-pinch" operation. Also the Python file has an explicit
command saying it is exactly the same algorithm, yet with no preview and
slower. Finally it was not even installed on stable build. It doesn't
look like there is any reason to keep it (it was probably a demo/test
Python plug-in).

As for clothify.py, a quick look at the short code shows it is exactly
the same algorithm as clothify.scm, with the same arguments and
installed on the same `Filters > Artistic` menu (except that the Python
version is not installed on stable builds).
So let's just keep the script-fu version as it has been the used version
until now, and there is no deprecation going on in one side or another.
So let's keep what already works.
2020-09-21 01:44:51 +02:00
Jehan a455c72929 plug-ins: update previous commit to API changes.
Since the patch was initially contributed, some parts of the
introspection changed. First all GUI-related code is in a GimpUi module
now.
Also Gimp.get_pdb().run_procedure() is now using a list instead of a
GimpValueArray.
2020-09-21 00:52:30 +02:00
Elad Shahar 12b4d9b097 Port histogram-export plugin to python 3 2020-09-21 00:38:29 +02:00
Elad Shahar 33085b5182 plug-ins: Port python-eval.py plugin to python 3.
To test that this works, run gimp in batch mode:

% gimp2.99 -i -b -

And then type: (python-fu-eval "print (2)") .
2020-09-21 00:30:41 +02:00
Elad Shahar a07576b219 Port benchmark-foreground-extract.py to python 3.
Note by reviewer (Jehan): merging this port as it was in GIMP 2.10
anyway, but is this even still needed code? This plug-in is not even
available on stable release, it looks like for-development only
benchmark, and I'm not sure if it's relevant anymore, especially in our
GEGL-fueled new world.

Please anyone who knows a bit more on the history of this plug-in and
the evolution of our gimp_drawable_foreground_extract() algorithm, feel
free to weigh in and tell us what this was for exactly and if it's still
relevant.
2020-09-21 00:13:35 +02:00
Elad Shahar cc2f064d8d plug-ins: Port palette-sort to Python 3
This is a basic port without any UI.
Invoking the plugin will just sort the entire palette based on
default parameters.
The original plugin had several broken options, which I tried to fix.
2020-09-20 23:58:02 +02:00
Niels De Graef 43d0f0fbd2 gimppdb: Allow more easy bindable API
Plug-ins that work from different bindings probably want to use their
own list-type to specify arguments, rather than working with a more
cumbersome `GimpValueArray`.

This new API should make it less verbose. For example:

```
args = Gimp.ValueArray.new(5)
args.insert(0, GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE))
args.insert(1, GObject.Value(Gimp.Image, image))
args.insert(2, GObject.Value(Gimp.Drawable, mask))
args.insert(3, GObject.Value(GObject.TYPE_INT, int(time.time())))
args.insert(4, GObject.Value(GObject.TYPE_DOUBLE, turbulence))
Gimp.get_pdb().run_procedure('plug-in-plasma', args)
```

becomes

```
Gimp.get_pdb().run_procedure('plug-in-plasma', [
    GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
    GObject.Value(Gimp.Image, image),
    GObject.Value(Gimp.Drawable, mask),
    GObject.Value(GObject.TYPE_INT, int(time.time())),
    GObject.Value(GObject.TYPE_DOUBLE, turbulence),
])
```
2020-09-20 11:36:01 +00:00
Elad Shahar 7d1e108b90 plug-ins: spyrogimp - fix type of new layer to include alpha channel 2020-09-01 11:44:11 +02:00
Elad Shahar 17b701a940 Issue #5043: Spyrogimp 'Live' Preview Pollutes Undo History
Reduce number of undo steps created by Spryrogimp previews.
First, by grouping them into a single undo.
The implementation adds a function for clearing the
incremental preview drawing that is being executed as an idle task,
and closing an undo group in case the preview left it open (which
would usually be the case). A second way to reduce undos is
by generating a new preview only upon mouse button release of
scales in the UI, and not while dragging the scale.
2020-08-31 12:43:52 +02:00
Félix Piédallu e78fbccea7 Fix pygimp.interp generation, add /usr/bin/python3 alias 2020-07-28 17:17:18 +02:00
PhotonQyv 5d412088af plug-ins: fix spyro-plus after Gimp/GimpUi split.
Since the Python bindings for Gimp has been split into Gimp and GimpUi
bindings this plug-in needs a slight tweak to still work correctly.
2020-06-08 20:38:53 +00:00
PhotonQyv c16e310c36 Corrected code to work with newer split Gimp and GimpUi bindings. 2020-06-08 20:09:21 +00:00
Jehan b00bb346a9 plug-ins: more complete naming for Python|Script-Fu consoles.
Just "Console" is enough in the context of menus with submenu hierarchy,
but when accessing directly the feature (with Action Search for
instance), a more accurate name is nicer. It avoids to have to check
what is what in the tooltip text.
2020-05-26 14:32:11 +02:00
Jehan ab172872ce plug-ins: fix python-console after GimpUi instrospection separation.
Patch by darix!
2020-05-26 14:15:17 +02:00
Elad Shahar 93602a3973 Issue #4326 - Add visual tab to spyrogimp plugin
Add visual tab to spyrogimp plugin for a more intuitive, visual
way of specifying the spyrograph pattern.
In addition, fix using the selection as the fixed gear, and add
option to save the pattern to a path.
2020-05-05 13:29:09 +03:00
Jehan 4fa7d078d0 plug-ins: install Python plug-ins in rwxr-xr-x.
Without the write permission for the owner, the `make install-plug-ins`
special target fails on Python plug-ins. And anyway I don't see a reason
why not give write permission to the owner (like all other plug-ins are
installed).
2019-12-25 11:51:56 +01:00
Jehan 7c6a147ffb plug-ins: allow "html" extension for colorxhtml.
There is no reason to limit it to "xhtml" only. Even more, in all
browsers I tried, the exported page was failing to load with the '.xtml'
extension, while it loads fine when renamed as '.html'.

Only problem is that now we have 2 plug-ins able to save as html (other
is file-html-table) and the first in the procedure list (with no
explicit logics right now) will just shadow the next one. We will have
to add some generic infrastructure to allow people to choose favorite
load/export plug-ins, probably in Preferences, next to the raw plug-in
selection.
2019-12-14 14:37:14 +01:00
Jehan 2e40b8d674 meson, autototools: install colorxhtml ported in previous commit. 2019-12-14 13:19:44 +01:00
Elad Shahar a3544fec6f Port pygimp colorxhtml plugin to python 3 2019-12-14 12:38:07 +01:00
Jehan e54467a8fa plug-ins: (meson) install Python plug-ins with execution permission.
Otherwise GIMP will skip them!
2019-11-26 20:24:28 +01:00
Elad Shahar b0ae5f1351 plug-ins: minor fixes to spyrogimp plugin.
Use Gtk Grid instead of deprecated table.
Fix use of some Gtk constants.
Fix top limit of scale widgets by setting page size of Adjustment to 0.
2019-11-26 20:08:59 +01:00
Jehan 30e7be6db1 plug-ins: fix usage of gimp_file_save() in py-slice.py.
Signature changed (commit f3fb3d1a), but build could not catch the
missing usage in non-compiled scripts. Thanks to Massimo for noticing
it.
2019-10-12 13:55:07 +02:00
Michael Natterer d257c7ba91 plug-ins: remove second parameter of gimp_ui_init() in all non-C plug-ins 2019-09-24 19:43:58 +02:00
Jehan 7777c5fa0c plug-ins: port gradients-save-as-css to Python 3 + new API. 2019-09-15 10:20:11 +02:00
Jehan 5495689180 plug-ins: fix Python plug-ins installation.
They were installed under $libdir/gimp/2.99/ instead of
$libdir/gimp/2.99/plug-ins/.
2019-09-14 22:39:39 +02:00
Félix Piédallu 65eff6f150 Meson port. 2019-09-11 16:42:04 +02:00
Michael Natterer 26a744f44d plug-ins: register thumbnail procedures before load procedures
so registering the thumbnail loader with the load procedure can
perform some checks for procedure existence and signature.
2019-09-10 19:36:54 +02:00
Sabri Ünal 2e766f67d4 Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer

metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 22:41:19 +03:00
Jehan 3c6360a373 plug-ins: port spyro-plus to Python 3 + new API.
It is a nearly full port. Some things would still need to be updated
(like deprecated use of GtkTable or gtk_range_set_update_policy()
removed), and other stuff need to be taken care of in GIMP API first.
But the core of the feature is there.
2019-09-02 11:42:38 +02:00
Jehan 34c6e8744c plug-ins: port py-slice to new API.
No GUI done yet on this one either. For now it will just slice the image
and export them, as well as a HTML table in the current directory.
2019-08-28 13:19:52 +02:00
Jehan cce5bbc344 plug-ins: port the core of foggify plug-in.
There are 2 TODOs to take care of here. First, there is no GUI yet for
the interactive mode which will just use the default values.
Second, the color argument is not working yet because I had issues
passing a GimpRGB as argument (ideally I should create a GimpParamRGB
with gimp_param_spec_rgb(), but since we still have the pygobject bugs
about manipulating GParamSpec data directly, I can't).

Anyway it works with default values, which is already a good first step.
:-)
2019-08-28 02:25:19 +02:00
Jehan 13ea5caec2 plug-ins: port file-openraster to Python 3 + new API.
Apart from porting, only code logics change is the whole
encode()/decode() code because it created a string vs bytes mess and the
zipfile API apparently didn't like to deal with bytes, even though the
docs say otherwise.
It's hard to test on my UTF-8 system, so please anyone working with
non-UTF-8 paths, we welcome reports if ORA load/save does not work
properly.

Other than this, load, save and load_thumb were all tested and working
properly so far.
2019-08-25 12:01:41 +02:00
Jehan ef5c091e58 plug-ins: add Python and JavaScript files to the DIST.
So it seems that whatever is in _SCRIPTS is not in the distribution by
default (I suppose the reason is that even scripts can be generated). So
let's add the non-generated scripts to EXTRA_DIST.
2019-08-16 14:53:19 +02:00
Jehan 9454567e8c plug-ins: pre-load Babl module in Python console. 2019-08-09 14:41:40 +02:00
Jehan f625e2ddfb menus, plug-ins: move script development related plug-ins in a...
"Development" submenu. Also get rid of the "Languages" placeholder.
2019-08-08 11:17:07 +02:00
Jehan faf2db71cd plug-ins: improve Makefile.am of python/ subdir.
The old rules were crap and basically copying the scripts in build
folder before installing. Get proper/simpler rules.
2019-08-07 19:52:09 +02:00
Jehan f16ad87f2d plug-ins: add .gitignore files. 2019-08-06 23:22:18 +02:00
Jehan bfda31a67e configure: fix the Python checks.
1/ First I realize we were still using AM_PATH_PYTHON() and not
   AM_PATH_PYTHON3().
2/ We don't need to check anymore for pygtk, pycairo, nor do we need
   Python headers. Everything is now taken care of by GObject
   Introspection and we have nothing else to build GIMP-side.
3/ Change --enable-python into --with-python. We don't actually build
   anything now. There is no Python support to enable or disable
   anymore. We simply install Python plug-ins or not. The 3 values are
   "yes" (default, configure breaks if a Python 3 interpreter is not
   found), "no" (Python plug-ins are not installed, not recommended) and
   "force" (install Python plug-ins anyway even if an interpreter is not
   found; this can be useful especially for cross-compilation since
   Python is not useful at build-time anymore).

   Note that --with-python=force, if an interpreter is not found, the
   file `pygimp.interp` won't be installed. This is not a problem at all
   if the interpreter can be found at runtime the standard way.
   Otherwise packagers should add themselves a pygimp.interp file with
   the known interpreter path.
2019-08-06 18:35:53 +02:00
Jehan dc8f9dd168 plug-ins: add interactive run mode for palette-offset.
In interactive run-mode, the offset amount can be selected through a
small dialog box.
Only a WITH_LAST_VALS mode is still to be done.
2019-08-06 17:31:30 +02:00
Jehan 82ada55b99 plug-ins: port palette-offset to Python 3.
Oups, I left the plug-in as Python 2. This was still a good
proof-of-concept that GIMP 3 will support as well Python 2 and Python 3
(even though Python 2 is end-of-life soon anyway).
2019-08-06 01:03:31 +02:00
Jehan dca353f8cd plug-ins: port palette-offset to new API.
This first version will just offset by 1 in interactive mode, by
default. The GIMP 2 version used to have a GUI, but it was not created
by the plug-in itself. I am guessing that maybe our Python wrapper used
to create GUI by default.
If so, this will have to change. Python plug-ins will be responsible of
their own GUI, just like C plug-ins.
2019-08-06 00:40:37 +02:00
Jehan 35d4b68edc plug-ins: add a "palette" argument to palette-to-gradient.
Older palette-to-gradient used to have a palette argument. Bring it
back. The logics is that if the string is empty or None, the procedure
will use the currently selected palette. Otherwise it will try to
transform the named palette into a gradient and will fail with an error
if this palette does not exist.
2019-08-06 00:29:33 +02:00
Jehan aa6a1d369c plug-ins: use GtkSettings values to determine whether to use header bar.
As we do in other parts of the code.
Also applies the same thing to the console dialog itself.
2019-08-05 16:10:12 +02:00
Jehan 0af32861e7 plug-ins: GimpProcBrowserDialog with "use-header-bar" in Python-console.
We have code for this in gimp_proc_browser_dialog_new(), but it cannot
be moved in the object init() because this is a construction-time only
property. So this needs to be passed from the python call too.
2019-08-05 15:16:32 +02:00
Jehan c822350fb3 plug-ins: forgot to change run() signature to new API in python-console. 2019-08-04 12:22:01 +02:00
Jehan 58b3ca816a plug-ins: port python-console to new API. 2019-08-03 09:46:52 +02:00
Jehan 04598b1522 plug-ins: use new gimp_procedure_add_*_from_property() in Python.
Since GParamSpec are not working fine (cf. pygobject#227), we have this
trick of initializing new arguments or return values with properties.
Use this trick in the palette-to-gradient plug-in.
2019-08-03 09:38:46 +02:00
Jehan bc7b358802 libgimp, plug-ins: remove n_procedures from (init|query)_procedures().
The way currently implemented plug-ins are, they are already
NULL-terminating the returned arrays. Since a procedure name cannot be
NULL itself by definition, defining the array length by a terminal NULL
is enough. There is no need to also add a n_procedures parameters which
is just one more possible bug source, even more as we were already
expecting the NULL termination by using g_strfreev() to free the memory.

Anyway a length parameter does not bring any advantage since a plug-in
can still "lie" about its array size (just as it can forget to
NULL-terminate it) and when this happens, the plug-in will segfault.
That's it, it's just a plug-in programming error.

Last but not least, some binding seem to have issues with returned array
setting an (out) parameter as the length. In pygobject at least, the
length parameter doesn't disappear and we end up with this ugly
signature:

> In [3]: Gimp.PlugIn.do_query_procedures.__doc__
> Out[3]: 'query_procedures(self) -> list, n_procedures:int'

See bug report pygobject#352.
To avoid this, we should either set both the array and the length as
(out) parameters or just set the returned array as NULL-terminated
(which is the solution I chose).
2019-08-02 13:50:38 +02:00
Jehan 3945701bd6 plug-ins: localization calls must happens inside query().
It's a bit weird because this has to happen during the query() step, but
plug-ins don't have access to this step anymore, apart from
query_procedures(), which then turns out to be badly named.
2019-08-02 12:58:37 +02:00
Jehan 17667b7ddf plug-ins: start porting palette-to-gradient to new GimpPlugIn API.
Several aspects of the new API are kind of broken in the Python binding,
especially the arguments. So this first version has no arguments at all.
This also means it cannot be installed in "<Palettes>" menu for the time
being. This is work-in-progress and the missing parts will be
uncommented later when we figure out how to fix the problems.
2019-08-02 03:03:47 +02:00
Jehan 67f33cb6ec plug-ins: add button mnemonics. 2019-07-30 16:34:06 +02:00
Jehan f1351df9eb plug-ins: replace set_alternative_button_order_from_array() by the...
... Gimp.Dialog alternative version.
Just to get rid of the warning.
2019-07-30 14:05:38 +02:00
Jehan 62d87f15d9 plug-ins: port python-console to new GObject-introspected API.
I may have missed things. That is the problem of non-compiled script
languages. There is also a known warning:
> DeprecationWarning: Gtk.Dialog.set_alternative_button_order_from_array is deprecated
I'll see later about this one.

Push-time note: calling various functions is actually broken right now
in the console since the late API changes (it was working fine yesterday
evening when I tested the same python-console code). Pushing anyway for
now.
2019-07-30 12:57:59 +02:00
Jehan aab75bb1d0 plug-ins: install the pygimp.interp file.
Python scripts should already properly run, whether you run them with a
direct python shebang or a `env python` one (cf. previous commit). But
it's still nice to install a `.interp` file, which allows to control
exactly the interpreter to use, overriding the shebang. With this file,
Python scripts will use installation-time Python interpreter.

Also update old code to make the interp contents about Python 3 instead
of 2.
2019-07-29 14:28:29 +02:00
Jehan 9e844ae1d7 app: when interpreter not found in interpreter DB, leave shebang as-is.
In particular, if the shebang is `#!/usr/bin/env lang` and we have not
registered a specific interpreter for `lang`, the system should leave
the env tool search the right interpreter for us. We only bypass env
when we set our own explicit interpreter.

Apply this to palette-to-gradient.py plug-in.
2019-07-29 14:11:25 +02:00
Jehan 0f0cf4df87 po-python: install again localization for Python plug-ins.
This used to be deactivated. Let's install them again.
Also activate localization in the palette-to-gradient plug-in.
2019-07-28 21:06:36 +02:00
Jehan 65fb7536e1 plug-ins: port Python plug-in palette-to-gradient to introspected API.
Localization still doesn't work, but this is normal (po-python is not
installed). I will later make the proper tests for this.

Other than this, it is a pretty simple port. It lost all particularities
and facilities of pygimp, but the fact that it now works similarly to
the C API is quite nice too.
It still uses the legacy API for plug-ins though and will have to be
ported further when the new API will be stable.

Also I still haven't figured out why we need to return the number of
returned values. With the proper annotations, an array length parameter
disappears in introspected Python (because it is useless as Python lists
know their length). But it would seem that this annotation doesn't work
the same for returned values, which is a bit sad as it creates ugly
redundancy.

It can be noted that I an going to move all Python plug-ins from
plug-ins/pygimp/plug-ins/ to plug-ins/python/. The whole pygimp/
subdirectory will actually be deleted eventually (I keep it around for
now as reference) as Python plug-in should not need to be considered
particularly from now on. They can just be considered as generic
executables.
2019-07-28 18:43:00 +02:00