aboutsummaryrefslogtreecommitdiff
path: root/src/ld-symbol-category.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2010-09-30 05:19:31 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2010-10-26 13:58:33 +0200
commite0e63649dc830cd63ae4e7a958e224ef3b2a1375 (patch)
treebfd6ebef764e0e439b2207d1f9d9ddb09985a0bd /src/ld-symbol-category.c
parent0c9b297e50ffaf9a34f50a99f7bc4e02ea295d1d (diff)
downloadlogdiag-e0e63649dc830cd63ae4e7a958e224ef3b2a1375.tar.gz
logdiag-e0e63649dc830cd63ae4e7a958e224ef3b2a1375.tar.xz
logdiag-e0e63649dc830cd63ae4e7a958e224ef3b2a1375.zip
Redesign the library and related components.
This step is needed, since the current design is quite chaotic and it would not be possible to finish the application. There's still a lot to be done. After this step, it's time to implement the rest of LdLua.
Diffstat (limited to 'src/ld-symbol-category.c')
-rw-r--r--src/ld-symbol-category.c101
1 files changed, 83 insertions, 18 deletions
diff --git a/src/ld-symbol-category.c b/src/ld-symbol-category.c
index 96e6bd1..15c1351 100644
--- a/src/ld-symbol-category.c
+++ b/src/ld-symbol-category.c
@@ -12,9 +12,9 @@
#include "config.h"
-#include "ld-library.h"
-#include "ld-symbol-category.h"
#include "ld-symbol.h"
+#include "ld-symbol-category.h"
+#include "ld-library.h"
/**
@@ -25,6 +25,19 @@
* #LdSymbolCategory represents a category of #LdSymbol objects.
*/
+/*
+ * LdSymbolCategoryPrivate:
+ * @name: The name of this category.
+ * @image_path: Path to the image for this category.
+ * @children: Children of this category.
+ */
+struct _LdSymbolCategoryPrivate
+{
+ gchar *name;
+ gchar *image_path;
+ GSList *children;
+};
+
G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT);
static void
@@ -38,16 +51,15 @@ ld_symbol_category_class_init (LdSymbolCategoryClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ld_symbol_category_finalize;
+
+ g_type_class_add_private (klass, sizeof (LdSymbolCategoryPrivate));
}
static void
ld_symbol_category_init (LdSymbolCategory *self)
{
- /* TODO: use _new_full, correct equal and specify destroy functions. */
- /* XXX: How's the situation with subcategory names and symbol names
- * within the same hashtable?
- */
- self->children = g_hash_table_new (g_str_hash, g_str_equal);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE
+ (self, LD_TYPE_SYMBOL_CATEGORY, LdSymbolCategoryPrivate);
}
static void
@@ -57,13 +69,10 @@ ld_symbol_category_finalize (GObject *gobject)
self = LD_SYMBOL_CATEGORY (gobject);
- if (self->name)
- g_free (self->name);
- if (self->image_path)
- g_free (self->image_path);
-
- g_object_unref (self->parent);
- g_hash_table_destroy (self->children);
+ if (self->priv->name)
+ g_free (self->priv->name);
+ if (self->priv->image_path)
+ g_free (self->priv->image_path);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_symbol_category_parent_class)->finalize (gobject);
@@ -76,15 +85,71 @@ ld_symbol_category_finalize (GObject *gobject)
* Create an instance.
*/
LdSymbolCategory *
-ld_symbol_category_new (LdLibrary *parent)
+ld_symbol_category_new (const gchar *name)
{
LdSymbolCategory *cat;
cat = g_object_new (LD_TYPE_SYMBOL_CATEGORY, NULL);
-
- cat->parent = parent;
- g_object_ref (parent);
+ cat->priv->name = g_strdup (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);
+}
+
+/**
+ * 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_image_path:
+ * @self: An #LdSymbolCategory object.
+ * @image_path: The new path to the image for this category. May be NULL.
+ */
+void
+ld_symbol_category_set_image_path (LdSymbolCategory *self,
+ const gchar *image_path)
+{
+ g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
+
+ if (self->priv->image_path)
+ g_free (self->priv->image_path);
+ self->priv->image_path = g_strdup (image_path);
+}
+
+/**
+ * ld_symbol_category_get_image_path:
+ * @self: An #LdSymbolCategory object.
+ *
+ * Return the filesystem path to the image for this category. May be NULL.
+ */
+const gchar *
+ld_symbol_category_get_image_path (LdSymbolCategory *self)
+{
+ g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
+ return self->priv->image_path;
+}
+