Re: [gtk-list] Drawing areas, Windows, oh my



On Fri, Feb 11, 2000 at 01:27:09AM -0800, David N. Welton wrote:
> So, my code has something like this at the beginning:
> 
>     gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
>     GTK_SIGNAL_FUNC(keypress_check), NULL);    

s/NULL/drawing_area/

>     gtk_object_set_data(GTK_OBJECT(drawing_area), "pixbuf", pixbuf);
> 
> The question is, how do I get at the drawing area stuff, the pixbuf,
> in particular, from the 'window' when keypress_check is called?
> 
> void keypress_check(GtkWidget *widget, GdkEventKey *evt, gpointer
> data)

GtkDrawingArea *da = (GtkDrawingArea*)data;

and then you gtk_object_get_data() the pixbuf.
Alternatively, you can stuff all the data you want in a structure
and use that as the user_data instead of the drawing_area
in gtk_signal_connect().

Shameless plug: with the perl binding you can have as much user_data
stuff as you want:-)

$window->signal_connect('key_press_event', \&callback, $drawing_area, $pixbuf);

lupus



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