2010-09-25 20:59:20 +02:00
|
|
|
/*
|
|
|
|
* ld-lua-symbol.c
|
|
|
|
*
|
|
|
|
* This file is a part of logdiag.
|
2011-01-08 06:44:40 +01:00
|
|
|
* Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
|
2010-09-25 20:59:20 +02:00
|
|
|
*
|
|
|
|
* See the file LICENSE for licensing information.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-10 11:20:14 +01:00
|
|
|
#include "liblogdiag.h"
|
2010-09-25 20:59:20 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2010-12-05 15:21:00 +01:00
|
|
|
#include "ld-lua-private.h"
|
2010-10-24 21:33:37 +02:00
|
|
|
#include "ld-lua-symbol-private.h"
|
|
|
|
|
2010-09-25 20:59:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:ld-lua-symbol
|
2011-01-28 17:39:40 +01:00
|
|
|
* @short_description: A symbol
|
2010-09-25 20:59:20 +02:00
|
|
|
* @see_also: #LdSymbol
|
|
|
|
*
|
|
|
|
* #LdLuaSymbol is an implementation of #LdSymbol.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void ld_lua_symbol_finalize (GObject *gobject);
|
|
|
|
|
2010-12-11 14:26:00 +01:00
|
|
|
static const gchar *ld_lua_symbol_real_get_name (LdSymbol *symbol);
|
|
|
|
static const gchar *ld_lua_symbol_real_get_human_name (LdSymbol *symbol);
|
2011-01-08 06:44:40 +01:00
|
|
|
static void ld_lua_symbol_real_get_area (LdSymbol *symbol, LdRectangle *area);
|
2011-01-08 12:09:45 +01:00
|
|
|
static const LdPointArray *ld_lua_symbol_real_get_terminals (LdSymbol *symbol);
|
2010-12-11 14:26:00 +01:00
|
|
|
static void ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr);
|
2010-09-29 09:13:26 +02:00
|
|
|
|
2010-09-25 20:59:20 +02:00
|
|
|
|
2011-01-04 14:52:57 +01:00
|
|
|
G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL);
|
|
|
|
|
2010-09-25 20:59:20 +02:00
|
|
|
static void
|
|
|
|
ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
object_class->finalize = ld_lua_symbol_finalize;
|
|
|
|
|
2010-12-11 14:26:00 +01:00
|
|
|
klass->parent_class.get_name = ld_lua_symbol_real_get_name;
|
|
|
|
klass->parent_class.get_human_name = ld_lua_symbol_real_get_human_name;
|
|
|
|
klass->parent_class.get_area = ld_lua_symbol_real_get_area;
|
2011-01-08 12:09:45 +01:00
|
|
|
klass->parent_class.get_terminals = ld_lua_symbol_real_get_terminals;
|
2010-12-11 14:26:00 +01:00
|
|
|
klass->parent_class.draw = ld_lua_symbol_real_draw;
|
2010-09-25 21:00:24 +02:00
|
|
|
|
2010-09-25 20:59:20 +02:00
|
|
|
g_type_class_add_private (klass, sizeof (LdLuaSymbolPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ld_lua_symbol_init (LdLuaSymbol *self)
|
|
|
|
{
|
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
|
|
|
|
(self, LD_TYPE_LUA_SYMBOL, LdLuaSymbolPrivate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ld_lua_symbol_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
LdLuaSymbol *self;
|
|
|
|
|
|
|
|
self = LD_LUA_SYMBOL (gobject);
|
|
|
|
|
2010-10-28 00:31:20 +02:00
|
|
|
if (self->priv->lua)
|
|
|
|
{
|
|
|
|
ld_lua_private_unregister (self->priv->lua, self);
|
|
|
|
g_object_unref (self->priv->lua);
|
|
|
|
}
|
2010-09-29 09:13:26 +02:00
|
|
|
|
2010-10-27 15:52:36 +02:00
|
|
|
if (self->priv->name)
|
|
|
|
g_free (self->priv->name);
|
|
|
|
if (self->priv->human_name)
|
|
|
|
g_free (self->priv->human_name);
|
|
|
|
|
2011-01-08 12:09:45 +01:00
|
|
|
if (self->priv->terminals)
|
|
|
|
ld_point_array_free (self->priv->terminals);
|
|
|
|
|
2010-09-25 20:59:20 +02:00
|
|
|
/* Chain up to the parent class. */
|
|
|
|
G_OBJECT_CLASS (ld_lua_symbol_parent_class)->finalize (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 14:26:00 +01:00
|
|
|
static const gchar *
|
|
|
|
ld_lua_symbol_real_get_name (LdSymbol *symbol)
|
2010-10-27 15:52:36 +02:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (LD_IS_LUA_SYMBOL (symbol), NULL);
|
|
|
|
return LD_LUA_SYMBOL (symbol)->priv->name;
|
|
|
|
}
|
|
|
|
|
2010-12-11 14:26:00 +01:00
|
|
|
static const gchar *
|
|
|
|
ld_lua_symbol_real_get_human_name (LdSymbol *symbol)
|
2010-10-27 15:52:36 +02:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (LD_IS_LUA_SYMBOL (symbol), NULL);
|
|
|
|
return LD_LUA_SYMBOL (symbol)->priv->human_name;
|
|
|
|
}
|
|
|
|
|
2010-12-11 14:26:00 +01:00
|
|
|
static void
|
2011-01-08 06:44:40 +01:00
|
|
|
ld_lua_symbol_real_get_area (LdSymbol *symbol, LdRectangle *area)
|
2010-10-27 15:52:36 +02:00
|
|
|
{
|
|
|
|
LdLuaSymbol *self;
|
|
|
|
|
|
|
|
g_return_if_fail (LD_IS_LUA_SYMBOL (symbol));
|
|
|
|
g_return_if_fail (area != NULL);
|
|
|
|
|
|
|
|
self = LD_LUA_SYMBOL (symbol);
|
|
|
|
*area = self->priv->area;
|
|
|
|
}
|
|
|
|
|
2011-01-08 12:09:45 +01:00
|
|
|
static const LdPointArray *
|
|
|
|
ld_lua_symbol_real_get_terminals (LdSymbol *symbol)
|
|
|
|
{
|
|
|
|
LdLuaSymbol *self;
|
|
|
|
|
|
|
|
g_return_val_if_fail (LD_IS_LUA_SYMBOL (symbol), NULL);
|
|
|
|
|
|
|
|
self = LD_LUA_SYMBOL (symbol);
|
|
|
|
return self->priv->terminals;
|
|
|
|
}
|
|
|
|
|
2010-10-24 21:33:37 +02:00
|
|
|
static void
|
2010-12-11 14:26:00 +01:00
|
|
|
ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr)
|
2010-09-25 20:59:20 +02:00
|
|
|
{
|
2010-09-29 09:13:26 +02:00
|
|
|
LdLuaSymbol *self;
|
2010-09-25 20:59:20 +02:00
|
|
|
|
2010-10-27 15:52:36 +02:00
|
|
|
g_return_if_fail (LD_IS_LUA_SYMBOL (symbol));
|
2010-09-29 09:13:26 +02:00
|
|
|
g_return_if_fail (cr != NULL);
|
|
|
|
|
2010-10-24 21:33:37 +02:00
|
|
|
self = LD_LUA_SYMBOL (symbol);
|
2010-11-16 10:30:10 +01:00
|
|
|
|
|
|
|
cairo_save (cr);
|
2010-10-24 21:33:37 +02:00
|
|
|
ld_lua_private_draw (self->priv->lua, self, cr);
|
2010-11-16 10:30:10 +01:00
|
|
|
cairo_restore (cr);
|
2010-09-25 20:59:20 +02:00
|
|
|
}
|
|
|
|
|