From 0dcc1111706713c2ca78cfe54cdff5a6b2cfd310 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Wed, 17 Dec 2014 12:30:36 +0100 Subject: [PATCH] Re-added Confi::set_root. --- src/libconfi.c | 27 +++++++++++++++++++++++++++ src/libconfi.h | 1 + tests/test.c | 7 ++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/libconfi.c b/src/libconfi.c index 19812bb..db5825c 100644 --- a/src/libconfi.c +++ b/src/libconfi.c @@ -264,6 +264,33 @@ gchar return strret; } +/** + * confi_set_root: + * @confi: a #Confi object. + * @root: the root. + * + */ +gboolean +confi_set_root (Confi *confi, const gchar *root) +{ + gboolean ret; + + ConfiPrivate *priv = CONFI_GET_PRIVATE (confi); + + if (priv->pluggable == NULL) + { + g_warning ("Not initialized."); + ret = FALSE; + } + else + { + g_object_set (priv->pluggable, "root", root, NULL); + ret = TRUE; + } + + return ret; +} + /** * confi_add_key: * @confi: a #Confi object. diff --git a/src/libconfi.h b/src/libconfi.h index d5798b5..beb8215 100644 --- a/src/libconfi.h +++ b/src/libconfi.h @@ -59,6 +59,7 @@ GList *confi_get_configs_list (const gchar *cnc_string, GNode *confi_get_tree (Confi *confi); gchar *confi_normalize_root (const gchar *root); +gboolean confi_set_root (Confi *confi, const gchar *root); ConfiKey *confi_add_key (Confi *confi, const gchar *parent, diff --git a/tests/test.c b/tests/test.c index 022e95d..bdcb560 100644 --- a/tests/test.c +++ b/tests/test.c @@ -94,9 +94,10 @@ main (int argc, char **argv) g_printf ("Value: %s\n", ck->value); g_printf ("\n"); - /*g_printf ("Setting root \"key2\"\n"); - confi_set_root (confi, "key2"); - g_printf ("Value from key \"key2-1\" %s\n", confi_path_get_value (confi, "key2-1"));*/ + g_printf ("Setting root \"folder/key2\"\n"); + confi_set_root (confi, "folder/key2"); + g_printf ("Value from key \"key2-1\" %s\n", confi_path_get_value (confi, "key2-1")); + g_printf ("Value from key \"folder/key1/key1_2\" (expected null) %s\n", confi_path_get_value (confi, "folder/key1/key1_2")); confi_destroy (confi); -- 2.49.0