Implement part of LdLuaSymbol.
The "new" method requires to be passed a parameter that makes it possible to call the appropriate render function. Stub-plemented the "draw" method.
This commit is contained in:
parent
9fc354e066
commit
0c9b297e50
@ -29,17 +29,21 @@
|
||||
|
||||
/*
|
||||
* LdLuaSymbolPrivate:
|
||||
* @lua: Parent Lua object.
|
||||
* @lua: Parent #LdLua object.
|
||||
* @ident: Identifier for the symbol.
|
||||
*/
|
||||
struct _LdLuaSymbolPrivate
|
||||
{
|
||||
LdLua *lua;
|
||||
gchar *ident;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL);
|
||||
|
||||
static void ld_lua_symbol_finalize (GObject *gobject);
|
||||
|
||||
static void ld_lua_symbol_draw (LdSymbol *self, cairo_t *cr);
|
||||
|
||||
|
||||
static void
|
||||
ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
|
||||
@ -49,7 +53,7 @@ ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = ld_lua_symbol_finalize;
|
||||
|
||||
/* TODO: Override the "draw" method of LdSymbol. */
|
||||
klass->parent_class.draw = ld_lua_symbol_draw;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (LdLuaSymbolPrivate));
|
||||
}
|
||||
@ -69,6 +73,8 @@ ld_lua_symbol_finalize (GObject *gobject)
|
||||
self = LD_LUA_SYMBOL (gobject);
|
||||
g_object_unref (self->priv->lua);
|
||||
|
||||
g_free (self->priv->ident);
|
||||
|
||||
/* Chain up to the parent class. */
|
||||
G_OBJECT_CLASS (ld_lua_symbol_parent_class)->finalize (gobject);
|
||||
}
|
||||
@ -76,23 +82,37 @@ ld_lua_symbol_finalize (GObject *gobject)
|
||||
|
||||
/**
|
||||
* ld_symbol_new:
|
||||
* @library: A library object.
|
||||
* @filename: The file from which the symbol will be loaded.
|
||||
* @lua: An #LdLua object.
|
||||
* @ident: Identifier for the symbol.
|
||||
*
|
||||
* Load a symbol from a file into the library.
|
||||
*/
|
||||
LdSymbol *
|
||||
ld_lua_symbol_new (LdSymbolCategory *parent, LdLua *lua)
|
||||
ld_lua_symbol_new (LdLua *lua, const gchar *ident)
|
||||
{
|
||||
LdLuaSymbol *symbol;
|
||||
LdLuaSymbol *self;
|
||||
|
||||
symbol = g_object_new (LD_TYPE_LUA_SYMBOL, NULL);
|
||||
g_return_val_if_fail (LD_IS_LUA (lua), NULL);
|
||||
g_return_val_if_fail (ident != NULL, NULL);
|
||||
|
||||
/* TODO: Create a separate ld-symbol-private.h, include it in this file
|
||||
* and then assign and ref the parent category here.
|
||||
*/
|
||||
self = g_object_new (LD_TYPE_LUA_SYMBOL, NULL);
|
||||
|
||||
symbol->priv->lua = lua;
|
||||
self->priv->lua = lua;
|
||||
g_object_ref (lua);
|
||||
|
||||
self->priv->ident = g_strdup (ident);
|
||||
return LD_SYMBOL (self);
|
||||
}
|
||||
|
||||
static void
|
||||
ld_lua_symbol_draw (LdSymbol *self, cairo_t *cr)
|
||||
{
|
||||
g_return_if_fail (LD_IS_SYMBOL (self));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
/* TODO: Implement. */
|
||||
/* Retrieve the function for rendering from the registry or wherever
|
||||
* it's going to end up, and call it.
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,6 @@ typedef struct _LdLuaSymbolClass LdLuaSymbolClass;
|
||||
|
||||
/**
|
||||
* LdLuaSymbol:
|
||||
* @name: The name of this symbol.
|
||||
*/
|
||||
struct _LdLuaSymbol
|
||||
{
|
||||
@ -54,7 +53,7 @@ struct _LdLuaSymbolClass
|
||||
|
||||
GType ld_lua_symbol_get_type (void) G_GNUC_CONST;
|
||||
|
||||
LdSymbol *ld_lua_symbol_new (LdSymbolCategory *parent, LdLua *lua);
|
||||
LdSymbol *ld_lua_symbol_new (LdLua *lua, const gchar *ident);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -269,7 +269,7 @@ ld_lua_logdiag_register (lua_State *L)
|
||||
*/
|
||||
|
||||
/*
|
||||
symbol = ld_lua_symbol_new (ud->category, ud->self);
|
||||
symbol = ld_lua_symbol_new (ud->self);
|
||||
ld_symbol_category_insert (ud->category, symbol, -1);
|
||||
g_object_unref (symbol);
|
||||
*/
|
||||
|
@ -65,6 +65,11 @@ GType ld_symbol_category_get_type (void) G_GNUC_CONST;
|
||||
LdSymbolCategory *
|
||||
ld_symbol_category_new (LdLibrary *parent);
|
||||
|
||||
/* TODO: Methods for inserting and removing children. */
|
||||
/* TODO: Create a separate ld-symbol-private.h, include it in this ld-s-c.c
|
||||
* and then assign and ref the parent category here.
|
||||
*/
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -65,6 +65,9 @@ gchar *ld_symbol_build_identifier (LdSymbol *self);
|
||||
void ld_symbol_draw (LdSymbol *self, cairo_t *cr);
|
||||
|
||||
/* TODO: An interface for symbol terminals etc. */
|
||||
/* TODO: Store a pointer to the parent, probably as a property,
|
||||
* using g_object_add_weak_pointer/remove_weak_pointer.
|
||||
*/
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user