From cf85c05fb6acaf71ebed6be764c5cd7c636dacbd Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 18 Dec 2014 13:22:51 +0100 Subject: [PATCH] Added Confi::get_plugin_info. --- src/libconfi.c | 21 ++++++++++++++++++++- src/libconfi.h | 4 ++++ tests/test.c | 13 +++++++++---- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/libconfi.c b/src/libconfi.c index e7acf44..0852f65 100644 --- a/src/libconfi.c +++ b/src/libconfi.c @@ -23,7 +23,6 @@ #include #include -#include #include "libconfi.h" @@ -173,6 +172,26 @@ Confi return confi; } +PeasPluginInfo +*confi_get_plugin_info (Confi *confi) +{ + PeasPluginInfo *ppinfo; + + ConfiPrivate *priv = CONFI_GET_PRIVATE (confi); + + if (priv->pluggable == NULL) + { + g_warning ("Not initialized."); + ppinfo = NULL; + } + else + { + ppinfo = peas_extension_base_get_plugin_info ((PeasExtensionBase *)priv->pluggable); + } + + return ppinfo; +} + /** * confi_get_configs_list: * @cnc_string: the connection string to use to connect to database that diff --git a/src/libconfi.h b/src/libconfi.h index beb8215..4d43f97 100644 --- a/src/libconfi.h +++ b/src/libconfi.h @@ -21,6 +21,8 @@ #include +#include + #include "commons.h" #include "confipluggable.h" @@ -53,6 +55,8 @@ GType confi_get_type (void); Confi *confi_new (const gchar *cnc_string); +PeasPluginInfo *confi_get_plugin_info (Confi *confi); + GList *confi_get_configs_list (const gchar *cnc_string, const gchar *filter); diff --git a/tests/test.c b/tests/test.c index bdcb560..06c9258 100644 --- a/tests/test.c +++ b/tests/test.c @@ -24,10 +24,7 @@ traverse_func (GNode *node, gpointer data) { ConfiKey *ck = (ConfiKey *)node->data; - if (ck->id != 0) - { - g_printf ("%s%s%s\n", ck->path, strcmp (ck->path, "") == 0 ? "" : "/", ck->key); - } + g_printf ("%s%s%s => %s\n", ck->path, g_strcmp0 (ck->path, "") == 0 ? "" : "/", ck->key, ck->value); return FALSE; } @@ -37,6 +34,7 @@ main (int argc, char **argv) { PeasEngine *engine; Confi *confi; + PeasPluginInfo *ppinfo; GList *confis; GNode *tree; @@ -71,6 +69,13 @@ main (int argc, char **argv) return 0; } + ppinfo = confi_get_plugin_info (confi); + g_printf ("Plugin info\n"); + g_printf ("Name: %s\n", peas_plugin_info_get_name (ppinfo)); + g_printf ("Module dir: %s\n", peas_plugin_info_get_module_dir (ppinfo)); + g_printf ("Module name: %s\n", peas_plugin_info_get_module_name (ppinfo)); + g_printf ("\n"); + gchar *val = confi_path_get_value (confi, "folder/key1/key1_2"); g_printf ("Value from key \"folder/key1/key1_2\"\n%s\n\n", val); confi_path_set_value (confi, "folder/key1/key1_2", "new value programmatically setted"); -- 2.49.0