Re: [gtk-list] Option menu preselection



I was going through the gtk tutorial, and got the the section that
discusses menu factories.  The sample code uses 4 or 5 routines to create
a menu bar using menu factories and sub menu factories.  I had trouble
customizing this to work in my sample application.  Finally I ripped out
all the supplied code, and took a shot in the dark:

static GtkMenuEntry menuItems[] =
{
   { "File/New",           "<control>N",  NULL, NULL },
   { "File/Open",          "<control>O",  NULL, NULL },
   { "File/Save",          "<control>S",  NULL, NULL },
   { "File/Save as",       NULL,          NULL, NULL },
   { "File/<separator>",   NULL,          NULL, NULL },
   { "File/Quit",          "<control>Q",  NULL, NULL },
   { "View/frame list",    NULL,          NULL, NULL },
   { "View/vertex list",   NULL,          NULL, NULL },
   { "Help",               NULL,          NULL, NULL }
};
static int numMenuItems = sizeof ( menuItems ) / sizeof(menuItems[0]);

GtkWidget *createMenuBar()
{
   GtkMenuFactory *factory = gtk_menu_factory_new ( GTK_MENU_FACTORY_MENU_BAR
);
   gtk_menu_factory_add_entries ( factory, menuItems, numMenuItems );
   return factory->widget;
}

The routine createMenuBar() returns a pointer to the menubar widget, which
I can then add to my window in the calling routine.  Granted, I'm not
handling an accelerator table, but I'm not concerned about this right now.

This code creates a menubar just like I want it.  So, I have 2
questions.  First, why does the tutorial use such a complicated example?
And second, what are sub menu factories and how do they work?  (Okay,
maybe that's three questions.  :> )

Cheers,
G.





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