Commit Graph

853 Commits

Author SHA1 Message Date
Jehan f5d2c5369c libgimpbase: fix annotations.
As per the changes in commit 005b3a05b8 and discussions in !800,
gimp_locale_directory() returns a string in the OS encoding for all but Windows
(UTF-8), i.e. the "filename" type in GIR annotations.
2023-01-24 19:59:40 +01:00
Luca Bacci 005b3a05b8 Make use of the gimp_bind_text_domain () util function 2023-01-24 14:48:44 +00:00
Luca Bacci cbcb9181d0 Add gimp_bind_text_domain () utility function
On UNIX it's just a stub calling bindtextdomain () directly;
on Windows it converts the path to UTF-16 and calls wbindtextdomain ().
2023-01-24 14:48:44 +00:00
Luca Bacci 54b3e3956e Use SHGetKnownFolderPath instead of the deprecated SHGetSpecialFolderLocation 2023-01-24 14:48:44 +00:00
Luca Bacci afe9625bdb Simpler way to get the module HANDLE 2023-01-24 14:48:44 +00:00
Luca Bacci 0657b85202 Use GLib to convert between UTF-8 and UTF-16 2023-01-24 14:48:44 +00:00
Jehan ca230cb770 meson: fix warnings of deprecated features.
Now that we bumped our meson requirement, meson is complaining about
several features now deprecated even in the minimum required meson
version:

s/meson.source_root/meson.project_source_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.

s/meson.build_root/meson.project_build_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.build_root. use meson.project_build_root() or meson.global_build_root() instead.

Fixing using path() on xdg_email and python ExternalProgram variables:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead

s/get_pkgconfig_variable *(\([^)]*\))/get_variable(pkgconfig: \1)/ to
fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
2022-08-31 01:29:37 +02:00
Jehan ccbf3c4bb0 app, libgimp*: add various stamp files to CLEANFILES.
Fixes:

> ERROR: files left in build directory after distclean:
2022-08-01 23:34:50 +02:00
Jehan 83e465ec16 app, libgimp*: updating autotools script in sync with meson.
Generated *enums.c now have an additional stamp no-op header include
(see last 2 commits). Sync this change into the autotools generation
scripts to prevent back and forth useless generation of these files each
time we switch from one build system to another.
2022-08-01 20:00:01 +02:00
Jehan 979acaaae2 app, libgimp*: commit the newly generated *enums.c files.
They are nearly the same as initially, except that now they include an
intermediate stamp header which will be generated by the build system.

The only 2 enums which don't need these includes (and are not versioned)
are libgimp/gimpenums.c and libgimpthumb/gimpthumb-enums.c.
2022-08-01 20:00:01 +02:00
Jehan 106f2a061d Issue #8145: meson: generation of '*-enums.c' files.
Our meson build system was not properly building the enums.c file,
because they are versionned.

I did a similar trick as what I did for the pdbgen, which is that I used
a wrapper script around the existing perl script, which sets proper
options and generate a stamp file in the end (which is considered by
meson as the actual custom target, not the C file since it is generated
in the source dir).

The most important part is that the stamp file is a generated header
source (not just a random text file) which is **included** by the
generated C file. This is what will force meson to regenerate the C file
if the header is updated, **then** build using this new version, not use
an outdated versionned version (which would make for hard to diagnose
bugs), through the indirection of the intermediate stamp header.

See #4201.
See also: https://github.com/mesonbuild/meson/issues/10196#issuecomment-1080742592
2022-08-01 19:59:53 +02:00
Lukas Oberhuber 271435534f macos: support for homebrew build
Supports running gimp in homebrew builds which have more complex
structures of where things are placed.
2022-07-27 17:06:21 +00:00
Jacob Boerema 5cf1ec62b4 libgimpbase: fix crash caused by the previous commit
In other cases we need to free value, but in this case it was used and
trying to free it caused a GIMP to crash.
Let's duplicate value, so we don't need to special case our g_free.
2022-06-02 17:45:13 -04:00
Jacob Boerema 3138fe5158 libgimpbase: fix resource leak in gimpmetadata
Variable value was not always freed. Move it outside the else block.
2022-06-02 15:14:33 -04:00
Jehan 0c01a44369 devel-docs, libgimpbase: getting rid of gimp_checks_get_shades().
In the original gimp-2-10 branch where this feature was originally
worked on, we had to keep gimp_checks_get_shades(). But on `master`
where we will reset and break API, let's get rid of this function which
should not be used anymore.
2022-05-14 17:43:39 +02:00
Jehan b112e708f5 libgimpbase: bump the protocol version.
Since we changed it, the version must be incremented too. It means that
third-party developers will have to rebuild their plug-ins.

