[Glade-users] append a page to a notebook
Damon Chaplin
damon@helixcode.com
Mon, 25 Sep 2000 16:37:38 +0100
jerome despatis wrote:
>
> Hello,
>
> I have a problem to append a page to a notebook, in
> fact it works on my computer (linux 2.2.16, Mandrake
> 7.1), but not on another distriution such as Redhat
>
> In fact, I create a window, with in it ann example of
> a complex page, I then find the widget of the page to
> add.
> Here is the piece of code:
>
> my_widget = create_window_notebook_ex();
> intab = lookup_widget(my_widget,"vbox_tab");
> sprintf(server_label_text,"new tab");
> server_label=gtk_label_new(server_label_text);
> gtk_notebook_append_page(GTK_NOTEBOOK(notebook),intab,server_label);
>
> and when i launch the program under a Redhat for
> example, i get:
> Gtk-CRITICAL **: file gtkwidget.c: line 3360
> (gtk_widget_set_parent): assertion
> 'widget->parent==NULL' failed.
It looks like your intab widget is already a child of something.
You will have to remove it from its parent before adding it to the
notebook.
You can usually use something like:
/* Ref intab so it doesn't get destroyed automatically. */
gtk_widget_ref (intab);
gtk_container_remove (GTK_CONTAINER (intab->parent), intab);
...
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),intab,server_label);
gtk_widget_unref (intab);
Damon