Commit Graph

212 Commits

Author SHA1 Message Date
Anders Jonsson e4e3dcca6b plug-ins: readd translation context for tag values
Originally added in 55aa462faa
2023-12-31 13:14:00 +00:00
Jacob Boerema ec999ee193 plug-ins: make metadata-editor/viewer use gimp_image_procedure_new
These were using gimp_procedure_new, which was causing warnings like
LibGimpConfig-WARNING **: 13:56:33.270: couldn't serialize property
 GimpProcedureConfig-plug-in-metadata-editor::image of type GimpImage,
and
gimp_plug_in_destroy_proxies: ERROR: GimpImage proxy with ID 1 was
refed by plug-in, it MUST NOT do that!

This also saves us from having to define image and run-mode parameters
ourselves.
2023-11-27 14:08:26 -05:00
Jehan bf8ee69570 plug-ins: fix some broken macros with a massive search-and-replace.
If we leave a space between the macro name and opening parenthese for argument
lists, the args are not considered macro args (which will be discovered when
using it). I experienced this issue while testing code on some plug-in
yesterday, so thought I might as well fix all these broken macros for casting to
the specific GimpPlugIn subclass, so that we won't have a next time.
2023-10-18 18:29:37 +02:00
Jehan 2b38a2df86 libgimp, plug-ins: rename gimp_procedure_new2() as gimp_procedure_new() and…
… remove the latter.

Now all GimpProcedure use this new implementation with use a config object.
2023-10-01 20:52:01 +02:00
Jehan e92ef9d45a plug-ins: port several of the easy plug-ins to gimp_procedure_new2(). 2023-10-01 20:52:01 +02:00
Jacob Boerema 40b2412fa4 plug-ins: add synchronization with certain Exif tags.
Exif tags Exif.Image.Artist, Exif.Image.ImageDescription, and
Exif.Image.Copyright were not being synchronized with their Xmp and
Iptc.IIM equivalents in the metadata-editor.

This commit adds synchronization of reading and writing of the metadata.

We adjust the struct for equivalent_metadata_tags by removing unused
fields and adding a field that points to the equivalent Exif tag in
a new struct called exif_tag_info.

On loading of the metadata tags we now also check a limited set of
Exif tags. If no value was set yet, we use the Exif value, or else
we check to make sure both had the same value. If not, print a
warning in the terminal.

On saving of metadata, we now also save to the marked Exif tags, or
if the value is NULL, we remove the tag.

In passing, we also fix two memory leaks by freeing with g_strfreev
temporary string lists.
2023-08-14 17:29:44 -04:00
Jacob Boerema 8495dd6eed plug-ins: improve creation date handling in metadata-editor
Dates in Xmp include a time and timezone, so add a default time when
selecting a date since we can't edit time and timezone yet.

So far, we didn't take into account that IPTC-IIM has separate date
and time+timezone values instead of the combined value in XMP for
DateCreated.

When loading DateCreated check if it has the same value as IPTC
values DateCreated and TimeCreated combined. If not, we show a
terminal error and ignore the IPTC values.
If neither Xmp nor Iptc has a DateCreated, then use Exif.Photo.
DateTimeOriginal combined with OffsetTimeOriginal to set an initial
value.

When saving, synchronize with IPTC-IIM by splitting the DateCreated
value in date and time+timezone and save each to the appropriate tag.
Also make sure that for IPTC-IIM the date separator is a '-'.
2023-08-14 16:50:15 -04:00
Jacob Boerema 83294ba4c7 plug-ins: improve spacing in metadata-editor
Adds a bottom margin to the grids because the horizontal scrollbar
was overlapping the bottom-most row of the grid.
Adds wordwrap and left/right margins to multiline text widgets,
mainly to make the text not start right at the edge of the widget.
2023-08-13 15:15:04 -04:00
Jacob Boerema b97f96249a plug-ins: Xmp.plus.ImageSupplierName can only have one value
as used in metadata-editor:
Change from MODE_MULTI to MODE_SINGLE.
2023-08-13 15:15:04 -04:00
Jacob Boerema c633091d54 plug-ins: in metadata-editor use array size constants...
instead of hard-coded numbers.
Also:
- remove unneeded set_tag_string for n_creatorContactInfoTags
- remove now unneeded structs
2023-08-13 15:15:04 -04:00
Jacob Boerema 4e40a3edd2 plug-ins: make mode in metadata-editor an enum
We were using a string for the metadata mode, meaning we had to compare
string values in a lot of places.

