Gobject and c++ types.



Hello. I'm trying to implement a system that works in a perfect way
with the GObject C library, so that things are easier to integrate
c++ classes in tools that use the metadata from GObject, like glade.

Maybe when I finish this, I could send it here to be able to integrate it
with glibmm and improve the object model.

My system must allow to register (yes, with macros, no other way) properties,
gobjects and signals, etc. So for now, what I can do is the following:

class MyClass : public glib::object {

};...


GLIB_REGISTER_CLASS(MyClass, glib::object);


int main(int argc, char * argv[])
{
    MyClass * c = (MyClass *)g_type_new(g_type_from_name("MyClass", NULL));
    c->method();
}


My problem is that now I want to install properties and use them. In
order for properties
to work well in C programs (like glade), they should be able to be set
from GObject:

g_object_set(G_OBJECT(c), "Prop", value);

My problem is that G_OBJECT macro fails with the following:

GLib-GObject-CRITICAL **: g_object_set: assertion `G_IS_OBJECT (object)' failed

But if I query this:

g_type_is_a(g_type_from_name("MyClass"), G_TYPE_OBJECT)

it returns 1. So I want to know why this fails in order to solve the
problem. I'm stuck here for now.

I use InstanceInit from GTypeInfo to call the c++ constructor, and
class_init from GTypeInfo to install properties.
But the casting fails and I don't know why. Thanks in advance.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]