2010-09-20 18:18:30 +02:00
|
|
|
/*
|
|
|
|
* ld-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"
|
|
|
|
|
2010-09-25 16:14:09 +02:00
|
|
|
#include "ld-library.h"
|
2010-09-20 18:18:30 +02:00
|
|
|
#include "ld-symbol-category.h"
|
|
|
|
#include "ld-symbol.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:ld-symbol
|
|
|
|
* @short_description: A symbol.
|
|
|
|
* @see_also: #LdDocument, #LdCanvas
|
|
|
|
*
|
|
|
|
* #LdSymbol represents a symbol in the #LdDocument that is in turn
|
|
|
|
* drawn onto the #LdCanvas.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LdSymbolPrivate:
|
2010-09-25 20:59:20 +02:00
|
|
|
* @parent: The parent LdSymbolCategory. It is used to identify
|
|
|
|
* the object within it's library.
|
2010-09-20 18:18:30 +02:00
|
|
|
*/
|
|
|
|
struct _LdSymbolPrivate
|
|
|
|
{
|
2010-09-25 20:59:20 +02:00
|
|
|
LdSymbolCategory *parent;
|
2010-09-20 18:18:30 +02:00
|
|
|
};
|
|
|
|
|
2010-09-25 20:59:20 +02:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT);
|
2010-09-20 18:18:30 +02:00
|
|
|
|
2010-09-25 20:59:20 +02:00
|
|
|
static void ld_symbol_finalize (GObject *gobject);
|
2010-09-20 18:18:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ld_symbol_class_init (LdSymbolClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
object_class->finalize = ld_symbol_finalize;
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (LdSymbolPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ld_symbol_init (LdSymbol *self)
|
|
|
|
{
|
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
|
2010-09-25 20:59:20 +02:00
|
|
|
(self, LD_TYPE_SYMBOL, LdSymbolPrivate);
|
2010-09-20 18:18:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ld_symbol_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
LdSymbol *self;
|
|
|
|
|
|
|
|
self = LD_SYMBOL (gobject);
|
2010-09-25 20:59:20 +02:00
|
|
|
g_object_unref (self->priv->parent);
|
2010-09-20 18:18:30 +02:00
|
|
|
|
|
|
|
/* Chain up to the parent class. */
|
|
|
|
G_OBJECT_CLASS (ld_symbol_parent_class)->finalize (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ld_symbol_build_identifier:
|
|
|
|
* @self: A symbol object.
|
|
|
|
*
|
|
|
|
* Build an identifier for the symbol.
|
|
|
|
* The identifier is in the format "Category/Category/Symbol".
|
|
|
|
*/
|
2010-09-25 20:59:20 +02:00
|
|
|
gchar *
|
2010-09-20 18:18:30 +02:00
|
|
|
ld_symbol_build_identifier (LdSymbol *self)
|
|
|
|
{
|
2010-09-25 20:59:20 +02:00
|
|
|
/* TODO: Implement. */
|
2010-09-20 18:18:30 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ld_symbol_draw:
|
|
|
|
* @self: A symbol object.
|
2010-09-25 16:03:48 +02:00
|
|
|
* @cr: A cairo surface to be drawn on.
|
2010-09-20 18:18:30 +02:00
|
|
|
*
|
|
|
|
* Draw the symbol onto a Cairo surface.
|
|
|
|
*/
|
|
|
|
void
|
2010-09-25 20:59:20 +02:00
|
|
|
ld_symbol_draw (LdSymbol *self, cairo_t *cr)
|
2010-09-20 18:18:30 +02:00
|
|
|
{
|
2010-09-25 20:59:20 +02:00
|
|
|
LdSymbolClass *klass;
|
|
|
|
|
|
|
|
g_return_if_fail (LD_IS_SYMBOL (self));
|
|
|
|
g_return_if_fail (cr != NULL);
|
|
|
|
|
|
|
|
klass = LD_SYMBOL_GET_CLASS (self);
|
|
|
|
if (klass->draw)
|
|
|
|
klass->draw (self, cr);
|
2010-09-20 18:18:30 +02:00
|
|
|
}
|