Fixed Conflicts from !274:
	libgimpbase/gimpprotocol.h
2022-05-14 16:31:58 +02:00
Jehan 916c5f9d11 app, libgimpbase: improve preferences and checkboard defaults.
- Slightly nicer layout for the checkboard color widgets.
- Also set the 2 color widgets insensitive when the check type is not
  GIMP_CHECK_TYPE_CUSTOM_CHECKS.
- Default the custom colors to the same colors as the basic default
  grayscale. I mean, red and blue defaults are fun and all, but that's
  like radioactive colors burning the eyes! Ahahah!
- Unlike the gimp-2-10 commit (cf. !274), on the main dev branch, use
  the new GimpLabelColor widget.

Fixed Conflicts from !274:
	app/dialogs/preferences-dialog.c
2022-05-14 16:31:58 +02:00
Jehan 87f7a92786 app, libgimp, libgimpbase, libgimpwidgets: better checkboard colors API.
- Some coding style fixes (alignment, etc.).
- Adding missing "Since: 3.0" annotations. We are still wondering
  whether this should go in 2.10, in which case, it would become
  "Since: 2.10.32" annotations. See discussion in !274.
- Changing gimp_checks_get_colors() signature: merge the 4 color
  arguments into 2 (inout) arguments which seems a bit nicer in C,
  whereas binding handles such arguments correctly. The other
  alternative would have been to at least change the order to have out
  arguments in the end.

  I also hesitated to get another API in libgimp, which would have been
  config-aware (just returning the 2 check colors, depending on user-set
  Preferences), then having GimpPreviewArea handling 2 colors (without a
  GimpCheckType input). But actually, doing this, we'd remove the nice
  menu popup where one could choose a generic check type (not everyone
  wants to play with specific non-gray colors) in Gimp*Preview widgets.
  So in the end, I left this whole thing as-is.
  Instead I document the function with code sample to initialize
  properly the GimpPreviewArea (since libgimpwidgets/ are independent
  with no knowledge of the core config) in order to respect user
  preferences.
- Hide the color properties in gimp_preview_area_menu_new() because
  anyway gimp_preview_area_menu_new() does not support GimpRGB
  properties right now (so all we get are warnings). It's still possible
  to select custom colors on GimpPreviewArea, simply we are stuck at the
  ones set in Preferences globally for now (unless a plug-in creates
  custom GUI to set these).

Fixed Conflicts from !274:
	libgimp/gimp.h
	libgimpwidgets/gimppreviewarea.c
2022-05-14 16:31:50 +02:00
Jehan a241538da7 libgimp: fix def files.
Fixing the CI for MR !274.
2022-05-14 16:27:26 +02:00
Ben Rogalski d90b84ba9d Custom transparency checkerboard colors
Reviewer (Jehan) note: cherry picked from MR !274. Still deciding
whether this will be pushed to gimp-2-10 branch too.

Fixed Conflicts from !274:
	app/dialogs/preferences-dialog.c
	app/display/gimpdisplayshell-draw.c
	app/plug-in/gimppluginmanager-call.c
	libgimp/gimp.c
	libgimp/gimp.h
	libgimpwidgets/gimppreviewarea.c
	libgimpwidgets/gimppreviewarea.h
	libgimpwidgets/gimpscrolledpreview.c
2022-05-14 16:27:15 +02:00
Jacob Boerema cadf485299 libgimpbase: fix #8025 Slow loading of XCF files...
with many Xmp.photoshop.DocumentAncestors tags

This is similar to #7464, but in this case the XMP metadata was already
included in an XCF image.

We check for the occurrence of Xmp.photoshop.DocumentAncestors and stop
handling values when there are more than a 1000.

