Commit Graph

2426 Commits

Author SHA1 Message Date
Jehan 899cf96ec5 libgimp: make sure gimp_item_get_by_id() allocates the right class.
It is theoretically possible for an id to be reused. Normally here this
should not happen, since the previous item would have been removed from
the hash table anyway, when it got destroyed. Let's still be thorough.
2019-08-22 15:54:37 +02:00
Jehan 08849a584c libgimp: GimpItem now also belong to libgimp. 2019-08-22 15:54:36 +02:00
Jehan d15388c8c9 libgimp: s/gimp_display_new_by_id/gimp_display_get_by_id/
GimpDisplay objects now also belongs to libgimp!
2019-08-22 15:54:36 +02:00
Jehan cfd30ec62a libgimp: s/gimp_image_new_by_id()/gimp_image_get_by_id()/
This means that images' ownership is not given to caller in particular.
libgimp will now keep a reference of all GimpImage-s it creates and
return this same reference if called again. It also means that you can
now compare images by pointer comparison (as 2 GimpImage objects
representing the same image ID will be equal).
Obviously as a side effect, gimp_image_list() is changed to (transfer
container) as you must only free the container now, not the elements.
Also various other functions creating new images are now (transfer none)
too.

Long-time plug-ins will have to be taken in consideration in a further
step (we currently never free GimpImage for destroyed images in
particular).
2019-08-22 15:54:36 +02:00
Jehan 7f91f6bc25 libgimp: GimpImageProcedure now uses GimpImage/GimpDrawable too. 2019-08-22 15:54:36 +02:00
Jehan ee8b467e9f libgimp: GimpSaveProcedure() now uses GimpImage/GimpDrawable object...
... as parameters.
And GimpLoadProcedure() now expects the run() function to return a
GimpImage object.
2019-08-22 15:54:36 +02:00
Jehan a1eeca490f libgimp: support all GimpItem subclasses as argument and return values. 2019-08-22 15:54:36 +02:00
Jehan 75f8a3804d libgimp: nicer API for functions returning a list.
I.e.: gimp_image_get_(layers|channels|vectors)(), gimp_image_list() and
gimp_item_get_children().
Instead of returning an array of IDs, these will now return a GList with
the right objects ready to use.
2019-08-22 15:54:36 +02:00
Jehan c409829be5 libgimp, pdb: no need to create deprecated versions for private API. 2019-08-22 15:54:36 +02:00
Jehan 5e6d4d8fbd libgimp: fix the non-generated API with the new class types. 2019-08-22 15:54:36 +02:00
Jehan 8c95499e14 pdb, libgimp: now make all ID types classes of their own.
No need of is_id_arg() anymore in pdb/lib.pl. Let's reuse the {id}
value. Also I had to add an additional trick for GimpDisplay which we
will now generate as such in libgimp PDB files, but still need to show
as GimpObject on app/pdb/.

As previously, only the new classes and the PDB generation for a first
step.
2019-08-22 15:54:36 +02:00
Jehan 8249afe2fc libgimp: allow object GParamSpec for GimpItem and child classes. 2019-08-22 15:54:36 +02:00
Jehan 3f1491e572 libgimp: update non-generated API using GimpItem/GimpDrawable/GimpLayer.
I did the same trick with GIMP_DEPRECATED_REPLACE_NEW_API macro, apart
for some minor widget API to preview drawable, which I will fix right
away in our plug-ins.
2019-08-22 15:54:36 +02:00
Jehan 79b319cf9d libgimp, pdb: add GimpItem > GimpDrawable > GimpLayer classes.
Only class and subclasses creation and PDB generation for this first
step.
I'll later do other types of items.
2019-08-22 15:54:36 +02:00
Jehan 793cba6675 libgimp: allow object GimpImage as procedure parameter.
Though it is still possible to use an image ID as procedure parameter,
it is now possible to pass a GimpImage GParamSpecObject.

Over the wire, this will transform back and forth into a GimpImageID,
totally transparently for the plug-in which will only always get a
GimpImage.
2019-08-22 15:54:36 +02:00
Jehan 09f0530dab libgimp: update non-generated API to allow old and new API.
Same as previous commit: by default the new API will be used. But if a
plug-in builds with GIMP_DEPRECATED_REPLACE_NEW_API macro, then the same
function names will call the old API with ids.
2019-08-22 15:54:36 +02:00
Jehan fec6034c7a pdb: keep both the old and new API alive.
By default the new API will be used. But if we build with
GIMP_DEPRECATED_REPLACE_NEW_API macro, then the same function names will
call the old API with ids.

This way, we don't have to update all our plug-ins at once (which I
tried and is very tedious work).

Note that bindings won't have access to the deprecated API at all.
2019-08-22 15:54:36 +02:00
Jehan 17a40b049f libgimp: generate functions both for old and new GimpImage APIs.
This way, it would still be possible to use the old API. WIP.
2019-08-22 15:54:36 +02:00
Jehan 688c3230d0 libgimp: create and use gimp_image_new_by_id().
Simpler than using g_object_new() in a bunch of places.
2019-08-22 15:54:36 +02:00
Jehan bb72504ea9 libgimp: change all non-generated API to use GimpImage.
We shouldn't pass as parameter nor return gint32 anymore.
2019-08-22 15:54:36 +02:00
Jehan 4db8cda24e app, pdb, libgimp: add a new GimpImage class for plug-ins.
This means that all functions which were returning or taking as
parameter an image id (as gint32) are now taking a GimpImage object
instead.
The PDB is still passing around an id only over the wire. But we create
an object for plug-ins to work on.

This is quite a huge API break, but is probably the best bet for the
future quality. It will make nicer API instrospection (and nicer API in
binding), will fix the issues with pspec on GimpImageID in Python
bindings (which makes the current Python API unusable as soon as we need
to work on images, which is most of our plug-ins!), etc.
Also it will allow to use signals on images, which will be a great asset
when we will finally have bi-directionnal communications (i.e. plug-ins
would be able to connect to image changes, destructions, and whatnot).
2019-08-22 15:54:36 +02:00
luz.paz 0340c4a904 libgimp/ documentation typo fixes
Found via `codespell -i 3 -w -S ./ChangeLog*,*.po -I ../gimp-word-whitelist.txt ./libgimp`
2019-08-20 08:40:58 +00:00
Michael Natterer 0f273a5959 app, libgimp: also UTF-8-validate all elements of PDB string arrays 2019-08-20 01:46:56 +02:00
Michael Natterer 6ed2d03c73 libgimp: use the new macros in all non-generated files 2019-08-20 01:21:32 +02:00
Michael Natterer 09eaf0295a libgimp: add a gazillion of macros to gimpprocedure-params.h
that make dealing with value arrays easier and shorter, e.g.

  g_value_get_boolean (gimp_value_array_index (args, n)):

becomes:

  GIMP_VALUES_GET_BOOLEAN (args, n);
2019-08-20 01:00:47 +02:00
Michael Natterer c4a973c30a libgimp: add GimpThumbnailProceudre
which handles the standard thmbnail procedure args and return values.
2019-08-19 14:02:34 +02:00
Michael Natterer fab806089a app, libgimp: UTF-8 validate all string arguments and return values
The only way for a plug-in to prevent this is now using
GIMP_PARAM_NO_VALIDATE.
2019-08-19 13:11:02 +02:00
Michael Natterer d62e75a41f Move GimpParamSpecString from libgimp back to app
It's just too weird to be public. Remove its properties from the wire
protocol and from pluginrc. Instead, have all GParamSpecs' flags on
the wire and in pluginrc, so we can use stuff like
GIMP_PARAM_NO_VALIDATE.

Port the remaining few places to GIMP_PROC_ARG_STRING().

