soylent r221 - trunk/libsoylent
- From: svenp svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r221 - trunk/libsoylent
- Date: Mon, 14 Jul 2008 21:46:49 +0000 (UTC)
Author: svenp
Date: Mon Jul 14 21:46:49 2008
New Revision: 221
URL: http://svn.gnome.org/viewvc/soylent?rev=221&view=rev
Log:
creation of SlPerson (including SlEntity) works
Modified:
trunk/libsoylent/sl-entity.c
trunk/libsoylent/sl-entity.h
trunk/libsoylent/sl-person.c
trunk/libsoylent/sl-person.h
Modified: trunk/libsoylent/sl-entity.c
==============================================================================
--- trunk/libsoylent/sl-entity.c (original)
+++ trunk/libsoylent/sl-entity.c Mon Jul 14 21:46:49 2008
@@ -52,9 +52,9 @@
static void sl_entity_class_init (gpointer g_class, gpointer class_data);
static void sl_entity_init (GTypeInstance *instance, gpointer g_class);
static void sl_entity_dispose (GObject *object);
-static void sl_entity_set_property (GObject *object, guint property_id,
+static void sl_entity_set_property (SlEntity *self, guint property_id,
const GValue *value, GParamSpec *pspec);
-static void sl_entity_get_property (GObject *object, guint property_id,
+static void sl_entity_get_property (SlEntity *self, guint property_id,
GValue *value, GParamSpec *pspec);
static void sl_attribute_class_init (gpointer g_class, gpointer class_data);
@@ -137,8 +137,17 @@
GObjectClass *obj_class = G_OBJECT_CLASS (g_class);
obj_class->dispose = sl_entity_dispose;
- obj_class->get_property = sl_entity_get_property;
- obj_class->set_property = sl_entity_set_property;
+ obj_class->set_property = (void (*)(GObject *, guint, const GValue *,
+ GParamSpec *)) sl_entity_set_property;
+ obj_class->get_property = (void (*)(GObject *, guint, GValue *, GParamSpec *))
+ sl_entity_get_property;
+
+ GParamSpec *pspec = NULL;
+ pspec = g_param_spec_pointer ("entity-handler", "entity-handler",
+ "Entity handler", G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
+
+ g_object_class_install_property (obj_class, SL_ENTITY_PROPERTY_ENTITY_HANDLER,
+ pspec);
}
static void
@@ -164,25 +173,37 @@
}
static void
-sl_entity_set_property (GObject *object, guint property_id, const GValue *value,
+sl_entity_set_property (SlEntity *self, guint property_id, const GValue *value,
GParamSpec *pspec)
{
- g_warning ("%s not implemented", __FUNCTION__);
+ switch (property_id)
+ {
+ case SL_ENTITY_PROPERTY_ENTITY_HANDLER:
+ self->priv->entity_handler = g_object_ref (g_value_get_pointer (value));
+ break;
+ default:
+ g_assert_not_reached();
+ }
}
static void
-sl_entity_get_property (GObject *object, guint property_id, GValue *value,
+sl_entity_get_property (SlEntity *self, guint property_id, GValue *value,
GParamSpec *pspec)
{
g_warning("%s not implemented", __FUNCTION__);
}
-SlEntity *
-sl_entity_new (void)
+/* ABSTRACT */
+/*SlEntity *
+sl_entity_new (SlEntityHandler *entity_handler)
{
- SlEntity *entity = g_object_new (SL_ENTITY_TYPE, NULL);
- return entity;
-}
+ g_return_val_if_fail (entity_handler != NULL &&
+ SL_IS_ENTITY_HANDLER (entity_handler), NULL);
+
+ SlEntity *self = g_object_new (SL_ENTITY_TYPE, "entity-handler",
+ entity_handler, NULL);
+ return self;
+}*/
SlEntityHandler *sl_entity_get_handler (SlEntity *self)
{
Modified: trunk/libsoylent/sl-entity.h
==============================================================================
--- trunk/libsoylent/sl-entity.h (original)
+++ trunk/libsoylent/sl-entity.h Mon Jul 14 21:46:49 2008
@@ -63,8 +63,15 @@
typedef struct _SlAttributeHandler SlAttributeHandler;
+typedef enum _SlEntityProperty SlEntityProperty;
+
typedef enum _SlAttributeHandlerType SlAttributeHandlerType;
+enum _SlEntityProperty
+{
+ SL_ENTITY_PROPERTY_ENTITY_HANDLER = 1
+};
+
enum _SlAttributeHandlerType
{
SL_ATTRIBUTE_HANDLER_TYPE_STRING,
@@ -98,10 +105,12 @@
GType sl_entity_get_type (void);
GType sl_attribute_get_type (void);
-void sl_entity_install_attribute_handler (const gchar *attrname, SlAttributeHandlerType type, gpointer (*writer)(const gchar *attrname, gpointer value), gpointer (*reader)(const gchar *attrname, gpointer value));
+void sl_entity_install_attribute_handler (const gchar *attrname,
+ SlAttributeHandlerType type, gpointer (*writer)(const gchar *attrname,
+ gpointer value), gpointer (*reader)(const gchar *attrname, gpointer value));
void sl_entity_remove_attribute_handler (const gchar *attrname);
-SlEntity *sl_entity_new (void);
+/*SlEntity *sl_entity_new (SlEntityHandler *entity_handler);*/
SlEntityHandler *sl_entity_get_handler (SlEntity *self);
SlAttribute *sl_entity_get_attribute (SlEntity *self, gchar *attrname);
GList *sl_entity_get_attributes (SlEntity *self);
@@ -109,7 +118,8 @@
void sl_entity_set (SlEntity *self, gchar *attrname, gpointer value);
gpointer sl_entity_get (SlEntity *self, gchar *attrname);
void sl_entity_remove (SlEntity *self, gchar *attrname);
-void sl_entity_set_at (SlEntity *self, gchar *attrname, gint index, gpointer value);
+void sl_entity_set_at (SlEntity *self, gchar *attrname, gint index,
+ gpointer value);
gpointer sl_entity_get_at (SlEntity *self, gchar *attrname, gint index);
void sl_entity_remove_at (SlEntity *self, gchar *attrname, gint index);
void sl_entity_set_values (SlEntity *self, gchar *attrname, GList *values);
Modified: trunk/libsoylent/sl-person.c
==============================================================================
--- trunk/libsoylent/sl-person.c (original)
+++ trunk/libsoylent/sl-person.c Mon Jul 14 21:46:49 2008
@@ -22,6 +22,7 @@
*/
#include "sl-person.h"
+#include "sl-entity-handler-eds.h"
/* private structs and fields */
@@ -111,8 +112,11 @@
}
SlPerson *
-sl_person_new (void)
+sl_person_new (const gchar *name)
{
- SlPerson *self = g_object_new (SL_PERSON_TYPE, NULL);
+ SlEntityHandlerEDS *entity_handler_eds = sl_entity_handler_eds_new ();
+ SlPerson *self = g_object_new (SL_PERSON_TYPE, "entity-handler",
+ entity_handler_eds, NULL);
+ /* TODO: set name */
return self;
}
Modified: trunk/libsoylent/sl-person.h
==============================================================================
--- trunk/libsoylent/sl-person.h (original)
+++ trunk/libsoylent/sl-person.h Mon Jul 14 21:46:49 2008
@@ -58,6 +58,6 @@
GType sl_person_get_type (void);
-SlPerson *sl_person_new (void);
+SlPerson *sl_person_new (const gchar *name);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]