Re: What to do with my realize callback




B McAndrews said:
I'm creating my own widget relying heavily on the "subclassing widgets"
doc at gtk2-perl.  My widget is subclassed from Gtk2::Container and
contains a Gtk2::DrawingArea.

ah.  creating a container subclass is a bit more work than creating a
composite widget or self-rendering widget.  i haven't done it, personally;
torsten made a few fixes several months ago to make it possible to reimplement
a box in perl, so i believe it should be possible.


What am I supposed to be doing inside my
realize handler with the drawing area?

your event handlers need to propagate the events to all your container's
children.  so, yes, you need to call realize on the child widget.  however, it
will fail if you haven't told that child widget that you are its parent (via
Gtk2::Widget::set_parent()).


I have tried calling realize on
the DrawingArea, but I get this error back

GLib-GObject-CRITICAL **: file gobject.c: line 1561 (g_object_ref):
assertion `G_IS_OBJECT (object)' failed at ./mywidget.pl line 104.
Gtk-CRITICAL **: file gtkstyle.c: line 845 (gtk_style_attach): assertion
`window != NULL' failed at ./mywidget.pl line 104.

I don't understand the G_IS_OBJECT(object) message, I thought the
drawingarea was an object?

i imagine that it's not actually the drawing area that's triggering the
assertion.

Apparently, the drawingarea does not have a window. How do I get it one?

the realize vfunc on the drawing area will create the window.  what's failing
is that when trying to attach the style, there is no valid window.  the
message mechanism doesn't, unfortunately say who called the function that's
complaining.


sounds to me like you didn't call set_parent(), though there's not really
enough info to make a definitive call.


-- 
muppet <scott at asofyet dot org>



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