[grilo] core: Add API to use booleans in GrlConfig
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] core: Add API to use booleans in GrlConfig
- Date: Thu, 13 Jan 2011 18:56:41 +0000 (UTC)
commit 31ac43b0d830c2bfe62c8209592ef59371993619
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Thu Jan 13 18:55:37 2011 +0000
core: Add API to use booleans in GrlConfig
Add grl_config_get/set_boolean() functions.
Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
src/data/grl-config.c | 20 ++++++++++++++++++++
src/data/grl-config.h | 4 ++++
2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/data/grl-config.c b/src/data/grl-config.c
index e9c0f36..3bfbafe 100644
--- a/src/data/grl-config.c
+++ b/src/data/grl-config.c
@@ -161,6 +161,14 @@ grl_config_set_float (GrlConfig *config, const gchar *param, gfloat value)
grl_config_set (config, param, &v);
}
+void
+grl_config_set_boolean (GrlConfig *config, const gchar *param, gboolean value)
+{
+ GValue v = { 0 };
+ g_value_init (&v, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&v, value);
+ grl_config_set (config, param, &v);
+}
const GValue *
grl_config_get (GrlConfig *config, const gchar *param)
@@ -205,6 +213,18 @@ grl_config_get_float (GrlConfig *config, const gchar *param)
}
}
+gboolean
+grl_config_get_boolean (GrlConfig *config, const gchar *param)
+{
+ g_return_val_if_fail (GRL_IS_CONFIG (config), FALSE);
+ const GValue *value = grl_config_get (config, param);
+ if (!value || !G_VALUE_HOLDS_BOOLEAN (value)) {
+ return FALSE;
+ } else {
+ return g_value_get_boolean (value);
+ }
+}
+
/**
* grl_config_set_plugin:
* @config: the config instance
diff --git a/src/data/grl-config.h b/src/data/grl-config.h
index f164ff8..86d68ce 100644
--- a/src/data/grl-config.h
+++ b/src/data/grl-config.h
@@ -120,6 +120,8 @@ void grl_config_set_int (GrlConfig *config, const gchar *param, gint value);
void grl_config_set_float (GrlConfig *config, const gchar *param, gfloat value);
+void grl_config_set_boolean (GrlConfig *config, const gchar *param, gboolean value);
+
const GValue *grl_config_get (GrlConfig *config, const gchar *param);
const gchar *grl_config_get_string (GrlConfig *config, const gchar *param);
@@ -128,6 +130,8 @@ gint grl_config_get_int (GrlConfig *config, const gchar *param);
gfloat grl_config_get_float (GrlConfig *config, const gchar *param);
+gboolean grl_config_get_boolean (GrlConfig *config, const gchar *param);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]