Convert LdSymbol into an abstract class.
Created LdLuaSymbol, which subclasses LdSymbol.
This commit is contained in:
@@ -28,18 +28,17 @@
|
||||
|
||||
/*
|
||||
* LdSymbolPrivate:
|
||||
* @library: The parent LdLibrary.
|
||||
* The library contains the real function for rendering.
|
||||
* @parent: The parent LdSymbolCategory. It is used to identify
|
||||
* the object within it's library.
|
||||
*/
|
||||
struct _LdSymbolPrivate
|
||||
{
|
||||
LdLibrary *library;
|
||||
LdSymbolCategory *parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT);
|
||||
G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
ld_symbol_finalize (GObject *gobject);
|
||||
static void ld_symbol_finalize (GObject *gobject);
|
||||
|
||||
|
||||
static void
|
||||
@@ -57,7 +56,7 @@ static void
|
||||
ld_symbol_init (LdSymbol *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
|
||||
(self, LD_TYPE_SYMBOL_LIBRARY, LdSymbolPrivate);
|
||||
(self, LD_TYPE_SYMBOL, LdSymbolPrivate);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -66,29 +65,12 @@ ld_symbol_finalize (GObject *gobject)
|
||||
LdSymbol *self;
|
||||
|
||||
self = LD_SYMBOL (gobject);
|
||||
g_object_unref (self->priv->library);
|
||||
g_object_unref (self->priv->parent);
|
||||
|
||||
/* Chain up to the parent class. */
|
||||
G_OBJECT_CLASS (ld_symbol_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
/**
|
||||
* ld_symbol_new:
|
||||
* @library: A library object.
|
||||
* @filename: The file from which the symbol will be loaded.
|
||||
*
|
||||
* Load a symbol from a file into the library.
|
||||
*/
|
||||
LdSymbol *ld_symbol_new (LdLibrary *library)
|
||||
{
|
||||
LdSymbol *symbol;
|
||||
|
||||
symbol = g_object_new (LD_TYPE_SYMBOL, NULL);
|
||||
|
||||
symbol->priv->library = library;
|
||||
g_object_ref (library);
|
||||
}
|
||||
|
||||
/**
|
||||
* ld_symbol_build_identifier:
|
||||
* @self: A symbol object.
|
||||
@@ -96,9 +78,10 @@ LdSymbol *ld_symbol_new (LdLibrary *library)
|
||||
* Build an identifier for the symbol.
|
||||
* The identifier is in the format "Category/Category/Symbol".
|
||||
*/
|
||||
char *
|
||||
gchar *
|
||||
ld_symbol_build_identifier (LdSymbol *self)
|
||||
{
|
||||
/* TODO: Implement. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -106,12 +89,18 @@ ld_symbol_build_identifier (LdSymbol *self)
|
||||
* ld_symbol_draw:
|
||||
* @self: A symbol object.
|
||||
* @cr: A cairo surface to be drawn on.
|
||||
* @param: Parameters for the symbol in a table.
|
||||
*
|
||||
* Draw the symbol onto a Cairo surface.
|
||||
*/
|
||||
void
|
||||
ld_symbol_draw (LdSymbol *self, cairo_t *cr, GHashTable *param)
|
||||
ld_symbol_draw (LdSymbol *self, cairo_t *cr)
|
||||
{
|
||||
return;
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user