aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ld-lua-symbol.c96
-rw-r--r--src/ld-lua-symbol.h63
-rw-r--r--src/ld-symbol.c47
-rw-r--r--src/ld-symbol.h13
4 files changed, 187 insertions, 32 deletions
diff --git a/src/ld-lua-symbol.c b/src/ld-lua-symbol.c
new file mode 100644
index 0000000..9b87f72
--- /dev/null
+++ b/src/ld-lua-symbol.c
@@ -0,0 +1,96 @@
+/*
+ * ld-lua-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-library.h"
+#include "ld-symbol.h"
+#include "ld-symbol-category.h"
+#include "ld-lua.h"
+#include "ld-lua-symbol.h"
+
+
+/**
+ * SECTION:ld-lua-symbol
+ * @short_description: A symbol.
+ * @see_also: #LdSymbol
+ *
+ * #LdLuaSymbol is an implementation of #LdSymbol.
+ */
+
+/*
+ * LdLuaSymbolPrivate:
+ * @lua: Parent Lua object.
+ */
+struct _LdLuaSymbolPrivate
+{
+ LdLua *lua;
+};
+
+G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL);
+
+static void ld_lua_symbol_finalize (GObject *gobject);
+
+
+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;
+
+ 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);
+ g_object_unref (self->priv->lua);
+
+ /* Chain up to the parent class. */
+ G_OBJECT_CLASS (ld_lua_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_lua_symbol_new (LdSymbolCategory *parent, LdLua *lua)
+{
+ LdLuaSymbol *symbol;
+
+ symbol = g_object_new (LD_TYPE_LUA_SYMBOL, NULL);
+
+ /* TODO: Create a separate ld-symbol-private.h, include it in this file
+ * and then assign and ref the parent category here.
+ */
+
+ symbol->priv->lua = lua;
+ g_object_ref (lua);
+}
+
diff --git a/src/ld-lua-symbol.h b/src/ld-lua-symbol.h
new file mode 100644
index 0000000..a90feb7
--- /dev/null
+++ b/src/ld-lua-symbol.h
@@ -0,0 +1,63 @@
+/*
+ * ld-lua-symbol.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __LD_LUA_SYMBOL_H__
+#define __LD_LUA_SYMBOL_H__
+
+G_BEGIN_DECLS
+
+
+#define LD_TYPE_LUA_SYMBOL (ld_lua_symbol_get_type ())
+#define LD_LUA_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LD_TYPE_LUA_SYMBOL, LdLuaSymbol))
+#define LD_LUA_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LD_TYPE_LUA_SYMBOL, LdLuaSymbolClass))
+#define LD_IS_LUA_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LD_TYPE_LUA_SYMBOL))
+#define LD_IS_LUA_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LD_TYPE_LUA_SYMBOL))
+#define LD_LUA_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LD_LUA_SYMBOL, LdLuaSymbolClass))
+
+typedef struct _LdLuaSymbol LdLuaSymbol;
+typedef struct _LdLuaSymbolPrivate LdLuaSymbolPrivate;
+typedef struct _LdLuaSymbolClass LdLuaSymbolClass;
+
+
+/**
+ * LdLuaSymbol:
+ * @name: The name of this symbol.
+ */
+struct _LdLuaSymbol
+{
+/*< private >*/
+ LdSymbol parent_instance;
+ LdLuaSymbolPrivate *priv;
+};
+
+/**
+ * LdLuaSymbolClass:
+ * @parent_class: The parent class.
+ */
+struct _LdLuaSymbolClass
+{
+ LdSymbolClass parent_class;
+};
+
+
+GType ld_lua_symbol_get_type (void) G_GNUC_CONST;
+
+LdSymbol *ld_lua_symbol_new (LdSymbolCategory *parent, LdLua *lua);
+
+
+G_END_DECLS
+
+#endif /* ! __LD_LUA_SYMBOL_H__ */
+
diff --git a/src/ld-symbol.c b/src/ld-symbol.c
index 4bfe6a2..9dc4394 100644
--- a/src/ld-symbol.c
+++ b/src/ld-symbol.c
@@ -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,39 +65,23 @@ 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.
*
* 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);
}
diff --git a/src/ld-symbol.h b/src/ld-symbol.h
index f3a2d35..3d5967c 100644
--- a/src/ld-symbol.h
+++ b/src/ld-symbol.h
@@ -45,19 +45,26 @@ struct _LdSymbol
gchar *name;
};
+/**
+ * LdSymbolClass:
+ * @parent_class: The parent class.
+ * @draw: Draw the symbol on a Cairo surface.
+ */
struct _LdSymbolClass
{
GObjectClass parent_class;
+
+ void (*draw) (LdSymbol *self, cairo_t *cr);
};
GType ld_symbol_get_type (void) G_GNUC_CONST;
-LdSymbol *ld_symbol_new (LdLibrary *library);
gchar *ld_symbol_build_identifier (LdSymbol *self);
-void ld_symbol_draw (LdSymbol *self, cairo_t *cr, GHashTable *param);
-/* TODO: An interface for symbol terminals. */
+void ld_symbol_draw (LdSymbol *self, cairo_t *cr);
+
+/* TODO: An interface for symbol terminals etc. */
G_END_DECLS