Commit Graph

847 Commits

Author SHA1 Message Date
Jehan 1873f0d65c libgimpbase: fix memory leak in gimp_installation_directory().
Argh I should have properly reviewed !392 (commit c264f0b705).
It was leaking the return value of a g_path_get_basename().
2021-01-19 12:04:53 +01:00
Jehan 58b98b941f libgimpbase: remove case of plug-ins binaries directly under plug-ins/.
In GIMP 3, plug-ins are mandatorily under a subdirectory. Though on GIMP
2.10.x, both cases are still possible. So only the previous commit
should be backported to gimp-2-10 branch.

See discussion in !392.
Thanks also to Christopher Nielsen for helping.
2021-01-19 11:40:00 +01:00
Pieter van Oostrum c264f0b705 gimp: macOS: fix for file export dialogs GIF and PNG. Authored by @pietervo, and he should be credited with this. 2021-01-19 10:36:40 +00:00
Jehan 64a6baad3d libgimp, libgimpbase: fix def files.
I again forgot to add the new functions to the def files.
2021-01-07 23:14:26 +01:00
Jehan 3e25ea532e libgimpbase: new gimp_parasite_get_data(). 2021-01-07 21:29:35 +01:00
Niels De Graef bba70f5869 gimpparamspecs: Add annotations about array length
Although most GObject bindings can't really deal with struct fields,
it's still a nice thing to be able to see that these are actually arrays
(it also becomes visible in the Vala VAPI file).
2020-12-25 15:02:44 +01:00
Jehan 8d5008d76f libgimp, libgimpbase, libgimpwidgets: new gimp_range_estimate_settings()
Similar code was used in 2 places basically (GimpLabelSpin and
GimpProcedureDialog) so just make it an utils function. It's good anyway
to have a generic function to estimate suitable increments and decimal
places depending on a range.

As a consequence also gimp_label_spin_new() now takes a gint digits
(instead of guint), with -1 meaning we want digits computed from the
range.
Similarly gimp_prop_scale_entry_new() docs adds the -1 meaning too.
2020-11-25 01:34:36 +01:00
Jacob Boerema d0f67faf29 libgimpbase: fix incorrect reading of iptc tags that appear more than once.
This is one of the problems mentioned in issue #5863. This commit only fixes
our loading (and saving) of this metadata.
Certain iptc tags like "Keywords" can appear multiple times. We were using
gexiv2_metadata_get_tag_string to get the value but that always returns
the first value so we replaced that by gexiv2_metadata_get_tag_multiple.
2020-11-19 23:25:27 +00:00
Jehan 435d5ce83a libgimpbase: do not use g_snprintf() with same source and buffer.
`man snprintf` clearly says (in NOTES) that when source and target
overlap, the result in undefined.

