#include <gtk/gtk.h>

void
on_size_allocate (GtkWidget *widget, GdkRectangle *allocation)
{
	static gint i = 0;
	g_message ("%s %d %p %s", __func__, ++i, widget, G_OBJECT_TYPE_NAME(widget));
}

/* gcc size_allocation_test.c `pkg-config --libs --cflags gtk+-3.0` */
int
main (int argc, char **argv)
{
	GtkWidget *win, *box;
	GtkCssProvider *css;
	gint i;

	gtk_init (&argc, &argv);

	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
	gtk_container_add (GTK_CONTAINER (win), box);

	g_signal_connect (win, "size-allocate", G_CALLBACK (on_size_allocate), NULL);
	g_signal_connect (box, "size-allocate", G_CALLBACK (on_size_allocate), NULL);
	
	for (i = 0; i < 10; i++) {
		GtkWidget *button = gtk_button_new_with_label ("A regular button with a label");
		g_signal_connect (button, "size-allocate", G_CALLBACK (on_size_allocate), NULL);
		gtk_container_add (GTK_CONTAINER (box), button);
	}

	css = gtk_css_provider_new ();
	gtk_css_provider_load_from_data (css, "button:hover { color: red;}", -1, NULL);
	gtk_style_context_add_provider_for_screen (gdk_screen_get_default(),
						   GTK_STYLE_PROVIDER (css),
						   GTK_STYLE_PROVIDER_PRIORITY_USER);

	gtk_widget_show_all (win);
	gtk_main();

	return 0;
}
