Re: [gtk-list] Getting the label from gtk_radio_menu_item_new_with_label()




Andy Kahn <ackahn@netapp.com> writes: 
> My question is this: how can get at the label widget which is created
> as part of the menu item from gtk_radio_menu_item_new_with_label() ?
> 

Hmm, the FAQ guys should get on this one.

All the *_new_with_label() convenience functions simply pack a
GtkLabel widget into the widget being created. To get the GtkLabel,
the official accessor function is gtk_container_children(), but 
GTK_BIN(menuitem)->child is also a supported way to access the child
of a GtkBin.

Note that code written this way is somewhat fragile. (If you later
change your code so it packs a pixmap into the menu item as well, the
callback breaks, with no compile errors or anything.) If this bothers
you, you can create the label manually, pack it in the menu item, and 
pass the label pointer explicitly via callback data or object data.

Havoc



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