It would be easier to just check length for all tags and always
ignore when there are more than a 1000 values.
But in that case we would need to be sure there are no valid reasons for
tags to occur more than a 1000 times. So let's just limit it to this
specific tag.
2022-04-04 16:52:10 -04:00
azetoy b17b9b7619 libgimpbase: update deprecated functions
"gexiv2_metadata_clear_tag" && "gexiv2_metadata_try_register_xmp_namespace"
2022-03-18 14:44:54 +00:00
Jehan 87916e5069 libgimpbase: pass a NULL GStrv as an empty GStrv.
NULL is not a proper value for GStrv yet we cannot escape it in the PDB
since we generate default values for non-passed arguments (especially in
interactive case where most procedure arguments aren't set). And for
such boxed type, it will be NULL.

So when we see a NULL GStrv parameter, let's not ignore it (which will
just crash the plug-in). Simply transform it to a GStrv of size 0.
2022-02-12 00:07:53 +00: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 bcdb1cdb6a Issue #7837: gimp_installation_directory() in macOS doesn't know about…
… extensions yet.
2022-02-09 12:47:37 +01:00
Jehan 2e8abf46ee libgimpbase: undeprecate GExiv2 calls in GimpMetadata.
There are still deprecations going around but for GExiv2 0.14.0 so we
can't change these yet.

Note also that I try a slightly different approach as I don't set a
GError for well-known tags as there is no reason these fail. I only add
a GError when we construct tags or similar calls.
2022-01-20 20:18:53 +01:00
Jehan 454d1daf1a Issue #5863: do not raise WARNINGs on Exiv2 unsupported tags on loading.
I was waiting for GExiv2 to merge a patch I submitted:
https://gitlab.gnome.org/GNOME/gexiv2/-/merge_requests/20

Then we waited for it to land in a released version then for this
version to be in Debian testing. It's all done now and we bumped the
GExiv2 dependency in the previous commit (which makes it a master-only
fix). So all good.
2021-12-28 02:54:12 +01:00
Jacob Boerema b2c715b52b plug-ins: fix #7464 GIMP stops responding opening metadata on import
Some images have huge amounts of XMP tag Xmp.photoshop.DocumentAncestors.
In certain cases more than 100000 values. This is apparently due to a bug
in certain versions of PhotoShop.

This makes deserializing it in the way we currently do too slow, probably
because of continuous reallocations after adding each value. Until we can
change this let's remove everything but the first 1000 values when
serializing. I think it is very unlikely there are any real cases where
more than a 1000 ancestor documents are referenced in an image. Testing
shows that this amount doesn't cause any serious slowdowns.
2021-12-15 12:01:39 -05:00
Jehan 9b94e347bc Issue #7539: Opening some images lock GIMP.
In some conditions, and only with some installations, the called GDB
ends up hanging and never returning. Worse, even if you use non-blocking
functions such as poll() or select() with a timeout, in order to wait
for the debugger output, these block anyway and never return.

We are currently unsure what exactly causes such problem, but not using
the thread command in gdb avoids it for now.

