Commit Graph

582 Commits

Author SHA1 Message Date
Ell 6a01bf2df2 Issue #5219 - Color>Info>Export histogram counts pixels twice
gimp_histogram() takes an inclusive range -- the plug-in has been
counting non-zero pixels twice.
2020-06-14 17:04:30 +03:00
Niels De Graef cf41d1fdf8 colorselector: Rename signal emitters
The GIR parser is giving warnings because both e.g. a signal, a
corresponding vfunc and a method emitting it are named
"channel_changed", which can and will give issues in some bindings.

The easiest option is to follow the general convention of starting the
signal emitters with `emit_`, which also makes clear the intention of
the method.
2020-05-03 23:23:44 +02:00
Elad Shahar a3544fec6f Port pygimp colorxhtml plugin to python 3 2019-12-14 12:38:07 +01:00
luzpaz 44d10e458c Fix various typos
Found via `codespell` (v1.17.0.dev0)
2019-09-21 17:10:46 +00:00
Jehan 7777c5fa0c plug-ins: port gradients-save-as-css to Python 3 + new API. 2019-09-15 10:20:11 +02:00
Félix Piédallu 65eff6f150 Meson port. 2019-09-11 16:42:04 +02:00
Jehan 71ccaa21ee pdb, libgimp: remove double API generation from PDB.
All plug-ins got ported. Let's remove support for the old API with IDs
instead of objects.
2019-09-03 13:31:27 +02: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 e0d50aa121 plug-ins: keep building all plug-ins with old API.
Build existing plug-ins with -DGIMP_DEPRECATED_REPLACE_NEW_API.
We will port the plug-ins one at a time to the new GimpImage API.
2019-08-22 15:54:36 +02:00
luz.paz c1585d609b Misc typo fixes in plug-ins/ 2019-08-13 11:50:51 -04: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 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 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
Michael Natterer d5ac62c6eb pygimp: argh... 2019-06-27 13:46:55 +02:00
Michael Natterer 61fe89ad02 pygimp: replace gimp_drawable_get_tile2() by gimp_drawable_get_tile() 2019-06-27 13:45:09 +02:00
Jehan 35eff00e2e Issue #2961: minor coding style fix.
Missing space, and anyway let's use named parameters, which makes the
code better self-documented.
2019-02-14 12:09:29 +01:00
Veerasamy Sevagen c7d5438b49 Update gimpfu.py 2019-02-13 15:38:29 +00:00
Veerasamy Sevagen 3b818f6a9b Update plug-ins/pygimp/gimpfu.py 2019-02-13 15:38:29 +00:00
Veerasamy Sevagen cdd686f752 Update plug-ins/pygimp/gimpui.py 2019-02-13 15:38:29 +00:00
Veerasamy Sevagen b44c2e9352 Update plug-ins/pygimp/gimpfu.py 2019-02-13 15:38:29 +00:00
Veerasamy Sevagen 582801ccc5 Setting the FileChooserbutton to a fixed width. 2019-02-13 15:38:29 +00:00
sabri ünal 4b3b22812b Typo - Put a blank after the fullstop. 2019-02-09 12:06:09 +00:00
Elad Shahar f6e4145756 Add i18n support for python spyrogimp plugin 2019-02-01 07:41:19 -05:00
Ell 12dbd4aee2 plug-ins: in pygimp/plug-ins/Makefile.am, simplify plug-in copy recipe 2019-02-01 07:41:19 -05:00
Ell 95044d86b3 plug-ins: in pygimp/plug-ins/Makefile.am, re-copy plug-ins upon change
In pygimp/plug-ins/Makefile.am, fix the rule for the generated
plug-in files, so that they're re-copied to the build dir upon
changes to the source plug-in files.
2019-02-01 04:33:55 -05:00
Ell bcd9f55526 plug-ins: in pygimp/plug-ins/Makesfile.am, use tab-width of 8
... like the rest of our makefiles.
2019-02-01 04:33:54 -05:00
Ell b295a33aaf Issue #1119 - Unable to give a layer group as a parameter to a python script
Pickle gimp.GroupLayer the same way we pickle gimp.Layer, so that
layer-group parameters can be properly saved.

All credit goes to Ofnuts :)
2019-01-26 16:02:21 -05:00
Ell 9851bc8962 plug-ins: avoid running pygimp plug-ins derived from gimpplugin.plugin at each startup
When initializing a pygimp plug-in derived from gimpplugin.plugin,
only pass the plug-in's init() and quit() functions to gimp.main()
if the plug-in actually implements them, instead of passing the
default NOP versions.  This avoids plug-ins that don't implement
init() from being registered as having an init function, causing
them to be run at each startup.
2019-01-25 04:34:22 -05:00
Jehan e91028df2f plug-ins: clean the new Spyrogimp, rename it and remove old version...
... from menus.
The script-fu version is still available through pdb (for scripts) and
even in the action search. But in menus, only the new Python version
will be shown. Also update the description and name of the old version
to make clear it is deprecated in favor of the new plug-in.
Finally rename the new version to simply "plug-in-spyrogimp" (dropping
the "-plus" part as we should consider it as a replacement rather than
as another plug-in, which the "plus" would imply). Anyway the old one
was called "script-fu-spyrogimp", so there is no name clash.

While at it, do some trailing whitespace cleaning in the new plug-in.

