+}
+
+/* Internal function: main thread version of destroy_windows_below, only more
+ DESTRUCTO-MATIC! */
+static void
+trash_windows_recursive(ChimaraGlkPrivate *priv, winid_t win)
+{
+ switch(win->type)
+ {
+ case wintype_Blank:
+ case wintype_TextGrid:
+ case wintype_TextBuffer:
+ gtk_widget_unparent(win->frame);
+ break;
+
+ case wintype_Pair:
+ trash_windows_recursive(priv, win->window_node->children->data);
+ trash_windows_recursive(priv, win->window_node->children->next->data);
+ break;
+
+ default:
+ ILLEGAL_PARAM("Unknown window type: %u", win->type);
+ return;
+ }
+ trash_stream_thread_independent(priv, win->window_stream);
+ trash_window_thread_independent(priv, win);
+}
+
+void
+_chimara_glk_free_window_private_data(ChimaraGlkPrivate *priv)
+{
+ /* Destroy the window tree */
+ if(priv->root_window) {
+ trash_windows_recursive(priv, priv->root_window->data);
+ g_node_destroy(priv->root_window);
+ }