Re: gdlmm



On Fri, 2005-09-16 at 13:02 +0200, Murray Cumming wrote:
> > Small question, is the use of _new functions in constructors always a
> > problem, or is something like _WRAP_CTOR(Dock(const Dock& original, bool
> > floating), gdl_dock_new_from) OK ?
> 
> That's good. That just tells _WRAP_CTOR() to look at gdl_dock_new_from()
> to see what C parameter types it takes, so it can know how to convert the
> C++ parameters to the C parameters (by looking at the .m4 conversion
> files.). It then uses g_object_new() in the generated .cc file.
> 

But it doesn't call the gdl_dock_new_from function, or does it ? If it
doesn't it will skip some stuff that should be called;

GtkWidget *
gdl_dock_new_from (GdlDock  *original,
                   gboolean  floating)
{
    GObject *new_dock;

    g_return_val_if_fail (original != NULL, NULL);

    new_dock = g_object_new (GDL_TYPE_DOCK,
                             "master", GDL_DOCK_OBJECT_GET_MASTER (original),
                             "floating", floating,
                             NULL);
    GDL_DOCK_OBJECT_UNSET_FLAGS (new_dock, GDL_DOCK_AUTOMATIC);

    return GTK_WIDGET (new_dock);
}


> You just need to make sure that you don't hard-code a _new function into
> the .ccg file. Where you need to hand-write a constructor, look at the
> gtkmm .ccg files - there's a macro (_CONSTRUCT, or something like that)
> that helps.

So for the example above i have to do something like; 

Dock::Dock(const Dock& original, bool floating)
: _CONSTRUCT("master", GDL_DOCK_OBJECT_GET_MASTER (original.gobj()), "floating", floating)
{
	this->unset_flag(GDL_DOCK_AUTOMATIC);
}

- Erwin






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