[grilo] Adjust key value accordingly to the key specification



commit c270e0a59371336be1389837be201305d5b3c5f0
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Mon Jun 7 15:32:20 2010 +0200

    Adjust key value accordingly to the key specification

 src/data/grl-data.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/data/grl-data.c b/src/data/grl-data.c
index b6e1e8b..7a0eac0 100644
--- a/src/data/grl-data.c
+++ b/src/data/grl-data.c
@@ -185,6 +185,10 @@ grl_data_get (GrlData *data, GrlKeyID key)
  *
  * Sets the value associated with the key. If key already has a value and
  * #overwrite is TRUE, old value is freed and the new one is set.
+ *
+ * Also, checks that value is compliant with the key specification, modifying it
+ * accordingly. For instance, if the key requires a number between 0 and 10, but
+ * value is outside this range, it will be adapted accordingly.
  **/
 void
 grl_data_set (GrlData *data, GrlKeyID key, const GValue *value)
@@ -201,6 +205,10 @@ grl_data_set (GrlData *data, GrlKeyID key, const GValue *value)
       g_value_copy (value, copy);
     }
 
+    if (g_param_value_validate (key, copy)) {
+      g_warning ("'%s' value invalid, adjusting",
+                 GRL_METADATA_KEY_GET_NAME (key));
+    }
     g_hash_table_insert (data->priv->data, key, copy);
   }
 }



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