I'm sure something is broken now wrt UTF-8 validation,
will add tighter checks in the next commit.
2019-08-19 12:54:52 +02:00
Michael Natterer de121374ef Change the "handles uri" flag of file procedures to "handle remote"
And always pass URIs to all file procedures, the ones what didn't
register as "handles remove" will only ever get local file:// URIs.

Change all file plug-ins (also legacy ones) to expect URIs instead
of filenames, and convert to local paths in the plug-in.

The wire protocol should now be almost 100% clean of non-UTF-8 strings.
2019-08-19 12:05:12 +02:00
Michael Natterer 9cabc8c8d0 libgimp, plug-ins: use the new macros everwhere
Except for gimp_param_spec_string() which is on its way back to the
core.
2019-08-19 10:02:07 +02:00
Michael Natterer 471285bda9 libgimp: add gimpprocedure-params.h
which looks much like gimpconfig-params.h and contains macros
(e.g. GIMP_PROC_ARG_BOOLEAN() and GIMP_PROC_VAL_BOOLEAN()) for all
GimpProcedure argument and return value types supported by the
protocol, and makes the boilerplate of setting up a procedure more
readable and much less indented.

This file is C-only and not introspected.
2019-08-19 09:56:20 +02:00
Michael Natterer d7e42b28e3 libgimp: move the GimpProcedure icon API next to the menu API 2019-08-18 14:04:45 +02:00
Michael Natterer 98bfe065e8 libgimp: add GimpImageProcedure with (run_mode, image, drawable) args
to save the boulerplate of handlin these 3 arguments in a lot of
plug-ins.
2019-08-18 12:46:07 +02:00
Michael Natterer f480d02823 libgimp: add precondition checks for gimp_is_canonical_identifier()
on all procedure name parameters.
2019-08-18 12:43:37 +02:00
Michael Natterer b610475122 libgimp: remove gimp_register_file_handler_priority() 2019-08-18 00:44:18 +02:00
Michael Natterer 515dcbb1ee libgimp: remove gimp_get_pdb_error() 2019-08-16 23:01:17 +02:00
Michael Natterer 449e84c108 pdb: use guint for tatoo, guide, sample point, which they are
and initialize GimpUnit with PIXEL instead of just 0.
2019-08-15 16:41:39 +02:00
Michael Natterer 652fd75891 Rename GIMP_TYPE_INT8_ARRAY to GIMP_TYPE_UINT8_ARRAY
and GimpParamSpecInt8Array to GimpParamSpecUInt8Array
2019-08-15 15:04:34 +02:00
Michael Natterer 350abba213 Remove GIMP_TYPE_INT16 and GimpParamSpecInt16
Use gint and GParamSpecInt with the right value range instead.
2019-08-15 14:17:17 +02:00
Michael Natterer 5a09523214 Remove GIMP_TYPE_INT32 and GimpParamSpecInt32
Use gint and GParamSpecInt instead.
2019-08-15 14:04:56 +02:00
Michael Natterer 1bf90ec77f Remove GIMP_TYPE_INT8 and GimpParamSpecInt8
Use guchar and GParamSpecUChar instead.
2019-08-15 13:34:11 +02:00
Michael Natterer 1bfa52b692 libgimp: remove gimp_plugin_icon_register() 2019-08-15 12:51:40 +02:00
Jehan 31bee77be9 libgimp: s/gimpdb-private.h/gimppdb-private.h/
Ok so that's why I thought it was not existing. There was actually a
typo!
2019-08-14 22:33:43 +02:00
Michael Natterer 2cc080cf60 libgimp, devel-docs: why bother having docs for gimplegacy.[ch]
It's about to be dumped...
2019-08-14 21:04:18 +02:00
Michael Natterer f8895f7f22 Revert "libgimp: gimpdb-private.h was removed."
It's very much alive :)

This reverts commit e67c922b00.
2019-08-14 20:44:36 +02:00
Jehan e67c922b00 libgimp: gimpdb-private.h was removed. 2019-08-14 20:28:10 +02:00
Michael Natterer 996564116d libgimp: gimp_pdb_temp_name() can also go, bye... 2019-08-14 19:43:54 +02:00
Michael Natterer 6801857b9c libgimp: remove all support for temp procs from gimplegacy.[ch] 2019-08-14 19:16:33 +02:00
Michael Natterer 5b076e990d libgimp: remove legacy support from gimpbrush,pattern,..select.c
Their users have all been ported to GimpPlugIn.
2019-08-14 19:03:48 +02:00
Michael Natterer 0246f34183 libgimp: remove some more cruft that is no longer needed 2019-08-14 10:18:34 +02:00
Michael Natterer aba2eea17c libgimp: remove gimp_run_procedure() and gimp_destroy_params() 2019-08-14 00:18:39 +02:00
Michael Natterer 35fb6ca716 libgimp: deal with NULL arrays in _gimp_value_to_gp_param()
How did this not crash even once before in my tests...
2019-08-13 22:52:19 +02:00
Michael Natterer 91ecb6317a libgimp: remove more cruft that is now unused 2019-08-13 20:38:01 +02:00
Michael Natterer a5cb30173c libgimp: don't call g_file_new_for_uri() on a path
in gimp_load_procedure_run() and gimp_save_procedure_run().
2019-08-13 19:10:55 +02:00
luz.paz 7e99aa59f5 Add other misc. typo fixes 2019-08-13 11:50:51 -04:00
Michael Natterer b8ee717269 libgimp: gimp_procedure_validate_args() support GIMP_PARAM_NO_VALIDATE
The flag is defined in libgimp now.
2019-08-13 13:37:52 +02:00
Michael Natterer d2add325bb libgimp: remove more legacy API that isn't used any longer by any plug-in 2019-08-13 11:20:52 +02:00
Michael Natterer 12cafbfe6e libgimp: refer to new API in GimpProcedure docs 2019-08-13 00:46:40 +02:00
Michael Natterer 79d92a5d05 libgimp: remove a lot of cruft because script-fu is ported now
Also remove all legacy code from GimpProcView and
GimpProcBrowserDialog.
2019-08-12 20:49:08 +02:00
Michael Natterer 3d935b0bb0 libgimp: don't unref() the GParamSpecs of a GimpPDBProcedure
after adding them to the procedure. We only own one reference, and
it's the floating one.
2019-08-12 19:11:05 +02:00
Michael Natterer 42e8a344ab libgimp: don't use G_IS_FILE() and g_file_get_path() on a NULL GFile
when registering the plug-in's translation domain. A NULL path is
allowed and used by script-fu.
2019-08-12 19:10:30 +02:00
Michael Natterer b33c3086a9 libgimp: allow to call gimp_procedure_add_menu_path() on installed procs
Adding menu paths must be possible even after the procedure has been
installed, script-fu registers all menu paths afer installing its
procedures so they are properly sorted.
2019-08-12 19:06:13 +02:00
Michael Natterer dbeed89858 libgimp: remove gimp_pdb_dump() and gimp_pdb_proc_exists() 2019-08-11 22:38:43 +02:00
Michael Natterer ae824dcab5 pdb, libgimp: remove the now unused gimp_pdb_proc_arg() and _proc_val()
Bye bye legacy.
2019-08-11 22:32:25 +02:00
Michael Natterer 533e947f50 libgimp: stop using gimp_pdb_proc_arg() and proc_val()
Their return values can be derived from the GParamSpec returned
by gimp_pdb_proc_argument() and proc_return_value().
2019-08-11 22:05:07 +02:00
Michael Natterer b35dbf0d77 libgimp: change the remaining "author" strings and variables to "authors" 2019-08-11 17:03:03 +02:00
Michael Natterer 1c9b3c7055 libgimp: add gimp_pdb_get_last_error() and _get_last_status()
and move the old API to gimplegacy.[ch].
2019-08-11 16:41:58 +02:00
Michael Natterer 6622cf0dc4 libgimp: add and fix docs, reorder GimpParamData and remove d_boundary 2019-08-11 15:38:07 +02:00
Michael Natterer d067441c31 libgimp: rename GimpLoad,SaveFunc to GimpRunLoad,SaveFunc
and document gimp_load,save_procedure_new().
2019-08-11 14:58:55 +02:00
Michael Natterer fc065f8add pdb, libgimp: add gimp_load_procedure_set_thumbnail_loader()
and move the old API to gimplegacy.[ch]
2019-08-11 14:27:41 +02:00
Michael Natterer 84629cc1d0 pdb, libgimp: move the old file proc registering API to gimplegacy.[ch]
Also, #define GIMP_DISABLE_COMPAT_CRUFT in all GimpPlugIn related
files to prevent accidential use of the old API.
2019-08-11 13:21:55 +02:00
Michael Natterer 0477e60200 libgimp: update gimp.def 2019-08-11 12:56:13 +02:00
Michael Natterer cd836e9d96 libgimp: add gimp_file_procedure_set_handles_uri()
Implementing a shiny new GimpFileProcedure doesn't mean the libraries
we use to load/save files are automatically capable of handling remote
files, so we still need this flag.
2019-08-11 12:52:28 +02:00
Michael Natterer a79eaaf503 libgimp: add GimpFileProcedure, GimpLoadProcedure and GimpSaveProcedure
which are GimpProcedure subclasses with API to register as load/save
handlers and their own kind of run functions that get their standard
arguments passed directly instead of packed into a GimpValueArray.

