Re: Unwrapped gtk+ API

On Thu, 2010-05-13 at 16:24 +0200, Torsten Schoenfeld wrote:

Thanks for the review, I'll make the change.

One thing I'm wondering, I've used
to "attach" the offscreen window to its widget (so that the widget
receive the expose events). GdkWindows use their user_data to hold a
reference to its widget. It's the only way I found to do that, and
though it works fine, maybe there should be a better way.

What does the C code do to achieve that, and what is missing from the 
bindings to make it possible in Perl?

see :

gdk_window_set_user_data (widget->window, widget);

I don't think there is a way to get the address of widget in perl.
( no luck with get_pointer )

Setting the gdkwindow user data is pretty much an obligation when using
gdkwindows created from perl, though if the widget already has a
gdkwindow (created by gtk) the trick I used will work.
(btw there is a bug in gdkwindow creation :

And by the way, it would be nice if there was a way to get the widget
of a gdkwindow (to be able to pick a widget with the mouse for
example), the only way I know of doing that is iterating through all
the widgets, and it would not work with gdkwindows that are not a
$widget->window. Also it would make accessing the widget's data from
the gdkwindow from-embedder/to-embedder callback much cleaner.

I don't think any such API exists in gdk, does it?

they use gdk_window_get_user_data, for example gtk_get_event_widget
returns the result of gdk_window_get_user_data
( again, no luck using Glib::Object->new_from_pointer )


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