We simplify and probably speed-up comparisons here by replacing the
mode string by an enum value.

The only place still needing the string values sometimes is
metadata-impexp.[ch] where we added a conversion table to convert
the mode to a string.
2023-08-13 15:15:03 -04:00
Alx Sa 5070e0e9ec plug-ins: Add additional DigitalSourceType...
types for the metadata editor.
2023-05-31 18:06:39 +00:00
Michael Natterer 26dce72d2c Remove autotools 2023-05-27 00:03:52 +02:00
Simon Budig 51311f913d metadata: shut up a weird warning 2023-05-20 23:32:18 +02:00
Jacob Boerema 1fa8e8617b plug-ins: fix previous metadata-editor commit
- Missed a necessary autotools change: forgot to remove ui/Makefile
from configure.ac
- Not all compilers allow declaring variables in a case statement without
putting them in a block, so we add a block now.
2023-05-10 14:28:42 -04:00
Jacob Boerema 8969bbcee8 plug-ins: Remove dependency on GtkBuilder from metadata-editor
Instead of loading the GtkBuilder .ui file we now create all widgets in
code.
Added several support functions to reduce code copy/pasting and making
additional widgets and supporting more metadata easier.
The overall layout should still look the same, with a few exceptions:
- Each notebook page only uses one grid. This makes it possible to align
all data entry widgets.
- Featured Organization and it's code were two treeviews next to each
other. These are now organized below each other to make automatic code
generation easier.
- Since we needed to touch this code anyway, I also fixed Xmp.dc.creator
and Xmp.iptcExt.ModelAge to be multiline. This closes #7286.
- The old icons used for the date button, add, and remove row buttons
were replaced by gimp-grid, list-add and list-remove.

Since this was the last .ui file used in GIMP plug-ins, we remove all
files from the .ui subdirectory and references to that.

Note that there are several more places where GtkBuilder is used, but
those cases uses strings defined in code instead of .ui files.
2023-05-10 13:25:12 -04:00
Jacob Boerema 415b32e763 plug-ins: refactor set_tag_string usage in metadata-editor
We had a lot of duplicate code using gexiv2_metadata_try_set_tag_string
and then checking for errors.

Simplify this by re-using the existing set_tag_string function by
introducing an extra parameter that tells us whether or not to clear
the tag first.
2023-05-10 12:48:01 -04:00
Jacob Boerema a57a62ce1a plug-ins: replace deprecated gexiv2 functions in metadata-editor
In the master branch we depend on gexiv2 0.14, so we can remove the
deprecated functions and replace them with the "try_" versions.

We can't backport this, since our stable branch has a lower dependency
for gexiv2.
2023-05-01 19:01:13 -04:00
Jacob Boerema 58e02b4f4e plug-ins: Reimplement date picker in metadata-editor without GtkBuilder
Also changes the dialog title to not have a ':' and make the title
express what the expected action is.
2023-05-01 19:01:13 -04:00
Jacob Boerema 9c11b40393 plug-ins: create metadata-viewer gui from code
The metadata-viewer uses a GtkBuilder .ui file to create the interface.
In GIMP we prefer our interfaces to be created in code and these builder
files are also not available anymore in GTK4.

This commit removes the .ui file and support code, and creates the
interface from code in our plug-in.
2023-04-30 16:01:40 -04: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 df074bfe09 plug-ins: label and documentation of plug-ins localized plug-in side.
This is the consequence of previous commit. Plug-ins' label and
documentation are now localized before sending these data to GIMP core.
In other words, we replace N_() macros with basic gettext calls.
2022-07-05 12:23:51 +02:00
Jehan 18c37f7084 plug-ins, libgimp: override set_i18n() for all our core plug-ins.
Hence avoiding the stderr messages. These are going to be localized with
centrally installed catalogs "gimp*-std-plugins", "gimp*-script-fu" and
"gimp*-python".

We now handle core plug-in localizations differently and in particular,
with kind of a reverse logic:

