[gimp] plug-ins: Do not write empty ModelReleaseStatus and DigitalSourceType.
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: Do not write empty ModelReleaseStatus and DigitalSourceType.
- Date: Tue, 23 Mar 2021 19:24:42 +0000 (UTC)
commit a229454915035628e6d39d6dabc920fec72b66cf
Author: Jacob Boerema <jgboerema gmail com>
Date: Tue Mar 23 15:19:27 2021 -0400
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.
plug-ins/metadata/metadata-editor.c | 36 ++++++++++++++++++++++++++----------
plug-ins/metadata/metadata-tags.c | 2 ++
2 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/plug-ins/metadata/metadata-editor.c b/plug-ins/metadata/metadata-editor.c
index ea15fd9673..6c00078717 100644
--- a/plug-ins/metadata/metadata-editor.c
+++ b/plug-ins/metadata/metadata-editor.c
@@ -1870,7 +1870,7 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0);
combo_widget = builder_get_widget (builder, "Xmp.plus.ModelReleaseStatus");
- for (i = 0; i < 4; i++)
+ for (i = 0; i < n_modelreleasestatus; i++)
{
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget),
gettext (modelreleasestatus[i].display));
@@ -1880,7 +1880,7 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
gtk_widget_set_size_request (combo_widget, 180, height);
combo_widget = builder_get_widget (builder, "Xmp.iptcExt.DigitalSourceType");
- for (i = 0; i < 5; i++)
+ for (i = 0; i < n_digitalsourcetype; i++)
{
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget),
gettext (digitalsourcetype[i].display));
@@ -3545,7 +3545,7 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
{
gint loop;
- for (loop = 0; loop < 4; loop++)
+ for (loop = 0; loop < n_modelreleasestatus; loop++)
{
if (! strcmp (modelreleasestatus[loop].data, value))
{
@@ -3566,7 +3566,7 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
{
gint loop;
- for (loop = 0; loop < 5; loop++)
+ for (loop = 0; loop < n_digitalsourcetype; loop++)
{
if (! strcmp (digitalsourcetype[loop].data, value))
{
@@ -4466,9 +4466,17 @@ metadata_editor_write_callback (GtkWidget *dialog,
else if (! strcmp ("Xmp.plus.ModelReleaseStatus",
default_metadata_tags[i].tag))
{
- gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
- default_metadata_tags[i].tag,
- modelreleasestatus[value].data);
+ if (value == 0)
+ {
+ gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata),
+ default_metadata_tags[i].tag);
+ }
+ else
+ {
+ gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
+ default_metadata_tags[i].tag,
+ modelreleasestatus[value].data);
+ }
}
else if (! strcmp ("Xmp.plus.PropertyReleaseStatus",
default_metadata_tags[i].tag))
@@ -4503,9 +4511,17 @@ metadata_editor_write_callback (GtkWidget *dialog,
else if (! strcmp ("Xmp.iptcExt.DigitalSourceType",
default_metadata_tags[i].tag))
{
- gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
- default_metadata_tags[i].tag,
- digitalsourcetype[value].data);
+ if (value == 0)
+ {
+ gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata),
+ default_metadata_tags[i].tag);
+ }
+ else
+ {
+ gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
+ default_metadata_tags[i].tag,
+ digitalsourcetype[value].data);
+ }
}
}
}
diff --git a/plug-ins/metadata/metadata-tags.c b/plug-ins/metadata/metadata-tags.c
index 9fae102041..7db06de273 100644
--- a/plug-ins/metadata/metadata-tags.c
+++ b/plug-ins/metadata/metadata-tags.c
@@ -166,6 +166,7 @@ const gint n_equivalent_metadata_tags = G_N_ELEMENTS (equivalent_metadata_tags);
*/
const combobox_str_tag digitalsourcetype[] =
{
+ { "", N_("Select a value")
},
{ "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture", N_("Original digital capture of a real
life scene") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/negativeFilm", N_("Digitized from a negative on film")
},
{ "http://cv.iptc.org/newscodes/digitalsourcetype/positiveFilm", N_("Digitized from a positive on film")
},
@@ -179,6 +180,7 @@ const gint n_digitalsourcetype = G_N_ELEMENTS (digitalsourcetype);
*/
const combobox_str_tag modelreleasestatus[] =
{
+ { "", N_("Select a value") },
{ "http://ns.useplus.org/ldf/vocab/MR-NON", N_("None") },
{ "http://ns.useplus.org/ldf/vocab/MR-NAP", N_("Not Applicable") },
{ "http://ns.useplus.org/ldf/vocab/MR-NAP", N_("Unlimited Model Releases") },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]