They also register their standard arguments themselves, which removes
quite some boilerplate from load/save plug-ins.

Remove gimpprocedure-private.[ch] because install() and uninstall()
are now virtual functions of GimpProcedure.
2019-08-10 22:01:37 +02:00
Michael Natterer e6d662e352 libgimp*: various doc fixes 2019-08-10 12:32:25 +02:00
Michael Natterer 60b6f34737 pdb, libgimp: fix various doc issues found by gtk-doc 2019-08-10 11:08:06 +02:00
Jehan 6fe24fcb0b libgimp: fix missing installed headers.
While doing so, better break the various source categories in libgimp/.
Otherwise we were duplicating some of the header list, hence we forgot
to install some of the headers.
2019-08-09 22:41:14 +02:00
Jehan 10c10e16b1 libgimp: add libgimp_built_sources inside libgimp_introspectable. 2019-08-09 18:58:48 +02:00
Michael Natterer 354ce5f742 pdb, libgimp: one more annotation for gimp_enums_get_type_names() 2019-08-09 18:47:55 +02:00
Michael Natterer 6d24eb9bb2 pdb, libgimp: annotate gimp_enums_get_type_names()
and manually add gimpenums.c to the list of introspectable files.
2019-08-09 18:41:58 +02:00
Jehan 8f79ddbfe0 libgimp: add some (nullable) annotation and fix some comments. 2019-08-09 12:48:41 +02:00
Michael Natterer 41fb552988 libgimp: more docs and annotations 2019-08-09 12:41:45 +02:00
Jehan d28af77fc2 libgimp: make GimpProcBrowserDialog work both with the old and new API.
The dialog was still calling the old API gimp_pdb_query() everywhere,
which made it fail to run when called with the new API (e.g. from the
Python console or directly from an action) whereas it worked well when
called from the old API (e.g. from the Script-fu console). By testing
the existence of the GimpPDB singleton, we can have this dialog work in
both cases.
2019-08-09 02:32:52 +02:00
lillolollo 4cef17c7cf Issue #3758: fixes the build on mingw-w64.
Fixes:
> '_argc' undeclared (first use in this function)
2019-08-09 01:18:22 +02:00
Michael Natterer 155bc75a75 libimp*, app: get rid of inline pixbufs in the API and in pluginrc
because they are deprecated.

Change GIMP_ICON_TYPE_INLINE_PIXBUF to GIMP_ICON_TYPE_PIXBUF and the
libgimp API to (icon-name, GdkPixbuf, GFile). Use the file's uri and a
PNG blob of the pixbuf to pass around on the wire and for storage in
pluginrc.
2019-08-09 00:16:35 +02:00
Michael Natterer 244b52bf0d pdb, libgimp: make the "pdb" PDB group private
and don't install its header. Temporarily add its only two remaining
needed functions to gimppdb.[ch].

Also some Makefile cleanup.
2019-08-08 21:55:11 +02:00
Jehan 25ec0a0381 libgimp: GObject Introspection now depends on Babl-0.1 introspected lib.
And that's a lot of less warnings now! Youhou!
2019-08-08 18:02:23 +02:00
Jehan f49f1b587a libgimp: improve GimpProcedure icon functions.
gimp_procedure_set_icon() and gimp_procedure_get_icon() are not very
nice functions for bindings. They are still usable, but in most
bindings, the data parameter/returned value would end up like a uint
list which you'd want to convert to a string in the icon name or file
path case. It's still possible but very cumbersome.

Instead, I skip both functions for bindings and create specific
gimp_procedure_set_icon_*() and gimp_procedure_get_icon_*() functions,
which are much more binding-friendly.
2019-08-08 17:35:20 +02:00
Jehan 9339741135 libgimp: unnecessary (out) annotation on return value.
Fixes:
> Warning: Gimp: unexpected annotation: out
2019-08-08 16:58:56 +02:00
Jehan 376552fbfc libgimp: fix the build.
Autotools were not able to recognize that libgimp-@GIMP_API_VERSION@.la
and ../libgimp/libgimp-@GIMP_API_VERSION@.la were the same dependency.
Hence with multi-thread builds, GI scanner was not waiting for the lib
to be totally built then failed randomly. Make the path recognizable,
and do the same for libgimpui.
For other libgimp*, I still need to keep a more complicated relative
path, but since libgimp/ is the last processed folder, AFAIK it won't
make problems.
2019-08-08 16:40:02 +02:00
Jehan 2dde79b3e7 libgimp*: move GObject Introspection into libgimp/.
libgimp is anyway processed at the very end after all other libgimp*
were built. This way, it also fixes #3746, by removing the $(top_srcdir)
everywhere from introspected files, hence making the build work again
with older automake.
2019-08-08 15:59:44 +02:00
Michael Natterer 35ead93a8f libgimp: simplify gimp_pdb_run_procedure_valist() a lot
by using gimp_value_array_new_from_types_valist().
2019-08-08 13:27:34 +02:00
Michael Natterer 30d63111c3 libgimp*, pdb: gimp_value_array_new_from_types*() takes (type, value)
So a value array can now we created like this:

array = gimp_value_array_new_from_types (&error_msg,
                                         G_TYPE_STRING, "foo",
                                         G_TYPE_INT,    23,
                                         G_TYPE_NONE);

