diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-07 22:46:15 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-07 22:46:15 -0400 |
| commit | 1e263930ebc6d1871c43bb70bc21c4917efaff1e (patch) | |
| tree | 0c556df727301ba8a0fb2e1f991637d0ad07ceec /new/window_unix.c | |
| parent | c6daf8d3086b270dba6047349b563a7b68bfbfb8 (diff) | |
Started working on code to monitor creation and deletion of UI objects correctly.
Diffstat (limited to 'new/window_unix.c')
| -rw-r--r-- | new/window_unix.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/new/window_unix.c b/new/window_unix.c index acdede7..9f61289 100644 --- a/new/window_unix.c +++ b/new/window_unix.c @@ -8,6 +8,14 @@ struct uiWindow { void *onClosingData; }; +static void onDestroy(GtkWindow *window, gpointer data) +{ + uiWindow *w = (uiWindow *) data; + +printf("destroying window; freeing uiWindow\n"); + uiFree(w); +} + uiWindow *uiNewWindow(char *title, int width, int height) { uiWindow *w; @@ -16,6 +24,7 @@ uiWindow *uiNewWindow(char *title, int width, int height) w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(w->widget), title); gtk_window_resize(GTK_WINDOW(w->widget), width, height); + g_signal_connect(w->widget, "destroy", G_CALLBACK(onDestroy), w); w->container = newContainer(); gtk_container_add(GTK_CONTAINER(w->widget), w->container); return w; @@ -24,7 +33,6 @@ uiWindow *uiNewWindow(char *title, int width, int height) void uiWindowDestroy(uiWindow *w) { gtk_widget_destroy(w->widget); - uiFree(w); } uintptr_t uiWindowHandle(uiWindow *w) @@ -44,7 +52,6 @@ void uiWindowHide(uiWindow *w) gtk_widget_hide(w->widget); } -// TODO will not free w static gboolean onClosing(GtkWidget *win, GdkEvent *e, gpointer data) { uiWindow *w = (uiWindow *) data; |
