GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Nov 26, 2014 11:01 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: What is a toplevel widget?
PostPosted: Thu Apr 03, 2008 9:23 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
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!

_________________
http://killocan.freezope.org


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 06, 2008 2:51 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
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.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject: hummm
PostPosted: Sun Apr 06, 2008 6:49 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
So, if i destroy only the HBox all components inside it will remain?

_________________
http://killocan.freezope.org


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 06, 2008 8:32 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
The other way around. If you destroy the HBox, it will also destroy all of its children. The ancestors (parent, etc) will be left.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject: :)
PostPosted: Sun Apr 06, 2008 9:05 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
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? :)

_________________
http://killocan.freezope.org


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 06, 2008 10:32 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
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.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject: :D
PostPosted: Mon Apr 07, 2008 1:18 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
Ok! I get it! Thank you so much!!!

_________________
http://killocan.freezope.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group