+#if MDEBUG
+static int widget_count, container_count;
+
+static void count_callback(GtkWidget *w,
+ gpointer attribute((unused)) data) {
+ ++widget_count;
+ if(GTK_IS_CONTAINER(w)) {
+ ++container_count;
+ gtk_container_foreach(GTK_CONTAINER(w), count_callback, 0);
+ }
+}
+
+static void count_widgets(void) {
+ widget_count = 0;
+ container_count = 1;
+ if(toplevel)
+ gtk_container_foreach(GTK_CONTAINER(toplevel), count_callback, 0);
+ fprintf(stderr, "widget count: %8d container count: %8d\n",
+ widget_count, container_count);
+}
+#endif
+