Change PDB generation to use this, which makes for much nicer code in
the libgimp wrappers, and only set arrays separately instead of all
values.
2019-08-08 13:01:50 +02:00
Michael Natterer dd8bf71f96 libgimp: make "pdb" a construct-only property of GimpPDBProcedure 2019-08-08 12:12:55 +02:00
Michael Natterer d156028c8a libgimp*, app: add the help-id to the wire protocol
Pass the help-id specified by the procedure to the core, and use it in
the core if set instead of always using the procedure's name (which
was probably good enough for all eternity, but it's still more
consistent this way).
2019-08-08 09:57:56 +02:00
Michael Natterer 0aa2dcfadb libgimp: replace gimp_pdb_dump() and gimp_pdb_query() by new API
and move them to gimplegacy.[ch].
2019-08-08 01:14:35 +02:00
Michael Natterer 5d80b74204 libgimp: more docs and annotations for GimpPDB 2019-08-08 00:34:16 +02:00
Michael Natterer e1276e2eda libgimp: help_func is (scope async) 2019-08-08 00:05:56 +02:00
Michael Natterer 6b2624f021 libgimp: don't connect a NULL destroy notify 2019-08-07 23:45:25 +02:00
Michael Natterer c6bcb3114f libgimp: add GDestroyNotify for image and item combo box data 2019-08-07 23:16:25 +02:00
Michael Natterer b2582e80f6 libimp: merge public gimppixbuf functions into gimplayer and gimpdrawable
and remove gimppuxbuf.h from the public API. Keep the files privately
for _gimp_pixbuf_from_data().
2019-08-07 22:26:05 +02:00
Michael Natterer c08186e6fe libgimp*: fix some parameter inconsistencies to silence GI warnings 2019-08-07 22:05:12 +02:00
Michael Natterer e437e00adf pdb, libgimp: hide gimpunit_pdb.h and gimpplugin_pdb.h from the API
They only contain private functions and don't need to be installed or
included by gimp_pdb_headers.h.

The PDB generation part is done by adding a "lib_private" variable
that can be set on PDB groups which should not be public API; the rest
is manual Makefile fiddling.
2019-08-07 18:47:24 +02:00
Jehan fc620ee67e libgimp: read and write channel should be boxed properties.
gpointer is not introspectable, and we should always prefer boxed types
over generic pointer types (thanks nielsdg!).
This also fixes gjs (JavaScript) binding of our API which was dropping
our properties even though they didn't need to be handled in JS.

See https://gitlab.gnome.org/GNOME/gjs/issues/266
2019-08-07 12:31:17 +02:00
Michael Natterer 0ef65bc647 pdb: move gimp_plugin_set,get_pdb_error_handler() to gimplegacy.[ch]
Hide the PDB wrappers and add the same API to GimpPlugIn.
2019-08-07 11:01:53 +02:00
Michael Natterer 1e6abab1d3 libgimp: name parameters "procedure_name" not just "name"
and some random cleanup.
2019-08-07 10:43:07 +02:00
Michael Natterer 7b58cb1d28 libgimp: move most old gimp_pdb functions to gimplegacy.[ch] 2019-08-07 00:27:34 +02:00
Michael Natterer 64d880f1fe libgimp: add gimp_pdb_temp_procedure_name() and hide the PDB wrapper 2019-08-07 00:19:38 +02:00
Michael Natterer 2599c6e071 libgimp: add some const to input parameters, like const GimpValueArray*
for procedure arguments. This implies creating a new value array in
gimp_procedure_run() if the passed array is too short, instead of
just appending to the passed array, which was ugly anyway.
2019-08-07 00:04:58 +02:00
Michael Natterer 877a116667 libgimp: fix typo in G_OS_WIN32 code 2019-08-06 23:54:34 +02:00
Michael Natterer 500a840f50 libgimp: forgot to add gimplegacy-private.h 2019-08-06 23:28:29 +02:00
Michael Natterer cc5e9240d2 libgmp: move the remaining legacy code to gimplegacy, even PLUG_IN_INFO
Add gimplegacy-private.h to keep it separate from gimp-private.h.

The legacy code could now be removed and GimpPlugIn-ported plug-ins
would not notice.
2019-08-06 23:06:15 +02:00
Michael Natterer 3c001a6123 libgimp: separate legacy from GimpPlugIn wire communication
Move all old wire code to gimplegacy.c and add wire code to
GimpPlugIn, which now talks with the GIMP core all by itself.

Add some more ASSERT_NO_PLUG_IN_EXISTS assertions to gimplegacy.c and
fix new code that was still using legacy API.
2019-08-06 22:21:50 +02:00
Michael Natterer caa61eef4f libgimp, pdb: remove gimp_run_procedure_with_array() from gimp.[ch]
and add it to gimplegacy.[ch] as gimp_run_procedure_array().
Regenerate all PDB wrapper accordingly.
2019-08-06 21:44:26 +02:00
Michael Natterer c2e5374845 pdb, libgimp: make all PDB wrappers use GimpPDB to run procedures 2019-08-06 21:34:00 +02:00
Michael Natterer 9a027140c8 libgimp: add read- and write-channel construct properties to GimpPlugIn
and change all GimpPlugIn-based code to get the channels from the
plug-in singleton instead of from the global variables.
2019-08-06 21:29:48 +02:00
Jehan b20aab0236 libgimp: add annotations to gimp_pdb_run_procedure_array().
Especially as an example of setting a (rename-to) since variable
arguments are not introspectable, hence gimp_pdb_run_procedure() won't
be available for non-C plug-ins.
2019-08-06 19:29:00 +02:00
Michael Natterer 84cb07f995 libgimp: add more comfortable ways to run procedures to GimpPDB
return_vals = gimp_pdb_run_procedure (pdb, "procedure-name",
                                      G_TYPE_STRING,  "string arg",
				      G_TYPE_INT      23,
				      G_TYPE_BOOLEAN, FALSE,
				      G_TYPE_NONE);
2019-08-06 19:13:06 +02:00
Michael Natterer 8860d78979 libgimp: more progress on the GimpPDB object
- add gimp_pdb_run_procedure()
- hide more functions in gimppdb_pdb.[ch], and add proper API
- add gimp_get_pdb() which returns the singleton
2019-08-06 19:13:06 +02:00
Michael Natterer 468276e4d2 pdb: remove the section docs from unit.pdb
The functions are all private and the section is already documented in
libgimpbase.
2019-08-06 12:55:34 +02:00
Michael Natterer 05baadcd1d pdb: rename the "procedural_db" PDB group to just "pdb" 2019-08-06 12:51:56 +02:00
Michael Natterer 450a9f90b4 libgimp: add a GimpPDB class and subclass GimpProcedure as GimpPDBProcedure
The idea is that we already have a GimpProcedure object in libgimp
which has name, help, blurb, arguments, return values and everything,
so we really don't need a parallel API to query PDB procedures for
their properties.

- make run() a virtual function of GimpProcedure
- move GIMP_PDB_ERROR to GimpPDB
- GimpPDBProcedure is a trivial subblass which populates
  GimpProcedure's members by querying the PDB.
- make "plug-in", "procedure-type" and "name" construct-only
  properties of GimpProcedure.

This is all work in progress.
2019-08-06 12:22:23 +02:00
Michael Natterer eacda4bb50 libgimp: remove includes and add "Since: 3.0" in gimpprocecure.c 2019-08-05 23:33:49 +02:00
Michael Natterer eaefe4f9d9 libgimp: fail gimp_procedure_new() on non-canonical procedure names 2019-08-05 23:22:39 +02:00
Michael Natterer 550ec68cff libgimp: reorder functions and members of GimpProcedure
to make more sense, as long as the file has little git history.
2019-08-05 23:01:25 +02:00
Michael Natterer 6cf1ec8200 libgimp: separate more new from old code by duplicating more logic in GimpPlugIn 2019-08-05 22:37:26 +02:00
Jehan 4a6b58507b libgimp, libgimpmath, libgimpwidgets: update def files.
So many things moved in the last few days, and we just didn't think of
updating these.
2019-08-05 16:55:35 +02:00
Michael Natterer f4b2cda964 Issue #3753 - Gimp master don't build on mingw-w64 errors on...
...gimp-shm.c

