GObject constructors
- From: Jacob Kroon <jacob kroon gmail com>
- To: gtk-list gnome org
- Subject: GObject constructors
- Date: Wed, 09 Nov 2005 18:43:17 +0100
I'm having problems with figuring out how to initialize my data properly.
My scenario is that I have:
struct Parent {
GObject parent;
float *data;
}
struct ParentClass {
GObjectClass parent;
int data_size;
}
struct Child {
Parent parent;
}
struct ChildClass {
ParentClass parent;
}
Each subclass of Parent will use different, but fixed data sizes, so I
want Child to tell Parent how much
data it needs, and then let Parent initialize the data accordingly.
The way I thought would work was this:
1. In child_class_init(*klass):
PARENT_CLASS(klass)->data_size = specific_size_for_this_subclass;
2. In parent_instance_init(*obj)
klass = PARENT_GET_CLASS(obj);
obj->data = g_new(float, klass->data_size);
but this wont work since PARENT_GET_CLASS(obj) in parent_instance_init()
returns the class for Parent,
not the subclass ChildClass, so data_size won't have the value I intended.
Any help would be gladly appreciated.
Regards Jacob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]