[Glade-users] signals with GtkOptionMenu's
- From: damon ximian com (Damon Chaplin)
- Subject: [Glade-users] signals with GtkOptionMenu's
- Date: Sun, 20 May 2001 20:02:32 -0400
Matt wrote:
Hey all,
I have spent quite a few hours trying to figure this out on my own
with no luck, so I hope you will forgive me if this is a frequently asked
question ...
Yes, it is!
I am creating GtkOptionMenu's with glade and I would like to
detect which menu option is currently selected. The only way I have
successfully been able to do this is to attach a signal to each menu
option which calls a signal handler and states which menu option has been
selected.
4.7 How do I get the value of a GtkOptionMenu?
Call gtk_menu_get_active() with the GtkOptionMenu's menu to get the currently
selected menu item. You can use g_list_index() to find its index in the menu:
void
on_button1_clicked (GtkButton *button,
gpointer user_data)
{
GtkWidget *option_menu, *menu, *active_item;
gint active_index;
option_menu = lookup_widget (GTK_WIDGET (button), "optionmenu1");
menu = GTK_OPTION_MENU (option_menu)->menu;
active_item = gtk_menu_get_active (GTK_MENU (menu));
active_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);
g_print ("Active index: %i\n", active_index);
}
Question 4.8 may also be useful. See http://glade.gnome.org for the FAQ.
Damon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]