Use of item factory to create menus without a menubar
- From: Brent Baccala <baccala vger freesoft org>
- To: gtk-app-devel-list gnome org
- Subject: Use of item factory to create menus without a menubar
- Date: Tue, 4 Mar 2003 20:56:58 -0500 (EST)
Hi -
I'm trying to use item factory (gtk+ 1.2) to create a pull-down menu
to add to an already constructed menubar. This is part of a module
that is optionally linked in with the program, so it doesn't always
compile, gets added dynamically on the fly, and therefore isn't part
of the "main" item factory. My code for this looks like this:
static GtkItemFactoryEntry menu_items[] =
{
{"/Soundcard/DMA", NULL, NULL, 0, "<Branch>"},
{"/Soundcard/DMA/tear", NULL, NULL, 0, "<Tearoff>"},
{"/Soundcard/DMA/4", NULL, dma, (int)"4", "<RadioItem>"},
{"/Soundcard/DMA/2", NULL, dma, (int)"2", "/Soundcard/DMA/4"},
{"/Soundcard/DMA/1", NULL, dma, (int)"1", "/Soundcard/DMA/2"},
};
extern GtkWidget *menubar; /* the existing menu bar */
void init_code() {
factory = gtk_item_factory_new(GTK_TYPE_MENU, "<soundcard>", NULL);
gtk_item_factory_create_items(factory, nmenu_items, menu_items, NULL);
menu = gtk_item_factory_get_widget(factory, "/Soundcard");
soundcard_item = gtk_menu_item_new_with_label ("Soundcard");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (soundcard_item), menu);
gtk_menu_bar_insert (GTK_MENU_BAR (menubar), soundcard_item, 11);
}
This works, but generates a GTK warning that menu is already attached to
a GtkMenuItem (presumably created in the item factory).
Any suggestions how to generate a pulldown submenu (preferably with
a menu item already attached, unlike this code) that won't produce
this warning?
Thank you.
--
-bwb
Brent Baccala
baccala freesoft org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]