Re: can anybody help with bebugging a little displaying program?



Simon Hookway <lord_seoman hotmail com> writes:
> 
> what you have:
> 
> GtkWidget *window;
> GdkPixbuf *pixbuf;
> GtkWidget *widget;
> 
> window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> widget = gtk_event_box_new();
> gdk_pixbuf_render_to_drawable (pixbuf, 
>   widget->window,widget->style->white_gc, 0, 0,0,0,
>   gdk_pixbuf_get_width(pixbuf),
> 
> widget->window is NOT a drawable, thus your mistake. Instead render it
> to a pixmap and pack the pixmap into the eventbox and then pack the
> eventbox into the window.
> 

widget->window is a drawable. The problems here are:
 - you need to draw in expose_event not immediately
 - there's no widget->window until the GtkWindow is realized
 - you should use GtkDrawingArea instead of GtkEventBox

Check out the "scribble" example in the GTK tutorial, or the GTK 2
docs on GtkDrawingArea, they have a simple example.

Havoc



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