From 9569d96cd6befed8a07d7bb7075b5ff00049a023 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Wed, 29 Aug 2012 18:44:47 +0200
Subject: Rename LdSymbolCategory to LdCategory.
---
CMakeLists.txt | 4 +-
liblogdiag/ld-category.c | 419 +++++++++++++++++++++++++++++++++++++++
liblogdiag/ld-category.h | 77 ++++++++
liblogdiag/ld-library-pane.c | 8 +-
liblogdiag/ld-library.c | 38 ++--
liblogdiag/ld-library.h | 2 +-
liblogdiag/ld-symbol-category.c | 424 ----------------------------------------
liblogdiag/ld-symbol-category.h | 82 --------
liblogdiag/liblogdiag.h | 2 +-
9 files changed, 523 insertions(+), 533 deletions(-)
create mode 100644 liblogdiag/ld-category.c
create mode 100644 liblogdiag/ld-category.h
delete mode 100644 liblogdiag/ld-symbol-category.c
delete mode 100644 liblogdiag/ld-symbol-category.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 282e49c..d59edba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,7 +125,7 @@ set (liblogdiag_SOURCES
liblogdiag/ld-diagram-view.c
liblogdiag/ld-library.c
liblogdiag/ld-library-pane.c
- liblogdiag/ld-symbol-category.c
+ liblogdiag/ld-category.c
liblogdiag/ld-symbol.c
liblogdiag/ld-lua.c
liblogdiag/ld-lua-symbol.c)
@@ -142,7 +142,7 @@ set (liblogdiag_HEADERS
liblogdiag/ld-diagram-view.h
liblogdiag/ld-library.h
liblogdiag/ld-library-pane.h
- liblogdiag/ld-symbol-category.h
+ liblogdiag/ld-category.h
liblogdiag/ld-symbol.h
liblogdiag/ld-lua.h
liblogdiag/ld-lua-private.h
diff --git a/liblogdiag/ld-category.c b/liblogdiag/ld-category.c
new file mode 100644
index 0000000..d0b2245
--- /dev/null
+++ b/liblogdiag/ld-category.c
@@ -0,0 +1,419 @@
+/*
+ * ld-category.c
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#include "liblogdiag.h"
+#include "config.h"
+
+
+/**
+ * SECTION:ld-category
+ * @short_description: A category of symbols
+ * @see_also: #LdSymbol, #LdLibrary
+ *
+ * #LdCategory represents a category of #LdSymbol objects.
+ */
+
+/*
+ * LdCategoryPrivate:
+ * @name: the name of this category.
+ * @human_name: the localized human-readable name of this category.
+ * @symbols: (element-type LdSymbol *): symbols in this category.
+ * @subcategories: (element-type LdCategory *) children of this category.
+ */
+struct _LdCategoryPrivate
+{
+ gchar *name;
+ gchar *human_name;
+ GSList *symbols;
+ GSList *subcategories;
+};
+
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_HUMAN_NAME
+};
+
+static void ld_category_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec);
+static void ld_category_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec);
+static void ld_category_finalize (GObject *gobject);
+
+static void on_category_notify_name (LdCategory *category,
+ GParamSpec *pspec, gpointer user_data);
+
+
+G_DEFINE_TYPE (LdCategory, ld_category, G_TYPE_OBJECT);
+
+static void
+ld_category_class_init (LdCategoryClass *klass)
+{
+ GObjectClass *object_class;
+ GParamSpec *pspec;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = ld_category_get_property;
+ object_class->set_property = ld_category_set_property;
+ object_class->finalize = ld_category_finalize;
+
+/**
+ * LdCategory:name:
+ *
+ * The name of this symbol category.
+ */
+ pspec = g_param_spec_string ("name", "Name",
+ "The name of this symbol category.",
+ "", G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_NAME, pspec);
+
+/**
+ * LdCategory:human-name:
+ *
+ * The localized human name of this symbol category.
+ */
+ pspec = g_param_spec_string ("human-name", "Human name",
+ "The localized human name of this symbol category.",
+ "", G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_HUMAN_NAME, pspec);
+
+ g_type_class_add_private (klass, sizeof (LdCategoryPrivate));
+}
+
+static void
+ld_category_init (LdCategory *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE
+ (self, LD_TYPE_CATEGORY, LdCategoryPrivate);
+}
+
+static void
+ld_category_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec)
+{
+ LdCategory *self;
+
+ self = LD_CATEGORY (object);
+ switch (property_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, ld_category_get_name (self));
+ break;
+ case PROP_HUMAN_NAME:
+ g_value_set_string (value, ld_category_get_human_name (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+ld_category_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ LdCategory *self;
+
+ self = LD_CATEGORY (object);
+ switch (property_id)
+ {
+ case PROP_NAME:
+ ld_category_set_name (self, g_value_get_string (value));
+ break;
+ case PROP_HUMAN_NAME:
+ ld_category_set_human_name (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+uninstall_category_cb (LdCategory *category, LdCategory *self)
+{
+ g_signal_handlers_disconnect_by_func (category,
+ on_category_notify_name, self);
+ g_object_unref (category);
+}
+
+static void
+ld_category_finalize (GObject *gobject)
+{
+ LdCategory *self;
+
+ self = LD_CATEGORY (gobject);
+
+ if (self->priv->name)
+ g_free (self->priv->name);
+ if (self->priv->human_name)
+ g_free (self->priv->human_name);
+
+ g_slist_foreach (self->priv->symbols, (GFunc) g_object_unref, NULL);
+ g_slist_free (self->priv->symbols);
+
+ g_slist_foreach (self->priv->subcategories,
+ (GFunc) uninstall_category_cb, self);
+ g_slist_free (self->priv->subcategories);
+
+ /* Chain up to the parent class. */
+ G_OBJECT_CLASS (ld_category_parent_class)->finalize (gobject);
+}
+
+
+/**
+ * ld_category_new:
+ * @name: the name of the new category.
+ * @human_name: the localized human name of the new category.
+ *
+ * Create an instance.
+ */
+LdCategory *
+ld_category_new (const gchar *name, const gchar *human_name)
+{
+ LdCategory *cat;
+
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (human_name != NULL, NULL);
+
+ cat = g_object_new (LD_TYPE_CATEGORY, NULL);
+ cat->priv->name = g_strdup (name);
+ cat->priv->human_name = g_strdup (human_name);
+
+ return cat;
+}
+
+/**
+ * ld_category_set_name:
+ * @self: an #LdCategory object.
+ * @name: the new name for this category.
+ */
+void
+ld_category_set_name (LdCategory *self, const gchar *name)
+{
+ g_return_if_fail (LD_IS_CATEGORY (self));
+ g_return_if_fail (name != NULL);
+
+ if (self->priv->name)
+ g_free (self->priv->name);
+ self->priv->name = g_strdup (name);
+
+ g_object_notify (G_OBJECT (self), "name");
+}
+
+/**
+ * ld_category_get_name:
+ * @self: an #LdCategory object.
+ *
+ * Return the name of this category.
+ */
+const gchar *
+ld_category_get_name (LdCategory *self)
+{
+ g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
+ return self->priv->name;
+}
+
+/**
+ * ld_category_set_human_name:
+ * @self: an #LdCategory object.
+ * @human_name: the new localized human name for this category.
+ */
+void
+ld_category_set_human_name (LdCategory *self, const gchar *human_name)
+{
+ g_return_if_fail (LD_IS_CATEGORY (self));
+ g_return_if_fail (human_name != NULL);
+
+ if (self->priv->human_name)
+ g_free (self->priv->human_name);
+ self->priv->human_name = g_strdup (human_name);
+
+ g_object_notify (G_OBJECT (self), "human-name");
+}
+
+/**
+ * ld_category_get_human_name:
+ * @self: an #LdCategory object.
+ *
+ * Return the localized human name of this category.
+ */
+const gchar *
+ld_category_get_human_name (LdCategory *self)
+{
+ g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
+ return self->priv->human_name;
+}
+
+/**
+ * ld_category_insert_symbol:
+ * @self: an #LdCategory object.
+ * @symbol: the symbol to be inserted.
+ * @pos: the position at which the symbol will be inserted.
+ * Negative values will append to the end of list.
+ *
+ * Insert a symbol into the category.
+ *
+ * Return value: %TRUE if successful (no name collisions).
+ */
+gboolean
+ld_category_insert_symbol (LdCategory *self, LdSymbol *symbol, gint pos)
+{
+ const gchar *name;
+ const GSList *iter;
+
+ g_return_val_if_fail (LD_IS_CATEGORY (self), FALSE);
+ g_return_val_if_fail (LD_IS_SYMBOL (symbol), FALSE);
+
+ /* Check for name collisions. */
+ name = ld_symbol_get_name (symbol);
+ for (iter = self->priv->symbols; iter; iter = iter->next)
+ {
+ if (!strcmp (name, ld_symbol_get_name (iter->data)))
+ {
+ g_warning ("attempted to insert multiple `%s' symbols into"
+ " category `%s'", name, ld_category_get_name (self));
+ return FALSE;
+ }
+ }
+
+ self->priv->symbols = g_slist_insert (self->priv->symbols, symbol, pos);
+ g_object_ref (symbol);
+ return TRUE;
+}
+
+/**
+ * ld_category_remove_symbol:
+ * @self: an #LdCategory object.
+ * @symbol: the symbol to be removed.
+ *
+ * Removes a symbol from the category.
+ */
+void
+ld_category_remove_symbol (LdCategory *self, LdSymbol *symbol)
+{
+ g_return_if_fail (LD_IS_CATEGORY (self));
+ g_return_if_fail (LD_IS_SYMBOL (symbol));
+
+ if (g_slist_find (self->priv->symbols, symbol))
+ {
+ self->priv->symbols = g_slist_remove (self->priv->symbols, symbol);
+ g_object_unref (symbol);
+ }
+}
+
+/**
+ * ld_category_get_symbols:
+ * @self: an #LdCategory object.
+ *
+ * Return value: (element-type LdSymbol *): a list of symbols. Do not modify.
+ */
+const GSList *
+ld_category_get_symbols (LdCategory *self)
+{
+ g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
+ return self->priv->symbols;
+}
+
+
+static void
+on_category_notify_name (LdCategory *category,
+ GParamSpec *pspec, gpointer user_data)
+{
+ LdCategory *self;
+
+ self = (LdCategory *) user_data;
+ g_warning ("name of a library subcategory has changed");
+
+ /* The easy way of handling it. */
+ g_object_ref (category);
+ ld_category_remove_child (self, category);
+ ld_category_add_child (self, category);
+ g_object_unref (category);
+}
+
+/**
+ * ld_category_add_child:
+ * @self: an #LdCategory object.
+ * @category: the category to be inserted.
+ *
+ * Insert a subcategory into the category.
+ *
+ * Return value: %TRUE if successful (no name collisions).
+ */
+gboolean
+ld_category_add_child (LdCategory *self, LdCategory *category)
+{
+ const gchar *name;
+ GSList *iter;
+
+ g_return_val_if_fail (LD_IS_CATEGORY (self), FALSE);
+ g_return_val_if_fail (LD_IS_CATEGORY (category), FALSE);
+
+ name = ld_category_get_name (category);
+ for (iter = self->priv->subcategories; iter; iter = iter->next)
+ {
+ gint comp;
+
+ comp = g_utf8_collate (name, ld_category_get_name (iter->data));
+ if (!comp)
+ {
+ g_warning ("attempted to insert multiple `%s' subcategories into"
+ " category `%s'", name, ld_category_get_name (self));
+ return FALSE;
+ }
+ if (comp < 0)
+ break;
+ }
+
+ g_signal_connect (category, "notify::name",
+ G_CALLBACK (on_category_notify_name), self);
+ self->priv->subcategories = g_slist_insert_before
+ (self->priv->subcategories, iter, category);
+ g_object_ref (category);
+ return TRUE;
+}
+
+/**
+ * ld_category_remove_child:
+ * @self: an #LdCategory object.
+ * @category: the category to be removed.
+ *
+ * Removes a subcategory from the category.
+ */
+void
+ld_category_remove_child (LdCategory *self, LdCategory *category)
+{
+ g_return_if_fail (LD_IS_CATEGORY (self));
+ g_return_if_fail (LD_IS_CATEGORY (category));
+
+ if (g_slist_find (self->priv->subcategories, category))
+ {
+ g_signal_handlers_disconnect_by_func (category,
+ on_category_notify_name, self);
+ self->priv->subcategories
+ = g_slist_remove (self->priv->subcategories, category);
+ g_object_unref (category);
+ }
+}
+
+/**
+ * ld_category_get_children:
+ * @self: an #LdCategory object.
+ *
+ * Return value: (element-type LdCategory *):
+ * a list of subcategories. Do not modify.
+ */
+const GSList *
+ld_category_get_children (LdCategory *self)
+{
+ g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
+ return self->priv->subcategories;
+}
+
diff --git a/liblogdiag/ld-category.h b/liblogdiag/ld-category.h
new file mode 100644
index 0000000..5bbb00f
--- /dev/null
+++ b/liblogdiag/ld-category.h
@@ -0,0 +1,77 @@
+/*
+ * ld-category.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __LD_CATEGORY_H__
+#define __LD_CATEGORY_H__
+
+G_BEGIN_DECLS
+
+
+#define LD_TYPE_CATEGORY (ld_category_get_type ())
+#define LD_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LD_TYPE_CATEGORY, LdCategory))
+#define LD_CATEGORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LD_TYPE_CATEGORY, LdCategoryClass))
+#define LD_IS_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LD_TYPE_CATEGORY))
+#define LD_IS_CATEGORY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LD_TYPE_CATEGORY))
+#define LD_CATEGORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LD_CATEGORY, LdCategoryClass))
+
+typedef struct _LdCategory LdCategory;
+typedef struct _LdCategoryPrivate LdCategoryPrivate;
+typedef struct _LdCategoryClass LdCategoryClass;
+
+
+/**
+ * LdCategory:
+ */
+struct _LdCategory
+{
+/*< private >*/
+ GObject parent_instance;
+ LdCategoryPrivate *priv;
+};
+
+/* TODO: If required sometime, categories (and maybe symbols) should implement
+ * a "changed" signal. This can be somewhat tricky. The library might be
+ * a good candidate for what they call a proxy. See GtkUIManager.
+ */
+struct _LdCategoryClass
+{
+/*< private >*/
+ GObjectClass parent_class;
+};
+
+
+GType ld_category_get_type (void) G_GNUC_CONST;
+
+LdCategory *ld_category_new (const gchar *name, const gchar *human_name);
+
+void ld_category_set_name (LdCategory *self, const gchar *name);
+const gchar *ld_category_get_name (LdCategory *self);
+void ld_category_set_human_name (LdCategory *self, const gchar *human_name);
+const gchar *ld_category_get_human_name (LdCategory *self);
+
+gboolean ld_category_insert_symbol (LdCategory *self,
+ LdSymbol *symbol, gint pos);
+void ld_category_remove_symbol (LdCategory *self, LdSymbol *symbol);
+const GSList *ld_category_get_symbols (LdCategory *self);
+
+gboolean ld_category_add_child (LdCategory *self, LdCategory *category);
+void ld_category_remove_child (LdCategory *self, LdCategory *category);
+const GSList *ld_category_get_children (LdCategory *self);
+
+
+G_END_DECLS
+
+#endif /* ! __LD_CATEGORY_H__ */
+
diff --git a/liblogdiag/ld-library-pane.c b/liblogdiag/ld-library-pane.c
index 5fe85c1..484b2be 100644
--- a/liblogdiag/ld-library-pane.c
+++ b/liblogdiag/ld-library-pane.c
@@ -199,7 +199,7 @@ reload_library (LdLibraryPane *self)
{
GSList *categories;
- categories = (GSList *) ld_symbol_category_get_children
+ categories = (GSList *) ld_category_get_children
(ld_library_get_root (self->priv->library));
g_slist_foreach (categories, load_category_cb, self);
}
@@ -209,18 +209,18 @@ static void
load_category_cb (gpointer data, gpointer user_data)
{
LdLibraryPane *self;
- LdSymbolCategory *cat;
+ LdCategory *cat;
GtkExpander *expander;
const gchar *human_name;
g_return_if_fail (LD_IS_LIBRARY_PANE (user_data));
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (data));
+ g_return_if_fail (LD_IS_CATEGORY (data));
self = user_data;
cat = data;
/* TODO: Set a child for the expander, recurse into category children. */
- human_name = ld_symbol_category_get_human_name (cat);
+ human_name = ld_category_get_human_name (cat);
expander = GTK_EXPANDER (gtk_expander_new (human_name));
gtk_box_pack_start (GTK_BOX (self), GTK_WIDGET (expander), FALSE, FALSE, 0);
diff --git a/liblogdiag/ld-library.c b/liblogdiag/ld-library.c
index 31f3855..2b4c704 100644
--- a/liblogdiag/ld-library.c
+++ b/liblogdiag/ld-library.c
@@ -17,7 +17,7 @@
/**
* SECTION:ld-library
* @short_description: A symbol library
- * @see_also: #LdSymbol, #LdSymbolCategory
+ * @see_also: #LdSymbol, #LdCategory
*
* #LdLibrary is used for loading symbols from their files. The library object
* itself is a container for categories, which in turn contain other
@@ -32,12 +32,12 @@
struct _LdLibraryPrivate
{
LdLua *lua;
- LdSymbolCategory *root;
+ LdCategory *root;
};
static void ld_library_finalize (GObject *gobject);
-static LdSymbolCategory *load_category (LdLibrary *self,
+static LdCategory *load_category (LdLibrary *self,
const gchar *path, const gchar *name);
static gboolean load_category_cb (const gchar *base,
const gchar *path, gpointer userdata);
@@ -81,7 +81,7 @@ ld_library_init (LdLibrary *self)
(self, LD_TYPE_LIBRARY, LdLibraryPrivate);
self->priv->lua = ld_lua_new ();
- self->priv->root = ld_symbol_category_new ("/", "/");
+ self->priv->root = ld_category_new ("/", "/");
}
static void
@@ -150,7 +150,7 @@ foreach_dir (const gchar *path,
typedef struct
{
LdLibrary *self;
- LdSymbolCategory *cat;
+ LdCategory *cat;
guint changed : 1;
guint load_symbols : 1;
}
@@ -164,7 +164,7 @@ LoadCategoryData;
*
* Loads a category into the library.
*/
-static LdSymbolCategory *
+static LdCategory *
load_category (LdLibrary *self, const gchar *path, const gchar *name)
{
gchar *category_file, *human_name;
@@ -183,7 +183,7 @@ load_category (LdLibrary *self, const gchar *path, const gchar *name)
human_name = g_strdup (name);
data.self = self;
- data.cat = ld_symbol_category_new (name, human_name);
+ data.cat = ld_category_new (name, human_name);
data.load_symbols = TRUE;
data.changed = FALSE;
foreach_dir (path, load_category_cb, &data, NULL);
@@ -211,12 +211,12 @@ load_category_cb (const gchar *base, const gchar *path, gpointer userdata)
if (g_file_test (path, G_FILE_TEST_IS_DIR))
{
- LdSymbolCategory *cat;
+ LdCategory *cat;
cat = load_category (data->self, path, base);
if (cat)
{
- ld_symbol_category_add_child (data->cat, cat);
+ ld_category_add_child (data->cat, cat);
g_object_unref (cat);
}
}
@@ -239,13 +239,13 @@ load_category_cb (const gchar *base, const gchar *path, gpointer userdata)
static void
load_category_symbol_cb (LdSymbol *symbol, gpointer user_data)
{
- LdSymbolCategory *cat;
+ LdCategory *cat;
g_return_if_fail (LD_IS_SYMBOL (symbol));
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (user_data));
+ g_return_if_fail (LD_IS_CATEGORY (user_data));
- cat = LD_SYMBOL_CATEGORY (user_data);
- ld_symbol_category_insert_symbol (cat, symbol, -1);
+ cat = LD_CATEGORY (user_data);
+ ld_category_insert_symbol (cat, symbol, -1);
}
/*
@@ -348,7 +348,7 @@ ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
{
gchar **id_el_start, **id_el;
const GSList *list, *list_el;
- LdSymbolCategory *cat;
+ LdCategory *cat;
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
g_return_val_if_fail (identifier != NULL, NULL);
@@ -368,11 +368,11 @@ ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
{
gboolean found = FALSE;
- list = ld_symbol_category_get_children (cat);
+ list = ld_category_get_children (cat);
for (list_el = list; list_el; list_el = g_slist_next (list_el))
{
- cat = LD_SYMBOL_CATEGORY (list_el->data);
- if (!strcmp (*id_el, ld_symbol_category_get_name (cat)))
+ cat = LD_CATEGORY (list_el->data);
+ if (!strcmp (*id_el, ld_category_get_name (cat)))
{
found = TRUE;
break;
@@ -387,7 +387,7 @@ ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
}
/* And then the actual symbol. */
- list = ld_symbol_category_get_symbols (cat);
+ list = ld_category_get_symbols (cat);
for (list_el = list; list_el; list_el = g_slist_next (list_el))
{
LdSymbol *symbol;
@@ -411,7 +411,7 @@ ld_library_find_symbol_error:
*
* Return value: (transfer none): the root category. Do not modify.
*/
-LdSymbolCategory *
+LdCategory *
ld_library_get_root (LdLibrary *self)
{
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
diff --git a/liblogdiag/ld-library.h b/liblogdiag/ld-library.h
index 667d861..1a71973 100644
--- a/liblogdiag/ld-library.h
+++ b/liblogdiag/ld-library.h
@@ -60,7 +60,7 @@ GType ld_library_get_type (void) G_GNUC_CONST;
LdLibrary *ld_library_new (void);
gboolean ld_library_load (LdLibrary *self, const gchar *directory);
LdSymbol *ld_library_find_symbol (LdLibrary *self, const gchar *identifier);
-LdSymbolCategory *ld_library_get_root (LdLibrary *self);
+LdCategory *ld_library_get_root (LdLibrary *self);
G_END_DECLS
diff --git a/liblogdiag/ld-symbol-category.c b/liblogdiag/ld-symbol-category.c
deleted file mode 100644
index f5f5b75..0000000
--- a/liblogdiag/ld-symbol-category.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * ld-symbol-category.c
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#include "liblogdiag.h"
-#include "config.h"
-
-
-/**
- * SECTION:ld-symbol-category
- * @short_description: A category of symbols
- * @see_also: #LdSymbol, #LdLibrary
- *
- * #LdSymbolCategory represents a category of #LdSymbol objects.
- */
-
-/*
- * LdSymbolCategoryPrivate:
- * @name: the name of this category.
- * @human_name: the localized human-readable name of this category.
- * @symbols: (element-type LdSymbol *): symbols in this category.
- * @subcategories: (element-type LdSymbolCategory *) children of this category.
- */
-struct _LdSymbolCategoryPrivate
-{
- gchar *name;
- gchar *human_name;
- GSList *symbols;
- GSList *subcategories;
-};
-
-enum
-{
- PROP_0,
- PROP_NAME,
- PROP_HUMAN_NAME
-};
-
-static void ld_symbol_category_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec);
-static void ld_symbol_category_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec);
-static void ld_symbol_category_finalize (GObject *gobject);
-
-static void on_category_notify_name (LdSymbolCategory *category,
- GParamSpec *pspec, gpointer user_data);
-
-
-G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT);
-
-static void
-ld_symbol_category_class_init (LdSymbolCategoryClass *klass)
-{
- GObjectClass *object_class;
- GParamSpec *pspec;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = ld_symbol_category_get_property;
- object_class->set_property = ld_symbol_category_set_property;
- object_class->finalize = ld_symbol_category_finalize;
-
-/**
- * LdSymbolCategory:name:
- *
- * The name of this symbol category.
- */
- pspec = g_param_spec_string ("name", "Name",
- "The name of this symbol category.",
- "", G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_NAME, pspec);
-
-/**
- * LdSymbolCategory:human-name:
- *
- * The localized human name of this symbol category.
- */
- pspec = g_param_spec_string ("human-name", "Human name",
- "The localized human name of this symbol category.",
- "", G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_HUMAN_NAME, pspec);
-
- g_type_class_add_private (klass, sizeof (LdSymbolCategoryPrivate));
-}
-
-static void
-ld_symbol_category_init (LdSymbolCategory *self)
-{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE
- (self, LD_TYPE_SYMBOL_CATEGORY, LdSymbolCategoryPrivate);
-}
-
-static void
-ld_symbol_category_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- LdSymbolCategory *self;
-
- self = LD_SYMBOL_CATEGORY (object);
- switch (property_id)
- {
- case PROP_NAME:
- g_value_set_string (value, ld_symbol_category_get_name (self));
- break;
- case PROP_HUMAN_NAME:
- g_value_set_string (value, ld_symbol_category_get_human_name (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-ld_symbol_category_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- LdSymbolCategory *self;
-
- self = LD_SYMBOL_CATEGORY (object);
- switch (property_id)
- {
- case PROP_NAME:
- ld_symbol_category_set_name (self, g_value_get_string (value));
- break;
- case PROP_HUMAN_NAME:
- ld_symbol_category_set_human_name (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-uninstall_category_cb (LdSymbolCategory *category, LdSymbolCategory *self)
-{
- g_signal_handlers_disconnect_by_func (category,
- on_category_notify_name, self);
- g_object_unref (category);
-}
-
-static void
-ld_symbol_category_finalize (GObject *gobject)
-{
- LdSymbolCategory *self;
-
- self = LD_SYMBOL_CATEGORY (gobject);
-
- if (self->priv->name)
- g_free (self->priv->name);
- if (self->priv->human_name)
- g_free (self->priv->human_name);
-
- g_slist_foreach (self->priv->symbols, (GFunc) g_object_unref, NULL);
- g_slist_free (self->priv->symbols);
-
- g_slist_foreach (self->priv->subcategories,
- (GFunc) uninstall_category_cb, self);
- g_slist_free (self->priv->subcategories);
-
- /* Chain up to the parent class. */
- G_OBJECT_CLASS (ld_symbol_category_parent_class)->finalize (gobject);
-}
-
-
-/**
- * ld_symbol_category_new:
- * @name: the name of the new category.
- * @human_name: the localized human name of the new category.
- *
- * Create an instance.
- */
-LdSymbolCategory *
-ld_symbol_category_new (const gchar *name, const gchar *human_name)
-{
- LdSymbolCategory *cat;
-
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (human_name != NULL, NULL);
-
- cat = g_object_new (LD_TYPE_SYMBOL_CATEGORY, NULL);
- cat->priv->name = g_strdup (name);
- cat->priv->human_name = g_strdup (human_name);
-
- return cat;
-}
-
-/**
- * ld_symbol_category_set_name:
- * @self: an #LdSymbolCategory object.
- * @name: the new name for this category.
- */
-void
-ld_symbol_category_set_name (LdSymbolCategory *self, const gchar *name)
-{
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
- g_return_if_fail (name != NULL);
-
- if (self->priv->name)
- g_free (self->priv->name);
- self->priv->name = g_strdup (name);
-
- g_object_notify (G_OBJECT (self), "name");
-}
-
-/**
- * ld_symbol_category_get_name:
- * @self: an #LdSymbolCategory object.
- *
- * Return the name of this category.
- */
-const gchar *
-ld_symbol_category_get_name (LdSymbolCategory *self)
-{
- g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
- return self->priv->name;
-}
-
-/**
- * ld_symbol_category_set_human_name:
- * @self: an #LdSymbolCategory object.
- * @human_name: the new localized human name for this category.
- */
-void
-ld_symbol_category_set_human_name (LdSymbolCategory *self,
- const gchar *human_name)
-{
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
- g_return_if_fail (human_name != NULL);
-
- if (self->priv->human_name)
- g_free (self->priv->human_name);
- self->priv->human_name = g_strdup (human_name);
-
- g_object_notify (G_OBJECT (self), "human-name");
-}
-
-/**
- * ld_symbol_category_get_human_name:
- * @self: an #LdSymbolCategory object.
- *
- * Return the localized human name of this category.
- */
-const gchar *
-ld_symbol_category_get_human_name (LdSymbolCategory *self)
-{
- g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
- return self->priv->human_name;
-}
-
-/**
- * ld_symbol_category_insert_symbol:
- * @self: an #LdSymbolCategory object.
- * @symbol: the symbol to be inserted.
- * @pos: the position at which the symbol will be inserted.
- * Negative values will append to the end of list.
- *
- * Insert a symbol into the category.
- *
- * Return value: %TRUE if successful (no name collisions).
- */
-gboolean
-ld_symbol_category_insert_symbol (LdSymbolCategory *self,
- LdSymbol *symbol, gint pos)
-{
- const gchar *name;
- const GSList *iter;
-
- g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), FALSE);
- g_return_val_if_fail (LD_IS_SYMBOL (symbol), FALSE);
-
- /* Check for name collisions. */
- name = ld_symbol_get_name (symbol);
- for (iter = self->priv->symbols; iter; iter = iter->next)
- {
- if (!strcmp (name, ld_symbol_get_name (iter->data)))
- {
- g_warning ("attempted to insert multiple `%s' symbols into"
- " category `%s'", name, ld_symbol_category_get_name (self));
- return FALSE;
- }
- }
-
- self->priv->symbols = g_slist_insert (self->priv->symbols, symbol, pos);
- g_object_ref (symbol);
- return TRUE;
-}
-
-/**
- * ld_symbol_category_remove_symbol:
- * @self: an #LdSymbolCategory object.
- * @symbol: the symbol to be removed.
- *
- * Removes a symbol from the category.
- */
-void
-ld_symbol_category_remove_symbol (LdSymbolCategory *self,
- LdSymbol *symbol)
-{
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
- g_return_if_fail (LD_IS_SYMBOL (symbol));
-
- if (g_slist_find (self->priv->symbols, symbol))
- {
- self->priv->symbols = g_slist_remove (self->priv->symbols, symbol);
- g_object_unref (symbol);
- }
-}
-
-/**
- * ld_symbol_category_get_symbols:
- * @self: an #LdSymbolCategory object.
- *
- * Return value: (element-type LdSymbol *): a list of symbols. Do not modify.
- */
-const GSList *
-ld_symbol_category_get_symbols (LdSymbolCategory *self)
-{
- g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
- return self->priv->symbols;
-}
-
-
-static void
-on_category_notify_name (LdSymbolCategory *category,
- GParamSpec *pspec, gpointer user_data)
-{
- LdSymbolCategory *self;
-
- self = (LdSymbolCategory *) user_data;
- g_warning ("name of a library subcategory has changed");
-
- /* The easy way of handling it. */
- g_object_ref (category);
- ld_symbol_category_remove_child (self, category);
- ld_symbol_category_add_child (self, category);
- g_object_unref (category);
-}
-
-/**
- * ld_symbol_category_add_child:
- * @self: an #LdSymbolCategory object.
- * @category: the category to be inserted.
- *
- * Insert a subcategory into the category.
- *
- * Return value: %TRUE if successful (no name collisions).
- */
-gboolean
-ld_symbol_category_add_child (LdSymbolCategory *self,
- LdSymbolCategory *category)
-{
- const gchar *name;
- GSList *iter;
-
- g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), FALSE);
- g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (category), FALSE);
-
- name = ld_symbol_category_get_name (category);
- for (iter = self->priv->subcategories; iter; iter = iter->next)
- {
- gint comp;
-
- comp = g_utf8_collate (name, ld_symbol_category_get_name (iter->data));
- if (!comp)
- {
- g_warning ("attempted to insert multiple `%s' subcategories into"
- " category `%s'", name, ld_symbol_category_get_name (self));
- return FALSE;
- }
- if (comp < 0)
- break;
- }
-
- g_signal_connect (category, "notify::name",
- G_CALLBACK (on_category_notify_name), self);
- self->priv->subcategories = g_slist_insert_before
- (self->priv->subcategories, iter, category);
- g_object_ref (category);
- return TRUE;
-}
-
-/**
- * ld_symbol_category_remove_child:
- * @self: an #LdSymbolCategory object.
- * @category: the category to be removed.
- *
- * Removes a subcategory from the category.
- */
-void
-ld_symbol_category_remove_child (LdSymbolCategory *self,
- LdSymbolCategory *category)
-{
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (category));
-
- if (g_slist_find (self->priv->subcategories, category))
- {
- g_signal_handlers_disconnect_by_func (category,
- on_category_notify_name, self);
- self->priv->subcategories
- = g_slist_remove (self->priv->subcategories, category);
- g_object_unref (category);
- }
-}
-
-/**
- * ld_symbol_category_get_children:
- * @self: an #LdSymbolCategory object.
- *
- * Return value: (element-type LdSymbolCategory *):
- * a list of subcategories. Do not modify.
- */
-const GSList *
-ld_symbol_category_get_children (LdSymbolCategory *self)
-{
- g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
- return self->priv->subcategories;
-}
-
diff --git a/liblogdiag/ld-symbol-category.h b/liblogdiag/ld-symbol-category.h
deleted file mode 100644
index 1ac7f59..0000000
--- a/liblogdiag/ld-symbol-category.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * ld-symbol-category.h
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#ifndef __LD_SYMBOL_CATEGORY_H__
-#define __LD_SYMBOL_CATEGORY_H__
-
-G_BEGIN_DECLS
-
-
-#define LD_TYPE_SYMBOL_CATEGORY (ld_symbol_category_get_type ())
-#define LD_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), LD_TYPE_SYMBOL_CATEGORY, LdSymbolCategory))
-#define LD_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
- ((klass), LD_TYPE_SYMBOL_CATEGORY, LdSymbolCategoryClass))
-#define LD_IS_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), LD_TYPE_SYMBOL_CATEGORY))
-#define LD_IS_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((klass), LD_TYPE_SYMBOL_CATEGORY))
-#define LD_SYMBOL_CATEGORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), LD_SYMBOL_CATEGORY, LdSymbolCategoryClass))
-
-typedef struct _LdSymbolCategory LdSymbolCategory;
-typedef struct _LdSymbolCategoryPrivate LdSymbolCategoryPrivate;
-typedef struct _LdSymbolCategoryClass LdSymbolCategoryClass;
-
-
-/**
- * LdSymbolCategory:
- */
-struct _LdSymbolCategory
-{
-/*< private >*/
- GObject parent_instance;
- LdSymbolCategoryPrivate *priv;
-};
-
-/* TODO: If required sometime, categories (and maybe symbols) should implement
- * a "changed" signal. This can be somewhat tricky. The library might be
- * a good candidate for what they call a proxy. See GtkUIManager.
- */
-struct _LdSymbolCategoryClass
-{
-/*< private >*/
- GObjectClass parent_class;
-};
-
-
-GType ld_symbol_category_get_type (void) G_GNUC_CONST;
-
-LdSymbolCategory *ld_symbol_category_new (const gchar *name,
- const gchar *human_name);
-
-void ld_symbol_category_set_name (LdSymbolCategory *self, const gchar *name);
-const gchar *ld_symbol_category_get_name (LdSymbolCategory *self);
-void ld_symbol_category_set_human_name (LdSymbolCategory *self,
- const gchar *human_name);
-const gchar *ld_symbol_category_get_human_name (LdSymbolCategory *self);
-
-gboolean ld_symbol_category_insert_symbol (LdSymbolCategory *self,
- LdSymbol *symbol, gint pos);
-void ld_symbol_category_remove_symbol (LdSymbolCategory *self,
- LdSymbol *symbol);
-const GSList *ld_symbol_category_get_symbols (LdSymbolCategory *self);
-
-gboolean ld_symbol_category_add_child (LdSymbolCategory *self,
- LdSymbolCategory *category);
-void ld_symbol_category_remove_child (LdSymbolCategory *self,
- LdSymbolCategory *category);
-const GSList *ld_symbol_category_get_children (LdSymbolCategory *self);
-
-
-G_END_DECLS
-
-#endif /* ! __LD_SYMBOL_CATEGORY_H__ */
-
diff --git a/liblogdiag/liblogdiag.h b/liblogdiag/liblogdiag.h
index d5773ae..1ea87aa 100644
--- a/liblogdiag/liblogdiag.h
+++ b/liblogdiag/liblogdiag.h
@@ -18,7 +18,7 @@
#include "ld-types.h"
#include "ld-symbol.h"
-#include "ld-symbol-category.h"
+#include "ld-category.h"
#include "ld-library.h"
#include "ld-undo-action.h"
--
cgit v1.2.3-70-g09d2