[niepce] Alternative localized data are read and saved properly.
- From: Hubert FiguiÃre <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Alternative localized data are read and saved properly.
- Date: Sun, 13 Nov 2011 06:50:38 +0000 (UTC)
commit 035baf37fce4837e0a9eb08c2919c2d775f16893
Author: Hub Figuiere <hub figuiere net>
Date: Sat Nov 12 17:25:00 2011 -0800
Alternative localized data are read and saved properly.
src/engine/db/libmetadata.cpp | 12 ++++++++++--
src/engine/db/xmpproperties.cpp | 11 +++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/engine/db/libmetadata.cpp b/src/engine/db/libmetadata.cpp
index af9a474..145d632 100644
--- a/src/engine/db/libmetadata.cpp
+++ b/src/engine/db/libmetadata.cpp
@@ -20,6 +20,7 @@
#include <string.h>
#include <time.h>
#include <exempi/xmpconsts.h>
+#include <exempi/xmperrors.h>
#include "fwk/base/debug.hpp"
#include "libmetadata.hpp"
@@ -49,8 +50,15 @@ bool LibMetadata::setMetaData(fwk::PropertyIndex meta, const fwk::PropertyValue
boost::get<int>(value), 0);
}
else if(value.type() == typeid(std::string)) {
- result = xmp_set_property(xmp(), ns, property,
- boost::get<std::string>(value).c_str(), 0);
+ std::string val = boost::get<std::string>(value);
+ result = xmp_set_property(xmp(), ns, property, val.c_str(), 0);
+ // FIXME we should know in advance it is localized.
+ if(!result && (xmp_get_error() == XMPErr_BadXPath)) {
+ result = xmp_set_localized_text(xmp(), ns, property, "", "x-default", val.c_str(), 0);
+ }
+ }
+ if(!result) {
+ ERR_OUT("error setting property %s:%s %d", ns, property, xmp_get_error());
}
}
else {
diff --git a/src/engine/db/xmpproperties.cpp b/src/engine/db/xmpproperties.cpp
index dbd27bc..45cf914 100644
--- a/src/engine/db/xmpproperties.cpp
+++ b/src/engine/db/xmpproperties.cpp
@@ -58,8 +58,15 @@ bool get_prop_from_xmp(const fwk::XmpMeta * meta, fwk::PropertyIndex p,
return false;
}
xmp::ScopedPtr<XmpStringPtr> xmp_value(xmp_string_new());
- if(xmp_get_property(meta->xmp(), iter->second.first,
- iter->second.second, xmp_value, NULL)) {
+ uint32_t prop_bits = 0;
+ const char * ns = iter->second.first;
+ const char * xmp_prop = iter->second.second;
+ bool found = xmp_get_property(meta->xmp(), ns, xmp_prop, xmp_value, &prop_bits);
+ if(found && XMP_IS_ARRAY_ALTTEXT(prop_bits)) {
+ found = xmp_get_localized_text(meta->xmp(), ns, xmp_prop, "", "x-default",
+ NULL, xmp_value, NULL);
+ }
+ if(found) {
const char * v = NULL;
v = xmp_string_cstr(xmp_value);
if(v) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]