Fix some stuff I had copied blindly because it's not built on
my machine.
2019-08-05 16:02:38 +02:00
Michael Natterer d5fbbf3f49 libgimp: #include <sys/types.h> in gimp-debug.c 2019-08-05 16:00:02 +02:00
Michael Natterer 254271971e libgimp*: more docs and annotations 2019-08-05 15:57:11 +02:00
Michael Natterer c6236ac140 pdb, libgimp: more docs and annotations 2019-08-05 15:31:43 +02:00
Jehan a76c9305bb libgimp: run the first search of GimpProcBrowserDialog in init().
Otherwise, if run in gimp_proc_browser_dialog_new(), this initial search
does not happen when constructing with g_object_new(). This is
especially bad for non-C plug-ins as gimp_proc_browser_dialog_new() is
not introspectable because of variable arguments.
2019-08-05 15:12:16 +02:00
Michael Natterer acbe229427 libgimp: make gimp_proc_view_new() show both new- and old-style args
And reduce its API to just (proc-name, menu-path), it can look up all
the shit from the PDB itself.
2019-08-05 14:17:18 +02:00
Michael Natterer 6c18492668 app, libgimp: support GParamParam as a GParamSpec
also add forgotten support for GimpParamEnum.
2019-08-05 14:16:09 +02:00
Michael Natterer a6516e5097 app, libgimp: support GParamUInt on the wire 2019-08-05 12:47:05 +02:00
Michael Natterer c8f38810d1 pdb: add gimp_procedural_db_proc_argument() and _return_value()
Which return proper GParamSpecs. Incuding some useless testing code in
gimp_procedural_db_proc_info(), to make sure things work, will go away
again soon.
2019-08-05 10:48:23 +02:00
Michael Natterer aa505b43dc app, libgimp*: add protocol support for GValues holding a GParamSpec
so we can have PDB introspection procedures for the new plug-in API.
2019-08-05 09:07:45 +02:00
Michael Natterer 8c1a43dff7 libgimp: move the debug code to new private files gimp-debug.[ch] 2019-08-04 23:26:31 +02:00
Michael Natterer a74f4de81e libgimp: some random minor cleanups 2019-08-04 23:02:42 +02:00
Michael Natterer 888c42fbb8 libgimpbase: remove the gimp protocol mutex and gp_lock()/gp_unlock()
The protocol is supposed to be used recursively, the locks just
deadlock in some situations. Threaded use of the wire protocol is
simply forbidden.
2019-08-04 22:42:15 +02:00
Michael Natterer 5ac8b70e47 pdb: generate the (array length=foo) annotation with less hacks
and more important: correctly.
2019-08-04 22:24:11 +02:00
Michael Natterer 360314eda7 pdb: fix generation of "Returns:" to not line-wrap annotations
Also generate comments like "Must be freed with g_free()" for all
return values instead of manually and inconsistently having them on
some return values only.
2019-08-04 22:09:04 +02:00
Michael Natterer 1c317a739b libgimp: forgot to actually add gimp-shm.[ch] 2019-08-04 20:18:10 +02:00
Michael Natterer ca1cb056fc libgimp: move the shm code to new private files gimp-shm.[ch]
and remove it from the public API, it should have never been
there in the first place.
2019-08-04 18:54:00 +02:00
Michael Natterer d34bc03229 libgimp: don't leak the temp callback name in the data select impls 2019-08-04 18:04:18 +02:00
Michael Natterer fad59611bc libgimp: port gimpprogress to the new plug-in API, untested
It's tested to still work when using the old API though.
2019-08-04 17:51:59 +02:00
Jehan 026cc0f149 libgimp: fix s/m_float/m_enum/ for GP_PARAM_DEF_TYPE_ENUM. 2019-08-04 17:23:54 +02:00
Michael Natterer 89feeecc96 libgimp: make GimpFontSelectButton interpret NULL as the current font
like all other select buttons do.
2019-08-04 17:14:18 +02:00
Michael Natterer ae7fa2a1de libgimp: clean up the instance private code in all select buttons 2019-08-04 17:04:22 +02:00
Michael Natterer 6e80a2324f libgimp: port gimp*select.[ch] to the new plug-in API
Use the new implementation only if a GimpPlugIn exists, use the old
code otherwise. Add a GDestroyNotify for the callabck's user_data.
2019-08-04 16:08:49 +02:00
Michael Natterer cc8fc0f90f libgimp*: add GI's .dirstamp to .gitigore 2019-08-03 19:50:17 +02:00
Michael Natterer 9549be2539 libgimp: kill the plug-in when old API is used while a GimpPlugIn exists 2019-08-03 18:20:28 +02:00
Michael Natterer 38089bb61f libgmp: more useless includes 2019-08-03 17:12:27 +02:00
Michael Natterer e705ab050e libgimp: remove useless includes 2019-08-03 17:11:30 +02:00
Michael Natterer 20d04e029f app, libgimp: support normal GParamInt for plug-in procedures 2019-08-03 17:00:43 +02:00
Michael Natterer 5b8deb68b4 libgimp: make sure GimpProcedures always get all their arguments
gimp_procedure_run(): fill the value array with default values so a
procedure's run callback always gets a complete value array. No more
number-of-arguments checking in any new-style plug-in.
2019-08-03 17:00:43 +02:00
Jehan 5cd09366e1 libgimp: fix gimp_procedure_add_*_from_property().
Argh I changed the signature and added a new parameter, but forgot to
update the implementation!
2019-08-03 16:42:19 +02:00
Michael Natterer ad8dcff199 libgimp: add _gimp_plug_in_read_expect_msg()
and make the places who need it dispatch between it and
_gimp_read_expect_msg() depending on whether there is a GimpPlugIn
instance. Also clean up some includes.
2019-08-03 12:52:22 +02:00
Michael Natterer 3dd79f42c3 Revert "libgimp: move _gimp_read_expect_msg() back to gimp.c"
This reverts commit 366047f423.
2019-08-03 12:37:32 +02:00
Michael Natterer 992f4b0e8a libgimp: add gimp_get_plug_in() which returns the GimpPlugIn singleton 2019-08-03 12:20:22 +02:00
Niels De Graef 5f92ced1f3 Add (nullable) if applicable
Basically this commit makes sure that all return values that are marked
as "Returns:" also have a `(nullable)` annotation if it is mentioned on
the same line that NULL can also be returned.

This will prevent a few problems in GObject-introspection.
2019-08-03 07:53:47 +00:00
Niels De Graef 1dda60154c Use "Returns:" to annotate return values
To be able to annotate return values through GObject-introspection, you
need to make sure it is tagged with `Returns:` and not something else.
2019-08-03 07:53:47 +00:00
Niels De Graef 746a72b956 Make sure to use % for constants
Documentation-wise in C, this doesn't matter a lot, but it allows
GObject-Introspection based bindings to use their built-in versions when
they want to render any kind of documentation (for example, docs for
Python plugins can render `%NULL` as `None`).
2019-08-03 07:53:47 +00:00
Jehan b6e6f0b71b libgimp: gimplegacy not introspected anymore.
Also remove several functions which never made it to a GIMP release.
They were really meant as temporary anyway from the start, waiting for
the new API to be usable.
And GimpParam is not boxed anymore. This is made useless by the fact it
is not an introspected type now.
2019-08-03 09:46:56 +02:00
Jehan 2c4a8c89ed libgimp, app: allow usage of GParamSpecString procedure arguments.
Just consider these as a GimpParamSpecString with default allow_non_utf8
and non_empty values (FALSE).
2019-08-03 09:38:46 +02:00
Jehan 0787510810 libgimp: add gimp_procedure_add_(argument|return_value)_from_property().
This will be used at least for the Python plug-ins. There is currently a
bug preventing to set a GParamSpec in a binded API.
See pygobject#227.

