summaryrefslogtreecommitdiff
path: root/src/ld-symbol-category.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2010-10-24 12:43:16 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2010-10-26 16:40:08 +0200
commitba3b348dfde4949c7632777bd93d951396c41694 (patch)
treedb51e339a55e4aa374b5574011dfc7d1844d16d6 /src/ld-symbol-category.c
parentffc57249c889e656f6dbacd567fd6cc458a3356d (diff)
downloadlogdiag-ba3b348dfde4949c7632777bd93d951396c41694.tar.gz
logdiag-ba3b348dfde4949c7632777bd93d951396c41694.tar.xz
logdiag-ba3b348dfde4949c7632777bd93d951396c41694.zip
Implement the rest of LdSymbolCategory.
Added GObject properties for object parameters. Implemented methods for children management.
Diffstat (limited to 'src/ld-symbol-category.c')
-rw-r--r--src/ld-symbol-category.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/src/ld-symbol-category.c b/src/ld-symbol-category.c
index 15c1351..0eb0dac 100644
--- a/src/ld-symbol-category.c
+++ b/src/ld-symbol-category.c
@@ -40,6 +40,21 @@ struct _LdSymbolCategoryPrivate
G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT);
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_IMAGE_PATH
+};
+
+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);
@@ -48,10 +63,33 @@ 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:image-path:
+ *
+ * Path to an image file representing this category.
+ */
+ pspec = g_param_spec_string ("image-path", "Image path",
+ "Path to an image file representing this category.",
+ "", G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_IMAGE_PATH, pspec);
+
g_type_class_add_private (klass, sizeof (LdSymbolCategoryPrivate));
}
@@ -63,6 +101,46 @@ ld_symbol_category_init (LdSymbolCategory *self)
}
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_IMAGE_PATH:
+ g_value_set_string (value, ld_symbol_category_get_image_path (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_IMAGE_PATH:
+ ld_symbol_category_set_image_path (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
ld_symbol_category_finalize (GObject *gobject)
{
LdSymbolCategory *self;
@@ -74,6 +152,9 @@ ld_symbol_category_finalize (GObject *gobject)
if (self->priv->image_path)
g_free (self->priv->image_path);
+ g_slist_foreach (self->priv->children, (GFunc) g_object_unref, NULL);
+ g_slist_free (self->priv->children);
+
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_symbol_category_parent_class)->finalize (gobject);
}
@@ -153,3 +234,54 @@ ld_symbol_category_get_image_path (LdSymbolCategory *self)
return self->priv->image_path;
}
+/**
+ * ld_symbol_category_insert_child:
+ * @self: An #LdSymbolCategory object.
+ * @child: The child to be inserted.
+ * @pos: The position at which the child will be inserted.
+ * Negative values will append to the end of list.
+ *
+ * Insert a child into the category.
+ */
+void
+ld_symbol_category_insert_child (LdSymbolCategory *self,
+ GObject *child, gint pos)
+{
+ g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
+ g_return_if_fail (G_IS_OBJECT (child));
+
+ g_object_ref (child);
+ self->priv->children = g_slist_insert (self->priv->children, child, pos);
+}
+
+/**
+ * ld_symbol_category_remove_child:
+ * @self: An #LdSymbolCategory object.
+ * @child: The child to be removed.
+ *
+ * Removes a child from the category.
+ */
+void
+ld_symbol_category_remove_child (LdSymbolCategory *self,
+ GObject *child)
+{
+ g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
+ g_return_if_fail (G_IS_OBJECT (child));
+
+ g_object_unref (child);
+ self->priv->children = g_slist_remove (self->priv->children, child);
+}
+
+/**
+ * ld_symbol_category_get_children:
+ * @self: An #LdSymbolCategory object.
+ *
+ * Return value: The internal list of children. 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->children;
+}
+