- We don't consider "gimp*-std-plugins" to be the default catalog
  anymore. It made sense in the old world where we would consider the
  core plug-ins to be the most important and numerous ones. But we want
  to push a world where people are even more encouraged to develop their
  own plug-ins. These won't use the standard catalog anymore (because
  there are nearly no reasons that the strings are the same, it's only a
  confusing logic). So let's explicitly set the standard catalogs with
  DEFINE_STD_SET_I18N macro (which maps to a different catalog for
  script-fu plug-ins).
- Doing something similar for Python plug-ins which have again their own
  catalog.
- Getting rid of the INIT_I18N macro since now all the locale domain
  binding is done automatically by libgimp when using the set_i18n()
  method infrastructure.
2022-06-05 01:57:02 +02:00
Jacob Boerema 6a8299d989 plug-ins: simplify adding tags to store in metadata-viewer
We were using parameter iter in metadata_dialog_add_tag and
metadata_dialog_add_translated_tag.

However, iter is only ever set inside metadata_dialog_add_tag by calling
gtk_list_store_append. So, there is no need to pass this parameter around.

For this reason, let's remove parameter iter from the above two functions
and replace with a local variable.
2022-06-02 21:45:27 -04:00
Jacob Boerema 477302fdab plug-ins: replace deprecated gexiv2 functions in metadata-viewer
Since we increased our minimum version of gexiv2 to 0.12.3, several
functions used in the metadata-viewer plug-in have been deprecated.

Replace these functions with the "try_" versions, which include an
error parameter. If this returns non NULL then we print the error
message to the console.
2022-03-09 11:30:56 -05:00
Jacob Boerema 641080c838 plug-ins: fix several issues detected by coverity
Detected issues fixed here:
- Use GString and g_string_append since otherwise we need to add g_free
after every g_strconcat.
- No error checking.
- We need to g_free value_utf.

Not detected by coverity:
- Wrong quotes around utf-8.
- Remove unused includes.
2021-10-24 22:14:13 -04:00
Jacob Boerema e90f041ca5 plug-ins: fix resource leaks detected by coverity
Several resource leaks here were detected by coverity:
- Not freeing value_utf.
- Strings returned by g_strconcat should be g_free'd. To handle the string
concatenations easier we use GString and g_string_append instead.
Also introduce function get_list_elements to reduce the number of
repetetive elements.
While we were at it, also remove unused includes.
2021-10-24 22:01:16 -04:00
Jacob Boerema 6eba73e714 plug-ins: fix #7408 metadata-editor plugin cashing when saving metadata
When writing metadata in the metadata-editor it did not check for empty
values. In combination with gexiv2 0.14.0 (which doesn't check in this
specific case for an empty list of gchar **) and trying to set a non
repeatable Iptc tag (Iptc.Application2.Headline) using
gexiv2_metadata_set_tag_multiple we get a crash.

This fix checks first for a non empty value before trying to save the
metadata tag.
Since the code is very similar also implemented this check for the Xmp
tags in addition to the Iptc and simplified some duplicate code.
2021-10-24 13:38:06 -04:00
Jacob Boerema b070c6fba6 plug-ins: Iptc.Application2.Headline is not a repeatable tag
See issue #7408 where this is causing a crash when using gexiv 0.14.0
in combination with trying to save it as a multiple tag with an empty list.
According to https://exiv2.org/iptc.html the tag Iptc.Application2.Headline
is not repeatable so we will set mode to "single.

In addition to that I added comments to explain the differences in the
meaning of "single" and "multi" between the list of Xmp tags and Iptc tags.
2021-10-24 12:53:37 -04:00
Jehan 52928e04a5 Issue #7327: Cannot build GIMP3 on MSYS2 using Meson.
This is untested on my side, because the bug only happens on native
builds with meson (our CI has cross-builds with meson and native builds
with autotools and I only do cross-builds locally) but I think/hope it
will work.

Basically we were using .full_path() because these rc files were also
used as input of some configure_file() calls which doesn't like custom
target objects as input (it wants strings or file objects). Yet a bug
in meson didn't like the colon used in native Windows full paths ('C:'
and such) when used in windows.compile_resources(). This has been fixed
by Luca Bacci in: https://github.com/mesonbuild/meson/pull/9368
Yet we just cannot depend on very early meson (or worse dev meson code).

