Commit Graph

810 Commits

Author SHA1 Message Date
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
Jehan c3cfab2477 libgimpbase: fix gimp_parasite_new() annotation.
Without the (element-type), parasite cannot be created in at least
PyGObject binding (I have not tested parasite creation in other
bindings) and we end up with such error:

> ValueError: Pointer arguments are restricted to integers, capsules, and None. See: https://bugzilla.gnome.org/show_bug.cgi?id=683599

With this change, we can create it from a list of ints (e.g. for a text,
encode it into UTF-8 bytes).
2021-04-07 00:20:44 +02:00
Jehan 70a9576f27 app, devel-docs, libgimpbase: s/gimp_parasite_name/gimp_parasite_get_name/…
… and s/gimp_parasite_flags/gimp_parasite_get_flags/

It is better to have a consistent API and the fact is that most
getter/setter functions use the _get|set_ naming, but these didn't.

I wondered if this was such a great idea to rename these anyway because
even though we are breaking API in GIMP 3, is it the best idea to rename
when no functional change happened? After discussing with Wormnest, we
still agreed it was still better to go for consistency rather than
regret later (and be stuck with these names for many more years).

Also this fixes these warnings:

> [649/1205] Generating gimp-3.0.vapi with a custom command
> Gimp-3.0.gir:24162.7-24162.56: warning: Field `Gimp.Parasite.flags' conflicts with method of the same name
> Gimp-3.0.gir:24318.7-24318.52: warning: Field `Gimp.Parasite.name' conflicts with method of the same name
2021-04-05 18:36:44 +02:00
Jehan de87a31825 libgimp, libgimpbase: update the .def files.
Argh, I will still forget these in 10 years, won't I?
2021-04-04 02:50:48 +02:00
Jehan b1fed22763 libgimpbase: new GimpProcedureSensitivityMask type.
This will be used by plug-ins to advertize their usage. Until now, we
were assuming that a plug-in wants a single drawable selected. Yet
multiple drawables can be selected now. Moreover even this information
is not so useful as many plug-ins don't care about what is being
selected. There is possibly even plug-ins which don't care whether an
image is opened (a plug-in to create new images for instance).

Note that this new type is skipped from the PDB because it is used as a
mask, hence not necessary, and was breaking script-fu (which was
incrementing through enums, hence assuming successive int values, not
bit mask values).
2021-04-04 01:40:00 +02:00
Axel Viala 9e4bc86f8a Fix -Wsign-compare in gimpbase/gimpparamspecs. 2021-03-22 13:14:56 +00:00
Jehan 362e00f209 libgimpbase: get rid of one more PATH_MAX.
See commit 47fbfc2f0e for the reason.
2021-03-20 21:15:15 +01:00
Jehan 8586f16f31 libgimpbase: fix _gimp_reloc_init_lib().
While testing the relocatable code paths, I realized that
_br_find_exe_for_symbol() was always returning NULL. The reason is that
our code looking at /proc/self/maps was expecting that the searched
pointer would be in a "r-xp" memory region. On my machine though, it was
in a "r--p" region.
Maybe in some cases or some older kernel, the "r-xp" permission is/was
right, I have no idea, so now let's just not make any assumption on the
region's permission, where we expect to find our static string, i.e.
let's not do any test on the region permission anymore.
2021-03-20 20:42:29 +01:00
Jehan 47fbfc2f0e libgimpbase: do not assume PATH_MAX to be the actual max size of paths.
Even though it is set by Linux's limits.h and apparently by other OSes
too, it seems this macro is mostly bogus. On many systems, the actual
allowed max size of paths is much higher.
On Hurd, they don't even define the macro as there is no upper limit.
See MR !424.

This commit replaces two usages of PATH_MAX:
- readlink() by g_file_read_link(). I checked the GLib implementation
  and could confirm it will do the proper thing, which is progressively
  incrementing their buffer allocation in a loop until the buffer is big
  enough to contain the symbolic link contents. Hence no need to rely on
  a bogus macro which is not the actual max.
- fgets() by g_data_input_stream_read_line() which also dynamically
  allocates the returned buffer, and also properly removes the newline
  and adds a NUL byte (hence simpler code).

Additionally I loop through the lines of /proc/self/maps until I find
the first "r-xp" pathname. Indeed the current code was assuming that the
first line was always right. Yet on my OS at least, the first line was
GIMP executable with "r--p" permission, hence the test would fail. The
second line had the right permission. So let's assume that we want the
first executable path, looping through each line.
2021-03-20 18:52:40 +01:00
Niels De Graef dffab0e9a4 Remove GimpInt16Array
It isn't being used by any plug-in or any code in GIMP at all even.
Let's get rid of it while we can still break API, so we can cut down on
all the complexity of the gimp-param stuff a bit.
2021-02-18 11:32:45 +00:00
Jehan 6bf7892cdf libgimpbase: fix def file. 2021-01-30 11:15:17 +01:00
Jehan 5d5ad7ea73 libgimpbase: finally get rid of gimp_parasite_data() and…
… gimp_parasite_data_size().

gimp_parasite_data() was non introspection friendly because calling code
needs to know the size of returned data a way or another (the concept of
data pointer with random contents, no known size and no way to know the
end of the buffer is not usable in many languages other than C).

Now that all usage have been replaced by gimp_parasite_get_data(), we
can just remove the functions from the v3 API.
2021-01-30 10:17:29 +01:00
Jehan 443b738e61 libgimpbase: improve gimp_parasite_get_data().
Allow @num_bytes to be nullable, but add text in the documentation that
this is only useful when you want to check if there is contents.

Also make @num_bytes into a guint32, and finally set it to 0 when there
is no parasite.
2021-01-29 23:40:23 +01:00
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