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



Havoc,

> > 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() ?
> > 
> 
> 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.
...

Thanks for the info.

Prior to the menu item's "activate" callback (right after creating the
menu item with label), this appears to work.  However, in the activate
callback itself, the widget doesn't appear to have any children.  That
is:

	/* create new menu item to be placed in an option menu */
	...
	menu_item = gtk_radio_menu_item_new_with_label(group, labeltext);
	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
			   menu_item_cb, NULL);
	group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item));
	gtk_menu_append(GTK_MENU(menu), menu_item);
	gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
	...

	void
	menu_item_cb(GtkWidget *menu_item, gpointer cbdata)
	{
		g_assert(GTK_IS_MENU_ITEM(menu_item));	/* this is ok */
		g_assert(GTK_BIN(menu_item)->child);	/* but this fails */
		...
	}

It suggests there's something happening during the "activate" callback
such that the menu item's child is moving elsewhere.  Where could it
be going?  Has it been moved (reparented?) within the option menu
heirarchy?
--andy



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