Re: Optionmenu question
- From: Owen Taylor <otaylor redhat com>
- To: gtk-list redhat com
- Subject: Re: Optionmenu question
- Date: 19 Apr 1999 09:43:55 -0400
> Mad Matt <md7141@Bristol.ac.uk> on 04/18/99 10:08:09 PM
>
> Please respond to gtk-list@redhat.com
>
> To: gtk-list@redhat.com
> cc: (bcc: Robert Gasch/PeopleSoft)
> Subject: [gtk-list] Optionmenu question
>
> I'm having real trouble working out what the currently selected item in
> an option menu is. I can set the active item, but not retrieve it.
>
> I've searched the tutorial but there doesn't seem to be much on option
> menu's specifically, can anyone help me?
There are two approaches:
1) Connect to "activate" on each menu item and remember
which one was selected last.
2) Dig around in the widget guts a bit.
Below is a function I recently used.
Regards,
Owen
=====
/* This really should be in GTK+
*/
static gint
option_menu_get_history (GtkOptionMenu *option_menu)
{
GtkWidget *active_widget;
g_return_val_if_fail (GTK_IS_OPTION_MENU (option_menu), -1);
active_widget = gtk_menu_get_active (GTK_MENU (option_menu->menu));
if (active_widget)
return g_list_index (GTK_MENU_SHELL (option_menu->menu)->children,
active_widget);
else
return -1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]