void widgetDestroy(widget_t *widget) { widget_t *walk, *last; if(widget == NULL) { return; } widgetThemeRelease(widget); _widgetOrphan(widget); while(widget->child != NULL) { widgetDestroy(widget->child); } if(widget->next != NULL) { widgetDestroy(widget->next); } if((widget->handlers != NULL) && (widget->handlers->destroy != NULL)) { widget->handlers->destroy(widget); } util_free(widget); }
void widgetRemoveChildImpl(widget *self, widget *child) { int i; for (i = 0; i < vectorSize(self->children); i++) { // If the child is the to-be-removed widget, remove it if (vectorAt(self->children, i) == child) { // Call the destructor for the widget widgetDestroy(vectorAt(self->children, i)); // Remove it from the list of children vectorRemoveAt(self->children, i); // Re-layout the window (so long as we are part of one) if (self->size.x != -1.0f && self->size.y != -1.0f) { widgetDoLayout(widgetGetRoot(self)); } } // See if it is one of its children else if (child->parent != self) { widgetRemoveChild(vectorAt(self->children, i), child); } } }
void tableRemoveChildImpl(widget *self, widget *child) { // If we are not the childs parent, delegate to widgetRemoveChildImpl if (self != child->parent) { widgetRemoveChildImpl(self, child); } // We are the childs parent, so there is some bookkeeping to tend to else { int i; // Find the index of the child for (i = 0; i < vectorSize(self->children); i++) { if (child == vectorAt(self->children, i)) { break; } } // Call the child's destructor and remove it widgetDestroy(vectorAt(self->children, i)); vectorRemoveAt(self->children, i); // Remove the childs positional information free(vectorAt(TABLE(self)->childPositions, i)); vectorRemoveAt(TABLE(self)->childPositions, i); // Remove any empty rows/columns tableRemoveEmptyRows(TABLE(self)); tableRemoveEmptyColumns(TABLE(self)); // Redo the layout of the window if (self->size.x != -1 && self->size.y != -1) { widgetDoLayout(widgetGetRoot(self)); } } }