g_snprintf() conforms to the same standard hence would not get the
expected result. In my case, the result was just tzstr (e.g. "+01:00").
2020-11-14 21:22:12 +01:00
Niels De Graef 79319803a2 GimpArray: Add missing array length GIR annotation 2020-10-28 20:51:48 +01:00
Jehan 90bcdf9bda app, libgimp, pdb: remove references of removed functions.
There were still a few references to functions which have been removed
from GIMP 3 (because they were deprecated in previous versions), which I
found as I was doing an inventory of removed functions.
2020-10-26 15:36:42 +01:00
Jacob Boerema 8e97d56d1e libgimp, libgimpbase: don't use a fixed GIMP 2.10 version number in exif metadata. 2020-10-24 14:23:53 -04:00
Jacob Boerema 679fe079f6 libgimpbase: fix copy-paste error in documentation comments. 2020-10-23 12:51:04 -04:00
Jacob Boerema 9069d812ef libgimpbase: fix #2253 saving metadata failed if Pentax PreviewOffset present in exif tags.
Partially based on the comments of Massimo Valentini we block all Pentax and PentaxDng
exif Preview tags from being exported. We leave finding a more flexible solution for
problematic tags to a future contributor.
2020-10-15 15:12:58 -04: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
Ell b2e223813b libgimpbase: avoid double definition of exported variables on Windows
... by qualifying them with "extern", in addition to
"__declspec(dllexport)".  Omitting "extern" happened to work in the
past, but recent GCC versions require it.
2020-06-10 18:29:23 +03:00
Niels De Graef 5092a32e75 gimpparamspecs: Add GIR annotations
I assume that we won't need most of these explicitly in bindings, but
_if_ it's needed, then it's best to make sure that people don't struggle
because they don't have proper API without annotations.
2020-06-06 13:22:57 +02:00
Niels De Graef febc5cc6e6 Revert "Don't forget to include <glib-object.h>"
This reverts commit 9fce4757ce.
2020-05-21 22:39:10 +02:00
Niels De Graef 9fce4757ce Don't forget to include <glib-object.h>
... when exposing symbols like `GType` in the header.
2020-05-21 15:02:00 +02:00
Niels De Graef 842dc7535f gir: (skip) functions with varargs
Bindings can't handle these, so they are not introspectable.
2020-05-21 13:49:38 +02:00
Niels De Graef 57d3837e40 gir: More missing annotations
Especially need to watch out with forgetting `(array)` and `(out)`
annotations, as they can really give a different API in certain (if not
most) bindings.
2020-05-08 16:57:45 +02:00
Niels De Graef 7f58f2d6e5 gir: Add more missing (array) and (out) annotations 2020-05-04 21:29:42 +02:00
Niels De Graef 52a146604b gir: Add some missing (array length) annotations
This will make sure that bindings can generate a more "native" API so
they don't have to pass the length explicitly.
2020-05-03 18:11:29 +02:00
Niels De Graef db0493aa0d gir: Add more (out) annotations
This will change the API for some bindings, so we probably want to do it
before a release.
2020-05-03 17:57:23 +02:00
Niels De Graef 5f1598f63d gir: Add more (out) tags when appropriate
This makes a big difference for bindings, so make sure out-parameters
are properly annotated.
2020-05-03 17:35:01 +02:00
Niels De Graef 8c7a2b42e6 gir: (optional) tag requires a (out) annotation 2020-05-03 15:31:46 +02:00
Niels De Graef 85d9730936 Add some missing (nullable) annotations
Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/4750
2020-05-01 15:34:56 +02:00
Oleksii Samorukov 5d0b0ad467 Fix meson build on macos 2020-01-18 23:39:34 +01:00
Jehan 8f87277653 libgimpbase: same fix as previous commit to other static types.
This member of the GTypeInfo structure is the size of the object
instance (not of the parent instance). Let's fix it for all static type
registrations in this file, which had the same bug as commit
0eb6ff41cf.
Happy new year everyone!
2019-12-31 20:10:00 +01:00
Michael Schumacher 0eb6ff41cf libgimpbase: fix wrong sizeof in gimp_param_object_array_get_type
Spotted by Massimo Valentini. Fixes issue #4417.
2019-12-31 14:35:39 +01:00
Michael Natterer 9a054fc248 libgimpbase: document the members of GimpArray, GimpStringArray
and GimpObjectArray.
2019-12-27 19:55:28 +01:00
Michael Natterer 1856990c2b libgimp*: check all return values of g_param_spec_internal()
like in the fix for issue #4392. Remove the reference to the issue
from gimp_param_spec_layer() because we can't have it in all places
that now do checks.
2019-12-27 19:53:08 +01:00
Michael Natterer 05896b4e2f libgimpbase: rename and reorder the values of enum GimpSelectCriterion 2019-11-19 22:25:57 +01:00
Michael Natterer 0141a28419 libgimpbase: remove enum value GIMP_FOREGROUND_EXTRACT_SIOX 2019-11-19 21:25:26 +01:00
Michael Natterer 0e5a03605a libgimpwidgets: remove enum value GIMP_CONVERT_PALETTE_REUSE 2019-11-19 21:21:16 +01:00
Michael Natterer 1be4ec2100 libgimpbase: remove enum GimpBlendMode, it's not used any longer 2019-11-19 21:13:31 +01:00
Niels De Graef a551043ffe libgimpbase: Use G_DEFINE_BOXED_TYPE()
This isn't any functional change, but allows us to get rid of some of
the GObject boilerplate.
2019-11-05 10:14:29 +00:00
Sabri Ünal 61f7eb768c Checking wrong sizeof in gimpmetadata.c
"Buffer 'strdata' is being written before its old content has been used."

(cherry picked from commit c5f597d5c0)
2019-10-20 01:01:06 +02:00
Jehan b8d8424ae0 app, libgimp*: (meson) fix all the generated `*-enums.c`.
More of the files were wrong, or at least not absolutely identical to
the files generated by the autotools. I am not doing any code change
other than trying to make both build systems produce identical files
(except for slight differences on 2 files not worth the effort) even
though maybe some things can be improved (especially on the include
list). Maybe to be improved later.

Also fixing 2 of the previously autotools-generated files because of
space typos which should have been committed earlier.

