Re: simple question: get menu item string
- From: Carlos Pereira <carlos pehoe civil ist utl pt>
- To: gtk-app-devel-list gnome org
- Subject: Re: simple question: get menu item string
- Date: Wed, 18 Oct 2000 20:27:56 +0100
thanks for the quick help, though it doesn't seem to return a label :(
GtkWidget* menu_item=gtk_menu_get_active(GTK_MENU(menu));
GtkWidget *label = GTK_BIN (menu_item)->child;
gtk_label_get (GTK_LABEL (label), val);
it fails when trying to get the label and returns a NULL pointer
I thought you were talking about menu_items in
menus while you are really talking about menu_items
in option_menus, which work quite differently, it seems.
I remember Havoc saying in this list that the method
to get the current string in option menus is sort
of broken, but I might be wrong.
The options in your option_menu are statically created,
i.e. you know them at compile time? if that is the case
you can use this method (which I use in my code):
/* get option */
option1 = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (dialog), "option1");
option2 = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (dialog), "option2");
option3 = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (dialog), "option3");
option_menu = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (dialog), "option_menu");
menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option_menu));
menu_item = gtk_menu_get_active (GTK_MENU (menu));
if (menu_item == option1)
do_option1;
else if (menu_item == option2)
do_option2;
else if (menu_item == option3)
do_option3;
Carlos
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]