diff --git a/unix/tab.c b/unix/tab.c index ab2aa082..c8e4be83 100644 --- a/unix/tab.c +++ b/unix/tab.c @@ -11,15 +11,11 @@ struct uiTab { GArray *pages; // []*struct child }; -static void onDestroy(uiTab *); +uiUnixControlAllDefaultsExceptDestroy(uiTab) -uiUnixDefineControlWithOnDestroy( - uiTab, // type name - onDestroy(this); // on destroy -) - -static void onDestroy(uiTab *t) +static void uiTabDestroy(uiControl *c) { + uiTab *t = uiTab(c); guint i; struct child *page; @@ -28,10 +24,11 @@ static void onDestroy(uiTab *t) childDestroy(page); } g_array_free(t->pages, TRUE); + // and free ourselves + g_object_unref(t->widget); + uiControlFree(uiControl(t)); } -// TODO tabContainerUpdateState() - void uiTabAppend(uiTab *t, const char *name, uiControl *child) { uiTabInsertAt(t, name, t->pages->len, child); @@ -86,7 +83,7 @@ uiTab *uiNewTab(void) { uiTab *t; - t = (uiTab *) uiNewControl(uiTab); + uiUnixNewControl(uiTab, t); t->widget = gtk_notebook_new(); t->container = GTK_CONTAINER(t->widget); @@ -96,8 +93,5 @@ uiTab *uiNewTab(void) t->pages = g_array_new(FALSE, TRUE, sizeof (struct child *)); - uiUnixFinishNewControl(t, uiTab); -//TODO uiControl(t)->ContainerUpdateState = tabContainerUpdateState; - return t; } diff --git a/unix/window.c b/unix/window.c index e442d8d9..ba2c9700 100644 --- a/unix/window.c +++ b/unix/window.c @@ -21,13 +21,6 @@ struct uiWindow { void *onClosingData; }; -static void onDestroy(uiWindow *); - -uiUnixDefineControlWithOnDestroy( - uiWindow, // type name - onDestroy(this); // on destroy -) - static gboolean onClosing(GtkWidget *win, GdkEvent *e, gpointer data) { uiWindow *w = uiWindow(data); @@ -44,8 +37,10 @@ static int defaultOnClosing(uiWindow *w, void *data) return 0; } -static void onDestroy(uiWindow *w) +static void uiWindowDestroy(uiControl *c) { + uiWindow *w = uiWindow(c); + // first hide ourselves gtk_widget_hide(w->widget); // now destroy the child @@ -55,9 +50,25 @@ static void onDestroy(uiWindow *w) if (w->menubar != NULL) freeMenubar(w->menubar); gtk_widget_destroy(w->vboxWidget); + // and finally free ourselves + g_object_unref(w->widget); + uiFreeControl(uiControl(w)); } -static void windowCommitShow(uiControl *c) +uiUnixControlDefaultHandle(uiWindow) +// TODO? +uiUnixControlDefaultParent(uiWindow) +uiUnixControlDefaultSetParent(uiWindow) +// end TODO + +static int uiWindowToplevel(uiControl *c) +{ + return 1; +} + +uiUnixControlDefaultVisible(uiWindow) + +static void uiWindowShow(uiControl *c) { uiWindow *w = uiWindow(c); @@ -67,13 +78,12 @@ static void windowCommitShow(uiControl *c) gtk_window_present(w->window); } -static void windowContainerUpdateState(uiControl *c) -{ - uiWindow *w = uiWindow(c); - - if (w->child != NULL) - childUpdateState(w->child); -} +uiUnixControlDefaultHide(uiWindow) +uiUnixControlDefaultEnabled(uiWindow) +uiUnixControlDefaultEnable(uiWindow) +uiUnixControlDefaultDisable(uiWindow) +// TODO? +uiUnixControlDefaultSetContainer(uiWindow) char *uiWindowTitle(uiWindow *w) { @@ -83,7 +93,6 @@ char *uiWindowTitle(uiWindow *w) void uiWindowSetTitle(uiWindow *w, const char *title) { gtk_window_set_title(w->window, title); - // don't queue resize; the caption isn't part of what affects layout and sizing of the client area (it'll be ellipsized if too long) } void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *data) @@ -121,7 +130,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) { uiWindow *w; - w = (uiWindow *) uiNewControl(uiWindow); + uiUnixNewControl(uiWindow, w); w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); w->container = GTK_CONTAINER(w->widget); @@ -149,9 +158,5 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) g_signal_connect(w->widget, "delete-event", G_CALLBACK(onClosing), w); uiWindowOnClosing(w, defaultOnClosing, NULL); - uiUnixFinishNewControl(w, uiWindow); - uiControl(w)->CommitShow = windowCommitShow; - uiControl(w)->ContainerUpdateState = windowContainerUpdateState; - return w; }