Finally it is to be noted that there is no logics to copy the generated
files back to the source directory in the meson rules. I am not sure
anyway this is really worth it and maybe we should just stop tracking
these generated files eventually.
2019-10-19 22:32:29 +02:00
Michael Natterer 2409b6f219 libgimp: manage boolean "save-comment" properties automatically
using the GimpProcedureConfig/GimpMetadata mechanism.
2019-10-10 01:30:29 +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
Ell 5cc289b642 libgimpbase, libgimp, app: inherit swap-compression in plug-ins
Pass the swap-compression option set in the preferences down to
plug-ins, so that they use the same swap-compression algorithm as
the main app.
2019-09-22 18:05:24 +03:00
Jehan 6bc6a07b7e libgimpbase, plug-ins: fix all warnings to g_stat() calls.
The second parameter should be GStatBuf*, which will be defined to be
the right struct depending on the actual platform. Using `struct stat*`
was good on Linux but was outputting warnings on other platforms (at
least on Win32).
2019-09-22 13:52:37 +02:00
luzpaz 44d10e458c Fix various typos
Found via `codespell` (v1.17.0.dev0)
2019-09-21 17:10:46 +00:00
Michael Natterer 1bca89163d libgimpbase: remove gimp_personal_rc_file()
and port its remaining users to gimp_directory_file().
2019-09-21 18:08:13 +02:00
Michael Natterer a4775d5b2d libgimpbase: remove gimp_gtkrc() 2019-09-21 12:56:52 +02:00
Michael Natterer a5ac3e45fe libgimpbase, libgimp, app: add libgimp support for passing GFiles
Which means support for GParamSpecObject with value_type ==
G_TYPE_FILE, and converting between GFile and its URI for wire
communication directly above the protocol layer.

This change requires passing a GParamSpec's value type as generic
member of GPParamDef, which in turn makes some members of its
sub-structures obsolete.
2019-09-11 21:40:17 +02:00
Félix Piédallu 65eff6f150 Meson port. 2019-09-11 16:42:04 +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 22a780c9d1 pdb: add gimp_pdb_set_proc_documentation() and _attribution()
and all the needed code in libgimp/ and app/ to set them on a
procedure using the new API. Remove the strings from GPProcInstall.
2019-09-09 00:36:24 +02:00
Michael Natterer 453b4f4aa2 pdb: add gimp_pdb_set_proc_menu_label()
and all the needed code in libgimp/ and app/ to set a plug-in
procedure's menu label using the new API. Remove the menu label from
GPProcInstall.
2019-09-08 17:30:54 +02:00
Michael Natterer 2a62287439 pdb: add gimp_pdb_set_proc_image_types()
and all the needed code in libgimp/ and app/ to set a plug-in
procedure's image types using the new API. Remove the image types from
GPProcInstall.
2019-09-08 16:54:08 +02:00
Michael Natterer b6b8e2c28d Revert the *enums.c part of the last commit
- it was changing generated files
- no dialog-specific mnemonics on generic enum labels
2019-09-06 01:39:36 +02:00
Sabri Ünal 2e766f67d4 Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer

metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 22:41:19 +03:00
Michael Natterer e902871926 libgimpbase: fix docs 2019-09-05 21:27:11 +02:00
Michael Natterer ccd516c569 libgimpbase: update gimpbase.def 2019-09-05 13:01:00 +02:00
Michael Natterer 85591eb799 libgimpbase: add support for arrays of object IDs to gimpprotocol 2019-09-05 13:01:00 +02:00
Michael Natterer 0fefb7e922 libgimpbase: add GimpObjectArray and GimpParamSpecObjectArray 2019-09-05 13:01:00 +02:00
Michael Natterer 738b17063a libgimpbase: add an own struct for GimpStringArray
instead of re-using the GimpArray struct, which was confusing
particularly because of the meaning of the "length" member.
2019-09-05 13:01:00 +02:00
Michael Natterer a351ce9126 Remove the entire old plug-in interface 2019-09-04 00:03:12 +02:00
Michael Natterer 8a78203aed Properly prefix the values of enum GimpPDBProcType
to be GIMP_PDB_PROC_TYPE_PLUGIN, _EXTENSION etc.
2019-08-30 12:52:28 +02:00
Michael Natterer 7201d48231 Get rid of capitalized "ID" in function and variable names
and use "id" instead.
2019-08-23 22:23:23 +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
Jehan f705bfb395 libgimpbase: return 0 for GIMP_UNIT_PIXEL in gimp_unit_get_factor().
Just as documented, pixel unit should always return factor 0. There is
no need to call _gimp_unit_vtable.unit_get_factor().

