Best way to handle gtk_images and creation.




I was working on a local C++ wrapper class around gtk images that
allows you to display image streams, and annotate them in a way
similar (but much more simplistic than) the Tk canvas widget.

The problem I ran into was that unlike the other widgets I had been
dealing with, gtk_images can't be created whenever you feel like it.
They rely on you having access to a window that you're sure is already
realized and mapped so that you can get a visual to use in creating
the gdk_image that you need when creating the gtk_image.

This makes automating a "constructor" for my wrapper class a little
awkward since at the point where the user creates an instance of my
wrapper class, I can't actually create the gtk_image since I don't
know what container they're going to add this instance to later.  And
even when they do add the instance to a container, I still may not be
able to create the gtk_image if the container still isn't mapped and
realized yet.

One way I saw around this problem was to always create an alignment
widget as part of the C++ instance and attach to it's realize/map
signals a function that will handle creating the gtk_image as a child
when it's safe.  Is there some better approach I'm overlooking?

Thanks
-- 
Rob



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