/* exported function documented in fbtk.h */ int fbtk_destroy_widget(fbtk_widget_t *widget) { fbtk_widget_t *parent; int ret = 0; ret = fbtk_post_callback(widget, FBTK_CBT_DESTROY); while (widget->first_child != NULL) { fbtk_destroy_widget(widget->first_child); } parent = widget->parent; if (parent != NULL) { /* unlink from siblings */ if (widget->prev != NULL) { widget->prev->next = widget->next; } else { /* must be the first widget, unlink from parent */ parent->first_child = widget->next; } if (widget->next != NULL) { widget->next->prev = widget->prev; } else { /* must be the last widget, unlink from parent */ parent->last_child = widget->prev; } free(widget); } return ret; }
static void gui_window_destroy(struct gui_window *gw) { fbtk_destroy_widget(gw->window); free(gw); }