aboutsummaryrefslogtreecommitdiff
path: root/liblogdiag/ld-diagram-symbol.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2011-01-15 15:31:01 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2011-01-15 17:59:07 +0100
commit1201caf8a41d106b07593c010cb91ecc0e08b3a0 (patch)
treef8ffb38da963a30a9e5031860c9759a6389036ce /liblogdiag/ld-diagram-symbol.c
parent9c5ade156a4266ce599d3163657d18a0f604e997 (diff)
downloadlogdiag-1201caf8a41d106b07593c010cb91ecc0e08b3a0.tar.gz
logdiag-1201caf8a41d106b07593c010cb91ecc0e08b3a0.tar.xz
logdiag-1201caf8a41d106b07593c010cb91ecc0e08b3a0.zip
Use JsonObject for LdDiagramObject parameters.
Make LdDiagramObject a regular class.
Diffstat (limited to 'liblogdiag/ld-diagram-symbol.c')
-rw-r--r--liblogdiag/ld-diagram-symbol.c60
1 files changed, 15 insertions, 45 deletions
diff --git a/liblogdiag/ld-diagram-symbol.c b/liblogdiag/ld-diagram-symbol.c
index 3308dbb..72a11a7 100644
--- a/liblogdiag/ld-diagram-symbol.c
+++ b/liblogdiag/ld-diagram-symbol.c
@@ -20,15 +20,6 @@
* #LdDiagramSymbol is an implementation of #LdDiagramObject.
*/
-/*
- * LdDiagramSymbolPrivate:
- * @klass: The class of this symbol.
- */
-struct _LdDiagramSymbolPrivate
-{
- gchar *klass;
-};
-
enum
{
PROP_0,
@@ -39,7 +30,6 @@ static void ld_diagram_symbol_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec);
static void ld_diagram_symbol_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec);
-static void ld_diagram_symbol_finalize (GObject *gobject);
G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT);
@@ -53,7 +43,6 @@ ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = ld_diagram_symbol_get_property;
object_class->set_property = ld_diagram_symbol_set_property;
- object_class->finalize = ld_diagram_symbol_finalize;
/**
* LdDiagramSymbol:class:
@@ -64,42 +53,24 @@ ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)
"The class of this symbol.",
"", G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CLASS, pspec);
-
- g_type_class_add_private (klass, sizeof (LdDiagramSymbolPrivate));
}
static void
ld_diagram_symbol_init (LdDiagramSymbol *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE
- (self, LD_TYPE_DIAGRAM_SYMBOL, LdDiagramSymbolPrivate);
-}
-
-static void
-ld_diagram_symbol_finalize (GObject *gobject)
-{
- LdDiagramSymbol *self;
-
- self = LD_DIAGRAM_SYMBOL (gobject);
-
- if (self->priv->klass)
- g_free (self->priv->klass);
-
- /* Chain up to the parent class. */
- G_OBJECT_CLASS (ld_diagram_symbol_parent_class)->finalize (gobject);
}
static void
ld_diagram_symbol_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
- LdDiagramSymbol *self;
+ LdDiagramObject *self;
- self = LD_DIAGRAM_SYMBOL (object);
+ self = LD_DIAGRAM_OBJECT (object);
switch (property_id)
{
case PROP_CLASS:
- g_value_set_string (value, ld_diagram_symbol_get_class (self));
+ ld_diagram_object_get_data (self, value, pspec);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -110,13 +81,13 @@ static void
ld_diagram_symbol_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
- LdDiagramSymbol *self;
+ LdDiagramObject *self;
- self = LD_DIAGRAM_SYMBOL (object);
+ self = LD_DIAGRAM_OBJECT (object);
switch (property_id)
{
case PROP_CLASS:
- ld_diagram_symbol_set_class (self, g_value_get_string (value));
+ ld_diagram_object_set_data (self, value, pspec);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -126,17 +97,16 @@ ld_diagram_symbol_set_property (GObject *object, guint property_id,
/**
* ld_diagram_symbol_new:
- * @klass: The class of the new symbol.
+ * @storage: A storage backend.
*
* Return value: A new #LdDiagramSymbol object.
*/
LdDiagramSymbol *
-ld_diagram_symbol_new (const gchar *klass)
+ld_diagram_symbol_new (JsonObject *storage)
{
LdDiagramSymbol *self;
- self = g_object_new (LD_TYPE_DIAGRAM_SYMBOL, NULL);
- ld_diagram_symbol_set_class (self, klass);
+ self = g_object_new (LD_TYPE_DIAGRAM_SYMBOL, "storage", storage, NULL);
return self;
}
@@ -149,12 +119,15 @@ ld_diagram_symbol_new (const gchar *klass)
const gchar *
ld_diagram_symbol_get_class (LdDiagramSymbol *self)
{
+ const gchar *klass;
+
g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), NULL);
- return self->priv->klass;
+ g_object_get (self, "class", &klass, NULL);
+ return klass;
}
/**
- * ld_diagram_symbol_get_class:
+ * ld_diagram_symbol_set_class:
* @self: An #LdDiagramSymbol object.
* @klass: The class.
*
@@ -164,8 +137,5 @@ void
ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass)
{
g_return_if_fail (LD_IS_DIAGRAM_SYMBOL (self));
-
- if (self->priv->klass)
- g_free (self->priv->klass);
- self->priv->klass = g_strdup (klass);
+ g_object_set (self, "class", klass, NULL);
}