Question about gtk-demo

hey all,

gtk-demo is pretty cool, but whenever i try the same trick with a
gtk_vbox or gtk_hbox,i always get:

Gtk-CRITICAL **: file gtkwidget.c: line 3357 (gtk_widget_set_parent):
assertion `widget->parent == NULL’ failed.
Gdk-ERROR **: BadWindow (invalid Window parameter)
serial 40 error_code 3 request_code 3 minor_code 0

it would be excellent to be able to embed sdl a few SDL screens in a
GUI. is the problem here that this hack only works with top level
windows?

pete

code snippet:

int main(int argc, char *argv[])
{
GtkWidget *notebook, *page1, *page2, *label;

gtk_init(&argc, &argv);

label = gtk_label_new(“hello”);
notebook = gtk_notebook_new();
page1 = gtk_vbox_new(FALSE, 0);
page2 = gtk_vbox_new(FALSE, 0);

/* Create a main window */
mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_add( GTK_CONTAINER(mainwin), notebook);
gtk_notebook_append_page( GTK_NOTEBOOK(notebook), page1, label);
gtk_notebook_append_page( GTK_NOTEBOOK(notebook), page2, label);

gtk_widget_set_usize(mainwin, WINSIZEX, WINSIZEY);
gtk_widget_realize(page1);

/* Hack to get SDL to use GTK window */
{ char SDL_windowhack[32];
sprintf(SDL_windowhack,“SDL_WINDOWID=%ld”,
GDK_WINDOW_XWINDOW(page1->window));
putenv(SDL_windowhack);
}

SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(WINSIZEX, WINSIZEY, 0, 0);

/* The last thing to get called */
gtk_main();
SDL_Quit();
return 0;
}

hey all,

gtk-demo is pretty cool, but whenever i try the same trick with a
gtk_vbox or gtk_hbox,i always get:

Gtk-CRITICAL **: file gtkwidget.c: line 3357 (gtk_widget_set_parent):
assertion `widget->parent == NULL’ failed.
Gdk-ERROR **: BadWindow (invalid Window parameter)
serial 40 error_code 3 request_code 3 minor_code 0

it would be excellent to be able to embed sdl a few SDL screens in a
GUI. is the problem here that this hack only works with top level
windows?

Yes.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment