Re: GtkMenuItems



On Wed, 5 Sep 2001, Jose Antonio Onieva González wrote:

> Hi
>   Firstly of all sorry for my poor english.
>   Well, my problem is that I'm trying to get the label of a
> GtkMenuItem.I've created a GtkOptionMenu (with Glade) which (if I'm not
> wrong) contains a GtkMenu which contains some GtkMenuItems. When I want
> to get the option selected, I wait for a "selection-done" signal in the
> GtkMenu. In that moment I try to catch the active GtkMenuItem with
> gtk_menu_get_active :
>
>     GtkMenuItem *menuit=GTK_MENU_ITEM(gtk_menu_get_active(menu); //menu
> is the parameter to the function that catch the signal
>     GtkBin *mibin=GTK_BIN(menuit);
>
> ..but surprisely (maybe for me of course,I'm a beginer) mibin->child is
> NULL. I've tried to follow the components of the structure GtkMenuItem
> looking for the label(u know,"more or less menuit->item->bin->child"),
> but ...equal.
>
>  So, securely there's another way of catching the active menu but if u
> consider that I'm not wrong at all, what's my error?
>  And if I'm wrong at all, what's the way I must follow?

First of all, this message should probably have been sent to gtk-list
rather than gtk-devel-list.  This list is for development of gtk, rather
than with gtk.

The option menu reparents the contents of the selected menu item into the
button so that it gets displayed when the menu is not popped up.  So the
active menu item having no child is not unexpected.

You can get the selected GtkMenuItem as
GTK_OPTION_MENU(option_menu)->menu_item, and the label that would usually
be inside the menu item as GTK_BIN(option_menu)->child.

James.

-- 
Email: james daa com au
WWW:   http://www.daa.com.au/~james/






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