Re: Finding a child widget



On Thu, 9 Aug 2001, rhfreeman wrote:

> Probably an obvious question.
> 
> I know how to find a top level widget, given a widget child widget somewhere
> below. But is it possible to reverse that?
> 
> I've got a window with a ctree (only one) in it. I know of the window. Is
> there a reverse to the function gtk_widget_get_ancestor() to find a child
> widget that I could use?

not really. one could implement such a function on top of gtk_container_list_children()
but it would be pretty expesnive, since it needs to visit the whole tree to find
a widget.
you're usually better off with storing the ctree pointer upon creation, e.g.
in a global variable.
or you could store it seperately on the window, e.g.:

ctree = /* ctree creation code */;
window = /* window creation code */;
gtk_object_set_data_full (GTK_OBJECT (window), "my-ctree",
                          gtk_object_ref (ctree),
                          gtk_object_unref);

and later retrive it with
ctree = gtk_object_get_data (GTK_OBJECT (window), "my-ctree");

> 
> Cheers!
> 
> Rich
> 

---
ciaoTJ





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]