[gimp/metadata-browser: 7/13] New function: xmp_model_find_xmptype_by



commit 1e366ba1c5dce82a9d2039741b7c1a522f19d280
Author: Roman Joost <roman bromeco de>
Date:   Sun Sep 4 17:28:38 2011 +1000

    New function: xmp_model_find_xmptype_by
    
    New function to return an XMPType. This is needed for widgets to
    determine which raw value has to be set.

 plug-ins/metadata/xmp-model.c |   39 +++++++++++++++++++++++++++++++++++++++
 plug-ins/metadata/xmp-model.h |    4 ++++
 2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/metadata/xmp-model.c b/plug-ins/metadata/xmp-model.c
index 0e9daba..7cafa25 100644
--- a/plug-ins/metadata/xmp-model.c
+++ b/plug-ins/metadata/xmp-model.c
@@ -1071,6 +1071,45 @@ xmp_model_set_property (XMPModel    *xmp_model,
 }
 
 /**
+ * xmp_model_find_xmptype_by:
+ * @xmp_model: An #XMPModel
+ * @schema_name: An #XMPSchema the property belongs to. Can be a schema
+ *               URI or prefix.
+ * @property_name: The name of the property to find the type for
+ *
+ * Finds the corresponding XMPType for the given schema and property
+ * name.
+ *
+ * Return value: XMPType or -1 if the property type can not be found.
+ **/
+XMPType
+xmp_model_find_xmptype_by (XMPModel     *xmp_model,
+                           const gchar  *schema_name,
+                           const gchar  *property_name)
+{
+  XMPSchema     *schema;
+  XMPProperty   *property = NULL;
+  int            i;
+
+  schema = find_xmp_schema_by_uri (xmp_model, schema_name);
+  if (! schema)
+    schema = find_xmp_schema_prefix (xmp_model, schema_name);
+
+  if (schema)
+   {
+    if (schema->properties != NULL)
+      for (i = 0; schema->properties[i].name != NULL; ++i)
+        if (! strcmp (schema->properties[i].name, property_name))
+         {
+          property = &(schema->properties[i]);
+          return property->type;
+         }
+   }
+
+  return -1;
+}
+
+/**
  * xmp_model_property_changed:
  * @xmp_model: An #XMPModel
  * @schema: An #XMPSchema the property belongs to
diff --git a/plug-ins/metadata/xmp-model.h b/plug-ins/metadata/xmp-model.h
index fd85c28..bb13e3e 100644
--- a/plug-ins/metadata/xmp-model.h
+++ b/plug-ins/metadata/xmp-model.h
@@ -109,6 +109,10 @@ const gchar  *xmp_model_get_scalar_property (XMPModel    *xmp_model,
                                              const gchar *schema_name,
                                              const gchar *property_name);
 
+XMPType       xmp_model_find_xmptype_by     (XMPModel    *xmp_model,
+                                             const gchar *schema_name,
+                                             const gchar *property_name);
+
 gboolean      xmp_model_set_property        (XMPModel    *xmp_model,
                                              XMPType      type,
                                              const gchar *schema_name,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]