[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    I can't understand the difference output of only a line differ
From:       Binary Chen <binary.chen () gmail ! com>
Date:       2007-12-06 9:40:24
Message-ID: 1196934024.11037.1.camel () binch-laptop
[Download RAW message or body]

Hi,

I tried gdk_draw_image with a small program, but the behavior is very
confusing, please help me find out whats happening.

With the sleep(1) the program shows nothing, but without it the window
will show, why?

Thanks.
Bin

#include <gtk/gtk.h>

main(int argc, char **argv)
{
	int ret;

	gtk_init(&argc, &argv);

	GtkWidget *win;
	GtkWidget *drawing;
	GdkImage *img;
	GdkGC *gc;

	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	drawing = gtk_drawing_area_new();
	gtk_widget_set_size_request(drawing, 200, 200);
	gtk_container_add(GTK_CONTAINER(win), drawing);
	img = gdk_image_new(GDK_IMAGE_FASTEST, gdk_visual_get_system(),
			200, 200);

	memset(img->mem, 1, 200 * 200 * 2);

	gtk_widget_show_all(win);

	gc = gdk_gc_new(drawing->window);

	while (1) {
		sleep(1);
		gdk_draw_image(drawing->window, gc, img, 0, 0, 0, 0, 200, 200);
	}

	gtk_main();

}

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic