From e22439c0a217845b29bbc6ab99728bc362cf0b6f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 29 Jun 2015 11:48:27 -0400 Subject: [PATCH] First draft of integrating holders into uiWindow. Increasing urge to just ditch the cross-platform uiBox and have the GTK+ uiBox be a thin GtkBox wrapper (in which case we don't even need containerWidget!). --- redo/unix/window.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/redo/unix/window.c b/redo/unix/window.c index 9bcd5fda..4d2c9630 100644 --- a/redo/unix/window.c +++ b/redo/unix/window.c @@ -16,7 +16,9 @@ struct window { GtkWidget *menubar; + uiControl *holder; uiControl *child; + int (*onClosing)(uiWindow *, void *); void *onClosingData; int margined; @@ -47,10 +49,11 @@ static void windowCommitDestroy(uiControl *c) // first hide ourselves gtk_widget_hide(w->widget); - // now destroy the bin - // we need to remove the bin from its parent first -//TODO uiBinRemoveOSParent(w->bin); -//TODO uiControlDestroy(uiControl(w->bin)); + // now destroy the child; removing it from its holder first + holderSetChild(w->holder, NULL); + uiControlDestroy(w->child); + // now destroy the holder + uiControlDestroy(w->holder); // now destroy the menus, if any if (w->menubar != NULL) freeMenubar(w->menubar); @@ -112,10 +115,10 @@ static void windowSetChild(uiWindow *ww, uiControl *child) struct window *w = (struct window *) ww; if (w->child != NULL) - uiControlSetParent(w->child, NULL); + holderSetChild(w->holder, NULL); w->child = child; if (w->child != NULL) { -//TODO uiControlSetParent(w->child, uiControl(w)); + holderSetChild(w->holder, w->child); uiControlQueueResize(w->child); } } @@ -147,6 +150,7 @@ static void windowResizeChild(uiWindow *ww) uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) { struct window *w; + GtkWidget *holderWidget; w = (struct window *) uiNewControl(uiTypeWindow()); @@ -171,14 +175,14 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) gtk_container_add(w->vboxContainer, w->menubar); } -/*TODO w->bin = newBin(); - binWidget = GTK_WIDGET(uiControlHandle(uiControl(w->bin))); - gtk_widget_set_hexpand(binWidget, TRUE); - gtk_widget_set_halign(binWidget, GTK_ALIGN_FILL); - gtk_widget_set_vexpand(binWidget, TRUE); - gtk_widget_set_valign(binWidget, GTK_ALIGN_FILL); - uiBinSetOSParent(w->bin, (uintptr_t) (w->vboxContainer)); -*/ + w->holder = newHolder(); + holderWidget = GTK_WIDGET(uiControlHandle(uiControl(w->holder))); + gtk_widget_set_hexpand(holderWidget, TRUE); + gtk_widget_set_halign(holderWidget, GTK_ALIGN_FILL); + gtk_widget_set_vexpand(holderWidget, TRUE); + gtk_widget_set_valign(holderWidget, GTK_ALIGN_FILL); + gtk_container_add(w->vboxContainer, holderWidget); + // show everything in the vbox, but not the GtkWindow itself gtk_widget_show_all(w->vboxWidget);