[grilo] core: Handle boolean values in GrlRelatedKeys
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] core: Handle boolean values in GrlRelatedKeys
- Date: Sat, 3 Nov 2012 00:42:49 +0000 (UTC)
commit c444d7c829b96c83d1679233c953a3dfc328528e
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Fri Nov 2 16:55:15 2012 +0000
core: Handle boolean values in GrlRelatedKeys
src/data/grl-related-keys.c | 44 +++++++++++++++++++++++++++++++++++++++++++
src/data/grl-related-keys.h | 7 ++++++
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/src/data/grl-related-keys.c b/src/data/grl-related-keys.c
index bfc1e6e..3f28a70 100644
--- a/src/data/grl-related-keys.c
+++ b/src/data/grl-related-keys.c
@@ -414,6 +414,50 @@ grl_related_keys_get_float (GrlRelatedKeys *relkeys,
}
/**
+ * grl_related_keys_set_boolean:
+ * @relkeys: set of related keys to change
+ * @key: (type GrlKeyID): key to change or add
+ * @booleanvalue: the new value
+ *
+ * Sets the value associated with @key into @relkeys. @key must have been
+ * registered as a boolean-type key. Old value is replaced by the new one.
+ **/
+void
+grl_related_keys_set_boolean (GrlRelatedKeys *relkeys,
+ GrlKeyID key,
+ gboolean booleanvalue)
+{
+ GValue value = { 0 };
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, booleanvalue);
+ grl_related_keys_set (relkeys, key, &value);
+}
+
+/**
+ * grl_related_keys_get_boolean:
+ * @relkeys: set of related keys to inspect
+ * @key: (type GrlKeyID): key to use
+ *
+ * Returns the value associated with @key from @relkeys. If @key has no value,
+ * or value is not a gboolean, or @key is not in @relkeys, then %FALSE is
+ * returned.
+ *
+ * Returns: float value associated with @key, or %FALSE in other case.
+ **/
+gboolean
+grl_related_keys_get_boolean (GrlRelatedKeys *relkeys,
+ GrlKeyID key)
+{
+ const GValue *value = grl_related_keys_get (relkeys, key);
+
+ if (!value || !G_VALUE_HOLDS_BOOLEAN (value)) {
+ return FALSE;
+ } else {
+ return g_value_get_boolean (value);
+ }
+}
+
+/**
* grl_related_keys_set_binary:
* @relkeys: set of related keys to change
* @key: (type GrlKeyID): key to change or add
diff --git a/src/data/grl-related-keys.h b/src/data/grl-related-keys.h
index da53327..2c94337 100644
--- a/src/data/grl-related-keys.h
+++ b/src/data/grl-related-keys.h
@@ -113,6 +113,10 @@ void grl_related_keys_set_float (GrlRelatedKeys *relkeys,
GrlKeyID key,
gfloat floatvalue);
+void grl_related_keys_set_boolean (GrlRelatedKeys *relkeys,
+ GrlKeyID key,
+ gboolean boolvalue);
+
void grl_related_keys_set_binary(GrlRelatedKeys *relkeys,
GrlKeyID key,
const guint8 *buf,
@@ -134,6 +138,9 @@ gint grl_related_keys_get_int (GrlRelatedKeys *relkeys,
gfloat grl_related_keys_get_float (GrlRelatedKeys *relkeys,
GrlKeyID key);
+gboolean grl_related_keys_get_boolean (GrlRelatedKeys *relkeys,
+ GrlKeyID key);
+
const guint8 *grl_related_keys_get_binary(GrlRelatedKeys *relkeys,
GrlKeyID key,
gsize *size);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]