Re: gtk_widget_unparent
- From: "Norman Black" <stonybrk ix netcom com>
- To: "gtk-app-devel-list" <gtk-app-devel-list gnome org>
- Subject: Re: gtk_widget_unparent
- Date: Thu, 21 Mar 2002 15:05:18 -0800
According to the docs, you are not supposed to use gtk_widget_unparent.
You should probably use gtk_container_remove to remove a widget from a
container widget, unless the contain widget has a specific removal API
call. For example the notebook widget has its own API for removing a
page. Things like the packing boxes do not.
Best Regards,
Norman Black
Stony Brook Software
----- Original Message -----
From: "Dr.Peter Rottengatter" <peter rottengatter de>
To: <gtk-app-devel-list gnome org>
Sent: Wednesday, March 20, 2002 1:46 PM
Subject: gtk_widget_unparent
Seems I haven't understood gtk_widget_unparent properly. Here is what
I did:
Problem: I create the GUI using Glade, amongst which is a window with
a notebook
widget. I use it to display a small set of measurement data, a trace
each page.
It is not previously determined how many traces there will be.
So I create a single instance of the trace page with Glade, and I need
to add
"clone" pages to the notebook at runtime as needed.
My thought was to use the Glade-created "create_notebook" function to
build a new
instance of the notebook widget tree, then unlink the trace page
sub-tree und
relink it into the notebook that is about to be used. After doing
that, that
additional instance of the notebook tree (now incomplete) won't be
needed
anymore.
I figured gtk_widget_unparent would do the unlink action, as
gtk_notebook_append_page
would do the relink. The additional instance of the notebook tree
could be destroyed
as usual, afterwards, I thought. Somewhere I thought badly wrong. I
did this in a
loop for every data trace:
dummy = create_notes();
page = lookup_widget (dummy, "nb_trace_vbox");
gtk_widget_unparent (page);
/* gtk_widget_destroy (dummy); */
gtk_widget_show_all (page);
sprintf (tab, "#%d", index);
gtk_widget_show (label = gtk_label_new (tab));
sprintf (tab, "Trace #%d", index);
gtk_widget_show (menu = gtk_label_new (tab));
gtk_notebook_append_page_menu (book, page, label, menu);
So far, it works. But it segfaults as soon as the gtk_widget_destroy
is uncommented.
I could just leave dummy in place and destroy it when the shown
notebook is destroyed.
Or is this fundamentally flawed, and I should do this in a different
way ?
Cheers Peter
--
---------------------------------------------------------------------
Dr. Peter Rottengatter peter rottengatter de
http://www.rottengatter.de
---------------------------------------------------------------------
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]