On the other hand, if the input is a custom_tgt object, it uses the
object ID which we give as first parameter of custom_target() so we know
it's appropriately named without colons (such as 'gimp_plugins_rc').
Thus we should not bump into this issue again.

For the few usage in configure_file(), I just add a .full_path() only
when needed at call time.

Last but not least, I replace the bogus `meson --version` call by a
`python3 -c 'exit()'` as advised by Eli Schwartz:
2afa019c70 (note_1284951)

The reason is that it is apparently possible (or will be when some
reimplementation of meson will be done) that the `meson` executable
itself does not exist. On the other hand, `python3` should always be
there, as a mandatory dependency of the build tool.

In order to use an appropriate `python3`, I made the
pythonmod.find_installation() check required in our build (which should
not be a problem since it's a meson requirement as well), even when the
-Dpython option is false (this one depends on other requirements too
anyway, such as version and pygobject). This way I can call this meson
variable of discovered python in my bogus call, instead of calling a
(potentially different) python from PATH environment.
2021-10-12 17:06:18 +02:00
Jacob Boerema a4cb134f14 plug-ins: fix saving of XMP BAG/SEQ array values in metadata-editor
XMP array tags of type BAG and SEQ can have multiple values, each of
which is on a separate line. However, we were reading and saving it as
just one value.

We change this by setting each line as a separate value with
gexiv2_metadata_set_tag_multiple.

In addition to that we found that setting the type of tag struct with
gexiv2_metadata_set_xmp_tag_struct caused arrays of multiple values per
tag to be set incorrectly: the last value in the list got added multiple
times. I'm not sure if we are using this function incorrectly, or that
there is a bug in gexiv2 or exiv2. Anyway, since it seems that all tags
and values I tested work without calling this function, let's just omit
this call.
2021-09-25 14:54:45 -04:00
Jacob Boerema 76dc649b3f plug-ins: improve loading of XMP BAG/SEQ tags in metadata-editor
XMP array tags of type BAG and SEQ can have multiple values, each of these
values needs to be on a separate line to be correctly recognized as a
different value in the tag array. We were incorrectly loading all values
on one line separated by a comma.
For those tags that have equivalent IPTC tags we were also comparing just
the one XMP value with the whole, possibly multiple lines, of the same
IPTC, which could cause a failure to recognize identical tags.

We changed this to now have each value in a tag array on a separate line
by adding \n between values.
Each IPTC equivalent tag value is now compared to each value in the XMP
tag array and only added when a different value is found.
2021-09-25 14:39:40 -04:00
Jacob Boerema baaa1380cf plug-ins: in metadata-viewer improve how we show XMP tags.
XMP tags that have multiple values (usually of type XMpBag or XmpSeq) were
shown on one line. Which, especially for long text values, could make it
difficult to see the separate values for that tag.

Let's do the same as we do for IPTC tags that can occur multiple times and
show each value on a separate line.
2021-09-24 15:22:49 -04:00
Jacob Boerema e9ab89fa4f plug-ins: use separate function for adding multiple values per tag
In the metadata-viewer refactor the code that adds multiple values per tag
to the list store into a separate function.
Currently used for IPTC tags only but the intention is to reuse it for
XMP tags with multiple values.
2021-09-24 15:14:48 -04:00
Jacob Boerema e7f65e4b9f plug-ins: improve formatting in metadata-viewer 2021-09-24 15:11:03 -04:00
Marie-P c112a55958 libgimp*, plug-ins: fix some warnings 2021-05-24 20:36:31 +00:00
Jacob Boerema 165b50abcc plug-ins:fix #6624 metadata viewer default window size is too small
Let's increase the default size of the metadata viewer a bit.
Ideally we would add some logic to determine the width of
the first column since that one currently depends on the
length of the longest tag. However for now this change
will be enough for most cases.
2021-04-24 12:45:52 -04:00
Jacob Boerema 5d14c59d2e plug-ins: fix incorrect saving of Iptc.Application2.Caption in metadata-editor.
The saved value for Iptc.Application2.Caption is copied from Xmp.dc.description.
However the last one is multiline but the former should be single line. This
caused only the first line to be saved instead of all lines.

To fix this we set Iptc.Application2.Caption to single and use a different
conversion based on whether the tags from Xmp and Iptc are both
multiline or whether Iptc is single line.
2021-03-24 12:51:59 -04:00
Jacob Boerema 93f591931b plug-ins: fix incorrect values for ModelReleaseStatus and PropertyReleaseStatus.
While testing the metadata-editor I noticed that certain values for 
ModelReleaseStatus and PropertyReleaseStatus were incorrectly
read back.

Apparently while copy pasting some values were forgotten to be
updated which caused incorrect values to be saved.

There probably are not many users of these metadata tags
since in all these years there hasn't been a bug report about this.
2021-03-23 16:44:02 -04:00
Jacob Boerema 0a902456ac plug-ins: Do not write to Iptc.Application2.DateCreated if no date was set.
The metadata-editor allowed Iptc tags to be set if an empty string was
used contrary to Xmp tags. In the case of DateCreated this cause an
invalid date "0-00-00" to be written.

We added a check to only write text Iptc metadata if the value is
not empty.
2021-03-23 15:24:07 -04:00
Jacob Boerema a229454915 plug-ins: Do not write empty ModelReleaseStatus and DigitalSourceType.
Fixes issue #3656 Empty metadata tags are written to XCF at least.

Xmp.plus.ModelReleaseStatus and Xmp.iptcExt.DigitalSourceType are
defined as combo boxes with a fixed number of possible values.
However there was no option to leave it empty so there always was
a value written when saving metadata in the metadata-editor.

We added a "select value" as default option and only write
metadata if a different value was chosen.

As a bonus we replaced the fixed loop numbers with
the current actual number of defined choices.
2021-03-23 15:24:07 -04:00
Jacob Boerema 34463786b1 plug-ins: interpret Exif.Photo.UserComment before showing in metadata-viewer. 2021-03-22 16:07:13 -04:00
Jacob Boerema a95371c2b0 plug-ins: in metadata-editor use /iptcExt instead of /Iptc4xmpExt when saving.
We need to work around an issue in Exiv2 that saving to /Iptc4xmpExt bag
records fails which seems related to it registering /iptcExt. Unregistering
that and registering the first one doesn't work.
See: https://gitlab.gnome.org/GNOME/gexiv2/-/issues/24

So let's use /iptcExt for saving even though it's the less common form
for now. When loading metadata we try to load the most common
form first and if that fails we will load /iptcExt.
2021-03-15 20:49:39 -04:00
Jacob Boerema d00fe2bfe2 plug-ins: set most common CreatorContactInfo last in metadata-editor.
Set Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:* last since the short
form Xmp.iptc.Ci* could have been used to set this information too.

Becausethe first (longer) form is the most common let that override the
shorter form in the (unlikely) case that both are present and also have
different values.

Due to a bug in the metadata-editor previously only the short form
was saved.
2021-03-14 19:19:09 -04:00
Jacob Boerema 184b803811 plug-ins: fix several memory leaks in metadata-editor. 2021-03-14 18:32:09 -04:00
Jacob Boerema f04b84cb39 plug-ins: fix using incorrect structs and fields in metadata-editor. 2021-03-14 18:07:46 -04:00
Jacob Boerema 4609def72f plug-ins: more refactoring of duplicate code in metadata-editor.
Reordered the strings in artworkorobject to be in the same
order as the columns.
Add write_metadata_tag_multiple function that handles most
of the previously duplicated code and check for special
handling of phonetype when necessary by adding
an enum and a get_phonetype function.
2021-03-12 22:05:52 -05:00
Jacob Boerema 9c2451d813 plug-ins: refactor writing single metadata tag in metadata-editor.
Use a separate function that can be reused and also get rid of
the large output_data array and strcat without length
checking. We will use GString instead.
2021-03-12 22:05:52 -05:00
Jacob Boerema 87763cbe27 plug-ins: remove use of strcpy without length checking in metadata-editor. 2021-03-12 22:05:52 -05:00
Jacob Boerema c2fa21ac7d plug-ins: remove use of global tagdata array in metadata-editor.
This removes some flawfinder warnings by not using a fixed
size array and using g_snprintf instead of g_sprintf and
using more safety checks.
2021-03-12 22:05:52 -05:00