Re: [gtk-list] Re: Use of optionmenu's
- From: "Lee" <lee0 callnetuk com>
- To: <gtk-list redhat com>
- Subject: Re: [gtk-list] Re: Use of optionmenu's
- Date: Fri, 2 Jul 1999 19:21:22 +0100
Havoc Pennington wrote:
> 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.
Good point. The Java API handles this by having what equates to:
gtk_menuitem_set_action_command(GtkMenuItem *item, gpointer user_data);
Where in the Java API, user_data is a String that can be used to identify
the menu item. The above call would work very well in co-operation with the
existing:
gtk_menu_get_active() function.
While this is similar to using gtk_object_set_user_data() on an item, I
think it's a much nicer way of doing so. It actually allows recognition of
each of the option menu items, and still allows the programmer to include an
arbitrary data pointer with gtk_object_set_user_data().
It also doesn't mess with internationalization because the label of the menu
item is a completely different attribute.
> 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).
Fair enough. I think my above suggestion is better than an index-based API.
What does anyone else think?
Regards,
--
Lee.
http://atlas.cs.york.ac.uk/~lrpm100/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]