Re: [gtk-list] Re: Use of optionmenu's




On Fri, 2 Jul 1999, Lee wrote:
> But how you extract the actual name of the item from what is returned, I
> don't know.
>

This probably isn't as good an idea as it might seem. Any reasonable
real-world application will want to provide for internationalization,
meaning the name is not fixed.
 
I find that a good approach is to 
gtk_object_set_user_data(option,"keystring",somethingmeaningfultoyourapp);

then connect to "activate" for each item, in the callback do
gtk_object_get_user_data() to retrieve the somethingmeaningfultoyourapp.

If the option menu API were index-based, you'd typically have to keep a
mapping from index to somethingmeaningful (in my experience), which is
pretty annoying. Index-based APIs can also be a real nightmare if you want
to dynamically change widgets, which is pretty common for menus (e.g. if
the option menu's contents are user-modifiable or depend on app state).

Havoc




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