Please don't revert this. At least it allows to use the new GimpPlugIn
API for Python plug-ins. Anyway even with the old API, I had to add ugly
temporary API for the introspection (which I will now remove as they
never made it to release). So we are trading an ugly situation for a
less ugly one.
We can always remove these 2 new functions before release if we find or
implement better solutions before.
2019-08-03 09:38:21 +02:00
Michael Natterer 219fa33eb2 libgimp: create the GimpPlugIn much later in gimp_main_internal()
it will soon get some construct properties that are not known earlier.
2019-08-02 20:53:43 +02:00
Michael Natterer a50069e176 libgimp: change the return values of GimpPlugIn::init_procedures()
and ::query_procedures() to a GList* of strings.
2019-08-02 19:10:13 +02:00
Michael Natterer e3374e7d4e libgimp: make gimp_close() static to gimp.c again
Instead of calling _gimp_close() and returning from both the main
plug-in loop variants, simply only return and call gimp_close() from
where both loops return to, at the end of gimp_main_internal().
2019-08-02 18:48:07 +02:00
Michael Natterer 366047f423 libgimp: move _gimp_read_expect_msg() back to gimp.c
and make it distinguish between old and new plug-in running.
2019-08-02 18:26:52 +02:00
Michael Natterer 856fe16070 libgimp: add _gimp_plug_in_run() and copy the main plug-in loop to GimpPlugIn
Move the legacy loop code to gimplegacy.c. Also remove some more stuff
from gimp.c, old and new are now completely separate apart from one
glitch which wll go next...
2019-08-02 17:05:51 +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
Michael Natterer 1e2efcf95e libgmp: reorder GimpPlugIn's query(), init(), quit()
in plug-in lifecycle order.
2019-08-02 12:05:28 +02:00
Michael Natterer 5f8d0ef27b libgimp: add gimp_plug_in_extension_enable() and _extension_process()
Start copying all the actual wire communication to GimpPlugIn, and
move the legacy versions to gimplegacy.c.

This implies having the entire protocol code twice, but without any
if(PLUG_IN) { plug_in_stuff(); } else { legacy_stuff(); }

At the moment it is a wild mixture of old and new, but when finished
the wire code in gimplegacy.c will be entirely separate from the wire
code in GimpPlugIn, which will make it easy to g_assert() that only
one API is used by a plug-in.
2019-08-02 12:02:20 +02:00
Jehan 0411c7ef97 libgimp: fix some annotations. 2019-08-02 03:21:59 +02:00
Jehan 512d2279af libgimp: fix various docs typos or small errors. 2019-08-02 03:03:52 +02:00
Michael Natterer ed86de48d2 app, libgimpbase: s/author/authors/ here too 2019-08-02 01:39:09 +02:00
Michael Natterer f86279fd1f libgimp: more GimpPlugIn and GimpProcedure docs and annotations
They are now GI-warning-free.
2019-08-02 01:32:16 +02:00
Michael Natterer 0bec2bcdec libgimp: add gimp_procedure_set_menu_label() and _set_documentation()
which replace _set_strings(). Add more docs.
2019-08-02 00:56:00 +02:00
Michael Natterer d1d56f136e libgimp: set a procedure's arguments and return values to defaults
We need this for named parameters, and it's cleaner anyway.
2019-08-02 00:39:22 +02:00
Michael Natterer b511cf34cf libgimp: add gimp_procedure_set_attribution()
Also rename "author" to "authors" and add some docs.
2019-08-02 00:35:17 +02:00
Michael Natterer 53ca87d693 libgimp: cleanup and more docs for GimpProcedure 2019-08-01 23:46:55 +02:00
Michael Natterer 0601b7f9a8 libgimp: add gimp_procedure_extension_ready()
which must be called by GIMP_EXTENSION procedures when they are ready
to run their temporary procedures. Move gimp_extension_ack() to
gimpobsolete.[ch].
2019-08-01 23:24:49 +02:00
Michael Natterer a841e0fb06 libgimp: add gimp_procedure_set_image_types()
and remove the "image_types" parameter from gimp_procedure_set_strings(),
which is only a bad hack copied from the core procedure class.
2019-08-01 23:09:01 +02:00
Michael Natterer e0a6eb38da libgimp: add run_data and run_data_destroy parameters to procedure_new()
so bindings work properly. Change plug-ins accordingly.
2019-08-01 22:45:49 +02:00
Michael Natterer 0cfaeb7a90 pdb: remove the section docs for the plug-in group
it was duplicated with the GimpPlugIn class section docs.
2019-08-01 16:15:27 +02:00
Jehan 67a0451ac5 libgimp: transfer ownership of @error parameter to...
... gimp_procedure_new_return_values().
When we see how this has been used in help or goat-exercise plug-ins so
far, we clearly see that we expect this function to be used as last call
in a run callback. Well we could save the result, free the error, then
return the result, but it's cumbersome.
So instead let's officially expect gimp_procedure_new_return_values() to
take ownership of the GError (i.e. it will free it in the end).
For this reason, remove the `const`.
2019-08-01 16:04:58 +02:00
Michael Natterer c12c031f2d pdb, libgimp*: add (out caller-allocates) to all GimpRGB* return values 2019-08-01 15:39:13 +02:00
Michael Natterer 498d478b61 libgimp: fix annotation for gimp_procedure_add_argument()
and _add_return_value(), the GParamSpecs are (transfer full).
2019-08-01 12:58:39 +02:00
Michael Natterer 0ccb40f89b pdb, libgimp: hide more functions that have new API in gimplegacy.[ch]
Also reorder some functions in plug_in.pdb
2019-08-01 12:28:01 +02:00
Jehan 1627aacaa5 libgimp, libgimpbase: add some documentation for new functions.
Just for a few of them just now as I needed these for my binding plug-in
tests, and without the proper annotations, these functions were
unavailable.
2019-08-01 12:24:06 +02:00
Jehan 6fe2508301 libgimp*: fix various missing (transfer) annotations. 2019-08-01 01:52:07 +02:00
Jehan ac0c3cf532 pdb: remove some formerly manually added annotations.
From the time when I was just manually editing these even in the PDB!
2019-07-31 22:56:43 +02:00
Jehan a87104fffb pdb, libgimp: fix missing colons at end of annotations. 2019-07-31 22:51:35 +02:00
Michael Natterer 05e68da4d4 pdb, libgimp: add (array length=foo) annotations for out args 2019-07-31 19:19:06 +02:00
Michael Natterer a40f139fdc pdb, libgimp: annotate input arrays with (array length=foo) 2019-07-31 19:08:01 +02:00
Michael Natterer e73916eab8 pdb, libgimp: annotate input arrays with (element-type foo) 2019-07-31 18:58:52 +02:00
Jehan 4a0f60d265 libgimp: fix GimpPlugin virtual method documentation.
The GimpPlugInClass:: prefix is important, otherwise GObject
Introspection tools don't take these docs/annotations into account (and
most methods ended up not introspected at all with annotations).

Also fix some typos/sillinesses (missing colon; useless (out) on Returns
value and useless (element-type) for easily scannable type).
2019-07-31 16:02:01 +02:00
Michael Natterer f02a218356 pdb, libgimp: add (out) annotations to everything returned via pointers 2019-07-31 13:12:46 +02:00
Michael Natterer e8c6ab7ce9 pdb: add (element-type foo) annotations to all returned arrays 2019-07-31 13:08:19 +02:00
Michael Natterer 5b6cfd9863 pdb, libgimp: generate (transfer full) annotations for libgimp
for all returned allocated memory.
2019-07-31 12:56:04 +02:00
Jehan 1291769cc7 libgimp: some fixes in GimpPlugin.
- We were leaking the result of query_procedures(). At least as far as
  the example port (help plug-in) shows, it returns a newly allocated
  array of strings, NULL-terminated. This needs to be freed by the
  calling code.
- Add documentations on GimpPlugIn virtual methods so that people know
  what to do with them, and what kind of data to return (like
  NULL-terminated array of procedure names for simple freeing).
- Fix _gimp_plug_in_init() which was registering the query procedures
  instead of the init ones. For this, I added a `init` boolean parameter
  to gimp_plug_in_register().
