Commit Graph

164 Commits

Author SHA1 Message Date
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