// TODO save and restore expands and aligns void uiWindowSetChild(uiWindow *w, uiControl *child) { if (w->child != NULL) { uiControlSetParent(w->child, NULL); uiUnixControlSetContainer(uiUnixControl(w->child), w->childHolderContainer, TRUE); } w->child = child; if (w->child != NULL) { uiControlSetParent(w->child, uiControl(w)); uiUnixControlSetContainer(uiUnixControl(w->child), w->childHolderContainer, FALSE); } }
void uiprivChildRemove(uiprivChild *c) { uiControlSetParent(c->c, NULL); uiUnixControlSetContainer(uiUnixControl(c->c), c->parent, TRUE); gtk_widget_set_hexpand(c->widget, c->oldhexpand); gtk_widget_set_halign(c->widget, c->oldhalign); gtk_widget_set_vexpand(c->widget, c->oldvexpand); gtk_widget_set_valign(c->widget, c->oldvalign); if (c->box != NULL) gtk_widget_destroy(c->box); uiprivFree(c); }
uiprivChild *uiprivNewChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer) { uiprivChild *c; if (child == NULL) return NULL; c = uiprivNew(uiprivChild); c->c = child; c->widget = GTK_WIDGET(uiControlHandle(c->c)); c->oldhexpand = gtk_widget_get_hexpand(c->widget); c->oldhalign = gtk_widget_get_halign(c->widget); c->oldvexpand = gtk_widget_get_vexpand(c->widget); c->oldvalign = gtk_widget_get_valign(c->widget); uiControlSetParent(c->c, parent); uiUnixControlSetContainer(uiUnixControl(c->c), parentContainer, FALSE); c->parent = parentContainer; return c; }
static void uiWindowDestroy(uiControl *c) { uiWindow *w = uiWindow(c); // first hide ourselves gtk_widget_hide(w->widget); // now destroy the child if (w->child != NULL) { uiControlSetParent(w->child, NULL); uiUnixControlSetContainer(uiUnixControl(w->child), w->childHolderContainer, TRUE); uiControlDestroy(w->child); } // now destroy the menus, if any if (w->menubar != NULL) freeMenubar(w->menubar); gtk_widget_destroy(w->childHolderWidget); gtk_widget_destroy(w->vboxWidget); // and finally free ourselves // use gtk_widget_destroy() instead of g_object_unref() because GTK+ has internal references (see #165) gtk_widget_destroy(w->widget); uiFreeControl(uiControl(w)); }