|
|
| Author |
Message |
|
|
killocan Familiar Face
Joined: 23 Jan 2008 Posts: 18 Location: Brasil
|
Posted: Thu Apr 03, 2008 9:23 pm Post subject: What is a toplevel widget? |
|
|
Hi! I'm seeking information on widgets destruction process. And I'm wondering what,
exactly, is a TOP-LEVEL widget, :) i have searched through a lot of sites and
documentations and they are a bit confuse about whats a top-level widget truly means.
For example, i found this statement:
1) If the widget "owns" any widgets other than its child
widgets, (for instance popup windows) it should
call gtk_widget_destroy () for them.
In another site (developers section at gnome site):
* In practice, this means that you only have to destroy toplevel widgets;
any widgets that are inside a container will be destroyed along with the container.
Ok at this point i figure out to myself that ANY gtk component child of GtkContainer
is itself a TOP-LEVEL widget, but in GtkWidget section (gtk_widget_destroy) i get:
...
* In most cases, only TOPLEVEL widgets (WINDOWS) require explicit destruction,
because when you destroy a toplevel its children will be destroyed as well.
So, i guess, I get it right. A TOP-LEVEL widget is, ANY, widget child of GtkContainer, and
this note (WINDOWS) in gtk_widget_destroy docs is just an example :)
NOTE: I looked at an pygtk site that states:
...
* If the widget is a toplevel (derived from gtk.Window ), it will be removed
from the list of toplevels...
This is very weird! :)
So, am i wrong about (TOPLEVEL == any GtkContainer) or not? :) Thanks! |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Sun Apr 06, 2008 2:51 pm Post subject: |
|
|
| Let's assume you have a window that contains a GtkHBox that contains other widgets. The window is the top-level widget since it has no parent widget. Top-level widgets have no parent widget. When you call gtk_widget_destroy() on a top-level, all of its children will also be destroyed, which means that you only need to call that function once for each top-level widget. |
|
| Back to top |
|
 |
killocan Familiar Face
Joined: 23 Jan 2008 Posts: 18 Location: Brasil
|
Posted: Sun Apr 06, 2008 6:49 pm Post subject: hummm |
|
|
| So, if i destroy only the HBox all components inside it will remain? |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Sun Apr 06, 2008 8:32 pm Post subject: |
|
|
| The other way around. If you destroy the HBox, it will also destroy all of its children. The ancestors (parent, etc) will be left. |
|
| Back to top |
|
 |
killocan Familiar Face
Joined: 23 Jan 2008 Posts: 18 Location: Brasil
|
Posted: Sun Apr 06, 2008 9:05 pm Post subject: :) |
|
|
| So the HBox can be called "toplevel" widget if we forget about the window. I mean, when we delete a HBox it will (remove/destroy) itself from the parent, and then clean (remove/destroy) all it's child... unless some child has a reference count higher that 1. right? :) |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Sun Apr 06, 2008 10:32 pm Post subject: |
|
|
| Correct in terms of the destroying. However, while you could technically call the HBox a top-level, in GTK+ that term should only be used to refer to widgets that can be displayed on the screen without a parent. |
|
| Back to top |
|
 |
killocan Familiar Face
Joined: 23 Jan 2008 Posts: 18 Location: Brasil
|
Posted: Mon Apr 07, 2008 1:18 pm Post subject: :D |
|
|
| Ok! I get it! Thank you so much!!! |
|
| Back to top |
|
 |
|