Re: Stock components.



I'm a little confused by this.  Is menu_edit_copy a pre-defined function?
If so, do I need to include a special header or something?  The compiler
doesn't know it.  If not, what would be in this function?  I was under the
impression there was a prewritten function for this.

Audrey


----- Original Message -----
From: "Ez Coder" <ezcoder ianandanne com>
To: "Audrey Vernon" <audrey vernon colorado edu>
Cc: "Gtk Application Development" <gtk-app-devel-list gnome org>
Sent: Monday, April 07, 2003 12:10 PM
Subject: Re: Stock components.


Hi!

I sent this before - but did not see it get through! So am sending it
again. Hope it gets through. :-)

If you are using the GtkItemFactory to create your menu's then just
set the item type <StockItem> and pass the StockItemId in the extra_data
pointer. This is new in Gtk2.

If you building the menu items by hand then you will need to create the
new menu item using gtk_image_menu_item_new_from_stock()

Just learning Gtk and thought I could answer this question. Hope it
helps.

Sample code follows:

/* START OF CODE */

static GtkItemFactoryEntry menubarItems[] =
{
{ "/_File", NULL, NULL, 0, "<Branch>" },
{
"/File/E_xit", "<Ctrl>Q",
(GtkItemFactoryCallback)menu_file_exit, 0,
"<Item>"
},
{ "/_Edit", NULL, NULL, 0, "<Branch>" },
{
"/Edit/Copy", NULL,
(GtkItemFactoryCallback)menu_edit_copy, 0,
"<Item>"
},
{
"/Edit/Separator", NULL,
NULL, 0,
"<Separator>"
},
{
"/Edit/Preferences", NULL,
(GtkItemFactoryCallback)menu_edit_preferences, 0,
"<StockItem>", GTK_STOCK_PREFERENCES
}
};

GtkWidget *create_menu_bar(void)
{
GtkAccelGroup *accel_group;
GtkItemFactory *ifac;

accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(MainWin), accel_group);

ifac = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>",
accel_group);
gtk_item_factory_create_items(ifac,
sizeof(menubarItems)/sizeof(menubarItems[0]),
menubarItems, NULL);

return gtk_item_factory_get_widget(ifac, "<main>");
}

/* END OF CODE */

On Fri, 2003-04-04 at 09:43, Audrey Vernon wrote:
Hey,

I'm trying to add cut, copy, paste stock components to my menu bar.  I
can't find any way examples online.  Can someone give me a quick tutorial?

Thanks,
Audrey





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