This is a bit of a regression, though most of the time anyway the useful
traces are the main thread ones (I think ever since I implemented this,
there must not have been more than 2 or 3 cases where we actually needed
the secondary traces). So it's acceptable, at least for now.
2021-12-01 18:37:18 +01:00
Jehan 7c99fa02f9 libgimpbase: read up to 255 bytes into a 256 bytes buffer.
Otherwise if we add a NUL byte after the last byte, we might right past
the allocated memory. Thanks to Massimo for reporting this error raised
by Address Sanitizer and valgrind (cf. #7539).
2021-11-25 09:53:00 +01:00
Jacob Boerema 6840bb9eba plug-ins: fix #7109 exported gimp .jpg not processable in Windows Photo Viewer
In cases where the whole EXIF MakerNote is invalid we still load that
MakerNote data and export it too, causing partial invalid EXIF metadata.
We don't need to explicitly save Exif.Photo.MakerNote at all, because
as soon as we try to save a brand specific tag exiv2 will create that
MakerNote tag itself.
So from now we don't save the MakerNote but only the tags that go in it.
In issues like #2159 where exiv2 doesn't parse all tags inside certain
brand specific MakerNotes correctly, we will still export invalid EXIF.
That is an exiv2 issue that we can't do much about unless we remove all
MakerNote metadata including those that we can read, which doesn't seem
like a good idea at all.
2021-11-21 18:39:35 -05:00
Emily Gonyer 3afa37cbc6 app, libgimp*, plug-ins: Changed gendered terms to be gender-neutral
Changed a handful of gendered terms to be gender-neutral, and one typo 
of 'he' to 'the' where appropriate.
2021-11-14 11:22:24 +00:00
Jacob Boerema 8e1f982945 libgimpbase: fix #7383 GIMP loses exif data when a folder has Hebrew letters
On Windows when exporting an image saving the exif and other metadata fails
if the path or filename includes non ASCII characters.
Reason is that gexiv2 changed to using utf-8.

In the past we had to convert the filename to current locale on Windows,
but since it now also expects utf-8 there, just remove the special
handling of filename there.
2021-11-02 12:04:26 -04:00
Lukas Oberhuber e6d0766821 Remove another error message 2021-10-20 00:29:37 +01:00
Lukas Oberhuber 219d9b4e1a Reduces noisy errors
Also avoids code that can't run properly on a Mac anyway.
2021-10-09 17:32:58 +01:00
Lukas Oberhuber f87ec4bcfe libgimpbase: GError set twice in gimpreloc.c
This patch fixes a double free error due to a pointer being freed and 
then not nulled out.
It appears this is corrupting memory on MacOS as the `/proc` file system 
is not available and therefore multiple errors are returned.

Fixes:

(process:54873): GLib-WARNING **: 23:09:25.976: GError set over the top of
a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL
before it's set.
The overwriting error message was: Error opening file /proc/self/maps: No
such file or directory
_br_find_exe: (NULL)gimp-console(54873,0x100957e00) malloc: *** error for
object 0x103f09e80: pointer being freed was not allocated
gimp-console(54873,0x100957e00) malloc: *** set a breakpoint in
malloc_error_break to debug
2021-10-03 00:29:15 +00:00
Jacob Boerema af888e481f plug-ins: fix #6258 Hierarchical XMP tag should be written to Array
When saving XMP metadata were using gexiv2_metadata_get_tag_string for all
tags, even those that can have multiple values. This caused those values
to be saved as one value instead of multiple.

To fix this we use gexiv2_metadata_get_tag_multiple, except for XmpText.
Then we add all returned values for that tag separately to our metadata.
2021-09-24 13:42:45 -04:00
Jehan 49e534247a app, libgimp*, pdb, plug-ins: use g_memdup2() instead of g_memdup()
Since it appeared with GLib 2.68.0, we could not change this until we
bumped the dependency which has only become possible a few days ago
(since Debian testing is our baseline for dependency bumps). Cf.
previous commit.

As this is a drop-in replacement (just a guint parameter changed to
gsize to avoid integer overflow), search-and-replace with:

> sed -i 's/g_memdup\>/g_memdup2/g' `grep -rIl 'g_memdup\>' *`

… followed by a few manual alignment tweaks when necessary.

This gets rid of the many deprecation warnings which we had lately when
building with a recent GLib version.
2021-08-26 17:32:09 +02:00
Jacob Boerema 65950de735 libgimpbase: fix #1350 Failure to load metadata importing image with non-latin unicode path
On Windows loading metadata from images with non ASCII characters in their
path failed. Part of the fix is in gexiv2 that now converts the path from
utf-8 to utf-16 on Windows.

However we were still sending a localized path to gexiv2 where it was
expecting utf-8. This caused the conversion and thus loading of metadata
to fail. Fix is to remove the special handling for Windows and use the
utf-8 filename.
2021-08-08 19:31:40 -04:00
Jehan 54263f254d libgimbase, meson: reorganize execinfo dependency testing.
As discussed in !455: remove duplicate testing, testing header and
testing the library are a same test in one (for instance we don't want
to get into weird cases where the lib is found but not the header; this
updated test takes such inconsistencies into account). Also it's better
to have all dependency tests together in the root meson file.

Finally adding some comments to make this all more understandable for
anyone looking at this in the future.
2021-08-04 21:18:42 +02:00
lloyd konneker 37593d6da3 Fix #6979 meson build fails link libexecinfo on Alpine 2021-08-04 18:21:22 +00:00
Marie-P c112a55958 libgimp*, plug-ins: fix some warnings 2021-05-24 20:36:31 +00:00
Jehan 802c6fe64b Issue #6767: sensitivity ALWAYS not working in Python.
The hexadecimal int doesn't work for some reason, so I just set G_MAXINT
as enum are integers in C (though the sign bit won't be 1 in such case).
2021-04-30 00:27:56 +02: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
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