This is even more important as there is one implementation of
unit_get_factor() in core, and another in libgimp and the one in libgimp
is expecting unit to always be >= GIMP_UNIT_INCH. So we were getting
CRITICALs in libgimp when calling gimp_unit_get_factor() on pixel unit
(for instance when drawing a GimpRuler).
2019-08-17 12:12:40 +02:00
Jehan 1320a22fd8 libgimpbase: update the def file. 2019-08-16 14:45:23 +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 b007269729 Use g_strlcpy() instead of strncpy() everywhere
except where I didn't understand the code after 10 seconds of
looking..
2019-08-14 23:52:38 +02:00
luz.paz 7e99aa59f5 Add other misc. typo fixes 2019-08-13 11:50:51 -04:00
Michael Natterer 299d657ff1 libgimpbase: change gimpprotocol GPParamDefInt's members to gint64
so the full range of any unsigned int param spec's values fits.
2019-08-10 16:25:22 +02:00
Michael Natterer e6d662e352 libgimp*: various doc fixes 2019-08-10 12:32:25 +02:00
Michael Natterer 31b8ea4a90 libgimpbase: add lots of const to GimpEnumDesc and GimpFlagsDesc APIs 2019-08-09 13:29:34 +02:00
Michael Natterer 4add4c6645 libgimpbase: add a GimpStringArray typedef and use it 2019-08-09 12:54:09 +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
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 0ac2cf6171 libgimpbase: some minor improvements to the previous commit 2019-08-08 13:27:04 +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 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 b4bccc9808 libgimpbase: some annotation and doc fixes 2019-08-07 23:32:15 +02:00
Jehan 17eb4c551f Revert "libgimpbase: fix/improve docs/annotations."
This partly reverts commit d999248d70.

The GimpStringArray is still very weirdly handled, in particular
regarding the difference of processing with static_data set or not.
Still this g_return_val_if_fail() was making more problems. It may come
back but will need more coding to handle the side effects.
2019-08-05 23:43:44 +02:00
Michael Natterer 2f3a83754f libgimpbase: add gboolean gimp_is_canonical_identifier() 2019-08-05 23:22:06 +02:00
Jehan fead2f7d9d libgimpbase: fix broken annotation.
s/default_/default_value/
2019-08-05 16:41:44 +02:00
Jehan d999248d70 libgimpbase: fix/improve docs/annotations.
Our GimpStringArray is so weird. We are obviously expecting it to be
NULL-terminated since, when we duplicate the data, we add one value.
Yet we were not checking that the stored data was NULL-terminated, in
particular when the string array is created with static data (in which
case, we use the input data as-is, without re-allocating).

Note that this doesn't fix the type mismatch Gimp.StringArray vs
Gimp.Array when introspecting.
2019-08-05 16:29:52 +02:00
Michael Natterer 254271971e libgimp*: more docs and annotations 2019-08-05 15:57:11 +02:00
Jehan 515bfe94e3 libgimpbase: add annotations to several functions.
Not all of the public functions in the file, but at least the ones with
warnings.
2019-08-05 15:43:35 +02:00
Michael Natterer 7764f8b34b libgimpbase: add support for GParamParam in GPParamDef too
to describe param specs that describe param specs, yay.
2019-08-05 14:12:19 +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 32823f1709 libgimpbase: reorder types and structs in gimpprotocol.h
so the next commit becomes more readable.
2019-08-04 23:59:25 +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 cc8fc0f90f libgimp*: add GI's .dirstamp to .gitigore 2019-08-03 19:50:17 +02: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 ed619d9ebd libgimpbase: add documentations on gimpparasite public functions.
Once again, the "Since:" is the result of a bit of `git log` archeology.
Hopefully it's right (should be according to tags. Still…).
2019-08-02 12:22:25 +02:00
Michael Natterer ed86de48d2 app, libgimpbase: s/author/authors/ here too 2019-08-02 01:39:09 +02:00
Jehan c059839e78 libgimpbase: use g_try_new0() when allocating the parameters.
Basically the number of parameters comes from plug-ins which could write
whatever crap on the wire. I had a case (playing with Python plug-ins)
where GIMP tried to allocate insane amount of parameters. This is bad
as it allows third-party plug-ins to crash GIMP core.

Instead only *try* to allocate, then return as though there were no
parameters if allocation fails. I also print some info on stderr, but
don't output WARNING/CRITICAL (this is not a core error, but a plug-in
error). Fixes:

> GLib-ERROR **: 16:30:23.357: gmem.c:135: failed to allocate 187186442160 bytes
2019-08-01 18:09:14 +02:00
Michael Natterer d66b845bac libgimpbase: capitalize some docs section titles 2019-08-01 12:48:41 +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
Michael Natterer 63695b4b21 libgimbase: merge gimpparam.h into gimpparamspecs.h
which means that it's now included normally via gimpbase.h
and not any longer via gimpbasetypes.h which we only did out
of lazyness. A *lot* of files in libgimp* and app/ now need to
2019-07-31 10:16:21 +02:00