Commit Graph

205 Commits

Author SHA1 Message Date
Jehan 698b7184b2 libgimp: add gimp_get_num_processors(). 2020-12-11 18:24:36 +01:00
Jehan 1b4834126f libgimp: better organization of gimp_image_metadata_*() API.
gimpimagemetadata.[ch] was built into libgimpui because GTK+ was used
for dialog query for rotation metadata. gimpimagemetadata-save.c only
was built into libgimp, which made no sense as the declaration for its
public function was inside gimpimagemetadata.h!
That was a weird situation and somehow only made visible in the build
system because GIR build was complaining about missing annotations to
gimp_image_metadata_save_prepare() (the annotation was actually present
but in the implementation which was not in the same library as the
header, how weird!):

> Warning: GimpUi: gimp_image_metadata_save_prepare: return value: Missing (transfer) annotation

Moreover it means that only plug-ins linking libgimpui had access to the
gimp_image_metadata*() API, which is obviously not cool (that should be
a core API).

Instead I moved everything into libgimp and replaced
gimp_image_metadata_load_finish() with
gimp_image_metadata_load_finish_batch(), which is essentially the same
function except that it's not interactive (it will proceed to rotate the
image without user confirmation, provided the right flag is present).
Then I add gimpimagemetadata-interactive.[ch] which contains only
gimp_image_metadata_load_finish() and is the alternative interactive
version of gimp_image_metadata_load_finish_batch(). Most plug-ins won't
even have to be changed (at least none in core GIMP) and would still
work as before, whereas now a non-interactive version exists, which
doesn't mandate to link GTK+.
2020-09-13 13:36:51 +02:00
Niels De Graef 25e535b5e0 Fix missing includes
We're exposing symbols in our header files like `GType`, `GFile` and
others, without actually including the proper headers. This also gives
errors in the GIR scanner (who can't resolve those symbols).
2020-05-21 16:02:55 +02:00
Michael Natterer 1c7028aaaa app, libgimp: add boolean "export-comment" gimprc property
export it to libgimp via GPConfig and add new API gimp_export_comment().
Bump the protocol version and improve variable names in both GPConfig
and libgimp/gimp.c.
2019-10-10 00:48:28 +02:00
Michael Natterer b441d100ff libgimp: add GimpProcedureConfig which implements the GimpConfig interface
It's the base for bringing proper management of saved settings
(including the last used values) and generated GUI using prop_widgets
to plug-ins.
2019-09-20 12:34:03 +02:00
Michael Natterer b587740a10 libgimp: make sure the GimpPlugIn and GimpPDB singletons get destroyed
Break reference cycles between the objects and the procedures they
keep by moving procedure destruction to dispose() and calling
g_object_run_dispose() before unrefing PLUG_IN and PDB in gimp.c.

Also some formatting and "Since: 3.0" annotation .
2019-09-09 11:16:39 +02:00
Michael Natterer a351ce9126 Remove the entire old plug-in interface 2019-09-04 00:03:12 +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 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
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 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 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 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 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
Jehan 8f79ddbfe0 libgimp: add some (nullable) annotation and fix some comments. 2019-08-09 12:48:41 +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 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 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 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 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 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 992f4b0e8a libgimp: add gimp_get_plug_in() which returns the GimpPlugIn singleton 2019-08-03 12:20:22 +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
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 6f8e063bbb libgimp: reindent gimp.h 2019-07-30 22:17:20 +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 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
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 0093487d33 libgimp: include the new file in gimp.h 2019-07-26 16:08:09 +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
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
Michael Natterer 6a59ccf840 libgimp: remove GimpTile from the public API, and kill the tile cache 2019-07-19 22:49:20 +02:00
Michael Natterer 60554eaed9 libgimp: remove GimpPixelRgn, it's now completely unused, yay! 2019-07-19 19:08:31 +02:00
Michael Natterer eb11aefa20 libgimp: remove gimppixelfetcher.[ch] it was deprecated and now unused
except for pygimp, but that's another pile to port to GEGL anyway and
isn't built currently.
2019-07-08 21:27:33 +02:00
Michael Natterer a7d86c572d libgimp: remove the deprecated gimpregioniterator.[ch]
it is now completely unused.
2019-07-07 17:16:40 +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
Michael Natterer fe648c87bd libgimp: remove gimp_gamma() 2018-06-18 03:06:34 +02:00
Michael Natterer 8c9c091021 Issue #701 - Add the ability to embed the GIMP built-in sRGB profile...
...upon exporting an image

Step 1: make it configurable just like "Export EXIF" etc.

app, libgimp: add "export-color-profile" config option

Add it to the preferences dialog, and pass it on to plug-ins in the
GPConfig message. Add gimp_export_color_profile() to libgimp.

Nothing uses this yet.
2018-06-18 02:19:41 +02:00
Michael Natterer b36205176e app, libgimp*: remove the config option to disable tooltips
Also remove all traces of it from the plug-in protocol and raise the
protocol version to 0x0100 (we now allow features and therefore
version bumps in stable, and the master protocol version should always
be higher). Fix the code that aborts plug-in startup on protocol
version mismatch, we can't use gimp_message() because we have no
protocol.
2018-06-06 19:23:30 +02:00
Ell 97925de8eb libgimpbase, libgimp, app: pass icon theme dir to plug-ins through config
Pass the current icon theme directory to plug-ins through the
config message, and add a gimp_icon_theme_dir() libgimp function
for retrieving it.  Note that we already have a similar
gimp_icon_get_theme_dir() PDB function, which we keep around, since
it can be used to dynamically query for the current icon dir,
unlike the former, and since it returns a dynamically-allocated
string, while the rest of the config-related functions return
statically allocated strings.

Use the new function, instead of gimp_get_icon_theme_dir(), in
gimp_ui_init().  This allows gimp_ui_init() to run without making
any PDB calls.  Consequently, this allows us to start plug-ins that
call gimp_ui_init() without entering the main loop in the main app.
We're going to add a plug-in that displays an interactive dialog
while the main app is blocking waiting for an operation to
complete, and we need to be able to start the plug-in without
entering the main loop, to avoid the possibility of arbitrary code
being executed during the wait.

Bump the protocol version.
2018-05-29 16:04:28 -04:00
Michael Natterer 7549b6efe4 Bug 794132 - Make the plug-in protocol version part of the plug-in command line
Also clean GPConfig struct from deprecated members and bump the
plug-in protocol version number.
2018-05-20 21:06:30 +02:00
Michael Natterer 9525c646e1 libgimp: remove tons of deprecated cruft 2018-05-20 21:06:29 +02:00
Jehan 2e18c80c58 libgimp: add gimp_get_pdb_status() to return the status of last...
... procedure call.
This is needed for plug-ins which depends on other plug-in's procedures.
If for instance, the second-level plug-in is interrupted interactively,
we don't want to process this as an error but as a cancellation.
Therefore we need to know the returned value of the plug-in. Currently
only way was to use gimp_get_pdb_error() but that was returning a
human-readable error, not a computer-processable error.
2018-01-19 14:19:55 +01:00