[Glade-devel] feature request: additional callback like post-create-function



On Thu, 2006-11-23 at 14:25 +0100, Oliver Nittka wrote:
Hi,

some gtkmm-users (including me) are currently investigating on how to
integrate gtkmm-style widgets into glade.

so far, we have already succeeded in getting the widgets into the glade
palette and have glade set their (Glib::Property-based) properties.
(this only involves a minor part of glue code.)

there remains, however, a problem that can only be solved by patching
glade: whenever a GObject is created, it is necessary to call a function
that wraps this GObject in its correspnding C++ class. this can be done
from the widget's post-create-function and works wonderfully.

however, when loading the widgets from a glade file, the properties of
the GObject get set before the wrapper function is called.
at that time, the custom properties of the respective did already
register a "set_property" function in their GWidgetClass, but as the
respective Glib::Properties are not yet created, the values are silently
lost and later, when the C++-object gets created, are set to their
default values.

I was reading this thread
http://marc.theaimsgroup.com/?l=gtkmm&m=116376755831015&w=2
and i think i am understanding whats the problem.
I think if you override GObject construct() method in the glibmm wrapper
and do all you have to do there (register the gtype and create the
wrapper if apropiate) it would solve most .

so.. if glibmm does this in his custom constructor() method you will not
have to do it in the post-create function and you will not have problems
with libglade either.


so, loading a glade file results in all of the custom properties getting
set to their default values.

a possible solution would be to introduce an additional callback
function in the style of "post-create-function", that gets called after
the GObject is created and before it's properties are set (i suppose in
glade_widget_build_object() right after the call to g_object_newv()).

yep...

from gtk docs

"constructor ()  the constructor function is called by g_object_new() to
complete the object initialization after all the construction properties
are set. The first thing a constructor implementation must do is chain
up to the constructor of the parent class. Overriding constructor should
be rarely needed, e.g. to handle construct properties, or to implement
singletons."

BTW it would be cool to add a way to specify the type name to be
registered so YourCustomWidget get registered as "YourCustomWidget" and
not something like "glibmm__YourCustomWidget"

greets

Juan Pablo





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