Re: [gtk-list] Re: referring to children of a container



On Thu, 24 Sep 1998, Scott Gifford wrote:

> >As far as I can see there are no functions to query index; it would help
> >to have a function to get notebook pagenumber from a child's GtkWidget*
> >for example.  That would be pretty easy. Also, GtkCList (which is designed
> >with dynamic changes in mind, I guess) returns the index of the
> >newly-added row from the append/etc. function, and has find_by_data
> >functions. How would people feel about adding these to more widgets?
> >
> >Any suggestions in general? Say for example a GtkMenu has been created and
> >then changed in arbitrary ways. I now want to set_active a particular item
> >(I know the name of the item and its callback, maybe its GtkWidget*, but
> >not the index).
> 
> 
>   An easy way to deal with this might be to just put the information into
> the parent widget with gtk_set_data.  You could use the address as the key
> (perhaps using sprintf to make things easier), and then store the index as
> the data.  Or perhaps just use the name as the key, and then the index
> number as the data.  All sorts of useful combinations are possible.

that is *not* possible, object data needs a string for the key, neither
the widget pointer itself nor the page index corresponds to a certain
string.
the correct approach is to use gtk_notebook_page_num() to retrive
the correct index for a widget. the return value for a certain child
may of course change after you inserted or removed other children.

> 
>   Glade does things similar to this, and it seems to me a very clever way of
> dealing with these types of problems.
> 
>   But I would agree that direct support for doing things like this without
> having to get and set data would be nice.
> 
> --------Scott.
> 

---
ciaoTJ



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