[core 3/7] core: Deprecate key_is_known() function



Deprecate GrlData and GrlRelatedKeys key_is_known() function.

has_key() replaces it.

Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
---
 src/data/grl-data.c         |   20 ++++----------------
 src/data/grl-data.h         |    2 +-
 src/data/grl-related-keys.c |   17 +++--------------
 src/data/grl-related-keys.h |    4 ++--
 src/grl-metadata-source.c   |    2 +-
 tools/grilo-test-ui/main.c  |    2 +-
 6 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/src/data/grl-data.c b/src/data/grl-data.c
index 0f5f0ac..e37c061 100644
--- a/src/data/grl-data.c
+++ b/src/data/grl-data.c
@@ -272,7 +272,7 @@ grl_data_set (GrlData *data, GrlKeyID key, const GValue *value)
     grl_related_keys_set (relkeys, key, value);
     grl_data_add_related_keys (data, relkeys);
   } else {
-    if (grl_related_keys_key_is_known (relkeys, key) &&
+    if (grl_related_keys_has_key (relkeys, key) &&
         !data->priv->overwrite) {
       /* relkeys already has a value, and we can not overwrite it */
       return;
@@ -609,22 +609,10 @@ grl_data_get_keys (GrlData *data)
 gboolean
 grl_data_key_is_known (GrlData *data, GrlKeyID key)
 {
-  const GValue *v;
+  GRL_WARNING ("grl_data_key_is_known() is deprecated. "
+               "Use instead grl_data_has_key()");
 
-  g_return_val_if_fail (GRL_IS_DATA (data), FALSE);
-  g_return_val_if_fail (key, FALSE);
-
-  v = grl_data_get (data, key);
-
-  if (!v) {
-    return FALSE;
-  }
-
-  if (G_VALUE_HOLDS_STRING (v)) {
-    return g_value_get_string (v) != NULL;
-  }
-
-  return TRUE;
+  return grl_data_has_key (data, key);
 }
 
 /**
diff --git a/src/data/grl-data.h b/src/data/grl-data.h
index 9c646ff..5a186b6 100644
--- a/src/data/grl-data.h
+++ b/src/data/grl-data.h
@@ -126,7 +126,7 @@ gboolean grl_data_has_key (GrlData *data, GrlKeyID key);
 
 GList *grl_data_get_keys (GrlData *data);
 
-gboolean grl_data_key_is_known (GrlData *data, GrlKeyID key);
+G_GNUC_DEPRECATED gboolean grl_data_key_is_known (GrlData *data, GrlKeyID key);
 
 void grl_data_add_related_keys (GrlData *data, GrlRelatedKeys *relkeys);
 
diff --git a/src/data/grl-related-keys.c b/src/data/grl-related-keys.c
index 14a9681..4a0d7d3 100644
--- a/src/data/grl-related-keys.c
+++ b/src/data/grl-related-keys.c
@@ -551,21 +551,10 @@ gboolean
 grl_related_keys_key_is_known (GrlRelatedKeys *relkeys,
                                GrlKeyID key)
 {
-  GValue *v;
+  GRL_WARNING ("grl_related_keys_key_is_known() is deprecated. "
+               "Use instead grl_related_keys_has_key()");
 
-  g_return_val_if_fail (GRL_IS_RELATED_KEYS (relkeys), FALSE);
-
-  v = g_hash_table_lookup (relkeys->priv->data, key);
-
-  if (!v) {
-    return FALSE;
-  }
-
-  if (G_VALUE_HOLDS_STRING (v)) {
-    return g_value_get_string (v) != NULL;
-  }
-
-  return TRUE;
+  return grl_related_keys_has_key (relkeys, key);
 }
 
 /**
diff --git a/src/data/grl-related-keys.h b/src/data/grl-related-keys.h
index ef5eb17..e3c5ff8 100644
--- a/src/data/grl-related-keys.h
+++ b/src/data/grl-related-keys.h
@@ -142,8 +142,8 @@ gboolean grl_related_keys_has_key (GrlRelatedKeys *relkeys,
 
 GList *grl_related_keys_get_keys (GrlRelatedKeys *relkeys);
 
-gboolean grl_related_keys_key_is_known (GrlRelatedKeys *relkeys,
-                                        GrlKeyID key);
+G_GNUC_DEPRECATED gboolean grl_related_keys_key_is_known (GrlRelatedKeys *relkeys,
+                                                          GrlKeyID key);
 
 GrlRelatedKeys *grl_related_keys_dup (GrlRelatedKeys *relkeys);
 
diff --git a/src/grl-metadata-source.c b/src/grl-metadata-source.c
index 16cc78c..a557c42 100644
--- a/src/grl-metadata-source.c
+++ b/src/grl-metadata-source.c
@@ -600,7 +600,7 @@ missing_in_data (GrlData *data, const GList *deps)
     return g_list_copy ((GList *) deps);
 
   for (iter = (GList *)deps; iter; iter = g_list_next (iter)) {
-    if (!grl_data_key_is_known (data, iter->data))
+    if (!grl_data_has_key (data, iter->data))
       result = g_list_append (result, iter->data);
   }
 
diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c
index 526df4f..8c8230d 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -541,7 +541,7 @@ metadata_cb (GrlMediaSource *source,
     keys = grl_data_get_keys (GRL_DATA (media));
     i = keys;
     while (i) {
-      if (grl_data_key_is_known (GRL_DATA (media), i->data)) {
+      if (grl_data_has_key (GRL_DATA (media), i->data)) {
         const GValue *g_value = grl_data_get (GRL_DATA (media), i->data);
         gchar *value = g_value ? g_strdup_value_contents (g_value) : "";
         gtk_list_store_append (GTK_LIST_STORE (view->metadata_model), &iter);
-- 
1.7.4



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