summaryrefslogtreecommitdiff
path: root/src/ld-diagram-symbol.c
blob: 96536264b5bee20a202456ed33e6ec6dbb48eb86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * ld-diagram-symbol.c
 *
 * This file is a part of logdiag.
 * Copyright Přemysl Janouch 2010. All rights reserved.
 *
 * See the file LICENSE for licensing information.
 *
 */

#include <gtk/gtk.h>

#include "config.h"

#include "ld-diagram-object.h"
#include "ld-diagram-symbol.h"


/**
 * SECTION:ld-diagram-symbol
 * @short_description: A symbol object.
 * @see_also: #LdDiagramObject
 *
 * #LdDiagramSymbol is an implementation of #LdDiagramObject.
 */

/*
 * LdDiagramSymbolPrivate:
 * @klass: The class of this symbol.
 */
struct _LdDiagramSymbolPrivate
{
	gchar *klass;
};

static void ld_diagram_symbol_finalize (GObject *gobject);


G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT);

static void
ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)
{
	GObjectClass *object_class;

	object_class = G_OBJECT_CLASS (klass);
	object_class->finalize = ld_diagram_symbol_finalize;

	/* TODO: A property for the class. */

	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);
}


/**
 * ld_diagram_symbol_new:
 * @klass: The class of the symbol (symbol identifier).
 *
 * Return value: A new #LdDiagramSymbol object.
 */
LdDiagramSymbol *
ld_diagram_symbol_new (const gchar *klass)
{
	LdDiagramSymbol *self;

	self = g_object_new (LD_TYPE_DIAGRAM_SYMBOL, NULL);
	ld_diagram_symbol_set_class (self, klass);
	return self;
}


/* TODO: gtk-doc comments. */
const gchar *
ld_diagram_symbol_get_class (LdDiagramSymbol *self)
{
	g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), NULL);
	return self->priv->klass;
}

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);
}