- Finally check the return value of gimp_plug_in_create_procedure(). It
  is possible that a plug-in not properly implemented returns NULL and
  we want to avoid the CRITICAL. Still output a warning as this is
  likely a plug-in development bug.
2019-07-31 12:51:54 +02:00
Michael Natterer cd1ba1cd17 pdb, libgimp: add proper support for multiline section comments
and move the "Gimp" section docs to the generated file.
2019-07-31 12:18:44 +02:00
Jehan 32c6c2ae43 libgimp: add some annotations.
Annotations reverted by commit 0a02855a59 were not all in PDB files.
Bring back the non-PDB annotations part.
2019-07-31 11:21:55 +02:00
Jehan 826c09b629 libgimp: keep gimplegacy as introspectable, at least temporarily.
Recent commits broke the Python plug-ins again because the old API is
not introspected anymore. Of course, by release of GIMP 3, we should
probably remove this deprecated API from introspection. But first, we
have to figure out how and if the new API can be used in bindings.
2019-07-31 11:18:00 +02:00
Michael Natterer 16043cec5e Revert "pdb, libgimp: append _pdb for gtk-doc SECTION names of pdb files."
This reverts commit 833666d462.

The _pdb files are an implementation detail and we do not want
separate doc sections for them, the conflicts need so be resolved in
another way.
2019-07-31 10:04:43 +02:00
Jehan 833666d462 pdb, libgimp: append _pdb for gtk-doc SECTION names of pdb files.
Otherwise we get a few duplicate sections since some of the non-PDB
files are named similarly.
Fix this GObject introspection warning and other similar warnings:

> libgimp/gimp_pdb.c:28: Warning: Gimp: multiple comment blocks
> documenting 'SECTION:gimp:' identifier (already seen at gimp.c:129).
2019-07-31 01:39:42 +02:00
Michael Natterer 8c4f73df8d app, libgimp: add copyright notices to the new stuff, minor cleanup 2019-07-31 00:13:49 +02:00
Michael Natterer 7dec3aa792 libgimp: move gimp_plugin_icon_register() to gimplegacy.[ch] 2019-07-30 23:59:13 +02:00
Michael Natterer 7201be78d9 libgimp: add gimp-private.h for private stuff shared between files
instead of declaring stuff n time in various files. This also removes
gimp_read_expect_msg() as public symbol from libgimp.
2019-07-30 23:49:54 +02:00
Michael Natterer c1499f873e libgimp: move more stuff to gimplegacy.c 2019-07-30 22:50:18 +02:00
Michael Natterer a42cb8051e libgimp: forgot the disable-single-include guard in gimplegacy.h 2019-07-30 22:39:18 +02:00
Michael Natterer 6f8e063bbb libgimp: reindent gimp.h 2019-07-30 22:17:20 +02:00
Michael Natterer e9c0732595 libgimp: move old plug-in and procedure registering/calling code to gimplegacy.c 2019-07-30 22:05:42 +02:00
Michael Natterer 7b7c518782 libgimp: move the old plug-in and procedure api to gimplegacy.h
The implementations are still in gimp.c.
2019-07-30 21:36:32 +02:00
Michael Natterer d64c0ebd30 libgimp: change GimpPlugIn and GimpProcedures so temp procs work 2019-07-30 21:02:58 +02:00
Michael Natterer 0a02855a59 Revert "pdb, libgimp: fix some annotations in gimp.c and gimp_pdb.c."
This reverts commit b687f111f6.

We will generate annotations for all PDB wrappers automatically.
2019-07-30 20:54:53 +02:00
Jehan b687f111f6 pdb, libgimp: fix some annotations in gimp.c and gimp_pdb.c. 2019-07-30 20:42:53 +02:00
Michael Natterer 7a9e0d984e libgimp: add more registering API to GimpPlugIn and GimpProcedure
Icon, menu branch, translation domain and help domain can now be
registered using the objects' API instead of the direct PDB calls.
2019-07-30 19:23:55 +02:00
Michael Natterer 271c656e2d pdb, libgimp: fix enum type generation in the libgimp PDB wrappers
Use the actual enum type not just G_TYPE_ENUM.
2019-07-30 18:45:10 +02:00
Jehan 84ff060ffa libgimp: GValue of type GEnum not possible.
This fixes such warning:
> Warning: gvalue.c:188: cannot initialize GValue with type 'GEnum',
> this type is abstract with regards to GValue use, use a more specific
> (derived) type

And obviously all subsequent errors because we failed to initialize and
set enum values. Such as:

> Warning: g_value_set_enum: assertion 'G_VALUE_HOLDS_ENUM (value)' failed

I have only fixed this in gimp_image_pdb. If enum types are used in
other places with GimpValueArray, we must fix them the same way.
2019-07-30 17:34:57 +02:00
Michael Natterer e36028d2ac app, libgimp, libgimpbase: forgot to support GIMP_TYPE_UNIT on the wire
This commit can serve as an example how to add new types to
GimpProtocol, note that zero public API changes.
2019-07-30 15:04:06 +02:00
Michael Natterer af5c587e21 pdb, libgimp: port lib.pl to the new GType based libgimp API
All foo_pdb.c functions in libgimp regenerated. I have reviewed this a
dozen times, but please have a look, there might well be glitches and
our public API is sortof important...
2019-07-30 10:51:16 +02:00
Michael Natterer ee0b06cbf1 libgimp: remove all validation code from gimp_value_set_foo_id()
Validation is not the job of a GValue setter, we have the GParamSpec's
value_validate for that. Also, we will use the new GType-based API in
the libgimp PDB wrappers soon, and it's really a bad idea to
implicitly call e.g. gimp_image_is_valid() from the generated
gimp_image_is_valid() wrapper.
2019-07-30 10:28:26 +02:00
Michael Natterer 9a547c14d5 libgimp: add preliminary function gimp_run_procedure_with_array()
which takes and returns GimpValueArrays. This or something similar is
the new central function for running core procedures. Use the new
function from gimp_run_procedure2().
2019-07-29 12:53:27 +02:00
Michael Natterer 39ee40b1f0 libgimp: pass the GimpValueArray to gimp_set_pdb_error()
not the cruft GimpParam array.
2019-07-29 12:42:47 +02:00
Michael Natterer 0402313e60 libgimp: forgot to enable one commented-out gimp_value_array_unref() 2019-07-29 12:33:08 +02:00
Michael Natterer 0a6f157d58 app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
  GValues we use, in the same way done for GPParamDef. GPParam is now
  different from GimpParam from libgimp, pointers can't be casted any
  longer. The protocol is now completely GimpPDBArgType-free. Remove
  gp_params_destroy() from the public API.

- libgimp: add API to convert between an array of GPParams and
  GimpValueArray, the latter is now the new official API for dealing
  with procedure arguments and return values, GimpParam is cruft (the
  wire now talks with GimpPlugIn more directly than with the members
  of GimpPlugInInfo, which need additional compat conversions).

- libgimp, app: rename gimpgpparamspecs.[ch] to simply
  gimpgpparams.[ch] which is also more accurate because they now
  contain GValue functions too. The code that used to live in
  app/plug-in/plug-in-params.h is now completely in libgimp.

- app: contains no protocol compat code any longer, the only place
  that uses GimpPDBArgType is the PDB query procedure implementation,
  which also needs to change.