(cherry picked from commit 8729f9a662)
2019-01-24 01:15:41 +01:00
Elad Shahar a702c6a327 plug-ins: Spyrogimp plugin rewrite.
Comment by reviewer (Jehan):

This was submitted through gimp-developer mailing list, by the same
author as the original Spyrogimp in script-fu, but this time in Python.

It does more than the original plug-in, with some automatic preview (by
drawing directly on a temporary layer, not as a GEGL preview), and using
the current tool options (current brush, etc.). The new API is similar
yet different. The much evolved possibilities makes that I don't think
it is worth trying to map 1-1 the new API to the old one, so I just let
the old plug-in next to the new one, with a different name.

Note finally that the author also contributed a new Spyrograph operation
to GEGL, yet with the comment: "The GEGL spyrograph operation is very
basic, and untested from gimp. I intend to keep developing it, since I
thought that on-canvas interaction would be very user-friendly. However,
I am not sure I will be able to get it work in a way that makes the
on-canvas interaction interactive enough.

Even if I do, it will not do what the Python plugin can do. It will be
much more basic."

So let's just integrate this evolved version of Spyrogimp for now. :-)
See: https://mail.gnome.org/archives/gimp-developer-list/2018-September/msg00008.html

(cherry picked from commit 529583430d)
2019-01-24 01:15:40 +01:00
Josef Ridky 2987f012f9 Issue #2087 - Issues discovered by coverity scan
Add missing fclose invocations and fix copy-paste issue.

This issues has been discovered by coverity scan proceeded by Red Hat.

Fixed some mistakes in the patch and added more fclose() (Mitch)

(cherry picked from commit 56c8f8320d)
2018-10-19 11:26:41 +02:00
Jehan cb892aa0e6 plug-ins: add more generated files in .gitignore. 2018-09-29 23:16:40 +02:00
Sergio Jiménez Herena 1e7d714f0a plug-ins: pygimp: Add autogenerated python files to .gitignore
(cherry picked from commit 0839a55d51)
2018-09-29 23:08:31 +02:00
Michal 04688c3111 Use the "with" keyword when dealing with file objects
According to: https://docs.python.org/3.6/tutorial/inputoutput.html
2018-09-29 20:25:40 +00:00
Michal 263b4722ca Use assignment operator 2018-09-29 20:25:40 +00:00
Michal 6090fd654f "Generator Expressions" improvements
https://www.python.org/dev/peps/pep-0289/
2018-09-29 20:25:40 +00:00
Michal 82e59a951d Use list comprehensions
https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
2018-09-29 20:25:40 +00:00
Michal 09d1a3c82f Comparision to None should be done with "is" or "is not"
https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2018-09-29 20:25:40 +00:00
Jehan de11e3532c Issue #1970: Python-fu missing in 2.10.4.
Do not set the interpreter to `python2` but to whatever was found by the
AM_PATH_PYTHON2() m4 macro.
It looks like the Python2 binary we ship in our DMG may be call "python"
only (without the '2'). Let's just make our code more resilient to
various builds.
I am not sure yet this is the only/actual problem for this issue on
macOS, but this is at least in the right way.

(cherry picked from commit 8f21c9483a)
2018-08-19 12:48:02 +02:00
Jehan b810590b44 plug-ins: include the right python source in the distribution.
The python path with directory are generated files and should not be in
the dist. The previous commit was fixing an in-tree `make check` but
this one fixes the `make distcheck` as the dist was packaging the wrong
python files.

(cherry picked from commit 55a7872e1b)
2018-08-18 12:51:59 +02:00
Jehan dbb9555d2f Issue #788: also install all python plug-ins in their own directory.
It seems I forgot to also install python plug-ins in a subdirectory
(because they are deactivated on master for the time being). I even
found a year-old patch from myself rotting in the tracker, and which was
doing exactly this.
I redid it, improved to fit changes.
2018-07-18 22:11:39 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Félix Piédallu 15075932be Fix Python files:
* Prefer python2 to python that may point on python3 on modern installs.
* Fix indent/spaces consistency.

(cherry picked from commit 2265701268)
2018-06-16 02:57:06 +02:00
Jehan 3c6f789ca5 plug-ins: recognize "python2" env to launch the python interpreter.
(cherry picked from commit 769325e51b)
2018-06-16 02:57:06 +02:00
Jehan 42b13216fc m4macros, plug-ins: run more accurately the "python2" interpreter.
Our configure test checks the presence of a Python2, but then uses
"python" as interpreter, which is a problem nowadays as the default
python is set to be Python 3 on some distributions (and this will be
more and more the case). So GIMP may end up trying to run our plug-ins
through Python 3 (which would fail) even if Python 2 is present.
Now AM_PATH_PYTHON2() m4 macro will set $PYTHON to a more accurate
Python version as priority.

Similarly let's use "python2" in the binfmt string for extension search.

(cherry picked from commit 03ea9cac54)
2018-06-16 02:07:02 +02:00
Jehan 79d55e09e4 Issue #248: Python console doesn't support input()/raw_input().
As noted by Massimo, we can just make the argument of raw_input() an
optional argument.

Also adding a modal implementation for input() so that it doesn't lock
the Python console waiting from input from the plug-in stdin. As noted
in Python doc, input() is equivalent to `eval(raw_input(prompt))`.
Not all that safe, but in the end, it is the developer's responsibility.

(cherry picked from commit 130ef5ce59)

Note: it is untested on master since we don't have Python right now, but
I don't see why it would not work here as well!
2018-06-15 18:44:27 +02:00