Re: Reverse-wrapping gtkmm widgets to gtk+ (for glade3)
- From: Alexander Brinkman <a brinkman marin nl>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list gnome org
- Subject: Re: Reverse-wrapping gtkmm widgets to gtk+ (for glade3)
- Date: Fri, 17 Nov 2006 22:27:36 +0100
On Fri, 2006-11-17 at 17:59 +0100, Murray Cumming wrote:
> > Indeed, registering your own GType is not too difficult (adding
> > Glib::OBjectBase("mywidget") to the constructor does it. However, for
> > Gtkmm custom widgets libglade still instantiates a widget of the parent
> > type. I assume the reason for this is that Gtkmm does not provide a full
> > Gtk+ gobj for my custom widgets;
>
> It should if you have used Glib::OBjectBase("mywidget") and that init
> function is being called to register that type. However, I'm not sure
> how we would register that type easily in the init function without
> instantiating the widget.
Although not the most pretty method; it is really not a problem to
instantiate and destroy a dummy widget to get a unique GType.
But it still seems that Glade misses something about these custom
widgets. I can only assume this is because the creation functions (etc.)
of this custom widget are still pointing to it's parent type? But I must
also confess that I know almost nothing of how Gtk+ handles these kind
of things internally...
Just a practical example:
Let's say I have a class MyWidget : public Gtk::Label. I do the
Glib::ObjectBase("mywidget"). I instantiate a dummy widget to get the
GType registered.
If I now do G_OBJECT_NAME(gobj()) I get gtkmm__CustomObject_mywidget.
Same goes for this->get_name(). All looks fine.
However, this->get_type() returns the same GType as
Gtk::Label::get_type(), which probably is wrong.
If I call G_OBJECT_TYPE(gobj()) I do get a different Gtype, but I
haven't tried to check if that is indeed the correct one.
If I now tell libglade to instantiate a widget of type
gtkmm__CustomObject_mywidget it looks like I'm getting a standard
Gtk::Label (or a GtkLabel, I'm not sure how the wrapping is done).
Perhaps because of the same reasons my get_type() is returning the
Gtk::Label GType?
Brgds,
Alexander Brinkman.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]