Commit Graph

36 Commits

Author SHA1 Message Date
Niels De Graef 89c359ce47 Remove GimpUint8Array in favor of GBytes
GLib has a specific type for byte arrays: `GBytes` (and it's underlying
GType `G_TYPE_BYTES`).

By using this type, we can avoid having a `GimpUint8Array` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GBytes`, we allow other languages to pass on byte arrays as they are
used to, while the bindings will make sure to do the right thing.

In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with byte arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).

Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
2023-05-23 23:37:50 +02:00
Niels De Graef 8eb7f6df9e Remove GimpStringArray in favor of GStrv
GLib has a specific type of NULL-terminated string arrays:
`G_TYPE_STRV`, which is the `GType` of `char**` aka `GStrv`.

By using this type, we can avoid having a `GimpStringArray` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GStrv`, we allow other languages to pass on string lists as they are
used to, while the bindings will make sure to do the right thing.

In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with string arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).

Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
2022-02-12 00:07:53 +00:00
Jehan 43f44288ef libgimp: new gimp_pdb_run_procedure_config() function.
While we do have quite a few gimp_pdb_run_procedure*() functions now, I
always felt that one based on a config file was missing, even more as we
are getting further and further into using config objects in plug-ins.

In C, the gimp_pdb_run_procedure() function is without a doubt the
easiest one. But such variable arg functions are not available on
bindings, and having to deal with GValue and GimpValueArray is a real
pain.

Also using a config file has the very great advantage that we don't need
to care about order. For instance, if I need to set the 10th argument of
a PDB call (and leave the rest to default values), I don't have to set
all 9 previous arguments. I can set only this one if I want. This
advantage is useful also for C code by the way.

For the record, here is how you could load then export an image with the
"file-png-*" PDB procedures in Python:

> c = Gimp.get_pdb().lookup_procedure('file-png-load').create_config()
> c.set_property('file', Gio.file_new_for_path('/path/sample.png'))
> r = Gimp.get_pdb().run_procedure_config('file-png-load', c)
> d = Gimp.Display.new(r.index(1)) # Give it a display to work on it.

Now exporting:

> img = r.index(1)
> c = Gimp.get_pdb().lookup_procedure('file-png-save').create_config()
> c.set_property('image', img)
> c.set_property('file', Gio.file_new_for_path('/path/exported.png'))
> layers = img.get_layers()
> c.set_property('drawables', Gimp.ObjectArray.new(Gimp.Drawable, layers, False))
> c.set_property('num-drawables', len(layers))
> r = Gimp.get_pdb().run_procedure_config('file-png-save', c)
2022-02-11 17:56:42 +01:00
Niels De Graef 92e80d12e8 docs: Migrate from gtk-doc to gi-docgen
gtk-doc has been slowly dying for the past few years; with gi-docgen we
have a nice successor.

This also makes sure the C documentation also uses the GIR file, which
in turn means faster build times (since all the C code doesn't have to
be parsed and recompiled again), and has a clear dependency graph.

See the [gi-docgen tutorial] for more info on how the system works.

[gi-docgen tutorial]: https://gnome.pages.gitlab.gnome.org/gi-docgen/tutorial.html
2021-12-27 10:47:34 +01:00
Lloyd Konneker cbce7b3a98 Issue #6033: fix calling gimp_pdb_run_procedure_argv() with no…
… arguments and allow creating empty GimpValueArray.
2021-04-08 21:14:02 +00:00
Niels De Graef 43d0f0fbd2 gimppdb: Allow more easy bindable API
Plug-ins that work from different bindings probably want to use their
own list-type to specify arguments, rather than working with a more
cumbersome `GimpValueArray`.

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

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

becomes

```
Gimp.get_pdb().run_procedure('plug-in-plasma', [
    GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
    GObject.Value(Gimp.Image, image),
    GObject.Value(Gimp.Drawable, mask),
    GObject.Value(GObject.TYPE_INT, int(time.time())),
    GObject.Value(GObject.TYPE_DOUBLE, turbulence),
])
```
2020-09-20 11:36:01 +00:00
bootchk 8d5afa76e7 issue 4669 2020-03-17 12:34:01 +00:00
Michael Natterer 3ce2c7e3f9 libgimp: s/filename/file/ in docs 2019-09-21 19:02:40 +02:00
Michael Natterer 14af676b51 pdb, libgimp: change "filename" to "file" in gimp_pdb_dump() 2019-09-11 22:37:40 +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 41fa670434 Rename all "nparams" and "nreturn_vals" members in the wire protocol
to "n_params" and "n_return_vals".
2019-09-09 01:00:54 +02:00
Michael Natterer bfe4a2f9dd app, libgimp: add _gimp_gp_params_free() to gimpgpparams
which frees exactly what _gimp_value_array_to_gp_params() has
allocated, honors its "full_copy" parameter, and plugs the last
libgimp refactoring leaks I'm currently aware of.
2019-09-05 20:59:57 +02:00
Michael Natterer 0f7f322fa5 libgimp: _gimp_gp_params_to_value_array() remove "gboolean full_copy"
With all the GValue and GimpValueArray copying involved, we can't
really make a shallow copy anyway, so don't let the API pretend we
could.
2019-09-05 20:17:22 +02:00
Michael Natterer ee86e5630e libgimp: don't leak the GPParam array after writing procedure return values
Annotate all calls to g_free(GPParam*) with /* FIXME leaking object arrays */
because we now do, and it needs to be fixed.
2019-09-05 16:24:09 +02:00
Michael Natterer 7d3427e91d libgimp: gimp_pdb_run_procedure_array() was leaking proc_run.params 2019-09-05 13:01:00 +02:00
Michael Natterer 4364b78446 libgimp: remove the GIMP_DISABLE_COMPAT_CRUFT define
there is no legacy API left a ported plug-in could accidentially use.
2019-08-30 13:00:00 +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 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 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 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 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 41fb552988 libgimp: more docs and annotations 2019-08-09 12:41:45 +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 9339741135 libgimp: unnecessary (out) annotation on return value.
Fixes:
> Warning: Gimp: unexpected annotation: out
2019-08-08 16:58:56 +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 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 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 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 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