diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2012-09-09 16:39:36 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2012-10-08 07:29:58 +0200 |
commit | 09d6bda3db6ba986dad3dd4150e502ef664d6812 (patch) | |
tree | 9483fd1f5b1f68ade1902adfdb3afac68ef0e98c /liblogdiag/ld-category.c | |
parent | 15d8c257d11a2c16094e644d9d609614b39b8b09 (diff) | |
download | logdiag-09d6bda3db6ba986dad3dd4150e502ef664d6812.tar.gz logdiag-09d6bda3db6ba986dad3dd4150e502ef664d6812.tar.xz logdiag-09d6bda3db6ba986dad3dd4150e502ef664d6812.zip |
Add ld_category_get_path() and use it.
Diffstat (limited to 'liblogdiag/ld-category.c')
-rw-r--r-- | liblogdiag/ld-category.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/liblogdiag/ld-category.c b/liblogdiag/ld-category.c index b15b6de..369de65 100644 --- a/liblogdiag/ld-category.c +++ b/liblogdiag/ld-category.c @@ -428,6 +428,38 @@ ld_category_get_parent (LdCategory *self) return self->priv->parent; } +/** + * ld_category_get_path: + * @self: an #LdCategory object. + * + * Return value: the path to this category within the library. + */ +gchar * +ld_category_get_path (LdCategory *self) +{ + LdCategory *iter; + gchar *path = NULL, *new_path; + + g_return_val_if_fail (LD_IS_CATEGORY (self), NULL); + + for (iter = self; iter; iter = ld_category_get_parent (iter)) + { + const gchar *name; + + /* Stop at the root category. */ + name = ld_category_get_name (iter); + if (!strcmp (name, LD_LIBRARY_IDENTIFIER_SEPARATOR)) + break; + + new_path = g_build_path + (LD_LIBRARY_IDENTIFIER_SEPARATOR, name, path, NULL); + g_free (path); + path = new_path; + } + + return path; +} + static void on_category_notify_name (LdCategory *category, GParamSpec *pspec, gpointer user_data) |