Commit 74564d14 authored by Paolo Bacchilega's avatar Paolo Bacchilega

Changed exif/xmp tag where the date is saved

Save the date entered in the edit metadata dialog in
Exif::Photo::DateTimeOriginal and in Xmp::exif::DateTimeOriginal
Use Exif::Image::DateTime to save the last modified date.
This fixes an error that prevented to delete the date from an image
with the edit metadata dialog.
parent e594821e
......@@ -500,10 +500,7 @@ set_attributes_from_tagsets (GFileInfo *info)
clear_studip_comments_from_tagset (info, _DESCRIPTION_TAG_NAMES);
clear_studip_comments_from_tagset (info, _TITLE_TAG_NAMES);
set_attribute_from_tagset (info, "general::datetime", _LAST_DATE_TAG_NAMES);
if (g_file_info_get_attribute_object (info, "general::datetime") == NULL)
set_attribute_from_tagset (info, "general::datetime", _ORIGINAL_DATE_TAG_NAMES);
set_attribute_from_tagset (info, "general::datetime", _ORIGINAL_DATE_TAG_NAMES);
set_attribute_from_tagset (info, "general::description", _DESCRIPTION_TAG_NAMES);
set_attribute_from_tagset (info, "general::title", _TITLE_TAG_NAMES);
......
......@@ -28,6 +28,10 @@
G_BEGIN_DECLS
extern const char *_LAST_DATE_TAG_NAMES[];
extern const char *_ORIGINAL_DATE_TAG_NAMES[];
extern const char *_DESCRIPTION_TAG_NAMES[];
gboolean exiv2_read_metadata_from_file (GFile *file,
GFileInfo *info,
GCancellable *cancellable,
......
......@@ -142,7 +142,6 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider *self,
"Iptc::Application2::Caption",
NULL
};
int i;
for (i = 0; tags_to_remove[i] != NULL; i++)
g_file_info_remove_attribute (file_data->info, tags_to_remove[i]);
......@@ -169,19 +168,8 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider *self,
}
}
else {
const char *tags_to_remove[] = {
"Exif::Image::ImageDescription",
"Xmp::tiff::ImageDescription",
"Iptc::Application2::Headline",
"Exif::Photo::UserComment",
"Xmp::dc::description",
"Iptc::Application2::Caption",
NULL
};
int i;
for (i = 0; tags_to_remove[i] != NULL; i++)
g_file_info_remove_attribute (file_data->info, tags_to_remove[i]);
for (i = 0; _DESCRIPTION_TAG_NAMES[i] != NULL; i++)
g_file_info_remove_attribute (file_data->info, _DESCRIPTION_TAG_NAMES[i]);
}
metadata = g_file_info_get_attribute_object (file_data->info, "general::title");
......@@ -220,11 +208,34 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider *self,
metadata = g_file_info_get_attribute_object (file_data->info, "general::datetime");
if (metadata != NULL) {
g_object_set (metadata, "value-type", NULL, NULL);
g_file_info_set_attribute_object (file_data->info, "Exif::Image::DateTime", metadata);
GthMetadata *xmp_metadata = NULL;
GTimeVal timeval;
if (_g_time_val_from_exif_date (gth_metadata_get_raw (GTH_METADATA (metadata)), &timeval)) {
char *xmp_format;
xmp_metadata = gth_metadata_dup (GTH_METADATA (metadata));
xmp_format = _g_time_val_to_xmp_date (&timeval);
g_object_set (xmp_metadata, "raw", xmp_format, NULL);
g_free (xmp_format);
}
for (i = 0; _ORIGINAL_DATE_TAG_NAMES[i] != NULL; i++) {
if (g_str_has_prefix (_ORIGINAL_DATE_TAG_NAMES[i], "Xmp::")) {
if (xmp_metadata != NULL)
g_file_info_set_attribute_object (file_data->info, _ORIGINAL_DATE_TAG_NAMES[i], G_OBJECT (xmp_metadata));
}
else
g_file_info_set_attribute_object (file_data->info, _ORIGINAL_DATE_TAG_NAMES[i], metadata);
}
_g_object_unref (xmp_metadata);
}
else {
for (i = 0; _ORIGINAL_DATE_TAG_NAMES[i] != NULL; i++)
g_file_info_remove_attribute (file_data->info, _ORIGINAL_DATE_TAG_NAMES[i]);
}
else
g_file_info_remove_attribute (file_data->info, "Exif::Image::DateTime");
if (exiv2_write_metadata_to_buffer (&buffer,
&size,
......
......@@ -151,6 +151,7 @@ GthMetadataInfo exiv2_metadata_info[] = {
{ "Xmp::dc::title", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Xmp::iptc::Location", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Xmp::iptc::Keywords", NULL, "Xmp::Embedded", 0, "XmpBag", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Xmp::exif::DateTimeOriginal", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Iptc::Application2::Headline", NULL, "Iptc", 0, "String", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Iptc::Application2::Caption", NULL, "Iptc", 0, "String", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment