#include <gtk/gtk.h>

int main(int argc, char **argv)
{
	GtkWidget *window, *button;
	GdkRectangle rect = {1, 1, 2, 2};
	GdkPixmap *pixmap;
	GdkPixbuf *pixbuf;
	GdkColormap *colormap;
	GError *error = NULL;
	int i;

	gtk_init(&argc, &argv);


	button = gtk_button_new_with_label("To je test");
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request(window, 200, 200);
	gtk_container_add(window, button);

	pixmap = gtk_widget_get_snapshot(window, NULL);

	colormap = gdk_drawable_get_colormap(pixmap);

	pixbuf = gdk_pixbuf_get_from_drawable(NULL,
		GDK_DRAWABLE(pixmap), NULL,
		0, 0, 0, 0 ,-1, -1);
	gdk_pixbuf_save (pixbuf, "/home/luka/Desktop/test.png", "png", &error, NULL);
	if (error)
		g_printf("Error: %s\n", error->message);
	i = gdk_pixbuf_get_width(pixbuf);

	printf("Width: %d\n", i);
	gtk_main();
	return 0;
}
