aboutsummaryrefslogtreecommitdiff
path: root/liblogdiag
diff options
context:
space:
mode:
Diffstat (limited to 'liblogdiag')
-rw-r--r--liblogdiag/ld-category-symbol-view.c11
-rw-r--r--liblogdiag/ld-category.c32
-rw-r--r--liblogdiag/ld-category.h1
3 files changed, 44 insertions, 0 deletions
diff --git a/liblogdiag/ld-category-symbol-view.c b/liblogdiag/ld-category-symbol-view.c
index 85f7c1e..36c0d0f 100644
--- a/liblogdiag/ld-category-symbol-view.c
+++ b/liblogdiag/ld-category-symbol-view.c
@@ -28,6 +28,7 @@
struct _LdCategorySymbolViewPrivate
{
LdCategory *category;
+ gchar *path;
guint height_negotiation : 1;
};
@@ -106,6 +107,7 @@ ld_category_symbol_view_finalize (GObject *gobject)
if (self->priv->category)
g_object_unref (self->priv->category);
+ g_free (self->priv->path);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_category_symbol_view_parent_class)->finalize (gobject);
@@ -234,8 +236,17 @@ ld_category_symbol_view_set_category (LdCategorySymbolView *self,
g_return_if_fail (LD_IS_CATEGORY (category));
if (self->priv->category)
+ {
g_object_unref (self->priv->category);
+ g_free (self->priv->path);
+ self->priv->path = NULL;
+ }
+
+ /* XXX: We should rebuild the path if the name changes but it shouldn't
+ * happen and we would have to track the parents, too. */
+ self->priv->path = ld_category_get_path (category);
+
self->priv->category = category;
g_object_ref (category);
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)
diff --git a/liblogdiag/ld-category.h b/liblogdiag/ld-category.h
index 59d6449..77afff2 100644
--- a/liblogdiag/ld-category.h
+++ b/liblogdiag/ld-category.h
@@ -67,6 +67,7 @@ const GSList *ld_category_get_symbols (LdCategory *self);
void ld_category_set_parent (LdCategory *self, LdCategory *parent);
LdCategory *ld_category_get_parent (LdCategory *self);
+gchar *ld_category_get_path (LdCategory *self);
gboolean ld_category_add_child (LdCategory *self, LdCategory *category);
void ld_category_remove_child (LdCategory *self, LdCategory *category);