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

getting label string from menuitem



Hi,

in an option menu I would like to retrieve the label of the current
selected item. That menuitem is created with gtk_menu_item_new_with_label()
Seems easy to me:

	GtkWidget *menuitem, *menu, *label;
	const gchar *lang;
	/* get the menu from the option_menu */
	menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(bfspell.lang));
	/* getting the active menuitem from the menu */
	menuitem = gtk_menu_get_active(GTK_MENU(menu));
	/* menuitem is a GtkBin, thus holds only 1 iterm, 
	this is an accel_label since I used gtk_menu_item_new_with_label()
	to create it */
	label = gtk_bin_get_child(GTK_BIN(menuitem));
	/* now get the string */
	lang = gtk_label_get_label(GTK_LABEL( label ));

unbfortunately, the 'label' pointer is NULL..., 

so gtk_bin_get_child(GTK_BIN(menuitem)) does return NULL for the menuitem.
I checked the gtkmenuitem.c file from gtk, but it really contains a child
(an accel_label).

Is my code correct? what is wrong with this bit of code?

thanks,
	Olivier

PGP signature



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