- app: change some forgotten int32 run-modes to enums.
2019-07-29 12:22:58 +02:00
Jehan 7e23ed454a libgimp: fix gimp.def.
A distcheck showed a bunch of missing functions, while others were
listed yet not exported.
2019-07-28 23:36:54 +02:00
Jehan ebc797a64e libgimp: update gimp.def.
How come I always forget this so annoying file?!
2019-07-28 20:02:40 +02:00
Jehan 6b442a1ba3 app, pdb, libgimp: fix annotations of some PDB functions.
These are used in the first port of a Python plug-in which I am doing
right now.
2019-07-28 18:43:00 +02:00
Jehan 3a9ae8cc69 libgimp: API to create GimpParam from values.
The `data` property of a GimpParam is a union. Unfortunately setting a
union is not supported by GObject Introspection yet. So I create some
APIs to create GimpParam-s from values. Note that this is temporary API
(i.e. it may be removed before GIMP 3 release) since we likely won't use
this GimpParam type anymore with the new plug-in API. But for now, this
is necessary, at least for testing and porting Python plug-ins.

Also for GimpParam to be actually introspectable, I had to make it a
boxed type, but since no length information is available for various
variants of the type (arrays, whose length information is a separate
parameter), the copy and free functions are basically broken or leaking
respectively for all types requiring a length.

Bottom line: this is ugly and we really need a new introspectable
parameter type. But for now, it allows to start porting some of our
Python plug-ins.
2019-07-28 18:43:00 +02:00
Michael Natterer 32ea28b6b1 app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
  information needed for constructing all GParamSpecs we use, don't
  use GimpPDBArgType in GPProcInstall but an enum private to the wire
  protocol plus the GParamSpec's GType name. Bump the wire protocol
  version.

- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
  take care of converting between GPParamDef and GParamSpec. They
  share code as far as possible.

- Change pluginrc writing and parsing to re-use GPParamDef and the
  utility functions from gimpgpparamspecs.

- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
  the entire core uses proper GParamSpecs from the wire protocol now,
  the whole file will follow down the drain once we use a GValue
  representation on the wire too.

- In gimp_plug_in_handle_proc_install(), change the "run-mode"
  parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
  already an enum). and change all places in app/ to treat it as an
  enum value.

- plug-ins: fix cml-explorer to register correctly, a typo in
  "run-mode" was never noticed until now.

- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
  between old-style wire communication and using GParamSpec and
  GValue, it contains some functions that are subject to change or
  even removal in the next steps.

- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
  able to actually install procedures the new way.

- plug-ins: change goat-exercise to completely use the new GimpPlugIn
  and GimpProcedure API, look here to see how plug-ins will look in
  the future, of course subject to change until this is finished.

- Next: changing GPParam to transmit all information about a GValue.
2019-07-28 17:34:40 +02:00
Michael Natterer 0093487d33 libgimp: include the new file in gimp.h 2019-07-26 16:08:09 +02:00
Michael Natterer 427b01a634 libgimp: add GType and GParamSpec types for all IDs, like image, drawable
Same set of functions and types as in app/, but purely ID-based.
2019-07-26 16:05:11 +02:00
Michael Natterer 4a5f0508e9 libgimp: remove GimpParamRegion, it was never used 2019-07-26 02:37:52 +02:00
Michael Natterer 8a462e867d libgimp: add a GimpProcedure class
Mostly the same code as GimpProcedure in app/pdb/.

Move the "run" function to GimpProcedure. Add API to GimpPlugIn to
list and create procedures, and always keep a list of the plug-ins
procedures around. Still only using the old params and return_vals.
2019-07-26 02:11:35 +02:00
Michael Natterer f2d399b17b libgimp: add initial version of a GimpPlugIn class
The new way of doing plug-ins:

- subclass GimpPlugIn in your plug-in
- implement its query() and run() methods, run() will move to a
  new GimpProcedure class soon
- instead of MAIN(), say GIMP_MAIN(YOUR_PLUG_IN_TYPE)

Instead of keeping around a GimpPlugInInfo struct, libgimp will
create an instance of your plug-in class, keep it around during
the plug-in's lifetime, and call its virtual functions.
2019-07-25 23:07:24 +02:00
Jehan c20645054c libgimp: update annotations for gimp_install_procedure() and...
... GimpRunProc function type.
In gimp_install_procedure(), make sure that @params and @return_vals are
processed as arrays, otherwise they are unusable.

As for the run procedure, make so that @return_vals and @n_return_vals
are considered as returned values. In Python binding for instance, that
makes these not parameters anymore, but actually returnable by the run
function.

With these changes, I made the first fully functional GI Python plug-in,
which just creates a new image and a display for this image. Still a lot
to improve clearly, but we are on the right track. :-)
2019-07-25 19:27:16 +02:00
Jehan 74c69ae3c2 libgimp: update the def.
Also add a "Since: 3.0" and fix the query_proc docs.
2019-07-25 16:58:18 +02:00
Jehan febc1a843d libgimp: add gimp_plug_in_info_set_callbacks().
This is an alternative way to set up a plug-in callbacks, apart from
setting directly the PlugInInfo struct properties.
The reason is that setting directly the Gimp*Proc properties crashes the
plug-in, when done through the Python GI binding.

It is most likely a bug in Pygobject, unless we need the proper
annotation (which I haven't found yet). See:
https://gitlab.gnome.org/GNOME/pygobject/issues/24#note_564968

Setting these callbacks from the C code works fine though, hence this
new API. It is to be noted that the '(scope async)' is the most
important part in this function annotations. Without these annotations,
the function pointers become invalid at the end of the set_callbacks()
call, hence the plug-in crashes when they are actually called.

Unfortunally I am also notified by ebassi that using (scope) at all (any
of the 3 possible values) is just wrong. An API change will be
necessary. For the time being, I leave this like this, for the sake of
testing further, but we'll need to improve things.
2019-07-25 16:23:07 +02:00
Michael Natterer c144cf69de libgimp*: use more g_clear_pointer() 2019-07-25 12:37:52 +02:00
Jehan 692272e580 libgimp: add some comment documentation to Gimp*Proc callback types.
It doesn't really help yet with the problem I encountered allowing to
set and run these Python callbacks from the C code (cf. pygobject#347),
but at least let's improve a bit the documentation.
2019-07-25 11:59:07 +02:00
Jehan c260b4d50d libgimp: add correct annotation for gimp_main().
With GObject introspection, this allows to properly use this function,
otherwise it sees the argv argument as a string (and not an array of
string), which cannot be used properly.
For instance, with Python binding, you can just call it like this:

> Gimp.main (info, sys.argv)
2019-07-25 11:02:53 +02:00
Jehan 6389bb4b58 libgimp, libgimpbase: both introspectable under same namespace Gimp.
At first I thought these could be different namespaces, but actually
GObject Introspection parses files and can only use (AFAICS) the
namespace actually used in our C function, which is always `gimp_` (and
not `gimpbase_` or whatever.

So make the introspection at the root level, and it will include all
libgimp* libraries in one namespace, same as the C lib anyway. For now
only libgimp and libgimpbase as I am still testing.
Also I move the introspectable sources in their own file in order to
share the list between the library building Makefile and the GI
makefile because I can't find how to pass over variables otherwise.
2019-07-25 10:51:03 +02:00
Michael Natterer 8bd4a4fac9 pdb: fix typo in the gimp-context-set-line-dash-pattern docs 2019-07-24 01:57:43 +02:00
Michael Natterer 1a7ea992f3 pdb, libgimp: generate some useless API docs for enums extracted from app/
To be improved...
2019-07-24 01:55:06 +02:00
Michael Natterer aca5f806c4 libgimp*: lots of doc fixes and new docs for structs and enums 2019-07-24 01:18:30 +02:00
Michael Natterer 05d552e634 libgimp: cleanup in GimpTileBackendPlugin 2019-07-20 02:43:58 +02:00
Michael Natterer b2f660ae43 app, pdb, libgimp: remove the "plug-in precision-enabled" API and logic
There is no old way of accessing pixels any longer, all plug-ins are
now precsion-enabled.
2019-07-20 01:53:31 +02:00